Skip to content

feat(cad): add multi-profile LoftGeometry + audit fixes for SweepGeometry/HelixGeometry - #98

Merged
jbingham merged 2 commits into
mainfrom
feat/cad-loft-geometry
Nov 13, 2026
Merged

jbingham merged 2 commits into
mainfrom
feat/cad-loft-geometry

Conversation

@jbingham

@jbingham jbingham commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Implements Stage 2 of the CAD & Pattern enhancement plan in three-live-cad (multi-profile LoftGeometry) and lands the post-merge audit fixes for #97 (SweepGeometry / HelixGeometry), since both share the same wall/cap emitters.

THREE.LoftGeometry(stations, options?)

  • Blends 2+ outer profiles (Shape, [x, y][], or { shape, y | offset, scale, twist, translate } stations) into a watertight 2-manifold mesh: square-to-round table legs, vases, handles, fairings, tapered housings.
  • Arc-length resampling + seam alignment: every station is resampled to profileSegments vertices and cyclically shifted to minimize twist against its neighbor (no diagonal creasing when blending a square into a circle).
  • Interpolation: 'linear' (default) or 'smooth' / 'catmull-rom' (Catmull-Rom with a 15% overshoot clamp; needs >= 3 stations).
  • Axial or spine lofts: axis: 'y' | 'z' | 'x', or a 3D path (Bishop frames); station offsets map proportionally onto the spine. closed: true (with path) loops back to the first station.
  • Hollow vessels: openTop: true + wallThickness builds outer wall, rim annulus, inner cavity, and inner floor in one watertight shell (vases, cups, planters, lampshades) without CSG. The inner wall contracts about the bounding-box center: exact for centered circles/rectangles, approximate otherwise.
  • Station shape.holes are ignored (documented).

Audit fixes for #97 (SweepGeometry, HelixGeometry) and Stage 2

  • Helix handedness: the default 'right' helix was actually left-handed. It is now counter-clockwise rising when seen from +Y (positive torsion); the test now checks the torsion sign.
  • Smooth shading: sweep/loft wall normals are now averaged across neighboring quads (always along the spine; around the ring unless the profile crease is sharper than ~50 deg), so tubes and coils look round like TubeGeometry while box/hex profiles keep sharp edges.
  • Closed sweeps: twist is rounded to whole turns and the end cross-section is welded to the start, so closed loops with odd twist or a taper no longer leave a seam gap.
  • Vertex quota: SweepGeometry and LoftGeometry throw a RangeError (SecurityError) before allocating more than 100,000 vertices; at most 64 sweep shapes and 256 loft stations are used.
  • Path lofts: frames are sampled from the station offsets (previously steps: 1 stopped mid-spine and > 512 rings piled up at the end); total rings are capped at 512.
  • Closed lofts: the closing span uses the seam-aligned ring (previously the walls could twist across each other when the last-to-first seam shift was non-zero); Catmull-Rom neighbors are re-aligned at the wrap.
  • Flattened cross-sections: a scale that goes to zero along only one axis (e.g. scale: u => [u, 1]) now emits full quads instead of leaving holes.
  • Negative loft height no longer turns the mesh inside out.
  • Docs and prompts: fixed the documented steps clamps and defaults, documented closed/openTop/wallThickness requirements, and added SweepGeometry / HelixGeometry / LoftGeometry to the LLM guide, authoring skill, llms.txt, and the AI edit / image-to-scene prompts (with matching Rust prompt mirrors in compiler/src/ai_edit.rs and ai_image.rs).

Bundle budgets

three-live-cad.min.js is 16.0 KB gz, so the budget moves from < 16 to < 17 KB gz. three-live-full moves to < 231 (229.7 KB) and xr-live-full to < 340 (338.6 KB).

Testing

  • node scripts/build.js --test: all suites pass (three-author 124/124), including new regression tests for helix torsion, closed odd-twist/tapered sweeps, seam-shifted closed lofts, steps: 1 path lofts, offset-to-spine mapping, negative height, the vertex quota, one-axis collapse, and smooth-vs-crease normals.
  • cargo test --manifest-path compiler/Cargo.toml: passes.

@jbingham
jbingham force-pushed the feat/cad-loft-geometry branch from ab4de3c to b321410 Compare November 13, 2026 15:18
@jbingham
jbingham changed the base branch from feat/cad-sweep-and-helix to main November 13, 2026 15:18
@jbingham
jbingham force-pushed the feat/cad-loft-geometry branch from b321410 to 96ab361 Compare November 13, 2026 15:19
- Right-handed helices now rise counter-clockwise seen from +Y.
- Smooth-shaded sweep/loft walls with crease detection.
- Closed sweeps round twist to whole turns and weld the seam.
- 100k vertex quota for SweepGeometry and LoftGeometry.
- Path lofts map station offsets onto the spine; ring count capped at 512.
- Closed lofts use the seam-aligned closing ring.
- One-axis scale collapse emits full quads; negative loft height stays outward.
- Document steps clamps, closed/openTop/wallThickness rules, ignored holes.
- Add Sweep/Helix/Loft to LLM guide, skills, llms.txt and AI prompts.
- Bundle budgets: cad < 17, full < 231, xr-full < 340 KB gz.
@jbingham jbingham changed the title feat(cad): add multi-profile LoftGeometry with hollow-vessel wallThickness feat(cad): add multi-profile LoftGeometry + audit fixes for SweepGeometry/HelixGeometry Nov 13, 2026
@jbingham
jbingham merged commit c6f7ee2 into main Nov 13, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants