Repository navigation
feat(cad): add PatternInstancer linear/grid/circular/alongCurve arrays - #99
Merged
Merged
Conversation
…s and InstancedMesh CSG operands
jbingham
added a commit
that referenced
this pull request
Nov 15, 2026
…isibility, and PatternInstancer (#101) * feat(cad): add PatternInstancer linear/grid/circular/alongCurve arrays and InstancedMesh CSG operands (#99) Co-authored-by: Jonathan Bingham <binghamj@google.com> * fix(web,ios): support opaque-origin static HTML hosting and hide internal XCFramework symbols * fix(ios): pass -platform_version to ld -r in build_ios_xcframework.sh for Xcode ld-prime --------- Co-authored-by: Jonathan Bingham <binghamj@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Stage 3 of the CAD & Pattern enhancement plan in
three-live-cad: declarativeTHREE.PatternInstancer(aliasTHREE.Pattern) arrays built onInstancedMesh, so LLM-authored scenes no longer need hand-written trigonometry andMatrix4loops. Stacked on #98.API
Each call returns an
InstancedMesh, so it exports asEXT_mesh_gpu_instancingin GLB andPointInstancerin USDZ, with at most 10,000 instances.PatternInstancer.linear(geo, mat, { count, step | span, direction, centered, startOffset, instanceRotation, rotationStep, scaleRange, colors })PatternInstancer.grid(geo, mat, { counts: [nx, ny, nz] | countX/Y/Z, spacing, centered, centerY, origin, checkerboard, colors })PatternInstancer.circular(geo, mat, { count, radius, axis: 'y' | 'z' | 'x', center, startAngle, angleSpan | endAngle, endpoint, alignRadial, axialStep, instanceRotation, scaleRange, colors })PatternInstancer.alongCurve(geo, mat, { count, path | curve, closed, alignTangent, up, instanceRotation, scaleRange, colors })new THREE.PatternInstancer(geo, mat, { mode: 'linear' | 'grid' | 'circular' | 'curve', ... })ornew THREE.Pattern(...)modeis omitted, it is inferred from the options. An unknownmodelogs a warning.PatternInstancer.toGeometry(inst)BufferGeometry: inverse-transpose normals, mirrored instances re-wound, and instance colors as vertex colors.THREE.CSG.subtract/union/intersectnow accept anInstancedMeshoperand, e.g. drilling a bolt-hole pattern in one call.userData.csgtargets accept one too.Audit fixes (self-review + independent audit)
instanceMatrixcapacity.checkerboard, the palette is indexed per kept cell, so 2 colors actually alternate.startAngle/endAngle/axialStep/alignRadialtoo.step/spanvalues are accepted, a negative radius uses its absolute value, and material arrays use their first material.Docs and prompts
Added to the README tables, AGENTS.md (new "Pattern Arrays" helper), the LLM guide, the authoring skill,
llms.txt, and the AI edit prompt (with its Rust mirror incompiler/src/ai_edit.rs).Bundle budgets
three-live-cad.min.jsis now 18.8 KB gz, so its budget moves to< 20 KB gz.three-live-fullmoves to< 233 KB gz(232.6 KB) andxr-live-fullto< 342 KB gz(341.6 KB).Testing
node scripts/build.js --test: all suites pass (three-author133/133). New coverage includes:toGeometrymirroring and watertightnessCSG.subtractwith anInstancedMeshcutter, GLB/USDZ export, checkerboard palettes, and the bake index capcargo test --manifest-path compiler/Cargo.toml -- --test-threads=4: passes (100 + 86).