Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge remote-tracking branch 'origin/main' into HEAD

Nguyen Xuan An32da7b669ad5
diff --cc CHANGELOG.md
index 680cfe0a,b12b7d71..65af45e5
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -2,8 -2,9 +2,11 @@@
## Unreleased
+- Add `curve` and `text` geometry (part of issue #45). `curve` sweeps a round or custom profile along a cubic Bezier chain with explicit or automatic handles, a taper along the length and flat caps; `text` extrudes the outlines of the bundled DejaVu Sans (printable ASCII, 20 KB, loaded on demand with its own `text` module and never in an entry) or of a font table added with `registerAgentSceneFont`, with size, depth, alignment, lines and curve resolution. Volume, area and bounds match Blender 5.2 to 2e-5 for two Bezier curves and for a letter and a word set in the same font. Recipes stay plain JSON with bounded, validated fields and vertex estimates checked before generation. The MCP schemas gain two strict entries in the geometry list (1.4 KB of the 190 KB across all tools; not offered as mesh bases or cutters); field types and limits live in `scene_capabilities` under `curveText`, and the MCP takes no font file or URL. The DejaVu licence is in `THIRD-PARTY-NOTICES.md`. Metaballs and NURBS surfaces are recorded as out of scope in `docs/parity.md`. Not done: a suite task in `bench/agent-modeling`, kerning, bevelled text, non-ASCII glyphs in the bundled font.
+
+ - Add frustum culling, levels of detail and live adaptive resolution (part of issue #37). `Renderer67` tests each instance of a batch against the view frustum with the geometry's bounding sphere and draws only the visible ones (on by default, `culling: false` turns it off; skinned, morphed, swaying, fire, smoke, water, assembly and blended batches and the shadow passes are not culled). A part's `lods`, the array from `generateGeometryLods`, makes each instance pick a level by pixel error (`lodPixelError`, default 1). Selection is a pure function of the camera and the matrices, so a seek draws the same frame. `createGpuTimer` and `AdaptiveResolution` in `src/adaptive-quality.js` give live viewers GPU timing and a resolution scale with a minimum; an export can not build one, and `src/main.js` uses it only outside `export=1`. New `large-outdoor` scene in `bench/runtime` with ablations: 1.55 ms against 8.41 ms without culling and 6.0 ms for three.js on an RTX 3060, 517 ms against 4,428 ms and 944 ms on SwiftShader. Core grows 1,845 bytes gzip (budget 81,500). Recipes cannot declare `lods` yet. See `docs/culling-lod.md`.
+
+ - Add relations between parts (part of issue #44, no new tool): a mesh node takes `relations` (`attach`, `gap`, `flush`, `align`, `centered`, up to 8) against other mesh nodes, or against the faces of one carrying a mesh tag (`region`). They work on world bounds, are solved after geometry exists and again on every `scene_apply`, so one edit to a body keeps the parts that sit against it. Unknown IDs and tags, two relations on one axis and cycles (a part waiting on its own child included) are rejected with the next action; solving is deterministic and independent of node order. The code loads on demand (`relations`). The schema carries only a generic `relations` list (597 bytes over `scene_create` and `scene_apply` together); the kinds and fields are in `scene_capabilities` `relations`, and the engine validates them. Measured on Sonnet (3 runs each), relations did not cut tool calls or errors: the kettle resize took 3.3 calls against 3.0, and a 12-part desk with three inspected resizes took 8 against 8, with 13% fewer output tokens (3,833 against 4,403) and the same cost and pass rate. The suite gains `kettle-resize`, `desk-resize` and their plain twins, and `touches` and `centreAt` checks.
- Add render passes, depth of field and camera motion blur (issue #54, first slice). Render jobs of kind `image` or `stills` take `settings.passes` (`albedo`, `normal`, `emission`, `depth`, `objectId`) and write each as a raw, unantialiased PNG beside the lit image (`render-depth.png`, `frame-3-objectId.png`); depth is 16 bits over 100 m in red and green, object IDs are 24 bits with the part names in the job metrics. In code, `renderer.render({ pass })` draws a pass into its own non-multisampled target. `effects.depthOfField` (`blur`, `focusDistance`) and `effects.motionBlur` (`shutter`) are new recipe effects: fixed sample patterns and a per-pixel rotation from the pixel position, so a seek to a frame repeats the same pixels. They live in the new `67js/addons/camera-effects` entry; the preview installs it, and the core renderer only gains a stage hook and the pass branch (a compiled-out shader feature). Motion blur follows camera tracks only, sampled from time at `motion.start + elapsed - shutter`. Measured on SwiftShader through MCP (`npm run smoke:render-passes`): 8 stills with 5 passes each, then four seeks, all byte-identical to the same frame in the sequence. Temporal anti-aliasing, accumulation and the compositing graph of #54 are not part of this slice.
- Expose clip layers, bone masks and name retargeting through MCP, and morph clips in `createAssetPose` (issue #59, in part). An asset recipe's `motion.layers` (up to 8) plays the file's own clips at motion time with a bone `mask`, `weight`, `speed`, `offset`, `loop`, `additive` with `reference`, `bones` (clip track to another asset node) and `morph`, before tracks and IK, so a character walks and waves at once; everything is checked against the asset and bounded, and a seek equals playing. `morphClipFromGltfAnimation` and a layer's `morphs` put morph weights through `createAssetPose` (masks pick parts by their owning bone), `createAssetLayerEvaluator` serves hosts that stage the pose themselves, and `asset.stagePose` takes `morphWeights`. Add the `robot-walk-wave` task to the agent modeling suite and extend `npm run smoke:character`. Not done: foot tilt on slopes, full-body IK, and rest-pose retargeting from another asset through MCP. Raise `entry:skeleton-pose` to 19,000 and `entry:agent-asset` to 85,200 bytes gzip, and the tool schema budgets by 800 bytes (`scene_apply` to 47,800, `scene_create_asset` to 20,150, total to 190,700).
diff --cc bench/size/baseline.json
index 7102dc97,b2561b0d..7187a920
--- a/bench/size/baseline.json
+++ b/bench/size/baseline.json
@@@ -41,12 -41,12 +41,12 @@@
"entry:gltf": {
"min": 154791,
"gzip": 47466,
- "brotli": 40606
+ "brotli": 40652
},
"entry:modeling": {
-- "min": 15517,
-- "gzip": 6416,
-- "brotli": 5712
++ "min": 21149,
++ "gzip": 8439,
++ "brotli": 7477
},
"entry:sculpt": {
"min": 5937,
@@@ -129,24 -129,24 +129,24 @@@
"brotli": 762
},
"entry:agent-scene": {
- "min": 192932,
- "gzip": 58010,
- "brotli": 50224
- "min": 195659,
- "gzip": 59291,
- "brotli": 51288
++ "min": 197811,
++ "gzip": 60176,
++ "brotli": 52094
},
"entry:agent-scene+lazy": {
- "min": 502792,
- "gzip": 166390,
- "brotli": 145171
- "min": 513028,
- "gzip": 170622,
- "brotli": 148944
++ "min": 546753,
++ "gzip": 183205,
++ "brotli": 159645
},
"entry:agent-asset": {
- "min": 283565,
- "gzip": 86956,
- "brotli": 75945
- "min": 286211,
- "gzip": 88211,
- "brotli": 76977
++ "min": 288169,
++ "gzip": 89020,
++ "brotli": 77694
},
"entry:agent-asset+lazy": {
- "min": 535164,
- "gzip": 175358,
- "brotli": 152837
- "min": 545319,
- "gzip": 179569,
- "brotli": 156544
++ "min": 578850,
++ "gzip": 192073,
++ "brotli": 167231
},
"entry:hdri": {
"min": 8075,
@@@ -164,24 -164,24 +164,24 @@@
"brotli": 1425
},
"scene:lit-box": {
- "min": 209451,
- "gzip": 57034,
- "brotli": 48658
+ "min": 214877,
+ "gzip": 58928,
+ "brotli": 50227
},
"scene:gltf-box": {
- "min": 268357,
- "gzip": 76237,
- "brotli": 65528
+ "min": 273787,
+ "gzip": 78107,
+ "brotli": 67034
},
"scene:agent-scene": {
- "min": 297376,
- "gzip": 85436,
- "brotli": 73344
- "min": 305458,
- "gzip": 88650,
- "brotli": 75931
++ "min": 307416,
++ "gzip": 89463,
++ "brotli": 76726
},
"scene:agent-scene+lazy": {
- "min": 607236,
- "gzip": 193818,
- "brotli": 168362
- "min": 622827,
- "gzip": 199984,
- "brotli": 173556
++ "min": 656358,
++ "gzip": 212494,
++ "brotli": 184255
}
}
}
diff --cc bench/size/budgets.json
index e62e8e1e,ddfcd88e..3016a785
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@@ -11,7 -11,7 +11,7 @@@
"entry:motion": 13600,
"entry:canvas2d": 9400,
"entry:gltf": 48500,
- "entry:modeling": 8500,
- "entry:modeling": 6600,
++ "entry:modeling": 8700,
"entry:sculpt": 2500,
"entry:surface": 10100,
"entry:mesh-query": 15900,
@@@ -28,16 -28,16 +28,16 @@@
"entry:grass": 4400,
"entry:clutter": 5300,
"entry:texture-set": 900,
- "entry:agent-scene": 59800,
- "entry:agent-scene+lazy": 180000,
- "entry:agent-asset": 88700,
- "entry:agent-asset+lazy": 188900,
- "entry:agent-scene": 60500,
- "entry:agent-scene+lazy": 174100,
- "entry:agent-asset": 90000,
- "entry:agent-asset+lazy": 183200,
++ "entry:agent-scene": 61400,
++ "entry:agent-scene+lazy": 186900,
++ "entry:agent-asset": 90900,
++ "entry:agent-asset+lazy": 196000,
"entry:hdri": 3300,
"entry:camera-effects": 8600,
"entry:render-passes": 1700,
- "scene:lit-box": 58200,
- "scene:gltf-box": 77800,
- "scene:agent-scene": 87200,
- "scene:agent-scene+lazy": 207300
+ "scene:lit-box": 60200,
+ "scene:gltf-box": 79700,
- "scene:agent-scene": 90500,
- "scene:agent-scene+lazy": 204000
++ "scene:agent-scene": 91300,
++ "scene:agent-scene+lazy": 216800
}
}
diff --cc docs/agent-scene.md
index 4f74c81e,caebd27e..fb22ec89
--- a/docs/agent-scene.md
+++ b/docs/agent-scene.md
@@@ -47,7 -47,7 +47,8 @@@ The normal frame loop can render retain
### On-demand code
+Mesh editing, `lathe`, `extrude`, `tube` and `curve` geometry, `text` geometry with its font, material `pattern` and `motion` load on demand, so a recipe of
+ Mesh editing, `lathe`, `extrude` and `tube` geometry, material `pattern`, `motion` and node `relations` load on demand, so a recipe of
primitives pays about half the bytes. `createAgentScene` and `apply` stay synchronous. When a recipe uses one of them,
load its code first; a missing module throws an error that names this call.
diff --cc skills/build-67js-scene/SKILL.md
index 658392ea,6e486308..d576856a
--- a/skills/build-67js-scene/SKILL.md
+++ b/skills/build-67js-scene/SKILL.md
@@@ -36,8 -36,8 +36,9 @@@ Use `simplify-code` and `engineering-wo
- Static vertex wrapping uses optional `src/shrinkwrap.js` and the checkout's `docs/shrinkwrap.md`.
- A rigid accessory on a morphing or skinned surface uses optional `src/surface-attachment.js` and `docs/surface-attachment.md`.
- Agent scene recipes use optional `src/agent-scene.js` and `docs/agent-scene.md`. Verify source versus published availability before importing.
+- Signs, labels and piping use recipe geometry `text` (bundled DejaVu Sans, printable ASCII; faces +Z, baseline on y=0, size is the em height) and `curve` (cubic Bezier points with optional absolute handles, `radius`, `taper`, `profile`). Their fields come from `scene_capabilities` `curveText.details`, not the tool schema; the MCP takes no font file or URL. Give a sign a board box a little deeper than the text `depth`, and keep text under about 40 characters at `curveSegments: 4`. See "Curve" and "Text" in the checkout's `docs/modeling.md`.
- Polygon modeling by an agent (extrude, inset, loop cut, bevel, booleans, mirror, array, solidify) uses the recipe `mesh` geometry and the MCP tools `mesh_inspect`, `mesh_edit` and `mesh_stack`. Read [mesh-modeling.md](references/mesh-modeling.md) before the first edit; check that the checkout's `docs/mesh.md` exists, since it is unreleased after npm 0.10.0.
+ - Parts that sit against each other (a handle on a body, a lid on a tank, legs under a top) use the node `relations` field: `attach`, `gap`, `flush`, `align` or `centered` against another mesh node, optionally a tagged `region` of it. They are solved again after every edit, so resize the body with one `set-node` instead of recomputing each part's translation. One relation per axis, no loops. Fields are in `scene_capabilities` `relations`; see "Relations between parts" in the checkout's `docs/agent-scene.md`.
- A surface look in a recipe (wood, planks, bricks, tiles, marble, stone, concrete, metal, rust, fabric) uses the material `pattern` field, which needs no UVs. See "Material patterns" in the checkout's `docs/agent-scene.md`. Your own look (bricks from noise and a ramp, stripes, a pattern that follows `uv_unwrap`) is `pattern: { type: "graph", graph, mapping: "uv" }`: a bounded JSON node graph baked to textures, never shader text; see "Material graphs" there.
- Glass, water, gems, car paint and cloth in a recipe use the material layer fields `transmission` (with `thickness` and `ior`), `clearcoat`, `sheenColor` and `specular`. A transmissive material needs a nonzero `thickness` to bend the view behind it, and does not show blended surfaces. Ranges and limits are in "Material layers" in the checkout's `docs/material-maps.md`.
- Layered skeletal animation in code (a clip on some joints only, additive clips, foot planting, reaching, looking at a point) uses `createAssetPose` from `src/skeleton-pose.js` and the checkout's `docs/skeleton-pose.md`. Clip layers are not available through MCP.