From 6c84c929072b4319a73f611668c700f77f02875b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 10 Nov 2026 14:36:28 -0800 Subject: [PATCH] 3D: a beveled cap and its walls draw their shared edge as the same curves A cap inset by a bevel fitted each run of sampled edges along one curve as a whole, while the wall next to it fitted each sampled edge by itself. The two outlines lay up to 0.25 pt apart on an 800 pt circle, which left a gap or an overlap between the cap and the wall. An inset outline is now fitted one sampled edge at a time in the cap as well, so both faces draw the same curves. Caps that are not inset keep one cubic for each curve of the art. Test: solid::tests::a_beveled_cap_and_its_walls_share_their_curves. Docs: docs/three-d.md, docs/target-app-parity.md. --- crates/three-d/src/solid/outline.rs | 6 +++-- crates/three-d/src/solid/tests.rs | 34 +++++++++++++++++++++++++++++ docs/target-app-parity.md | 2 +- docs/three-d.md | 3 ++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/crates/three-d/src/solid/outline.rs b/crates/three-d/src/solid/outline.rs index 1d22e6450c..07fb0ce58b 100644 --- a/crates/three-d/src/solid/outline.rs +++ b/crates/three-d/src/solid/outline.rs @@ -129,9 +129,11 @@ fn contour(path: &mut BezPath, ring: &Ring, points: &[Point], step: &Along, budg i += 1; continue; }; - // The run of edges that follow this curve one after the other. + // The run of edges that follow this curve one after the other. An inset outline is fitted + // one edge at a time, as `wall` fits it, so a cap and its walls share the same curves. let (mut j, mut t1, mut last) = (i, span.t1, span.t0); - while let Some(Some(next)) = ring.spans.get(j + 1) + while step.map.is_some() + && let Some(Some(next)) = ring.spans.get(j + 1) && next.curve == span.curve && next.t0 == t1 { diff --git a/crates/three-d/src/solid/tests.rs b/crates/three-d/src/solid/tests.rs index 5749e2e367..af9322bc12 100644 --- a/crates/three-d/src/solid/tests.rs +++ b/crates/three-d/src/solid/tests.rs @@ -426,6 +426,40 @@ fn a_cap_in_perspective_fits_the_projected_curves() { } } +/// A cap inset by a bevel and the walls next to it draw the edge they share as the same curves, so +/// no gap or overlap opens between them. +#[test] +fn a_beveled_cap_and_its_walls_share_their_curves() { + for (r, width) in [(40.0, 4.0), (400.0, 40.0)] { + for art in [circle(Point::new(r, r), r), letter_d()] { + let (p, b) = shape(&art); + let o = Extrude { depth: 50.0, bevel: Some(Bevel { inside: true, width, height: width, ..Bevel::default() }), ..Extrude::default() }; + let f = extrude(&p, FillRule::EvenOdd, b, o, View { rotation_x: 20.0, rotation_y: 30.0, ..front() }).unwrap(); + let caps: Vec<&Facet> = f.iter().filter(|f| f.depth == f64::MAX).collect(); + let outlines: Vec> = caps.iter().flat_map(|f| fine(&f.path().to_bezpath(), |q| q)).collect(); + let on_cap = |q: Point| caps.iter().flat_map(|f| f.contours.iter().flatten()).any(|v| v.distance(q) < 1e-9); + let (mut far, mut shared) = (0.0f64, 0); + for wall in f.iter().filter(|f| f.depth != f64::MAX && f.outline.is_some()) { + let path = wall.path(); + for sp in &path.subpaths { + for i in (0..sp.anchors.len()).filter(|i| !sp.segment_is_line(*i)) { + let c = sp.segment(i); + if !on_cap(c.p0) || !on_cap(c.p3) { + continue; + } + shared += 1; + for k in 0..=16 { + far = far.max(edge_distance(&outlines, c.eval(f64::from(k) / 16.0))); + } + } + } + } + assert!(shared > 0, "no wall shares a curved edge with a cap"); + assert!(far <= 1e-4, "{far}"); + } + } +} + /// A twisted, tapered back cap follows the turned, scaled art; a cap inset by a bevel stays /// within the sampling tolerance of the solid; a tiny circle and a curve with a handle of zero /// length keep their cubics. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3d4d6b95cc..f0bfe6802a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1059,7 +1059,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Extrude & Bevel, Inflate and Rotate apply to type: it makes a solid of its glyph outlines, painted with its own fills and strokes or, when it has none, its characters' colour (the first run's), and stays type, so editing the text reshapes the solid (#4715). - Extrude & Bevel, Inflate and Rotate (Effect › 3D and Materials): live effects in the `three-d` crate with depth, twist, taper, solid or hollow caps, five original bevel shapes (width, height, repeat, spacing, inside, both sides), Inflate's volume, both sides, twist, taper and cap, Rotate's turned fills and strokes, Position presets, the rotation and light gizmos, SVG/PDF vector output and Expand Appearance; one 3D effect per object; covered by geometry, effect, canvas-versus-export, command and dialog tests ([three-d.md](three-d.md)). - Extrude & Bevel and Inflate build detailed shapes: each solid takes up to 65,536 outline points and 163,840 faces (VectorCraft's own limits, was 2,048 points and 32,768 faces), counted before any point is sampled; when the faces do not fit, every curve takes fewer pieces, down to 4. A closed path of 2,000 curves extrudes with a bevel and inflates, and paths of 5,000 and 10,000 curves build at the default settings (`crates/three-d/src/solid/tests_limits.rs`). - - Extrude & Bevel (both kinds) and Rotate keep the art's curves in the faces they draw, export and expand: caps and the edges of walls and bevels where they meet a cap are cubics with smooth anchors where the art's are, fitted within 0.001 pt in perspective and within the sampling tolerance on a bevel's inset. An edge of a twisted wall that is cut into pieces, a piece of curve that does not fit after 8 halvings, and the curves past 1,048,576 for one solid stay straight (VectorCraft's own values; [three-d.md](three-d.md#what-differs-from-the-public-documentation)). Tests `solid::tests::a_cap_keeps_the_curves_of_the_art`, `a_cap_in_perspective_fits_the_projected_curves`, `twisted_beveled_tiny_and_degenerate_caps_keep_their_curves`. + - Extrude & Bevel (both kinds) and Rotate keep the art's curves in the faces they draw, export and expand: caps and the edges of walls and bevels where they meet a cap are cubics with smooth anchors where the art's are, fitted within 0.001 pt in perspective and within the sampling tolerance on a bevel's inset. An edge of a twisted wall that is cut into pieces, a piece of curve that does not fit after 8 halvings, and the curves past 1,048,576 for one solid stay straight (VectorCraft's own values; [three-d.md](three-d.md#what-differs-from-the-public-documentation)). Tests `solid::tests::a_cap_keeps_the_curves_of_the_art`, `a_cap_in_perspective_fits_the_projected_curves`, `a_beveled_cap_and_its_walls_share_their_curves`, `twisted_beveled_tiny_and_degenerate_caps_keep_their_curves`. - Export 3D Object (Asset Export's menu): an object with Extrude & Bevel, Revolve, Inflate or Rotate becomes a 3D asset whose Format is USDA (the default), USDZ, glTF or OBJ, and Export writes each of its solids as a mesh with a material in its paint's color (`assets.add3D`, `assets.set3DFormat`, `assets.export3D`; [export 3D vector artwork](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/export-3d-vector-artwork.html)). - Initial live Revolve (#605, #846): a portable geometry and shading crate (`three-d`), editable path and compound profiles, compact options with artboard rotation and light gizmos, SVG/PDF vector output and Expand Appearance that can trim covered faces. Open ends have continuous caps by default, shading is smooth with one to ten colored lights, and intersecting surfaces' visibility is approximate ([revolve.md](revolve.md)). - Revolve takes type, as its glyph outlines, and groups or layers, whose members sweep about one axis as [the help page](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html) describes; a surface can have up to 16,384 profile points, and curves take fewer samples when a surface would pass 163,840 faces (#3617). diff --git a/docs/three-d.md b/docs/three-d.md index 38d96369ce..1362563d23 100644 --- a/docs/three-d.md +++ b/docs/three-d.md @@ -250,7 +250,8 @@ out, perspective). No Adobe software, assets, presets or bevel shapes were used. curves, with smooth anchors where the art's are smooth, while visibility and depth are worked out on the sampled points. Without perspective and bevel each curve maps exactly. With perspective, a curve is split into cubics until each lies within 0.001 pt of the projected outline. A face inset or outset by a bevel follows its - sampled outline within the sampling tolerance above. The edges between two bevel steps or two wall slices, a + sampled outline within the sampling tolerance above, one curve for each sampled edge through its two sampled + points, so the cap and the walls next to it draw the edge they share as the same curves. The edges between two bevel steps or two wall slices, a piece of curve that does not fit after 8 halvings, an edge of a twisted wall cut into pieces, and the curves past 1,048,576 for one solid stay straight. The tolerances and limits are VectorCraft's own values. Inflate's faces are polygons.