3D engine that AI agents drive
Merge remote-tracking branch 'origin/main' into HEAD
Nguyen Xuan An827cef42da0e
diff --cc CHANGELOG.mdindex 95501e5a,d7336b46..4bbe8eb6--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -2,7 -2,9 +2,10 @@@## Unreleased+- 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.- Add a bounded material node graph (issue #50): material `pattern` of `type: "graph"` bakes noise, voronoi, wave, checker, gradient, ramp, maths and `uv` nodes on the CPU into base colour, roughness, metallic, emission and height (a normal map, so bump). The graph is data, never shader text; nodes, depth, ramp stops, texture size and work are checked before any pixel is computed. Add `mapping: "uv"` to every pattern so it follows `uv_unwrap` UVs instead of box projection; the emissive map now box-maps like the other maps. The 11 presets bake the same bytes as before. Covered in the MCP schema, `scene_capabilities` (`materialGraph`, `materialMappings`), GLB export, `docs/agent-scene.md`, `docs/material-maps.md` and the `brick-graph` reference scene.- Add `decimate`, `remesh` and generated levels of detail (issue #40). `decimate` (a `ratio` of triangles) is a quadric edge collapse of our own that keeps open boundaries, the borders between tags and the tags themselves; it measured 0.25 to 0.85 of the Hausdorff error of meshoptimizer 1.3.0 on the same meshes and adds no dependency, but takes about 2.5 s on 100k triangles where meshoptimizer takes 0.09 s. `remesh` (`voxelSize` or `resolution`, at most 192 per side and 4,194,304 cells, checked before allocation) builds a closed quad surface from a BVH signed distance with surface nets. Both are edits and stack nodes, in the MCP schemas, and load on demand with the mesh code. `generateMeshLods`, `generateGeometryLods` and `generateAssetLods` (also in `67js/addons/mesh`) return levels with a measured error for runtime selection (issue #37). Four decimate and two remesh cases join the Blender comparison, compared by volume, area and Hausdorff distance because face counts differ.diff --cc bench/size/baseline.jsonindex d51f5448,0c615fd5..02e1b477--- a/bench/size/baseline.json+++ b/bench/size/baseline.json@@@ -129,24 -129,24 +129,24 @@@"brotli": 762},"entry:agent-scene": {- "min": 190633,- "gzip": 57324,- "brotli": 49617+ "min": 190657,- "gzip": 57334,- "brotli": 49621++ "gzip": 57336,++ "brotli": 49589},"entry:agent-scene+lazy": {- "min": 501545,- "gzip": 165243,- "brotli": 144083- "min": 497784,- "gzip": 164822,- "brotli": 143860++ "min": 500517,++ "gzip": 165719,++ "brotli": 144583},"entry:agent-asset": {- "min": 278340,- "gzip": 84653,- "brotli": 73752- "min": 273341,- "gzip": 83733,- "brotli": 72966++ "min": 281287,++ "gzip": 86290,++ "brotli": 75357},"entry:agent-asset+lazy": {- "min": 533859,- "gzip": 174177,- "brotli": 151519- "min": 524940,- "gzip": 172137,- "brotli": 149822++ "min": 532886,++ "gzip": 174694,++ "brotli": 152213},"entry:hdri": {"min": 8075,@@@ -159,19 -159,19 +159,19 @@@"brotli": 47903},"scene:gltf-box": {- "min": 264230,- "gzip": 74991,- "brotli": 64299+ "min": 265256,+ "gzip": 75253,+ "brotli": 64620},"scene:agent-scene": {- "min": 294018,- "gzip": 84354,- "brotli": 72502+ "min": 294042,+ "gzip": 84365,+ "brotli": 72463},"scene:agent-scene+lazy": {- "min": 604930,- "gzip": 192275,- "brotli": 166938- "min": 601169,- "gzip": 191853,- "brotli": 166724++ "min": 603902,++ "gzip": 192748,++ "brotli": 167481}}}diff --cc bench/size/budgets.jsonindex cf09ceb4,88289792..26b3db79--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@@ -10,7 -10,7 +10,7 @@@"entry:nature": 13200,"entry:motion": 13600,"entry:canvas2d": 9400,-- "entry:gltf": 47700,++ "entry:gltf": 48000,"entry:modeling": 6600,"entry:sculpt": 2500,"entry:surface": 10100,@@@ -21,7 -21,7 +21,7 @@@"entry:physics": 18000,"entry:spume": 9000,"entry:retarget": 15700,- "entry:skeleton-pose": 19000,- "entry:skeleton-pose": 18500,++ "entry:skeleton-pose": 19200,"entry:vehicle": 14700,"entry:vegetation": 17900,"entry:terrain": 3100,@@@ -29,13 -29,13 +29,13 @@@"entry:clutter": 5300,"entry:texture-set": 900,"entry:agent-scene": 58500,- "entry:agent-scene+lazy": 167700,- "entry:agent-asset": 85200,- "entry:agent-asset+lazy": 175200,- "entry:agent-scene+lazy": 168200,- "entry:agent-asset": 85500,- "entry:agent-asset+lazy": 175600,++ "entry:agent-scene+lazy": 169100,++ "entry:agent-asset": 88100,++ "entry:agent-asset+lazy": 178200,"entry:hdri": 3300,"scene:lit-box": 57200,-- "scene:gltf-box": 76500,++ "scene:gltf-box": 76800,"scene:agent-scene": 86100,- "scene:agent-scene+lazy": 195300- "scene:agent-scene+lazy": 195700++ "scene:agent-scene+lazy": 196700}}diff --cc bench/tool-cost-budgets.jsonindex 0bb88bdf,f7517b6b..ca1b9c61--- a/bench/tool-cost-budgets.json+++ b/bench/tool-cost-budgets.json@@@ -1,11 -1,11 +1,11 @@@{- "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; was 373388 schema bytes before shared IDs and recipe references",- "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 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",-- "schemaTotalBytes": 190700,++ "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",++ "schemaTotalBytes": 191350,"schemaToolBytes": {- "scene_create": 60900,- "scene_apply": 47800,+ "scene_create": 60920,- "scene_apply": 47550,++ "scene_apply": 47880,"mesh_edit": 34000,- "scene_create_asset": 19750,+ "scene_create_asset": 20150,"mesh_stack": 11500},"schemaOtherToolBytes": 4000,