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 An99cc2fe66738
diff --cc CHANGELOG.md
index da053266,53267afe..7a5eda19
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -2,8 -2,11 +2,13 @@@
## Unreleased
+- 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/size/baseline.json
index 7a376cc4,42d25d0d..3bc3c06f
--- a/bench/size/baseline.json
+++ b/bench/size/baseline.json
@@@ -64,9 -64,9 +64,9 @@@
"brotli": 12998
},
"entry:mesh": {
- "min": 144153,
- "gzip": 48359,
- "brotli": 41816
- "min": 194667,
- "gzip": 65618,
- "brotli": 55758
++ "min": 210457,
++ "gzip": 71261,
++ "brotli": 60364
},
"entry:shrinkwrap": {
"min": 56188,
@@@ -129,24 -129,24 +129,24 @@@
"brotli": 762
},
"entry:agent-scene": {
- "min": 162579,
- "gzip": 48203,
- "brotli": 41448
- "min": 189885,
- "gzip": 57054,
- "brotli": 49352
++ "min": 189992,
++ "gzip": 57090,
++ "brotli": 49452
},
"entry:agent-scene+lazy": {
- "min": 422954,
- "gzip": 137805,
- "brotli": 120313
- "min": 474013,
- "gzip": 155506,
- "brotli": 135715
++ "min": 489100,
++ "gzip": 160873,
++ "brotli": 140211
},
"entry:agent-asset": {
- "min": 245362,
- "gzip": 74061,
- "brotli": 64428
- "min": 269646,
- "gzip": 81874,
- "brotli": 71244
++ "min": 269753,
++ "gzip": 81908,
++ "brotli": 71452
},
"entry:agent-asset+lazy": {
- "min": 448381,
- "gzip": 144778,
- "brotli": 126295
- "min": 501114,
- "gzip": 162775,
- "brotli": 141809
++ "min": 516201,
++ "gzip": 168134,
++ "brotli": 146309
},
"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
},
"scene:gltf-box": {
- "min": 258732,
- "gzip": 73801,
- "brotli": 63362
+ "min": 264183,
+ "gzip": 74981,
+ "brotli": 64331
},
"scene:agent-scene": {
- "min": 260808,
- "gzip": 74153,
- "brotli": 63460
- "min": 293270,
- "gzip": 84072,
- "brotli": 72169
++ "min": 293377,
++ "gzip": 84106,
++ "brotli": 72209
},
"scene:agent-scene+lazy": {
- "min": 521183,
- "gzip": 163754,
- "brotli": 142345
- "min": 577398,
- "gzip": 182530,
- "brotli": 158566
++ "min": 592485,
++ "gzip": 187890,
++ "brotli": 162954
}
}
}
diff --cc bench/size/budgets.json
index 27dfbd1c,2217fefa..1d2d99fa
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@@ -15,7 -15,7 +15,7 @@@
"entry:sculpt": 2500,
"entry:surface": 10100,
"entry:mesh-query": 15900,
- "entry:mesh": 56900,
- "entry:mesh": 67000,
++ "entry:mesh": 72700,
"entry:shrinkwrap": 18300,
"entry:surface-attachment": 11800,
"entry:physics": 18000,
@@@ -28,14 -28,14 +28,14 @@@
"entry:grass": 4400,
"entry:clutter": 5300,
"entry:texture-set": 900,
- "entry:agent-scene": 49200,
- "entry:agent-scene+lazy": 147900,
- "entry:agent-asset": 75600,
- "entry:agent-asset+lazy": 155000,
- "entry:agent-scene": 58200,
- "entry:agent-scene+lazy": 158700,
++ "entry:agent-scene": 58300,
++ "entry:agent-scene+lazy": 164100,
+ "entry:agent-asset": 83600,
- "entry:agent-asset+lazy": 166100,
++ "entry:agent-asset+lazy": 171500,
"entry:hdri": 3300,
- "scene:lit-box": 56000,
- "scene:gltf-box": 75300,
- "scene:agent-scene": 75700,
- "scene:agent-scene+lazy": 174400
+ "scene:lit-box": 57200,
+ "scene:gltf-box": 76500,
+ "scene:agent-scene": 85800,
- "scene:agent-scene+lazy": 186200
++ "scene:agent-scene+lazy": 191700
}
}
diff --cc bench/tool-cost-budgets.json
index 00000000,10e76192..644c2e22
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": 181400,
++ "schemaTotalBytes": 183800,
+ "schemaToolBytes": {
+ "scene_create": 59400,
+ "scene_apply": 44300,
+ "mesh_edit": 34000,
+ "scene_create_asset": 18300,
+ "mesh_stack": 11500
+ },
+ "schemaOtherToolBytes": 4000,
+ "resultBytes": {
- "scene_capabilities": 3010,
++ "scene_capabilities": 3050,
+ "scene_create": 1400,
+ "scene_inspect": 1400,
+ "mesh_inspect": 1200,
+ "mesh_edit": 2400,
+ "scene_apply": 200,
+ "scene_export_recipe": 2800
+ }
+ }
diff --cc docs/parity.md
index 647d0c04,e52792aa..9215afbe
--- a/docs/parity.md
+++ b/docs/parity.md
@@@ -47,8 -47,8 +47,8 @@@ To move to a new Blender release, run `
| Modeling > Meshes > Editing | partial | 26 edits, including extrude, inset, bevel, loop cut, boolean, merge, bisect, bridge, fill, grid fill, dissolve, edge subdivision and a knife by projected polyline. All but the knife match Blender on fixtures; the knife is compared only with a straight plane cut. | [Blender results](../tests/fixtures/blender/golden.json) | #41 |
| Modeling > Meshes > Properties | partial | `smoothAngle` and face tags. There is no sharp edge attribute or crease. | | #39 |
| Modeling > Meshes > UVs | partial | `uv_unwrap` with LSCM, axis charts and shelf packing. Patterns can not use the result yet. | | #50 |
- | Modeling > Meshes > Mesh Analysis | partial | `lintMesh` reports topology problems. There is no check for thin walls or intersections. | | #66 |
+ | Modeling > Meshes > Mesh Analysis | partial | `lintMesh` reports topology problems. With `{ geometry: true }` (always on in `mesh_inspect`) it also warns of crossing parts, a solid cutting itself, thin walls, floating parts and near-symmetry, using the BVH within face budgets. Checks are heuristics on parts, not Blender's exact Select Non-Manifold or Intersect checks. | [tests/mesh-lint-geometry.test.js](../tests/mesh-lint-geometry.test.js), [src/mesh-lint-geometry.js](../src/mesh-lint-geometry.js) | #66 |
-| Modeling > Meshes > Remeshing | missing | No remesh. | | #40 |
+| Modeling > Meshes > Remeshing | partial | `remesh` rebuilds a closed mesh as an even quad surface on a voxel grid (surface nets over a BVH signed distance). Quad remesh and Instant Meshes style retopology are not here. | [blender golden](../tests/blender-golden.test.js) | #40 |
| Modeling > Curves | partial | `tube` follows a curve and `extrude` follows a contour. There is no curve object. | | #45 |
| Modeling > Curves (New) | missing | No hair curves. | | #63 |
| Modeling > Surfaces | out of scope | Issue #45 records NURBS surfaces as out of scope unless demand appears. | | |