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 An769e45ca59a2
diff --cc CHANGELOG.md
index 92174c76,4df02c5f..fbfdc253
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -2,8 -2,12 +2,14 @@@
## Unreleased
+- 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
+
+ - Reach Rapier from recipes: a `physics` section (and a `set-physics` operation) puts rigid bodies on node IDs with box, ball, capsule, convex or trimesh colliders fitted to their geometry, joints, gravity and a duration of up to 10 seconds. It is recorded once at 60 steps a second and seeks like `motion`, so a seek back repeats the same frame (checked as identical PNG bytes on SwiftShader through MCP). `scene_inspect` reports per-body final positions and resting times, contacts and sensor enter and leave events. Rapier stays an optional peer, served to the preview from `node_modules` like Manifold, so the MCP server bundle does not grow.
+ - Add trimesh and convex-hull colliders (bounded triangle and point counts, checked before allocation), sensors with enter and leave events, and 16-bit collision groups and masks to `addons/physics`, plus `contactEvents`, `restFrames`, `bakePhysicsScene`, `loadPhysicsEngine` and `setPhysicsModuleLoader`. A collider with `sensor` now bakes instead of throwing.
+ - Add the `tray-drop` task to the agent modeling suite: balls dropped into a pocket cut in an authored mesh, graded on a fixed trimesh body, balls resting on the pocket floor and a repeatable seek. Raise four size budgets for the physics code (`entry:physics` to 17,900, `entry:agent-scene` to 121,100, `entry:agent-asset` to 128,500, `scene:agent-scene` to 147,300 bytes gzip).
+
+ - Add bounded field expressions: a JSON language of math, comparison, logic, vectors, seeded noise and attributes (position, normal, index, tags) that compiles once to closures over typed arrays and never executes a string. It limits nodes (64), depth (12), elements (250,000) and node-evaluations (8 million) before it evaluates, and only reads operator names from a fixed table. It drives a `{ "field": expression }` face selection rule, `set_position` and `displace` as edits and stack nodes, and a `where` filter for instances. `displace` and `set_position` match Blender's Displace modifier and a Geometry Nodes Set Position node in five new golden cases
+ - Add `instances` on a recipe node: repeat its geometry at the points of a grid, a seeded scatter in a box or the surface of a geometry, with `where`, `yaw`, `alignToNormal` and `scale`, at most 2048 candidate points. It expands to ordinary nodes that share geometry and material, so the renderer draws one instanced batch. Add the `pillar-court` task to the agent modeling suite
- Add the `scene_export_glb` MCP tool (22 tools now) and morph weight clips in `exportGlb`. The tool writes the active recipe or imported asset scene as a GLB under `<jobs>/exports/` with a server-chosen name and returns the path, byte count and SHA-256; it takes no path, keeps the newest eight files and refuses more than 32 MiB. It exports the current pose (pattern textures, imported textures, skins, morph weights, IK as posed), `motionTime` seeks authored motion first, and `clip` adds an imported asset's source clip. Clip tracks with `property: 'weights'` write a SCALAR sampler of one weight per target. Checked in Blender 5.2: a patterned recipe opens with 2 meshes and 3 images, the robot with IK opens as 1 armature, 43 bones and 20 meshes, and its Walking clip as one action of 23 frames. Nothing in `src/index.js` changes, so no size budget moves
- Add material layers: `clearcoat` and `clearcoatRoughness`, `transmission` with `thickness`, `ior`, `attenuationColor` and `attenuationDistance`, `sheenColor` and `sheenRoughness`, and `specular` and `specularColor`. Recipes, the MCP schema, glTF import and export (`KHR_materials_clearcoat`, `transmission`, `volume`, `ior`, `specular`, `sheen`) all take them, each checked at the boundary. Transmission refracts the opaque scene like the `liquid` material. Anisotropy and iridescence are not rendered yet. Import of those two still warns
- Change the glTF import of the six layer extensions above from accepted-and-ignored to rendered, so `asset.warnings` no longer lists them
diff --cc bench/agent-modeling/README.md
index c93d8f9c,c844e091..ef04788f
--- a/bench/agent-modeling/README.md
+++ b/bench/agent-modeling/README.md
@@@ -36,7 -36,7 +36,8 @@@ own mesh report
| crate-uv | The crate with even UVs |
| crate-wood | The crate with a wood material pattern, to see whether agents find `pattern` |
| arm-reach | A jointed arm whose tip moves between two points, to see whether agents find `motion.ik` |
+| leg-plant | A leg that plants its foot on two points with the knee bending forward: `motion.ik` with `bendToward`, `pole` and `limits` |
+ | tray-drop | Recipe physics: balls dropped into a pocket cut in an authored mesh, on a fixed trimesh body, graded on resting height, contact and a repeatable seek |
| robot-reach | The CC0 robot from `tests/fixtures`: IK over its Idle clip, found through the asset catalog and hierarchy |
| dice | Rounded edges plus 21 recessed pips, in one piece (harder) |
| flange | A hollow pipe with flanges and 12 bolt holes, in one piece (harder) |
diff --cc bench/agent-modeling/tasks.mjs
index 14b4d15b,dfd2ca06..0d7e48db
--- a/bench/agent-modeling/tasks.mjs
+++ b/bench/agent-modeling/tasks.mjs
@@@ -245,23 -245,37 +245,54 @@@ For this task the object does not need
{ kind: 'nodeDistance', from: 'elbow', to: 'tip', time: 1, distance: 0.4 },
],
},
+ {
+ id: 'leg-plant',
+ prompt: `A walking character's leg that plants its foot on two points, the way a real knee bends. Use three nodes with
+these exact IDs, each with a small visible geometry: hip at [0, 1, 0], knee 0.5 m below the hip, and foot 0.5 m below the knee.
+Make knee a child of hip and foot a child of knee. The character faces +z, so the knee must bend forward, never backward.
+Add a 2 second motion in which the foot is exactly at [0.1, 0.5, 0.35] at time 0 and exactly at [0.1, 0.6, 0.2] at time 2,
+with both bones keeping their lengths and the knee in front of the hip-to-foot line at both times.
+For this task the object does not need to rest on the ground.`,
+ checks: [
+ { kind: 'nodeAt', node: 'foot', time: 0, position: [0.1, 0.5, 0.35] },
+ { kind: 'nodeAt', node: 'foot', time: 2, position: [0.1, 0.6, 0.2] },
+ { kind: 'nodeDistance', from: 'hip', to: 'knee', time: 1, distance: 0.5 },
+ { kind: 'nodeDistance', from: 'knee', to: 'foot', time: 1, distance: 0.5 },
+ { kind: 'bendsToward', from: 'hip', node: 'knee', to: 'foot', time: 0, direction: [0, 0, 1], minOffset: 0.02 },
+ { kind: 'bendsToward', from: 'hip', node: 'knee', to: 'foot', time: 2, direction: [0, 0, 1], minOffset: 0.02 },
+ ],
+ },
+ {
+ id: 'tray-drop',
+ prompt: `A pocketed block with three balls dropped into it, using recipe physics. The block is node "tray", a mesh of
+ 2 m by 0.4 m by 2 m (X, Y, Z) standing on the ground, with a square pocket 1.2 m wide cut 0.3 m deep into the middle of
+ its top face. Three balls of radius 0.1 m are nodes "ball-1", "ball-2" and "ball-3", starting above the pocket at
+ [0, 1, 0], [0.25, 1.5, 0.1] and [-0.25, 2, -0.1]. Add a 3 second physics section: the tray is a fixed body with a
+ trimesh collider, so it follows the pocket, and the balls are dynamic ball bodies. The balls must end resting on the
+ pocket floor, not on the block's top. Check the result with scene_inspect.
+ For this task the balls do not need to rest on the ground at time 0.`,
+ checks: [
+ { kind: 'lint' },
+ { kind: 'physicsBody', node: 'tray', type: 'fixed', shape: 'trimesh', label: 'tray is a fixed trimesh' },
+ { kind: 'physicsRest', nodes: ['ball-1', 'ball-2', 'ball-3'], height: [0.17, 0.23], within: 0.5, touching: 'tray', label: 'balls rest on the pocket floor' },
+ { kind: 'physicsSeek', label: 'seek back repeats the frame' },
+ ],
+ },
+ {
+ id: 'pillar-court',
+ prompt: `A pillar court: a grid of 5 pillars along X by 3 along Z. Each pillar is a square column 0.1 m wide and
+ 0.5 m tall. Pillars are 0.4 m apart along X and 0.5 m apart along Z, centre to centre, the whole grid centred on
+ X = 0 and Z = 0, every pillar standing on the ground. Repeat one pillar over the grid instead of modelling fifteen.`,
+ checks: [
+ { kind: 'lint' },
+ { kind: 'size', expected: [1.7, 0.5, 1.1] },
+ { kind: 'ground' },
+ { kind: 'holes', equals: 0 },
+ { kind: 'volume', min: 0.0725, max: 0.0775 },
+ { kind: 'section', axis: 'y', at: 0.25, equals: 15, label: 'fifteen pillars' },
+ { kind: 'section', axis: 'x', at: 0.4, equals: 3, label: 'three pillars along Z in the column at X = 0.4' },
+ ],
+ },
{
id: 'robot-reach',
assets: true,
diff --cc bench/size/baseline.json
index 8cd460f9,f74c23e2..2e850a56
--- a/bench/size/baseline.json
+++ b/bench/size/baseline.json
@@@ -39,9 -39,9 +39,9 @@@
"brotli": 7331
},
"entry:gltf": {
-- "min": 151944,
-- "gzip": 46674,
-- "brotli": 39985
++ "min": 151968,
++ "gzip": 46679,
++ "brotli": 40033
},
"entry:modeling": {
"min": 15517,
@@@ -94,9 -94,9 +94,9 @@@
"brotli": 12962
},
"entry:skeleton-pose": {
-- "min": 51635,
-- "gzip": 16806,
-- "brotli": 14274
++ "min": 55080,
++ "gzip": 18056,
++ "brotli": 15427
},
"entry:vehicle": {
"min": 42067,
@@@ -129,14 -129,14 +129,14 @@@
"brotli": 762
},
"entry:agent-scene": {
- "min": 344496,
- "gzip": 108633,
- "brotli": 92877
- "min": 399226,
- "gzip": 126629,
- "brotli": 107783
++ "min": 419435,
++ "gzip": 133124,
++ "brotli": 113067
},
"entry:agent-asset": {
- "min": 371020,
- "gzip": 116055,
- "brotli": 99302
- "min": 425353,
- "gzip": 133851,
- "brotli": 113836
++ "min": 445545,
++ "gzip": 140377,
++ "brotli": 119117
},
"entry:hdri": {
"min": 8075,
@@@ -149,14 -149,14 +149,14 @@@
"brotli": 46863
},
"scene:gltf-box": {
-- "min": 258708,
-- "gzip": 73797,
++ "min": 258732,
++ "gzip": 73801,
"brotli": 63362
},
"scene:agent-scene": {
- "min": 444099,
- "gzip": 134816,
- "brotli": 114839
- "min": 498424,
- "gzip": 152612,
- "brotli": 129631
++ "min": 518633,
++ "gzip": 159129,
++ "brotli": 135030
}
}
}
diff --cc bench/size/budgets.json
index a625ced9,52cf5d30..94138060
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@@ -15,24 -15,24 +15,24 @@@
"entry:sculpt": 2500,
"entry:surface": 10100,
"entry:mesh-query": 15900,
- "entry:mesh": 44700,
+ "entry:mesh": 49400,
"entry:shrinkwrap": 18300,
"entry:surface-attachment": 11800,
- "entry:physics": 16500,
+ "entry:physics": 18000,
"entry:spume": 9000,
"entry:retarget": 15700,
- "entry:skeleton-pose": 18100,
- "entry:skeleton-pose": 17200,
++ "entry:skeleton-pose": 18500,
"entry:vehicle": 14700,
"entry:vegetation": 17900,
"entry:terrain": 3100,
"entry:grass": 4400,
"entry:clutter": 5300,
"entry:texture-set": 900,
- "entry:agent-scene": 115200,
- "entry:agent-asset": 122600,
- "entry:agent-scene": 129200,
- "entry:agent-asset": 136600,
++ "entry:agent-scene": 135800,
++ "entry:agent-asset": 143200,
"entry:hdri": 3300,
"scene:lit-box": 56000,
"scene:gltf-box": 75300,
- "scene:agent-scene": 141400
- "scene:agent-scene": 155700
++ "scene:agent-scene": 162400
}
}
diff --cc skills/build-67js-scene/SKILL.md
index ffce5e1a,8cfd4ce6..7c9f611c
--- a/skills/build-67js-scene/SKILL.md
+++ b/skills/build-67js-scene/SKILL.md
@@@ -40,9 -40,10 +40,10 @@@ Use `simplify-code` and `engineering-wo
- 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`.
- 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.
-- Jointed motion (an arm reaching, a lamp or head tracking a point) on a recipe or an imported character uses `motion.ik`, which needs no quaternions: on a recipe parent the joint nodes and put sizes on child mesh nodes, on an asset find `node-N` IDs with `scene_inspect` kind hierarchy and aim with `worldForward`. Read `motionIk` from `scene_inspect`. See "Inverse kinematics" in the checkout's `docs/agent-motion.md`.
+- Jointed motion (an arm reaching, a lamp or head tracking a point) on a recipe or an imported character uses `motion.ik`, which needs no quaternions: on a recipe parent the joint nodes and put sizes on child mesh nodes, on an asset find `node-N` IDs with `scene_inspect` kind hierarchy and aim with `worldForward`. Read `motionIk` from `scene_inspect`: besides `reached`, it lists `warnings` (`wrong-bend` when a knee or elbow bends the unnatural way, `hyperextended`) and `limited` (poses a joint limit changed). Give a leg or arm `bendToward` (a world direction, such as `[0, 0, 1]` for a knee on a character facing +z) and `limits` per joint in degrees, and fix any warning before you finish. `motion.constraints` (copy, limit, `track_to`, `child_of`, `floor`, Blender's meanings, Euler XYZ degrees) and `motion.drivers` (a node or material property from a bounded JSON expression) run after IK and give the same pose at any time. See "Inverse kinematics", "Constraints" and "Drivers" in the checkout's `docs/agent-motion.md`.
- Agent tool calls use the installed `67js-mcp` stdio server from release `0.5.0` onward. Read `docs/mcp.md` for launch and PNG feedback.
- Agent render jobs use `docs/agent-render-jobs.md`. Check source versus published support, configure a private store and poll until terminal.
+ - Things that fall, pile up or rest on an authored mesh (dropped objects, a ball in a bowl, a trigger zone) use the recipe `physics` section: bodies on root node IDs, `shape: 'trimesh'` on a fixed body so objects follow the mesh, `sensor: true` for triggers, `layer` and `collidesWith` for masks. Seek with `motionTime` like motion, and read `physics` from `scene_inspect` (resting times, contacts, sensor events) instead of guessing from a picture. Needs the optional peer `@dimforge/rapier3d-compat`; bodies bound to bones for ragdolls are not supported. See "Recipe physics" in the checkout's `docs/physics.md`.
- Agent procedural animation uses `docs/agent-motion.md` from release `0.7.0`. Author recipe tracks, then seek through `sampleMotion` or MCP `motionTime`.
- Agent imported character motion uses `docs/agent-character-motion.md` from release `0.8.0`. Inspect source joints before authoring local tracks.
- Agent comparisons use `scene_review` from release `0.9.0`. Read `docs/agent-review.md` for isolated views and independent pose samples.
diff --cc src/agent-scene-capabilities.js
index d2f489d6,5be08100..754d5244
--- a/src/agent-scene-capabilities.js
+++ b/src/agent-scene-capabilities.js
@@@ -37,7 -45,13 +45,15 @@@ export const AGENT_SCENE_CAPABILITIES
lightLinking: false,
proceduralMotion: true,
motionIk: Object.freeze(['two-bone', 'aim']),
+ motionConstraints: Object.freeze(['copy_location', 'copy_rotation', 'copy_scale', 'limit_location', 'limit_rotation', 'track_to', 'child_of', 'floor']),
+ motionDrivers: Object.freeze({ maxDrivers: 32, maxConstraints: 32, maxExpressionParts: 64, maxExpressionDepth: 8 }),
+ // Recipe physics: Rapier (an optional peer) bakes bodies on nodes offline; playback is a seek into the bake.
+ physics: Object.freeze({
+ bodyTypes: Object.freeze(['dynamic', 'fixed', 'kinematic']),
+ shapes: Object.freeze(['box', 'ball', 'capsule', 'convex', 'trimesh']),
+ jointTypes: Object.freeze(['spherical', 'revolute', 'prismatic', 'fixed']),
+ sensors: true, collisionLayers: 16, boneBodies: false,
+ limits: Object.freeze({ maxBodies: 64, maxJoints: 64, maxDuration: 10, framesPerSecond: 60, maxTrimeshTriangles: 20000, maxHullPoints: 2048 }),
+ }),
motionLimits: Object.freeze({ maxTracks: 128, maxKeyframesPerTrack: 64, maxKeyframes: 2048, maxDuration: 30 }),
});