Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Measure relations on a 12-part desk and cut their schema cost

Nguyen Xuan An293a60a78e18
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 22f09a38..d927f636 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
## 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 `scene_create` and `scene_apply` schemas grew by about 1.3 KB each (budgets raised by 2600 bytes in total). The agent modeling suite gains `kettle-resize` and `kettle-resize-plain` and a `touches` check; on Sonnet both pass 3 of 3 in 3 to 4 calls each, so relations did not cut tool calls on a task that one batched `scene_apply` already solves.
+- 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 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 --git a/bench/agent-modeling/README.md b/bench/agent-modeling/README.md
index 75c67f58..97a0bad0 100644
--- a/bench/agent-modeling/README.md
+++ b/bench/agent-modeling/README.md
@@ -34,6 +34,7 @@ own mesh report:
| soap | Rounding every edge (bevel) |
| pebble | A smooth solid from a box (subdivision) |
| crate-uv | The crate with even UVs |
+| desk-resize, desk-resize-plain | A 12-part desk (legs, drawers with handles, lamp, book) resized in three inspected steps, graded on contact for every attached pair and on where parts end up. Relations against absolute positions |
| kettle-resize, kettle-resize-plain | Resize a kettle body so the lid, handle and spout stay against it. The first start recipe holds `relations`, the second absolute positions; the difference in tool calls is what relations are worth |
| 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` |
diff --git a/bench/agent-modeling/check.mjs b/bench/agent-modeling/check.mjs
index acf614ae..6b7b8274 100644
--- a/bench/agent-modeling/check.mjs
+++ b/bench/agent-modeling/check.mjs
@@ -105,6 +105,13 @@ function checkOne(check, measures) {
const overlaps = otherAxes.every(other => node.min[other] < against.max[other] && node.max[other] > against.min[other]);
return { pass: Math.abs(gap) <= TOUCH_TOLERANCE && overlaps, detail: `${check.node} is ${round(gap)} m from ${check.against}${overlaps ? '' : ' and does not overlap it'}` };
}
+ case 'centreAt': {
+ const bounds = measures.nodeBounds(check.node);
+ if (!bounds) return { pass: false, detail: `no drawn node ${check.node}` };
+ const centre = bounds.min.map((minimum, axis) => (minimum + bounds.max[axis]) / 2);
+ const distance = Math.hypot(...centre.map((value, axis) => value - check.position[axis]));
+ return { pass: distance <= 0.01, detail: `${check.node} centre is ${round(distance)} m from where it belongs` };
+ }
case 'nodeAt': {
const position = measures.nodePosition(check.node, check.time);
if (!position) return { pass: false, detail: `no drawn node ${check.node}` };
diff --git a/bench/agent-modeling/desk.mjs b/bench/agent-modeling/desk.mjs
new file mode 100644
index 00000000..1c91bd00
--- /dev/null
+++ b/bench/agent-modeling/desk.mjs
@@ -0,0 +1,129 @@
+// A desk of 12 parts stacked on each other: top, four legs, two drawers with a handle each, a lamp on a base and a
+// book. The relations version states where each part sits; the plain version holds the same absolute positions.
+
+const DESK_HEIGHT = 0.75;
+const LEG_SIZE = 0.05;
+const LEG_INSET = 0.05;
+const DRAWER_INSET = 0.1;
+const DRAWER_SIZE = [0.5, 0.12, 0.5];
+const HANDLE_SIZE = [0.1, 0.02, 0.02];
+const LAMP_BASE_SIZE = [0.15, 0.03, 0.15];
+const LAMP_SIZE = [0.03, 0.4, 0.03];
+const BOOK_SIZE = [0.25, 0.04, 0.18];
+
+function placed(withRelations, relations) {
+ return withRelations ? { relations } : {};
+}
+
+function legParts(topSize, withRelations) {
+ const [topWidth, topThickness, topDepth] = topSize;
+ const underside = DESK_HEIGHT - topThickness;
+ const parts = [];
+ for (const [xName, xSign] of [['left', -1], ['right', 1]]) {
+ for (const [zName, zSign] of [['back', -1], ['front', 1]]) {
+ parts.push({
+ id: `leg-${xName}-${zName}`, geometry: 'block', scale: [LEG_SIZE, underside, LEG_SIZE],
+ translation: [xSign * (topWidth / 2 - LEG_INSET - LEG_SIZE / 2), underside / 2, zSign * (topDepth / 2 - LEG_INSET - LEG_SIZE / 2)],
+ ...placed(withRelations, [
+ { kind: 'gap', to: 'top', side: '-y' },
+ { kind: 'align', to: 'top', axis: 'x', at: xSign < 0 ? 'min' : 'max', offset: -xSign * LEG_INSET },
+ { kind: 'align', to: 'top', axis: 'z', at: zSign < 0 ? 'min' : 'max', offset: -zSign * LEG_INSET },
+ ]),
+ });
+ }
+ }
+ return parts;
+}
+
+function drawerParts(topSize, drawerDepth, withRelations) {
+ const [topWidth, topThickness] = topSize;
+ const drawerY = DESK_HEIGHT - topThickness - DRAWER_SIZE[1] / 2;
+ const parts = [];
+ for (const [name, sign] of [['left', -1], ['right', 1]]) {
+ const drawerX = sign * (topWidth / 2 - DRAWER_INSET - DRAWER_SIZE[0] / 2);
+ parts.push({
+ id: `drawer-${name}`, geometry: 'block', scale: [DRAWER_SIZE[0], DRAWER_SIZE[1], drawerDepth], translation: [drawerX, drawerY, 0],
+ ...placed(withRelations, [
+ { kind: 'gap', to: 'top', side: '-y' },
+ { kind: 'align', to: 'top', axis: 'x', at: sign < 0 ? 'min' : 'max', offset: -sign * DRAWER_INSET },
+ { kind: 'centered', to: 'top', axes: ['z'] },
+ ]),
+ });
+ parts.push({
+ id: `handle-${name}`, geometry: 'block', scale: HANDLE_SIZE, translation: [drawerX, drawerY, drawerDepth / 2 + HANDLE_SIZE[2] / 2],
+ ...placed(withRelations, [{ kind: 'attach', to: `drawer-${name}`, side: '+z' }]),
+ });
+ }
+ return parts;
+}
+
+function topParts(topSize, withRelations) {
+ const [topWidth] = topSize;
+ const lampBaseX = topWidth / 2 - DRAWER_INSET - LAMP_BASE_SIZE[0] / 2;
+ const lampBaseY = DESK_HEIGHT + LAMP_BASE_SIZE[1] / 2;
+ return [
+ {
+ id: 'lamp-base', geometry: 'block', scale: LAMP_BASE_SIZE, translation: [lampBaseX, lampBaseY, 0],
+ ...placed(withRelations, [
+ { kind: 'gap', to: 'top', side: '+y' },
+ { kind: 'align', to: 'top', axis: 'x', at: 'max', offset: -DRAWER_INSET },
+ { kind: 'centered', to: 'top', axes: ['z'] },
+ ]),
+ },
+ {
+ id: 'lamp', geometry: 'block', scale: LAMP_SIZE, translation: [lampBaseX, lampBaseY + LAMP_BASE_SIZE[1] / 2 + LAMP_SIZE[1] / 2, 0],
+ ...placed(withRelations, [{ kind: 'attach', to: 'lamp-base', side: '+y' }]),
+ },
+ {
+ id: 'book', geometry: 'block', scale: BOOK_SIZE, translation: [-topWidth / 2 + DRAWER_INSET + BOOK_SIZE[0] / 2, DESK_HEIGHT + BOOK_SIZE[1] / 2, 0],
+ ...placed(withRelations, [
+ { kind: 'gap', to: 'top', side: '+y' },
+ { kind: 'align', to: 'top', axis: 'x', at: 'min', offset: DRAWER_INSET },
+ { kind: 'centered', to: 'top', axes: ['z'] },
+ ]),
+ },
+ ];
+}
+
+/** The desk for a top of [width, thickness, depth] metres and drawers of the given depth. */
+export function deskRecipe(topSize, drawerDepth, withRelations) {
+ const parts = [
+ { id: 'top', geometry: 'block', scale: topSize, translation: [0, DESK_HEIGHT - topSize[1] / 2, 0] },
+ ...legParts(topSize, withRelations),
+ ...drawerParts(topSize, drawerDepth, withRelations),
+ ...topParts(topSize, withRelations),
+ ];
+ return {
+ format: '67js.scene', schemaVersion: 1,
+ geometries: [{ id: 'block', type: 'box', bevel: 0 }],
+ materials: [{ id: 'paint', color: [0.6, 0.55, 0.5] }],
+ nodes: parts.map(part => ({ material: 'paint', ...part })),
+ };
+}
+
+export const DESK_START = deskRecipe([1.2, 0.04, 0.6], 0.5, true);
+export const DESK_START_PLAIN = deskRecipe([1.2, 0.04, 0.6], 0.5, false);
+export const DESK_FINAL = deskRecipe([1.6, 0.08, 0.8], 0.7, true);
+export const DESK_FINAL_PLAIN = deskRecipe([1.6, 0.08, 0.8], 0.7, false);
+
+const touchPairs = [
+ ...['left-back', 'left-front', 'right-back', 'right-front'].map(name => ({ node: `leg-${name}`, against: 'top', side: '-y' })),
+ { node: 'drawer-left', against: 'top', side: '-y' },
+ { node: 'drawer-right', against: 'top', side: '-y' },
+ { node: 'handle-left', against: 'drawer-left', side: '+z' },
+ { node: 'handle-right', against: 'drawer-right', side: '+z' },
+ { node: 'lamp-base', against: 'top', side: '+y' },
+ { node: 'lamp', against: 'lamp-base', side: '+y' },
+ { node: 'book', against: 'top', side: '+y' },
+];
+
+/** Contact for every attached pair, plus where the parts must end up after the last step. */
+export const DESK_CHECKS = [
+ { kind: 'lint' },
+ { kind: 'size', expected: [1.6, 1.18, 0.8] },
+ { kind: 'ground' },
+ ...touchPairs.map(pair => ({ kind: 'touches', ...pair })),
+ ...DESK_FINAL.nodes
+ .filter(node => ['leg-left-back', 'leg-right-front', 'drawer-left', 'drawer-right', 'handle-right', 'lamp', 'book'].includes(node.id))
+ .map(node => ({ kind: 'centreAt', node: node.id, position: node.translation })),
+];
diff --git a/bench/agent-modeling/references.mjs b/bench/agent-modeling/references.mjs
index ecd320ee..9fdf19fa 100644
--- a/bench/agent-modeling/references.mjs
+++ b/bench/agent-modeling/references.mjs
@@ -7,6 +7,7 @@ const PEBBLE_SIZE = [0.08, 0.03, 0.05];
import { walkerRecipe } from './walker.mjs';
import { KETTLE_RESIZED, KETTLE_RESIZED_PLAIN } from './kettle.mjs';
+import { DESK_FINAL, DESK_FINAL_PLAIN } from './desk.mjs';
const material = [{ id: 'paint', color: [0.6, 0.55, 0.5] }];
@@ -164,6 +165,8 @@ function robotArmSolver(root, middle, end, target) {
export const REFERENCES = {
'kettle-resize': KETTLE_RESIZED,
'kettle-resize-plain': KETTLE_RESIZED_PLAIN,
+ 'desk-resize': DESK_FINAL,
+ 'desk-resize-plain': DESK_FINAL_PLAIN,
'chamfer-plate': scene(
[{
id: 'plate', type: 'mesh', base: { type: 'box', bevel: 0 }, edits: [
diff --git a/bench/agent-modeling/results/2026-10-31-11-48-sonnet-relations-desk.json b/bench/agent-modeling/results/2026-10-31-11-48-sonnet-relations-desk.json
new file mode 100644
index 00000000..33ac5267
--- /dev/null
+++ b/bench/agent-modeling/results/2026-10-31-11-48-sonnet-relations-desk.json
@@ -0,0 +1,299 @@
+{
+ "run": "2026-10-31-11-48-sonnet-relations-desk",
+ "model": "claude-sonnet-5-5",
+ "date": "2026-10-31T11:53:11.635Z",
+ "skill": false,
+ "runsPerTask": 3,
+ "passed": 6,
+ "tasks": 6,
+ "toolCalls": 48,
+ "costUsd": 2.61,
+ "byModel": {
+ "claude-sonnet-5-5": {
+ "runs": 6,
+ "passed": 6,
+ "successRate": 1,
+ "toolCalls": 48,
+ "toolErrors": 0,
+ "inputTokens": 3663877,
+ "outputTokens": 24708,
+ "costUsd": 2.61,
+ "tasks": {
+ "desk-resize": {
+ "runs": 3,
+ "passed": 3,
+ "successRate": 1,
+ "toolCalls": 24,
+ "toolErrors": 0,
+ "inputTokens": 1894000,
+ "outputTokens": 11498,
+ "costUsd": 1.35
+ },
+ "desk-resize-plain": {
+ "runs": 3,
+ "passed": 3,
+ "successRate": 1,
+ "toolCalls": 24,
+ "toolErrors": 0,
+ "inputTokens": 1769877,
+ "outputTokens": 13210,
+ "costUsd": 1.26
+ }
+ }
+ }
+ },
+ "records": [
+ {
+ "task": "desk-resize",
+ "attempt": 1,
+ "pass": true,
+ "passed": 21,
+ "total": 21,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 8,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_apply": 3,
+ "scene_inspect": 3,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": [],
+ "motionIk": [],
+ "motionTracks": 0
+ },
+ "look": {
+ "error": "page.evaluate: Error: This recipe needs the relations code, which loads on demand: await loadAgentSceneModules(recipe) before createAgentScene or apply."
+ },
+ "turns": 10,
+ "costUsd": 0.40273050000000005,
+ "inputTokens": 568446,
+ "outputTokens": 3937,
+ "wallSeconds": 39,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "desk-resize-plain",
+ "attempt": 1,
+ "pass": true,
+ "passed": 21,
+ "total": 21,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 8,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_apply": 3,
+ "scene_inspect": 3,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": [],
+ "motionIk": [],
+ "motionTracks": 0
+ },
+ "look": {
+ "silhouette": {
+ "views": {
+ "front": 1,
+ "side": 1,
+ "three-quarter": 1
+ },
+ "mean": 1
+ },
+ "images": [
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/1/desk-resize-plain-front.png",
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/1/desk-resize-plain-side.png",
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/1/desk-resize-plain-three-quarter.png"
+ ]
+ },
+ "turns": 10,
+ "costUsd": 0.3964034,
+ "inputTokens": 558407,
+ "outputTokens": 4414,
+ "wallSeconds": 40,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "desk-resize",
+ "attempt": 2,
+ "pass": true,
+ "passed": 21,
+ "total": 21,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 8,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_apply": 3,
+ "scene_inspect": 3,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": [],
+ "motionIk": [],
+ "motionTracks": 0
+ },
+ "look": {
+ "error": "page.evaluate: Error: This recipe needs the relations code, which loads on demand: await loadAgentSceneModules(recipe) before createAgentScene or apply."
+ },
+ "turns": 10,
+ "costUsd": 0.4730645,
+ "inputTokens": 663156,
+ "outputTokens": 3873,
+ "wallSeconds": 38,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "desk-resize-plain",
+ "attempt": 2,
+ "pass": true,
+ "passed": 21,
+ "total": 21,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 8,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_apply": 3,
+ "scene_inspect": 3,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": [],
+ "motionIk": [],
+ "motionTracks": 0
+ },
+ "look": {
+ "silhouette": {
+ "views": {
+ "front": 1,
+ "side": 1,
+ "three-quarter": 1
+ },
+ "mean": 1
+ },
+ "images": [
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/2/desk-resize-plain-front.png",
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/2/desk-resize-plain-side.png",
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/2/desk-resize-plain-three-quarter.png"
+ ]
+ },
+ "turns": 10,
+ "costUsd": 0.46708440000000007,
+ "inputTokens": 652593,
+ "outputTokens": 4528,
+ "wallSeconds": 44,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "desk-resize",
+ "attempt": 3,
+ "pass": true,
+ "passed": 21,
+ "total": 21,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 8,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_apply": 3,
+ "scene_inspect": 3,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": [],
+ "motionIk": [],
+ "motionTracks": 0
+ },
+ "look": {
+ "error": "page.evaluate: Error: This recipe needs the relations code, which loads on demand: await loadAgentSceneModules(recipe) before createAgentScene or apply."
+ },
+ "turns": 10,
+ "costUsd": 0.47067070000000005,
+ "inputTokens": 662398,
+ "outputTokens": 3688,
+ "wallSeconds": 39,
+ "exitCode": 0,
+ "stopped": "success"
+ },
+ {
+ "task": "desk-resize-plain",
+ "attempt": 3,
+ "pass": true,
+ "passed": 21,
+ "total": 21,
+ "failed": [],
+ "model": "claude-sonnet-5-5",
+ "toolCalls": 8,
+ "toolErrors": 0,
+ "toolsByName": {
+ "ToolSearch": 1,
+ "scene_create": 1,
+ "scene_apply": 3,
+ "scene_inspect": 3,
+ "scene_export_recipe": 1
+ },
+ "features": {
+ "geometryTypes": [
+ "box"
+ ],
+ "meshOperations": [],
+ "motionIk": [],
+ "motionTracks": 0
+ },
+ "look": {
+ "silhouette": {
+ "views": {
+ "front": 1,
+ "side": 1,
+ "three-quarter": 1
+ },
+ "mean": 1
+ },
+ "images": [
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/3/desk-resize-plain-front.png",
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/3/desk-resize-plain-side.png",
+ "artifacts/agent-modeling/2026-10-31-11-48-sonnet-relations-desk/look/3/desk-resize-plain-three-quarter.png"
+ ]
+ },
+ "turns": 10,
+ "costUsd": 0.3955793000000001,
+ "inputTokens": 558877,
+ "outputTokens": 4268,
+ "wallSeconds": 42,
+ "exitCode": 0,
+ "stopped": "success"
+ }
+ ]
+}
diff --git a/bench/agent-modeling/tasks.mjs b/bench/agent-modeling/tasks.mjs
index 07eeb830..d2b434d2 100644
--- a/bench/agent-modeling/tasks.mjs
+++ b/bench/agent-modeling/tasks.mjs
@@ -3,6 +3,7 @@
import { REFERENCES } from './references.mjs';
import { KETTLE_START, KETTLE_START_PLAIN } from './kettle.mjs';
+import { DESK_START, DESK_START_PLAIN, DESK_CHECKS } from './desk.mjs';
export const PROMPT_PREAMBLE = `You are modeling with the 67.js MCP tools. Build the object described below as a procedural recipe scene:
start it with scene_create, refine it with mesh_edit, mesh_stack and scene_apply, and look at it with scene_look when
@@ -45,6 +46,21 @@ const KETTLE_TASKS = [
{ id: 'kettle-resize-plain', startRecipe: KETTLE_START_PLAIN, prompt: KETTLE_PROMPT, checks: KETTLE_CHECKS },
];
+// Twelve stacked parts and three resizes, one after the other, with a check between steps. The start recipe either
+// holds relations or absolute positions; the same checks grade both after the last step.
+const DESK_PROMPT = `The desk scene below has 12 parts stacked on each other: a top, four legs, two drawers hanging under the top
+with a handle on the front (+Z) of each, a lamp on a base and a book on the top. Do three steps in order, and after each step
+call scene_inspect with includeBounds to check the result before the next. Step 1: widen the top to 1.6 m along X.
+Step 2: deepen the top to 0.8 m along Z and deepen both drawers to 0.7 m along Z. Step 3: thicken the top to 0.08 m while its
+upper surface stays at 0.75 m, and shorten the legs so they still run from the ground to the underside of the top. Keep the
+size of every other part. After the last step every part must sit where it sat before, relative to what it sits against: legs
+0.05 m in from the edges of the top, drawers 0.1 m in from the ends of the top and centred in Z, a handle touching the front
+of its drawer and centred on it, the lamp base and the book on the top at the same offsets from its ends, the lamp on its base.`;
+const DESK_TASKS = [
+ { id: 'desk-resize', startRecipe: DESK_START, prompt: DESK_PROMPT, checks: DESK_CHECKS },
+ { id: 'desk-resize-plain', startRecipe: DESK_START_PLAIN, prompt: DESK_PROMPT, checks: DESK_CHECKS },
+];
+
const LONG_TASKS = [
{
id: 'chamfer-plate',
@@ -492,6 +508,7 @@ recipe is what gets graded.`,
],
},
...KETTLE_TASKS,
+ ...DESK_TASKS,
...LONG_TASKS,
];
diff --git a/bench/size/baseline.json b/bench/size/baseline.json
index 245eca36..453d141d 100644
--- a/bench/size/baseline.json
+++ b/bench/size/baseline.json
@@ -129,24 +129,24 @@
"brotli": 762
},
"entry:agent-scene": {
- "min": 191009,
- "gzip": 57473,
- "brotli": 49639
+ "min": 191746,
+ "gzip": 57799,
+ "brotli": 49970
},
"entry:agent-scene+lazy": {
- "min": 506697,
- "gzip": 167503,
- "brotli": 146027
+ "min": 507434,
+ "gzip": 167835,
+ "brotli": 146305
},
"entry:agent-asset": {
- "min": 270689,
- "gzip": 82267,
- "brotli": 71609
+ "min": 271426,
+ "gzip": 82591,
+ "brotli": 71883
},
"entry:agent-asset+lazy": {
- "min": 533717,
- "gzip": 174748,
- "brotli": 152144
+ "min": 534454,
+ "gzip": 175075,
+ "brotli": 152461
},
"entry:hdri": {
"min": 8075,
@@ -164,14 +164,14 @@
"brotli": 64299
},
"scene:agent-scene": {
- "min": 294313,
- "gzip": 84458,
- "brotli": 72526
+ "min": 295050,
+ "gzip": 84782,
+ "brotli": 72739
},
"scene:agent-scene+lazy": {
- "min": 610001,
- "gzip": 194494,
- "brotli": 168859
+ "min": 610738,
+ "gzip": 194821,
+ "brotli": 169066
}
}
}
diff --git a/bench/size/budgets.json b/bench/size/budgets.json
index 9fb937a1..640edb9c 100644
--- a/bench/size/budgets.json
+++ b/bench/size/budgets.json
@@ -29,7 +29,7 @@
"entry:clutter": 5300,
"entry:texture-set": 900,
"entry:agent-scene": 58500,
- "entry:agent-scene+lazy": 167700,
+ "entry:agent-scene+lazy": 168000,
"entry:agent-asset": 83800,
"entry:agent-asset+lazy": 175200,
"entry:hdri": 3300,
diff --git a/bench/tool-cost-budgets.json b/bench/tool-cost-budgets.json
index d75adf40..1412bddd 100644
--- a/bench/tool-cost-budgets.json
+++ b/bench/tool-cost-budgets.json
@@ -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 2600 total, 1300 for scene_create and 1350 for scene_apply for the node relations field (no new tool); was 373388 schema bytes before shared IDs and recipe references",
- "schemaTotalBytes": 193300,
+ "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,
"schemaToolBytes": {
- "scene_create": 62200,
- "scene_apply": 48900,
+ "scene_create": 61200,
+ "scene_apply": 47900,
"mesh_edit": 34000,
"scene_create_asset": 19750,
"mesh_stack": 11500
},
"schemaOtherToolBytes": 4000,
"resultBytes": {
- "scene_capabilities": 3410,
+ "scene_capabilities": 4200,
"scene_create": 1400,
"scene_inspect": 1400,
"mesh_inspect": 1200,
diff --git a/docs/agent-scene.md b/docs/agent-scene.md
index fd7ed50d..caebd27e 100644
--- a/docs/agent-scene.md
+++ b/docs/agent-scene.md
@@ -262,7 +262,7 @@ child included) is rejected with the loop spelled out. Solving is deterministic:
translations, whatever the order of the nodes. A relation that cannot be satisfied, such as an unknown tag, rejects the
whole edit and names the relation. `relations: []` in `set-node` removes them and keeps the part where it is. The
exported recipe holds both the relations and the solved translations. Motion and physics move nodes after the solve and
-know nothing of relations. The code loads on demand (`relations`, see On-demand code).
+know nothing of relations. The code loads on demand (`relations`, see On-demand code). The MCP schema only says `relations` is a list; the kinds and fields are in `scene_capabilities` under `relations`.
## Transactions and ownership
diff --git a/docs/parity.md b/docs/parity.md
index fd7c7ae0..46b12c0a 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -241,7 +241,7 @@ The goal also needs this work, and no page in the Blender manual covers it.
| Runtime speed | partial | `bench/runtime` compares 7 scenes, and three.js wins most of them. There is no culling, LOD selection or adaptive quality, and bakes run on the main thread. | #28, #37, #38, #74 |
| Agent measurement | partial | A task suite runs on one model and reads recipes only. | #29, #30, #31, #69 |
| Pull request checks | partial | The `Test` workflow reports a status and does not block a merge. | #32 |
-| Relations between parts | partial | The agent version of snapping: node `relations` (`attach`, `gap`, `flush`, `align`, `centered`) over world bounds or a tagged region, solved again on every edit, cycles rejected. Tests in [part-relations](../tests/part-relations.test.js); suite tasks `kettle-resize` and `kettle-resize-plain`. No snapping to edges or vertices, no relation on the part's own tagged region. | #44 |
+| Relations between parts | partial | The agent version of snapping: node `relations` (`attach`, `gap`, `flush`, `align`, `centered`) over world bounds or a tagged region, solved again on every edit, cycles rejected. Tests in [part-relations](../tests/part-relations.test.js); suite tasks `kettle-resize` and `desk-resize` with plain twins (no gain in calls measured on Sonnet). No snapping to edges or vertices, no relation on the part's own tagged region. | #44 |
| Imported mesh editing | missing | Imported assets accept poses and transforms. Their topology is fixed. | #48 |
| Rendering backend | missing | WebGL2 only. WebGPU is not evaluated. | #56 |
| Terrain and navigation | partial | Terrain with 4 splat layers and no holes. There is no navmesh. | #64 |
diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjs
index ce1369c4..fd692059 100644
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@ -26,17 +26,7 @@ const skinSpec = z.strictObject({
maxInfluences: z.number().int().min(1).max(4).optional().describe('Bones that move one vertex. Defaults to 4.'),
maxDistance: positive.optional().describe('Metres from the nearest bone beyond which a vertex counts as unweighted in scene_inspect rig. Defaults to a quarter of the rig size.'),
}).describe('Bind this mesh node to an armature with automatic weights: each vertex follows its nearest bones, by distance to the bone segments. Needs the armature at rest where the mesh is.');
-const relationSpec = z.strictObject({
- kind: z.enum(['attach', 'flush', 'align', 'centered', 'gap']),
- to: identifier.describe('Mesh node to place against.'),
- region: z.string().min(1).max(128).optional().describe('A mesh tag: use only those faces of the target.'),
- side: z.enum(['+x', '-x', '+y', '-y', '+z', '-z']).optional(),
- axis: z.enum(['x', 'y', 'z']).optional(),
- at: z.enum(['min', 'center', 'max']).optional(),
- axes: z.array(z.enum(['x', 'y', 'z'])).max(3).optional(),
- offset: z.number().optional().describe('Metres; for attach and gap the distance from the face, negative sinks in.'),
-}).meta({ id: 'Relation' });
-const relationList = z.array(relationSpec).max(8).describe('Place this mesh node from other nodes in world space, solved again after each edit. attach and gap take side (target face): attach touches it and centres on the other axes, gap touches on that axis only. flush takes side: same face level. align takes axis and at. centered takes axes. One relation per axis, no loops, overrides translation on its axes. [] removes them.').meta({ id: 'Relations' });
+const relationList = z.array(z.record(z.string(), z.unknown())).max(8).describe('Relations against other mesh nodes; fields in scene_capabilities relations. [] removes them.').meta({ id: 'Relations' });
const nodeFields = {
relations: relationList.optional(),
skin: skinSpec.optional(),
diff --git a/skills/build-67js-scene/SKILL.md b/skills/build-67js-scene/SKILL.md
index 38555aca..5239866e 100644
--- a/skills/build-67js-scene/SKILL.md
+++ b/skills/build-67js-scene/SKILL.md
@@ -37,7 +37,7 @@ Use `simplify-code` and `engineering-workflows` for implementation.
- A rigid accessory on a morphing or skinned surface uses optional `src/surface-attachment.js` and `docs/surface-attachment.md`.
- Agent scene recipes use optional `src/agent-scene.js` and `docs/agent-scene.md`. Verify source versus published availability before importing.
- Polygon modeling by an agent (extrude, inset, loop cut, bevel, booleans, mirror, array, solidify) uses the recipe `mesh` geometry and the MCP tools `mesh_inspect`, `mesh_edit` and `mesh_stack`. Read [mesh-modeling.md](references/mesh-modeling.md) before the first edit; check that the checkout's `docs/mesh.md` exists, since it is unreleased after npm 0.10.0.
-- Parts that sit against each other (a handle on a body, a lid on a tank, legs under a top) use the node `relations` field: `attach`, `gap`, `flush`, `align` or `centered` against another mesh node, optionally a tagged `region` of it. They are solved again after every edit, so resize the body with one `set-node` instead of recomputing each part's translation. One relation per axis, no loops. See "Relations between parts" in the checkout's `docs/agent-scene.md`.
+- Parts that sit against each other (a handle on a body, a lid on a tank, legs under a top) use the node `relations` field: `attach`, `gap`, `flush`, `align` or `centered` against another mesh node, optionally a tagged `region` of it. They are solved again after every edit, so resize the body with one `set-node` instead of recomputing each part's translation. One relation per axis, no loops. Fields are in `scene_capabilities` `relations`; see "Relations between parts" in the checkout's `docs/agent-scene.md`.
- 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`. Your own look (bricks from noise and a ramp, stripes, a pattern that follows `uv_unwrap`) is `pattern: { type: "graph", graph, mapping: "uv" }`: a bounded JSON node graph baked to textures, never shader text; see "Material graphs" there.
- 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.
diff --git a/src/agent-scene-capabilities.js b/src/agent-scene-capabilities.js
index a8a3adc0..8cb1bf2e 100644
--- a/src/agent-scene-capabilities.js
+++ b/src/agent-scene-capabilities.js
@@ -64,6 +64,18 @@ export const AGENT_SCENE_CAPABILITIES = Object.freeze({
proceduralMotion: true,
motionIk: Object.freeze(['two-bone', 'aim']),
// Authored rigs: armatures expand into bone nodes, and a node `skin` binds a mesh with automatic weights (four influences).
+ // Node relations place a mesh node against other mesh nodes (world bounds), solved again after every edit.
+ relations: Object.freeze({
+ maxPerNode: 8, maxNodes: 256, sides: Object.freeze(['+x', '-x', '+y', '-y', '+z', '-z']),
+ kinds: Object.freeze({
+ attach: 'to, side, offset: touch the face of the target on side and centre on the other axes; offset is the distance, negative sinks in',
+ gap: 'to, side, offset: as attach on that axis only',
+ flush: 'to, side, offset: own face on side level with the same face of the target',
+ align: 'to, axis, at (min, center, max), offset: anchor on one axis',
+ centered: 'to, axes (default x, y, z): centre on those axes',
+ }),
+ notes: 'Optional region (a mesh tag) uses only those faces of the target. One relation per axis, no loops, mesh nodes only. A relation replaces translation on its axes. set-node with relations [] removes them.',
+ }),
rigging: Object.freeze({ presets: Object.freeze(['humanoid', 'quadruped']), maxArmatures: 16, maxBones: 128, maxInfluences: 4, weights: 'bone-distance' }),
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 }),
diff --git a/tests/desk-tasks.test.js b/tests/desk-tasks.test.js
new file mode 100644
index 00000000..b935b35f
--- /dev/null
+++ b/tests/desk-tasks.test.js
@@ -0,0 +1,25 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { gradeRecipe } from '../bench/agent-modeling/check.mjs';
+import { taskById } from '../bench/agent-modeling/tasks.mjs';
+import { REFERENCES } from '../bench/agent-modeling/references.mjs';
+import { DESK_START, DESK_START_PLAIN } from '../bench/agent-modeling/desk.mjs';
+
+const failedKinds = grade => grade.results.filter(result => !result.pass).map(result => result.kind);
+
+test('the desk has 12 parts and the relations version differs from the plain one only by relations', () => {
+ assert.equal(DESK_START.nodes.length, 12);
+ const stripped = DESK_START.nodes.map(({ relations, ...node }) => node);
+ assert.deepEqual(stripped, DESK_START_PLAIN.nodes);
+});
+
+test('both desk tasks accept their reference and reject a desk whose parts were left behind', async () => {
+ for (const id of ['desk-resize', 'desk-resize-plain']) {
+ assert.equal((await gradeRecipe(taskById(id), REFERENCES[id])).pass, true, id);
+ }
+ const widenedOnly = structuredClone(REFERENCES['desk-resize-plain']);
+ widenedOnly.nodes = widenedOnly.nodes.map(node => (node.id === 'top' ? node : structuredClone(DESK_START_PLAIN.nodes.find(start => start.id === node.id))));
+ const failures = failedKinds(await gradeRecipe(taskById('desk-resize-plain'), widenedOnly));
+ assert.ok(failures.includes('touches'));
+ assert.ok(failures.includes('centreAt'));
+});