Where overlapping faces of a solid are put in the order of their depths (local_order, also Revolve's surface_order) and some lie in front of one another in a ring, no order draws them all correctly. When the sort could draw no face next, it drew the first face left by depth, whether or not that face was part of a ring. A face that is only in front of a ring's face, and comes before the ring by depth, was then drawn under it: dashed strokes on bars that overlap in a ring, extruded as a 3D group, had whole wall panels drawn over their dashes. The sort now follows the faces that go before the first face left back, among the faces that come before the next face drawn last, to a ring that waits for no other of them (Tarjan's algorithm on the pairs reversed, stopped at the first component completed). That ring gives up its own face that comes first in the order of their depths, and the faces left are looked at afresh, since they may be a smaller ring or none. Only pairs of a ring, and pairs with a face drawn last, are then drawn the wrong way round. A face drawn last (a cap) still follows every face before it. Cost and memory: - Comparing pairs and looking for rings share MAX_LOCAL_CHECKS steps: every face and pair looked at takes a step, and a face's list of the faces before it is charged before it is read. Past the limit the first face left by depth goes next, as before. - A first face left that waits only for the next face drawn last, or faces after it, goes next with no search and no step: each face keeps a count of the faces not drawn before it that come before the face drawn last. - The search goes on from where it stopped, less the group that gave up a face, so rings apart or one behind the other take a few steps a face. A ring that is still a ring after it gives up a face is walked again, so a large ring can cost about the square of its faces. - The pairs are held as two u32 (8 bytes), dropped once each face's list of the faces after it is made; both kinds of list are one array of 4 bytes a pair. The lists of the faces before each face take a step a pair to make, not taken from the limit, and are made only when the room left is at least a quarter of the pairs, so making them costs no more than four times the room left. A solid whose comparing leaves less breaks its rings at the first face left by depth. draw_order, cut_stroke_faces and in_one_order are unchanged. Tests (solids::tests): - a_face_in_front_of_a_cycle_waits_for_it: [0, 2, 3, 1] where the first face by depth gave [3, 0, 2, 1]; with a cap, it stays last. - the_faces_left_are_looked_at_afresh_after_each_face_released, the_ring_released_waits_for_no_face_outside_it, a_ring_is_looked_for_before_the_next_face_drawn_last. - breaking_a_ring_draws_no_more_pairs_wrong_than_the_first_face_by_depth: 6,000 random sets (up to 30 faces, pairs shuffled and repeated, up to four faces drawn last), each held to the order worked out plainly. - breaking_rings_stops_at_its_room, breaking_rings_takes_a_few_steps_a_face_but_for_a_ring_of_many_pairs: the steps are counted, not timed, and bounded from above. - a_face_that_waits_only_for_the_face_drawn_last_costs_no_search: 1,000 such faces before a ring take no search. - the_lists_for_rings_are_made_only_with_room_for_a_quarter_of_the_pairs. - a_list_longer_than_the_room_left_is_not_read: the entries read are counted where they are read, and stay within the room. - a_depth_cycle_keeps_the_cap_last is unchanged and passes. With no ring looked for, the ring tests fail; without the skip or the room for the lists, their tests fail. Docs: docs/three-d.md, docs/revolve.md, docs/effects-parity.md, docs/target-app-parity.md. Part of #7023.
13 KiB
Revolve
This initial implementation follows the scope agreed in issue #605.
Select a path, compound path, type, clipping group, blend, symbol instance, or a group or layer of them, then choose Effect > 3D and Materials > Revolve. On a group or layer, every visible member sweeps about one axis, as the help page describes for a group. The following rules are VectorCraft's own: type stays editable and sweeps as its glyph outlines, the shared axis lies on the chosen edge of the members' bounds together, and each member keeps its own paint. The faces of all members draw in one back-to-front order. The opacity, blending mode and opacity mask of a member, or of a group inside the group, apply once to all its faces. Where a face of another member lies between its faces in that order and overlaps them on the page, its faces are split there, and the opacity, blending mode and opacity mask apply once to each part. The mask stays where it is on the page; it does not turn with the faces. Two faces overlap when the convex hulls of their outlines come within the 0.75 pt seam stroke of each other. After 4,194,304 overlap tests on one group, each further face of such a member is drawn as a part of its own. The profile's horizontal distance from a vertical axis is its radius. Axis side chooses the left or right edge of the profile's bounds; Offset moves the axis outward. For a cylinder made from a vertical line, give it a nonzero offset. A vertical line at zero offset lies on the axis and has no surface.
Revolve angle sweeps 0 to 360 degrees. Rotation X/Y/Z rotates the viewing direction, with all three axes defaulting to 0 degrees. Perspective runs 0° to 160°, as documented: 0° is an orthographic view, and wider angles bring the eye nearer (see three-d.md). Segments controls radial resolution (8 to 128 for a full turn). Lighting supports one to ten directional lights with the documented Light Settings (see three-d.md): Color, Intensity, Rotation, Height, Softness and Ambient Light, and Light behind the object. Color is white by default, with a picker and a reset dot. Colored light preserves neutral ambient illumination. Turn Shading off to keep the source paint without lighting.
Shaded Revolve surfaces automatically use smooth lighting from the profile's tangents, represented by linear gradients on vector triangles. There is no separate smoothing control. Segments still controls the body silhouette; smoothing does not increase radial resolution. Capped endpoint rings use curved vector boundaries. Original profile corners remain sharp, and circular end caps keep uniform flat lighting. Turning Shading off disables lighting. Smooth lighting follows the same light gizmo, rotation, perspective, preview, Cancel and undo behavior. SVG and PDF export retain vector paths and gradients; Expand Appearance keeps those gradients at their original positions when trimming visible surfaces. Non-solid source paints retain their paint with a gradient shading overlay.
The dialog has Rotation and Lighting tabs. Rotation groups the profile and view controls. Drag a value or its label to adjust it, use its slider, or double-click the value to type. Angles show degrees and lighting values show percentages. Segments is in the Advanced section. Lighting controls are disabled when Shading is off. A filled dot at the end of a row means the value differs from its default; click the dot to reset that value. Reset all restores every Revolve parameter to its default.
The compact settings dialog opens beside the artboard. With Preview enabled, the selected object has X (red), Y (green) and Z (blue) rotation rings directly on the artboard. Drag a ring to adjust that axis; drag inside the rings to rotate freely. Hold Shift to snap to 15-degree increments. The rings and the rotation fields stay in sync. Escape during a drag restores that gesture and keeps the settings open. Escape again or Cancel restores the document before the dialog opened. The gizmo appears while editing Revolve; normal source-path selection returns when the dialog closes.
Select the Lighting tab to use the light gizmo on the artboard. Drag the sun handle to move the light on its side of the object: round the centre for its Rotation, towards the centre for a greater Height. A hollow sun marks a light behind the object. Drag the Rotation ring or its label horizontally to turn the light round the object; drag the Height line or its label vertically to raise or lower it. The labels remain usable when the ring shrinks to a point (Height 90°). Hold Shift to snap to 15-degree increments. Light gestures update their matching fields without rotating the object, and keep the same temporary preview, Escape, Cancel and undo behaviour. Intensity, Softness and Ambient Light are draggable fields and sliders. The Lights list selects which light the gizmo and settings edit; Add Light and Delete Light manage up to ten lights, keeping at least one. Ambient is shared and applied once. Preview, Cancel, Reset all and undo include the whole list.
Shading off hides the light gizmo and disables lighting controls. Switch to Rotation to return to the object rings. Show axis in Advanced displays the source's vertical axis on the object. Turning Preview off restores the original artwork and hides artboard controls until Preview is enabled. In small windows, the controls scroll while OK and Cancel stay visible. Reset dots restore individual settings; Reset all restores parameters on both tabs.
Preview changes are temporary until OK. Cancel restores the document; OK creates one undo step. The source anchors remain editable. Appearance lists the effect for reopening its options. SVG/PDF export evaluates filled vector faces; native saves retain the profile and effect parameters. Object > Expand Appearance replaces the live effect with ordinary editable vector faces.
Cap in the shape controls closes the circular rings at the endpoints of an open profile.
It is on by default. Its saved parameter is cap (boolean, default true); missing parameters
also use caps. Set it to false to keep the ends open. The reset dot and Reset all restore Cap to on. Each cap is one closed curved vector path from the endpoint ring to the rotation axis,
with uniform flat shading. A full turn produces a projected circular disk (an ellipse in an
orthographic view); a partial turn produces a sector. Body faces share the same curved rim,
so no triangle patches interrupt the cap edge. Caps share the surface's rotation, perspective and paint, and appear in preview,
SVG/PDF export and Expand Appearance. The checkbox has a reset dot and is included in Reset all.
An endpoint on the axis needs no cap. Each open subpath of a compound profile is capped independently.
With an Angle below 360°, Cap also closes the two angular cut sides, so the object appears solid; with Cap off it is hollow (Revolve options). Each cut side is flat and uniformly shaded, and is drawn in depth order with the rest of the surface. It covers the region between each open subpath and the axis, and the area the closed subpaths fill together under the object's fill rule, with one face for each region. A closed subpath that walls a hole leaves that hole open in the face of the region around it, and where closed subpaths overlap, the overlap is filled or left open as the fill rule fills it. A self-intersecting open subpath, or a self-intersecting closed subpath that is the only closed one, fills what the nonzero rule fills, with one face for each loop it encloses; this is VectorCraft's own rule. A cut side seen edge on is not drawn. The cut sides appear in preview, SVG/PDF export, Expand Appearance, Expand as Wireframes, Revolve (Classic) and exported 3D meshes. Cap does not make intersecting profiles into a watertight solid.
In Advanced, Keep visible surfaces only when expanding is on by default. Expansion removes
completely covered faces and trims partially covered ones using the current rotation and perspective.
Visible interior surfaces through open ends remain. Uncheck it to retain every projected face.
The checkbox has its own reset dot and is included in Reset all. Its saved command parameter is
expandVisibleOnly; it does not change the live preview or SVG/PDF export baking.
Trimming applies to opaque solid paint. Transparent objects, gradients, patterns, non-normal blending, later geometry effects and surfaces exceeding bounded visibility limits keep their complete geometry to preserve their appearance. Visibility follows the same painter order as the live effect, including its approximation for intersecting surfaces. Uncut faces keep their curved outlines. Visibility calculations use bounded polygon approximations of curved rims; clipped portions become vector polygons. Expansion changes are undoable with the standard command.
Initial limits
- Lighting offers Standard, Diffuse, Top Left and Right, using the shared original rigs. Other effective settings show Custom; changing the view does not change the recognized lighting preset.
- Paths, compound paths, type, clipping groups, blends, symbol instances, and groups or layers of them. A clipping group, a blend or a symbol instance sweeps the art it shows about one axis, as described in three-d.md. Images must be traced first with Object › Image Trace › Make, and other live objects expanded.
- Open profiles have circular end caps by default, and a partial sweep closes its angular cut sides; turning Cap off keeps both open. Closed profile boundaries are swept as provided.
- One Revolve per source object. Edit its options rather than applying another.
- Object-level Revolve uses the top visible fill, falling back to a stroke. Per-item Revolve uses that item's paint.
- Smooth diffuse shading, one to ten directional lights, no textures, cast shadows or physical materials. Smooth shading interpolates lighting in projected triangles; it does not smooth the silhouette or add specular highlights.
- Faces are drawn back to front by the depths of their centers. When that order draws the nearer of two overlapping faces of a surface first, every pair of overlapping faces goes in the order of their depths at the middle of where they overlap; faces that lie in front of one another in a ring, so that no order draws them all correctly, give up the ring's own face that comes first by depth, as Extrude & Bevel's do. The sort compares pairs and looks for rings within 4,000,000 steps in all (VectorCraft's own limit); the pairs past that keep the depths of their centers, and a ring past it is broken at the first face left by depth. Caps facing the camera cover their rim seams; a cap facing away is drawn behind the body except where it is nearer than a body face it overlaps. Intersecting profiles can have incorrect visibility.
- Curves use sixteen samples per segment, and as few as four when a surface would otherwise pass its limits. Surfaces are limited to 16,384 profile points and 163,840 faces, the members of a group together. A straight segment takes one point, a curve takes at least four, and each contour takes one. Smooth shaded side quads become two triangles and share the face limit. A continuous cap retains its original radial mesh cost within this limit, and each region of a cut side counts as one face. Projected ring curves have a 0.001-point fitting tolerance and a shared 32,768-curve limit.
- Axis, bounds and ordinary selection handles continue to refer to the editable 2D source profile.
- Extrude & Bevel, Inflate and Rotate are described in three-d.md. Materials remain unimplemented.
Architecture
Revolve geometry in vectorcraft-three-d uses vectorcraft-geom; the crate also uses vectorcraft-pathops
for the other 3D types. It creates a surface of revolution,
applies Euler view rotation, projects it, shades faces and sorts their depth. It has no UI or GPU dependency.
vectorcraft-effects turns those faces into document art. The renderer, export baking and
Expand Appearance use the same evaluator. The standard effect.apply, effect.setParams,
effect.remove and effect.expandAppearance commands expose it to the CLI, control channel and MCP.
Generated faces include narrow matching strokes to cover antialiasing seams. Their round joins bound the overlap to half the stroke width, preventing acute triangle corners from creating spikes along the silhouette in the canvas, SVG/PDF and expanded artwork.
Behaviour references: public 3D and Materials options and public 3D effects documentation. This implementation uses original mathematics and source code, with no Adobe software, assets or presets.