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 An56802eb02b60
diff --cc CHANGELOG.md
index 07c7487e,7a5eda19..053f8484
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -2,7 -2,13 +2,14 @@@
## Unreleased
+- 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.
+
+ - Make the default look good without tuning. Recipes get an image-based environment: `environment.setup` (`daylight` by default, `overcast`, `sunset`, `studio`) selects a small procedural sky map generated in code, plus its key light, with `environmentIntensity` and `environmentRotation`; no URLs or files from tool input. `effects.ambientOcclusion` (0 to 1) and `ambientOcclusionRadius` add screen-space ambient occlusion from the depth texture. It is off by default: measured with `npm run reference -- --ambient-occlusion`, it improved no score by more than 0.002 (strength 0.8: -0.0019 in foliage, +0.0047 in lit-interior; strength 0.4, radius 0.3: within +0.0013 everywhere). When used it compiles and allocates on first use and costs about 16 ms on a 190 ms SwiftShader frame (8 percent). `scene_capabilities` lists `lightingSetups`, `defaultLightingSetup` and `ambientOcclusion`. **This changes the look of every existing recipe that sets no lighting**: it now has an environment map, a key color of `[3, 2.8, 2.5]` instead of `[5.2, 4.7, 4.1]`, and a fill intensity of `0` instead of `1`. The engine default is unchanged (occlusion off, no map) so code scenes keep their pixels. Screen-space reflections are not part of this. The `scene:lit-box` size budget rises by 100 bytes gzip for the environment and occlusion code. The reference suite gets `--ambient-occlusion`, and its Blender renderer drops triangles that repeat a vertex, which crashed Blender on the skinned character
+ - Measure and cut the cost of the MCP tools (issue #65). `node scripts/measure-tool-cost.mjs` reports each tool schema and each typical result in bytes and estimated tokens (3.5 characters a token). The 22 schemas came to 373,388 bytes (about 107,000 tokens) and are now 173,216 (about 49,500): recipe geometries and asset recipes point to `mesh_edit`, `mesh_stack` and `scene_create` for the mesh edit, stack and motion detail instead of repeating about 45 KB and 35 KB in each tool, and vectors, colours, quaternions and IDs are shared `$ref` definitions. The backend still validates every field. `tests/tool-cost.test.js` fails when the schema total, one tool's schema or a typical result passes `bench/tool-cost-budgets.json`. A small mesh change is 187 bytes as `mesh_edit` against 1,254 as dispose plus a whole-recipe `scene_create` on a 7-node recipe.
+ - Return diagnostics that name the next action (issue #66). `mesh_inspect` lint adds `intersecting-parts`, `self-intersection`, `thin-wall`, `floating-part` and `asymmetric` warnings from the BVH, with face budgets and a `skippedChecks` list; they never turn `ok` off and the agent modeling suite does not grade them. `scene_inspect` adds `diagnostics` for material fields the renderer ignores, blended transmission and unused materials or geometries, and asset inspection adds decoder warnings (accepted but not drawn features), skinned meshes with no joints, joints with no skin and assets with no clips. Error messages now list allowed fields, known IDs and the next call: a missing session (the largest group, 21 of 68 recorded errors) names the active session or says to call `scene_create`, and page errors no longer carry the bundle stack. `tests/tool-errors.test.js` walks 27 error paths and rejects a message with no next action.
+
+ - Add authored rigs (#46): a recipe `armatures` list (bones with a name, parent, head and tail, or a `humanoid` or `quadruped` preset fitted to a mesh node's bounds, with `landmarks` to move bones), and a `skin` on a mesh node that binds it with automatic weights, plus a `set-armatures` operation. Each bone becomes a recipe node, so keyframed bone rotation and `motion.ik` run through the same paths as imported rigs, and humanoid bones carry the `HUMANOID_BONES` names so `retargetClip` maps them. Weights are the distance to each bone segment with an inverse-fourth-power falloff, the nearest four kept; they depend only on position, so hard-edge seams never open. `scene_inspect` gains `rig`: unweighted vertices, bones with no vertices, and joint axis problems (zero-length bones, straight limb chains, knees that bend backward). `scene_export_glb` writes the bones and a walk clip baked at 30 frames a second from tracks and IK. Add the `rigged-walker` task to the agent modeling suite, with a reference and three failing variants. Blender 5.2 opens the exported walker as 1 armature, 21 bones, 14 meshes with 21 vertex groups each and 1 action of 24 frames; three.js loads 14 skinned meshes and the clip.
- Load agent scene code on demand: mesh editing, `lathe`/`extrude`/`tube`, material `pattern` and `motion` now sit behind `loadAgentSceneModules(recipe)` (or `loadAllAgentSceneModules()`), and `createAgentScene` throws an error naming that call when a needed module is missing. A recipe of primitives drops from 141,241 to 73,581 bytes gzip in `scene:agent-scene` (every lazy chunk still totals 145,049). `npm run size` now bundles with code splitting and reports the initial load, plus a `+lazy` row for the total. `npm test` preloads every module. The archive no longer carries 29 docs that the site serves (physics, lighting, terrain and the other addon docs); agent docs stay
- Add joint limits, node constraints and drivers to motion (issue #58). Two-bone IK takes `limits` per joint and axis in degrees and `bendToward`; `scene_inspect` `motionIk` now carries `limited` (each pose a limit changed) and `warnings` (`hyperextended`, and `wrong-bend` for a knee or elbow bent the unnatural way, which a wrong pole used to hide behind `reached`). `motion.constraints` adds `copy_location`, `copy_rotation`, `copy_scale`, `limit_location`, `limit_rotation`, `track_to`, `child_of` (with an inverse and an influence blend) and `floor`, and `motion.drivers` sets a node component or material property from a bounded JSON expression over time and other nodes (never run as code). The order is tracks, IK, drivers, constraints, with no state between samples, so a seek equals playing. `copy_rotation`, `limit_rotation`, `track_to`, `child_of` and `floor` match Blender 5.2 world matrices in 8 recorded cases (`tests/fixtures/blender/constraints.json`). Joint limits are also in `67js/addons/skeleton-pose`. The `leg-plant` task joins the agent modeling suite. The expression language is a new small one in `src/motion-expression.js`: the field expressions of the mesh addon were not on `main` yet
diff --cc bench/agent-modeling/measure.mjs
index 034a2a2a,c6cf94e9..761c2ab1
--- a/bench/agent-modeling/measure.mjs
+++ b/bench/agent-modeling/measure.mjs
@@@ -277,8 -329,8 +329,9 @@@ export async function measureRecipe(rec
nodes: geometries.length,
physics,
physicsSeekStable,
+ rig: recipe.armatures ? measureRig(scene, recipe.motion?.duration ?? 0) : null,
patternTypes: scene.exportRecipe().materials.filter(material => material.pattern).map(material => material.pattern.type),
+ patternMappings: scene.exportRecipe().materials.filter(material => material.pattern).map(material => material.pattern.mapping ?? 'box'),
parts,
closedParts,
holes: allClosed ? (2 * parts - eulerCharacteristic) / 2 : null,
diff --cc bench/reference/baseline.json
index 605b8dab,772a3bf0..dfa58394
--- a/bench/reference/baseline.json
+++ b/bench/reference/baseline.json
@@@ -1,144 -1,132 +1,144 @@@
{
-- "metric": "FLIP (LDR), mean error, lower is better",
-- "blenderVersion": "5.2.2 LTS",
-- "seconds": {
- "brick-graph": {
- "cycles": 8.9,
- "eevee": 15.2
- },
-- "car-paint": {
- "cycles": 13.8,
- "eevee": 11.5
- "cycles": 35.4,
- "eevee": 82.5
-- },
-- "character": {
- "cycles": 21.6,
- "eevee": 6.2
- "cycles": 19.2,
- "eevee": 4.5
-- },
-- "fog": {
- "cycles": 40.5,
- "eevee": 7.2
- "cycles": 63.5,
- "eevee": 36.3
-- },
-- "foliage": {
- "cycles": 13.0,
- "eevee": 4.6
- "cycles": 39.5,
- "eevee": 27.4
-- },
-- "glass": {
- "cycles": 11.5,
- "eevee": 2.6
- "cycles": 29.5,
- "eevee": 13.7
-- },
-- "lit-interior": {
- "cycles": 19.4,
- "cycles": 77.4,
-- "eevee": 2.6
-- },
-- "material-spheres": {
- "cycles": 12.7,
- "eevee": 9.4
- "cycles": 25.0,
- "eevee": 60.5
-- },
-- "metal": {
- "cycles": 38.4,
- "eevee": 13.3
- "cycles": 42.2,
- "eevee": 30.4
-- },
-- "outdoor-hdri": {
- "cycles": 17.1,
- "eevee": 7.1
- "cycles": 42.9,
- "eevee": 12.9
-- },
-- "spot-area": {
- "cycles": 31.3,
- "eevee": 5.6
- "cycles": 28.5,
- "eevee": 10.1
-- }
-- },
-- "graphics": {
-- "gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)",
-- "cpu": "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)"
-- },
-- "scores": {
- "brick-graph": {
- "gpu-vs-cycles": 0.2269,
- "gpu-vs-eevee": 0.148,
- "cpu-vs-cycles": 0.2268,
- "cpu-vs-eevee": 0.1479,
- "eevee-vs-cycles": 0.144,
- "gpu-vs-cpu": 0.0074
- },
-- "car-paint": {
-- "gpu-vs-cycles": 0.1521,
- "gpu-vs-eevee": 0.1324,
- "gpu-vs-eevee": 0.1323,
-- "cpu-vs-cycles": 0.152,
- "cpu-vs-eevee": 0.1324,
- "eevee-vs-cycles": 0.082,
- "cpu-vs-eevee": 0.1323,
- "eevee-vs-cycles": 0.0819,
-- "gpu-vs-cpu": 0.0055
-- },
-- "character": {
-- "gpu-vs-cycles": 0.0995,
-- "gpu-vs-eevee": 0.0833,
-- "cpu-vs-cycles": 0.099,
-- "cpu-vs-eevee": 0.0826,
-- "eevee-vs-cycles": 0.074,
-- "gpu-vs-cpu": 0.0068
-- },
-- "fog": {
-- "gpu-vs-cycles": 0.2612,
-- "gpu-vs-eevee": 0.0542,
-- "cpu-vs-cycles": 0.2608,
- "cpu-vs-eevee": 0.0543,
- "cpu-vs-eevee": 0.0542,
-- "eevee-vs-cycles": 0.2662,
-- "gpu-vs-cpu": 0.0085
-- },
-- "foliage": {
-- "gpu-vs-cycles": 0.1594,
-- "gpu-vs-eevee": 0.1386,
-- "cpu-vs-cycles": 0.159,
-- "cpu-vs-eevee": 0.1384,
-- "eevee-vs-cycles": 0.0783,
-- "gpu-vs-cpu": 0.0096
-- },
-- "glass": {
-- "gpu-vs-cycles": 0.1326,
- "gpu-vs-eevee": 0.1472,
- "gpu-vs-eevee": 0.1471,
-- "cpu-vs-cycles": 0.1323,
-- "cpu-vs-eevee": 0.1474,
-- "eevee-vs-cycles": 0.115,
-- "gpu-vs-cpu": 0.0075
-- },
-- "lit-interior": {
-- "gpu-vs-cycles": 0.5055,
-- "gpu-vs-eevee": 0.0923,
-- "cpu-vs-cycles": 0.5051,
-- "cpu-vs-eevee": 0.0928,
-- "eevee-vs-cycles": 0.5159,
-- "gpu-vs-cpu": 0.0062
-- },
-- "material-spheres": {
-- "gpu-vs-cycles": 0.1598,
-- "gpu-vs-eevee": 0.1196,
-- "cpu-vs-cycles": 0.1595,
-- "cpu-vs-eevee": 0.1194,
-- "eevee-vs-cycles": 0.1006,
-- "gpu-vs-cpu": 0.0069
-- },
-- "metal": {
-- "gpu-vs-cycles": 0.1868,
-- "gpu-vs-eevee": 0.1565,
-- "cpu-vs-cycles": 0.1867,
-- "cpu-vs-eevee": 0.1565,
-- "eevee-vs-cycles": 0.0934,
-- "gpu-vs-cpu": 0.0063
-- },
-- "outdoor-hdri": {
-- "gpu-vs-cycles": 0.0676,
-- "gpu-vs-eevee": 0.052,
-- "cpu-vs-cycles": 0.0672,
-- "cpu-vs-eevee": 0.0515,
- "eevee-vs-cycles": 0.0383,
- "eevee-vs-cycles": 0.0384,
-- "gpu-vs-cpu": 0.0058
-- },
-- "spot-area": {
-- "gpu-vs-cycles": 0.1242,
-- "gpu-vs-eevee": 0.1707,
-- "cpu-vs-cycles": 0.1242,
-- "cpu-vs-eevee": 0.1709,
-- "eevee-vs-cycles": 0.1935,
-- "gpu-vs-cpu": 0.0032
++ "metric": "FLIP (LDR), mean error, lower is better",
++ "blenderVersion": "5.2.2 LTS",
++ "seconds": {
++ "brick-graph": {
++ "cycles": 8.9,
++ "eevee": 15.2
++ },
++ "car-paint": {
++ "cycles": 35.4,
++ "eevee": 82.5
++ },
++ "character": {
++ "cycles": 19.2,
++ "eevee": 4.5
++ },
++ "fog": {
++ "cycles": 63.5,
++ "eevee": 36.3
++ },
++ "foliage": {
++ "cycles": 39.5,
++ "eevee": 27.4
++ },
++ "glass": {
++ "cycles": 29.5,
++ "eevee": 13.7
++ },
++ "lit-interior": {
++ "cycles": 77.4,
++ "eevee": 2.6
++ },
++ "material-spheres": {
++ "cycles": 25,
++ "eevee": 60.5
++ },
++ "metal": {
++ "cycles": 42.2,
++ "eevee": 30.4
++ },
++ "outdoor-hdri": {
++ "cycles": 42.9,
++ "eevee": 12.9
++ },
++ "spot-area": {
++ "cycles": 28.5,
++ "eevee": 10.1
++ }
++ },
++ "graphics": {
++ "gpu": "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x00002487) Direct3D11 vs_5_0 ps_5_0, D3D11)",
++ "cpu": "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)"
++ },
++ "scores": {
++ "brick-graph": {
++ "gpu-vs-cycles": 0.2269,
++ "gpu-vs-eevee": 0.148,
++ "cpu-vs-cycles": 0.2268,
++ "cpu-vs-eevee": 0.1479,
++ "eevee-vs-cycles": 0.144,
++ "gpu-vs-cpu": 0.0074
++ },
++ "car-paint": {
++ "gpu-vs-cycles": 0.1521,
++ "gpu-vs-eevee": 0.1323,
++ "cpu-vs-cycles": 0.152,
++ "cpu-vs-eevee": 0.1323,
++ "eevee-vs-cycles": 0.0819,
++ "gpu-vs-cpu": 0.0055
++ },
++ "character": {
++ "gpu-vs-cycles": 0.0995,
++ "gpu-vs-eevee": 0.0833,
++ "cpu-vs-cycles": 0.099,
++ "cpu-vs-eevee": 0.0826,
++ "eevee-vs-cycles": 0.074,
++ "gpu-vs-cpu": 0.0068
++ },
++ "fog": {
++ "gpu-vs-cycles": 0.2612,
++ "gpu-vs-eevee": 0.0542,
++ "cpu-vs-cycles": 0.2608,
++ "cpu-vs-eevee": 0.0542,
++ "eevee-vs-cycles": 0.2662,
++ "gpu-vs-cpu": 0.0085
++ },
++ "foliage": {
++ "gpu-vs-cycles": 0.1594,
++ "gpu-vs-eevee": 0.1386,
++ "cpu-vs-cycles": 0.159,
++ "cpu-vs-eevee": 0.1384,
++ "eevee-vs-cycles": 0.0783,
++ "gpu-vs-cpu": 0.0096
++ },
++ "glass": {
++ "gpu-vs-cycles": 0.1326,
++ "gpu-vs-eevee": 0.1471,
++ "cpu-vs-cycles": 0.1323,
++ "cpu-vs-eevee": 0.1474,
++ "eevee-vs-cycles": 0.115,
++ "gpu-vs-cpu": 0.0075
++ },
++ "lit-interior": {
++ "gpu-vs-cycles": 0.5055,
++ "gpu-vs-eevee": 0.0923,
++ "cpu-vs-cycles": 0.5051,
++ "cpu-vs-eevee": 0.0928,
++ "eevee-vs-cycles": 0.5159,
++ "gpu-vs-cpu": 0.0062
++ },
++ "material-spheres": {
++ "gpu-vs-cycles": 0.1598,
++ "gpu-vs-eevee": 0.1196,
++ "cpu-vs-cycles": 0.1595,
++ "cpu-vs-eevee": 0.1194,
++ "eevee-vs-cycles": 0.1006,
++ "gpu-vs-cpu": 0.0069
++ },
++ "metal": {
++ "gpu-vs-cycles": 0.1868,
++ "gpu-vs-eevee": 0.1565,
++ "cpu-vs-cycles": 0.1867,
++ "cpu-vs-eevee": 0.1565,
++ "eevee-vs-cycles": 0.0934,
++ "gpu-vs-cpu": 0.0063
++ },
++ "outdoor-hdri": {
++ "gpu-vs-cycles": 0.0676,
++ "gpu-vs-eevee": 0.052,
++ "cpu-vs-cycles": 0.0672,
++ "cpu-vs-eevee": 0.0515,
++ "eevee-vs-cycles": 0.0384,
++ "gpu-vs-cpu": 0.0058
++ },
++ "spot-area": {
++ "gpu-vs-cycles": 0.1242,
++ "gpu-vs-eevee": 0.1707,
++ "cpu-vs-cycles": 0.1242,
++ "cpu-vs-eevee": 0.1709,
++ "eevee-vs-cycles": 0.1935,
++ "gpu-vs-cpu": 0.0032
++ }
}
-- }
}
diff --cc bench/reference/render-blender.py
index 6c669535,3c2573d4..557aa2b5
--- a/bench/reference/render-blender.py
+++ b/bench/reference/render-blender.py
@@@ -51,9 -51,12 +51,13 @@@ def build_mesh(name, geometry)
positions = decode(geometry["positions"]).reshape(-1, 3)
normals = decode(geometry["normals"]).reshape(-1, 3)
triangles = decode(geometry["indices"]).reshape(-1, 3)
+ # A triangle that repeats a vertex has no area and is invisible, but Blender builds an invalid face from it
+ # and crashes in mesh_set_custom_normals (the skinned character has three).
+ repeats_vertex = (triangles[:, 0] == triangles[:, 1]) | (triangles[:, 1] == triangles[:, 2]) | (triangles[:, 0] == triangles[:, 2])
+ triangles = triangles[~repeats_vertex]
mesh = bpy.data.meshes.new(name)
mesh.from_pydata(positions.tolist(), [], triangles.tolist())
+ mesh.validate()
mesh.normals_split_custom_set_from_vertices(normals.tolist())
uvs = decode(geometry.get("uvs"))
if uvs is not None:
diff --cc bench/size/baseline.json
index 7a376cc4,3bc3c06f..132a1512
--- a/bench/size/baseline.json
+++ b/bench/size/baseline.json
@@@ -14,9 -14,9 +14,9 @@@
},
"bundles": {
"entry:core": {
- "min": 268794,
- "gzip": 76776,
- "brotli": 65546
- "min": 274298,
- "gzip": 77983,
- "brotli": 66640
++ "min": 274345,
++ "gzip": 77993,
++ "brotli": 66486
},
"entry:model": {
"min": 40093,
@@@ -39,9 -39,9 +39,9 @@@
"brotli": 7331
},
"entry:gltf": {
- "min": 151968,
- "gzip": 46679,
- "brotli": 40033
- "min": 152103,
- "gzip": 46693,
- "brotli": 39999
++ "min": 152150,
++ "gzip": 46704,
++ "brotli": 39993
},
"entry:modeling": {
"min": 15517,
@@@ -129,24 -129,24 +129,24 @@@
"brotli": 762
},
"entry:agent-scene": {
- "min": 162579,
- "gzip": 48203,
- "brotli": 41448
- "min": 189992,
- "gzip": 57090,
- "brotli": 49452
++ "min": 190633,
++ "gzip": 57326,
++ "brotli": 49610
},
"entry:agent-scene+lazy": {
- "min": 422954,
- "gzip": 137805,
- "brotli": 120313
- "min": 489100,
- "gzip": 160873,
- "brotli": 140211
++ "min": 498812,
++ "gzip": 164401,
++ "brotli": 143354
},
"entry:agent-asset": {
- "min": 245362,
- "gzip": 74061,
- "brotli": 64428
- "min": 269753,
- "gzip": 81908,
- "brotli": 71452
++ "min": 270394,
++ "gzip": 82147,
++ "brotli": 71444
},
"entry:agent-asset+lazy": {
- "min": 448381,
- "gzip": 144778,
- "brotli": 126295
- "min": 516201,
- "gzip": 168134,
- "brotli": 146309
++ "min": 525913,
++ "gzip": 171671,
++ "brotli": 149210
},
"entry:hdri": {
"min": 8075,
@@@ -154,24 -154,24 +154,24 @@@
"brotli": 2801
},
"scene:lit-box": {
- "min": 200858,
- "gzip": 54820,
- "brotli": 46863
- "min": 206306,
- "gzip": 56013,
- "brotli": 47870
++ "min": 206353,
++ "gzip": 56023,
++ "brotli": 47903
},
"scene:gltf-box": {
- "min": 258732,
- "gzip": 73801,
- "brotli": 63362
- "min": 264183,
- "gzip": 74981,
- "brotli": 64331
++ "min": 264230,
++ "gzip": 74991,
++ "brotli": 64299
},
"scene:agent-scene": {
- "min": 260808,
- "gzip": 74153,
- "brotli": 63460
- "min": 293377,
- "gzip": 84106,
- "brotli": 72209
++ "min": 294018,
++ "gzip": 84354,
++ "brotli": 72502
},
"scene:agent-scene+lazy": {
- "min": 521183,
- "gzip": 163754,
- "brotli": 142345
- "min": 592485,
- "gzip": 187890,
- "brotli": 162954
++ "min": 602197,
++ "gzip": 191435,
++ "brotli": 166207
}
}
}
diff --cc bench/size/budgets.json
index 03675e94,1d2d99fa..9fb937a1
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@@ -28,14 -28,14 +28,14 @@@
"entry:grass": 4400,
"entry:clutter": 5300,
"entry:texture-set": 900,
- "entry:agent-scene": 49200,
- "entry:agent-scene+lazy": 141400,
- "entry:agent-asset": 75600,
- "entry:agent-asset+lazy": 148400,
- "entry:agent-scene": 58300,
- "entry:agent-scene+lazy": 164100,
- "entry:agent-asset": 83600,
- "entry:agent-asset+lazy": 171500,
++ "entry:agent-scene": 58500,
++ "entry:agent-scene+lazy": 167700,
++ "entry:agent-asset": 83800,
++ "entry:agent-asset+lazy": 175200,
"entry:hdri": 3300,
- "scene:lit-box": 56000,
- "scene:gltf-box": 75300,
- "scene:agent-scene": 75700,
- "scene:agent-scene+lazy": 167400
+ "scene:lit-box": 57200,
+ "scene:gltf-box": 76500,
- "scene:agent-scene": 85800,
- "scene:agent-scene+lazy": 191700
++ "scene:agent-scene": 86100,
++ "scene:agent-scene+lazy": 195300
}
}
diff --cc bench/tool-cost-budgets.json
index 00000000,644c2e22..93612b60
mode 000000,100644..100644
--- a/bench/tool-cost-budgets.json
+++ b/bench/tool-cost-budgets.json
@@@ -1,0 -1,21 +1,21 @@@
+ {
+ "measured": "2026-10-31, from scripts/measure-tool-cost.mjs; was 373388 schema bytes before shared IDs and recipe references",
- "schemaTotalBytes": 183800,
++ "schemaTotalBytes": 189900,
+ "schemaToolBytes": {
- "scene_create": 59400,
- "scene_apply": 44300,
++ "scene_create": 60900,
++ "scene_apply": 47400,
+ "mesh_edit": 34000,
- "scene_create_asset": 18300,
++ "scene_create_asset": 19750,
+ "mesh_stack": 11500
+ },
+ "schemaOtherToolBytes": 4000,
+ "resultBytes": {
- "scene_capabilities": 3050,
++ "scene_capabilities": 3410,
+ "scene_create": 1400,
+ "scene_inspect": 1400,
+ "mesh_inspect": 1200,
+ "mesh_edit": 2400,
+ "scene_apply": 200,
+ "scene_export_recipe": 2800
+ }
+ }
diff --cc scripts/mcp-server.mjs
index d7df9e9f,7401b2b2..5e6bc698
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@@ -5,7 -5,7 +5,7 @@@ import { setPriority, constants } from
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import packageMetadata from '../package.json' with { type: 'json' };
- import { MATERIAL_PATTERN_TYPES, MATERIAL_MAPPINGS, MATERIAL_GRAPH_OUTPUTS, MATERIAL_GRAPH_OPERATORS, MATERIAL_GRAPH_LIMITS } from '../src/agent-scene-capabilities.js';
-import { MATERIAL_PATTERN_TYPES, LIGHTING_SETUP_NAMES } from '../src/agent-scene-capabilities.js';
++import { MATERIAL_PATTERN_TYPES, MATERIAL_MAPPINGS, MATERIAL_GRAPH_OUTPUTS, MATERIAL_GRAPH_OPERATORS, MATERIAL_GRAPH_LIMITS, LIGHTING_SETUP_NAMES } from '../src/agent-scene-capabilities.js';
import { MATERIAL_LAYER_SCALAR_RANGES, MATERIAL_LAYER_COLOR_RANGES } from '../src/material-layers.js';
const finite = z.number().min(-3.4028234663852886e38).max(3.4028234663852886e38);
@@@ -39,13 -45,9 +45,13 @@@ const instanceSpec = z.strictObject(
alignToNormal: z.boolean().optional().describe('Surface only: tilt up to the surface normal.'),
scale: z.tuple([z.number().min(0.001).max(1000), z.number().min(0.001).max(1000)]).optional().describe('Random uniform scale range [min, max].'),
}).describe('Exactly one of grid, scatter or surface. Expands at scene_create into a group node plus one child node per point (<id>.0, <id>.1, ...) that share geometry and material and draw as one instanced batch. At most 2048 candidate points.');
- const nodeRecord = z.strictObject({ id: identifier, geometry: identifier.optional(), material: identifier.optional(), instances: instanceSpec.optional().describe('Repeat geometry and material at points; needs both ids. Only in the recipe given to scene_create, not in add-node.'), ...nodeFields });
+ const nodeRecord = z.strictObject({ armature: identifier.optional().describe('Set on nodes an armature generates, and ignored on input. Edit bones through armatures.'), id: identifier, geometry: identifier.optional(), material: identifier.optional(), instances: instanceSpec.optional().describe('Repeat geometry and material at points; needs both ids. Only in the recipe given to scene_create, not in add-node.'), ...nodeFields });
+const graphNode = z.union([finite, vector3, z.record(z.string(), z.unknown())]);
+const materialGraph = z.strictObject(Object.fromEntries(MATERIAL_GRAPH_OUTPUTS.map(output => [output, graphNode.optional()]))).describe(`Node graph, plain JSON and never code or shader text, baked on the CPU into textures. One or more outputs: color (linear RGB; a number is grey), roughness, metallic, emission (colour; needs no emission field, it defaults to 1), height (becomes a normal map: bump gives relief). A node is a number, [x,y,z] or an object with one operator: ${MATERIAL_GRAPH_OPERATORS.join(' ')}. Textures: {"noise":{"scale":8,"seed":1,"octaves":4}}, {"voronoi":{"scale":6,"output":"distance"|"edge"|"cell"}}, {"wave":{"frequency":4,"direction":"u"|"v"|"diagonal","shape":"sine"|"saw"|"triangle"}}, {"checker":{"count":8}}, {"gradient":{"type":"u"|"v"|"radial"}}; each takes "at" (a vector such as {"uv":"both"}) to warp it, scales are whole numbers 1 to 64 so it tiles. {"uv":"u"|"v"|"both"} are the coordinates. {"ramp":{"value":node,"stops":[[0,[r,g,b]],[1,[r,g,b]]]}} maps a number to colours (2 to ${MATERIAL_GRAPH_LIMITS.maxStops} stops). Maths: add sub mul div min max pow take [a,b]; abs floor fract sqrt invert take one node; clamp smoothstep mix take [a,b,c]; {"vec":[r,g,b]}. Numbers combine with vectors per component. At most ${MATERIAL_GRAPH_LIMITS.maxNodes} nodes, depth ${MATERIAL_GRAPH_LIMITS.maxDepth}, and a work limit that wants a smaller resolution for a big graph. Example: {"color":{"ramp":{"value":{"noise":{"scale":8}},"stops":[[0,[0.1,0.05,0.02]],[1,[0.6,0.4,0.2]]]}},"height":{"noise":{"scale":8}}}`);
const materialPattern = z.strictObject({
- type: z.enum(MATERIAL_PATTERN_TYPES).describe('Surface look. Directional types (wood, planks, metal) run along axis.'),
+ type: z.enum([...MATERIAL_PATTERN_TYPES, 'graph']).describe('Surface look: a preset, or graph for your own node graph (give graph). Directional presets (wood, planks, metal) run along axis.'),
+ graph: materialGraph.optional().describe('Only with type graph.'),
+ mapping: z.enum(MATERIAL_MAPPINGS).optional().describe('box (default) projects along the object axes and needs no UVs; uv follows the geometry UVs, so the mesh needs a uv_unwrap node or geometry.uvs. size and axis only apply to box.'),
colors: z.array(color).min(2).max(3).optional().describe('Linear RGB colours to mix, darker first. Bricks take a third for the mortar. Each type has good defaults.'),
size: z.number().min(0.01).max(100).optional().describe('Metres per repeat of the texture, so it keeps its real size on any object and node scale.'),
count: z.number().int().min(1).max(64).optional().describe('Features per repeat: planks, bricks across, tiles across, wood rings or noise cells.'),
diff --cc src/agent-scene-capabilities.js
index 438df36f,87ad67e2..a8a3adc0
--- a/src/agent-scene-capabilities.js
+++ b/src/agent-scene-capabilities.js
@@@ -45,10 -41,10 +50,12 @@@ export const AGENT_SCENE_CAPABILITIES
materialTags: Object.freeze(['surface', 'unlit', 'liquid', 'foam']),
alphaModes: RECIPE_ALPHA_MODES,
materialPatterns: MATERIAL_PATTERN_TYPES, maxMaterialPatterns: MAX_MATERIAL_PATTERNS,
+ materialMappings: MATERIAL_MAPPINGS,
+ materialGraph: Object.freeze({ outputs: MATERIAL_GRAPH_OUTPUTS, operators: MATERIAL_GRAPH_OPERATORS, ...MATERIAL_GRAPH_LIMITS }),
fixedResources: false, dynamicTopology: true, checkpoints: true, positiveScaleOnly: true,
authoredLook: true, maxPointLights: 8,
+ lightingSetups: LIGHTING_SETUP_NAMES, defaultLightingSetup: DEFAULT_LIGHTING_SETUP,
+ ambientOcclusion: Object.freeze({ default: DEFAULT_AMBIENT_OCCLUSION, defaultRadius: 0.5, off: 0 }),
// Local lights: spot and rectangular area lights. Shadows share one 2048 x 3072 depth atlas of 24 tiles; a shadowed
// point light uses 6 tiles and a shadowed spot light 1. Area lights cast no shadow. Light linking is not supported.
maxSpotLights: 8, maxAreaLights: 4,
diff --cc src/agent-scene.js
index 72e7a9bf,8c5507a1..8bdb0199
--- a/src/agent-scene.js
+++ b/src/agent-scene.js
@@@ -17,9 -19,9 +19,9 @@@ export
const DEFAULT_LIMITS = AGENT_SCENE_DEFAULT_LIMITS;
const MAX_MESH_REPORTS = 16;
const CAMERA_DEFAULTS = Object.freeze({ eye: [4, 3, 5], target: [0, 0, 0], up: [0, 1, 0], fov: 45, near: 0.1, far: 1000 });
- const NODE_FIELDS = ['translation', 'rotation', 'scale', 'parent', 'label', 'geometry', 'material'];
+ const NODE_FIELDS = ['translation', 'rotation', 'scale', 'parent', 'label', 'geometry', 'material', 'skin'];
const MATERIAL_FIELDS = ['color', 'metallic', 'roughness', 'emission', 'emissiveColor', 'opacity', 'alphaMode', 'doubleSided', 'pattern', ...MATERIAL_LAYER_FIELDS];
-const PATTERN_TEXTURE_FIELDS = ['map', 'normalMap', 'metallicRoughnessMap', 'boxMapScale', 'boxMapAxis'];
+const PATTERN_TEXTURE_FIELDS = ['map', 'normalMap', 'metallicRoughnessMap', 'emissiveMap', 'boxMapScale', 'boxMapAxis'];
const CAMERA_FIELDS = Object.keys(CAMERA_DEFAULTS);
const LOOK_OPERATION_FIELDS = Object.freeze({
'set-environment': 'environment',