3D engine that AI agents drive
Merge remote-tracking branch 'origin/main' into HEAD
Nguyen Xuan An6afb69a5b226
diff --cc CHANGELOG.mdindex d927f636,216fdc15..44ccbd3a--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -2,7 -2,10 +2,11 @@@## Unreleased+- 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).+ - Use one expression language for fields and drivers (issue #98). `src/expression.js` holds the limits, number literals, operator table, syntax and hostile-input checks; `src/mesh-fields.js` (per mesh element: attributes, noise, random, vectors) and `src/motion-expression.js` (per time: `time`, node reads) only add their own inputs, and each rejects the other's with a message that names the context. **This changes driver expressions** (neither language was released): an operator with one operand may be written bare, `{"neg": x}`, in drivers as in fields; `if` takes its second operand when the condition is not 0 (a driver used above 0); `sqrt` of a negative, `pow` overflow and `mod` by 0 give 0 instead of an error; `smoothstep` with equal edges is a step; `div` by 0 is still a non-finite error in a driver, because a hostile-input test pins it, and 0 in a field. Drivers gain `ceil`, `round`, `sign`, `lte`, `gte`, `eq`, `and`, `or`, `not` and booleans; fields gain `atan2` and `saturate`. The unknown-operator hint of fields lists operators in a new order. Error messages for a malformed driver changed in wording and are all TypeErrors. The MCP schema for drivers now points at the field language instead of listing operators (schemas 183,741 to 183,762 bytes), and the `scene_capabilities` budget rises from 3,050 to 3,100 bytes for two operator names.- Add branches and labelled images to the agent tools (part of issue #67, no new tool). `scene_apply` with a `branch` name runs the operations on a scratch copy and stores the result in a snapshot store that holds one copy per distinct recipe (8 branches), leaving the scene, its revision and its checkpoints untouched. `scene_review` shots take a `branch` and render it in a private scene; `scene_restore` with `branch` keeps one. `labels: true` on `scene_look` and `scene_review` draws part names, material tags and mesh lint problems on the image and returns them as JSON with pixel positions. Branch names are bounded (`^[a-z][a-z0-9_-]{0,23}$`). The tool-schema budget rose by 800 bytes in total (150 for `scene_apply`). `npm run smoke:agent-branches` drives it through MCP on SwiftShader.diff --cc bench/agent-modeling/tasks.mjsindex d2b434d2,8bf99880..9b73685a--- a/bench/agent-modeling/tasks.mjs+++ b/bench/agent-modeling/tasks.mjs@@@ -507,8 -471,18 +507,20 @@@ recipe is what gets graded.`{ kind: 'assetReach', endLabel: 'Palm2.R', from: [-1.3, 2.6, 0.8], to: [-1, 1.7, 1.1] },],},+ ...KETTLE_TASKS,+ ...DESK_TASKS,+ {+ id: 'robot-walk-wave',+ assets: true,+ prompt: `The asset catalog holds an imported robot character. Create a scene from it, then give it a 2 second looping motion in+ which it walks and waves at the same time: its legs and body play the Walking clip, and only its right arm (the+ joint labelled UpperArm.R and everything below it) plays the Wave clip instead. Find the clips and joints by inspecting the+ scene. When it is finished, call scene_export_recipe once: the exported recipe is what gets graded.`,+ ownPreamble: true,+ checks: [+ { kind: 'assetWalkAndWave', walk: 'Walking', wave: 'Wave', legs: ['LegL', 'LegR', 'LowerLegL_1', 'LowerLegR_1'], arm: 'ArmR', otherArm: 'ArmL' },+ ],+ },...LONG_TASKS,];diff --cc bench/size/baseline.jsonindex 453d141d,7102dc97..85a56cb9--- a/bench/size/baseline.json+++ b/bench/size/baseline.json@@@ -129,49 -129,59 +129,59 @@@"brotli": 762},"entry:agent-scene": {- "min": 191746,- "gzip": 57799,- "brotli": 49970- "min": 192932,- "gzip": 58010,- "brotli": 50224++ "min": 195659,++ "gzip": 59292,++ "brotli": 51242},"entry:agent-scene+lazy": {- "min": 507434,- "gzip": 167835,- "brotli": 146305- "min": 502792,- "gzip": 166390,- "brotli": 145171++ "min": 513028,++ "gzip": 170623,++ "brotli": 148898},"entry:agent-asset": {- "min": 271426,- "gzip": 82591,- "brotli": 71883- "min": 283565,- "gzip": 86956,- "brotli": 75945++ "min": 286211,++ "gzip": 88215,++ "brotli": 76934},"entry:agent-asset+lazy": {- "min": 534454,- "gzip": 175075,- "brotli": 152461- "min": 535164,- "gzip": 175358,- "brotli": 152837++ "min": 545319,++ "gzip": 179573,++ "brotli": 156501},"entry:hdri": {"min": 8075,"gzip": 3138,"brotli": 2801},+ "entry:camera-effects": {+ "min": 23985,+ "gzip": 8396,+ "brotli": 6688+ },+ "entry:render-passes": {+ "min": 3412,+ "gzip": 1608,+ "brotli": 1425+ },"scene:lit-box": {- "min": 206353,- "gzip": 56023,- "brotli": 47903+ "min": 209451,+ "gzip": 57034,+ "brotli": 48658},"scene:gltf-box": {- "min": 264230,- "gzip": 74991,- "brotli": 64299+ "min": 268357,+ "gzip": 76237,+ "brotli": 65528},"scene:agent-scene": {- "min": 295050,- "gzip": 84782,- "brotli": 72739- "min": 297376,- "gzip": 85436,- "brotli": 73344++ "min": 300023,++ "gzip": 86690,++ "brotli": 74386},"scene:agent-scene+lazy": {- "min": 610738,- "gzip": 194821,- "brotli": 169066- "min": 607236,- "gzip": 193818,- "brotli": 168362++ "min": 617392,++ "gzip": 198024,++ "brotli": 172011}}}diff --cc bench/size/budgets.jsonindex 640edb9c,212db5cc..97ad3088--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@@ -28,14 -28,16 +28,16 @@@"entry:grass": 4400,"entry:clutter": 5300,"entry:texture-set": 900,- "entry:agent-scene": 58500,- "entry:agent-scene+lazy": 168000,- "entry:agent-asset": 83800,- "entry:agent-asset+lazy": 175200,- "entry:agent-scene": 59200,- "entry:agent-scene+lazy": 169800,- "entry:agent-asset": 88700,- "entry:agent-asset+lazy": 178900,++ "entry:agent-scene": 60500,++ "entry:agent-scene+lazy": 174100,++ "entry:agent-asset": 90000,++ "entry:agent-asset+lazy": 183200,"entry:hdri": 3300,- "scene:lit-box": 57200,- "scene:gltf-box": 76500,- "scene:agent-scene": 86100,- "scene:agent-scene+lazy": 195300+ "entry:camera-effects": 8600,+ "entry:render-passes": 1700,+ "scene:lit-box": 58200,+ "scene:gltf-box": 77800,- "scene:agent-scene": 87200,- "scene:agent-scene+lazy": 197700++ "scene:agent-scene": 88500,++ "scene:agent-scene+lazy": 202000}}diff --cc bench/tool-cost-budgets.jsonindex 1412bddd,adde1006..d8898e1c--- a/bench/tool-cost-budgets.json+++ b/bench/tool-cost-budgets.json@@@ -1,16 -1,16 +1,16 @@@{- "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool), then by 600 total, 300 for scene_create and 350 for scene_apply for the node relations field (no new tool; its fields are in scene_capabilities, whose result budget grew from 3410 to 4200); was 373388 schema bytes before shared IDs and recipe references",- "schemaTotalBytes": 191300,- "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool); raised by 650 total and 80 for scene_apply for clip layers, bone masks and retargeting through MCP; raised by 20 for scene_create and 20 for the scene_capabilities result after merging the expression language with the material graph; was 373388 schema bytes before shared IDs and recipe references; trimmed after the render-passes merge: material graph, depth of field, motion blur and passes details moved to scene_capabilities, budgets set to the measured value plus 0.5% (total 188267, scene_capabilities result 5167)",++ "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; raised by 800 total and 150 for scene_apply for branch and labels fields (no new tool); raised by 650 total and 80 for scene_apply for clip layers, bone masks and retargeting through MCP; raised by 20 for scene_create and 20 for the scene_capabilities result after merging the expression language with the material graph; was 373388 schema bytes before shared IDs and recipe references; trimmed after the render-passes merge: material graph, depth of field, motion blur and passes details moved to scene_capabilities, budgets set to the measured value plus 0.5% (total 188267, scene_capabilities result 5167); raised by 95 for scene_apply and 690 for the scene_capabilities result for node relations",+ "schemaTotalBytes": 189210,"schemaToolBytes": {- "scene_create": 61200,- "scene_apply": 47900,- "mesh_edit": 34000,- "scene_create_asset": 19750,- "mesh_stack": 11500+ "scene_create": 60495,- "scene_apply": 46225,++ "scene_apply": 46320,+ "mesh_edit": 33875,+ "scene_create_asset": 19450,+ "mesh_stack": 11335},"schemaOtherToolBytes": 4000,"resultBytes": {- "scene_capabilities": 4200,- "scene_capabilities": 5195,++ "scene_capabilities": 5885,"scene_create": 1400,"scene_inspect": 1400,"mesh_inspect": 1200,