3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Name a fractional crowd seed at recipe validation (#2487)
Nguyen Xuan An51df261fe7e4
diff --git a/changes/2487.md b/changes/2487.mdindex 75b90673..c266f22f 100644--- a/changes/2487.md+++ b/changes/2487.md@@ -1 +1 @@-- Retargeting refuses a bone mapping that repeats a joint or names an unknown bone, rig joints with a zero rotation or a non-finite translation, and a crowd seed that is not a whole number from -2147483648 to 4294967295 (#2487, #2488, #2489)+- Retargeting refuses a bone mapping that repeats a joint or names an unknown bone, rig joints with a zero rotation or a non-finite translation, and a crowd seed that is not a whole number from -2147483648 to 4294967295 ; a scene recipe names a fractional `crowd.seed` at validation (#2487, #2488, #2489)diff --git a/docs/agent-scene.md b/docs/agent-scene.mdindex ff577d08..0c818d6b 100644--- a/docs/agent-scene.md+++ b/docs/agent-scene.md@@ -342,7 +342,7 @@ An asset placement with a `crowd` field fills its group node with `count` (1 to{ "id": "people", "asset": { "id": "<catalog asset id>", "crowd": { "clip": 3, "count": 200, "seed": 7, "spacing": 2, "farDistance": 25, "farRate": 6 } } }```-- `clip` is a clip index, `layout` is `grid` or `scatter`, and the pose is a pure function of scene time, `seed` and the recipe camera, so a render at a time equals the frame reached by playing. People farther than `farDistance` from the recipe camera hold each pose for `1 / farRate` seconds. The distance is measured from each person's world position at that time, so it follows a parent group that moves or has a motion track.+- `clip` is a clip index, `seed` is a whole number from -2147483648 to 2147483647, `layout` is `grid` or `scatter`, and the pose is a pure function of scene time, `seed` and the recipe camera, so a render at a time equals the frame reached by playing. People farther than `farDistance` from the recipe camera hold each pose for `1 / farRate` seconds. The distance is measured from each person's world position at that time, so it follows a parent group that moves or has a motion track.- The crowd takes one decoded copy of the asset, the generated part nodes (count times materials) count against `maxNodes`, and `scene_inspect` lists it under `assets` with `kind: "crowd"`, `instances`, `batches`, `frames`, `paletteBytes` and `boundsRadius`.### Seams between meshesdiff --git a/docs/retarget.md b/docs/retarget.mdindex 364bfe94..a019e8b9 100644--- a/docs/retarget.md+++ b/docs/retarget.md@@ -135,7 +135,7 @@ An agent asks for a crowd in a recipe (`scene_create`, `scene_apply`) with the `{ "id": "people", "asset": { "id": "<catalog asset id>", "crowd": { "clip": 3, "count": 200, "seed": 7, "spacing": 2, "farDistance": 25, "farRate": 6 } } }```-`clip` is the clip index (`scene_inspect` lists them), `count` is 1 to 1000, and `layout`, `spacing`, `columns`, `size`, `rateJitter`, `randomYaw`, `speed`,+`clip` is the clip index (`scene_inspect` lists them), `count` is 1 to 1000, `seed` is a whole number from -2147483648 to 2147483647, and `layout`, `spacing`, `columns`, `size`, `rateJitter`, `randomYaw`, `speed`,`frameRate`, `lods`, `morphs`, `farDistance` and `farRate` are the options above. The crowd is a group node of generated part nodes (count times thematerials, which count against `maxNodes`), placed by the node transform. The pose depends on the scene time, the seed and the recipe camera, soa frame rendered at a time equals the one reached by playing to it. `scene_inspect` lists the crowd under `assets` with `kind: "crowd"`, its instances, batches, clip, baked frames,diff --git a/src/agent-crowd.js b/src/agent-crowd.jsindex 7fdfa6d2..e43fa7a8 100644--- a/src/agent-crowd.js+++ b/src/agent-crowd.js@@ -42,6 +42,12 @@ function numberWithin(value, minimum, maximum, label) {return value;}++// createCrowd refuses a fractional seed, so the recipe check names the field first.+function wholeSeed(value) {+ if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) throw invalidField('crowd.seed', value, 'a whole number from -2147483648 to 2147483647, such as 1');+ return value;+}/** Validate the `crowd` field of an asset placement. Returns the canonical form kept in the recipe. */export function normalizeCrowd(value) {if (!value || typeof value !== 'object' || Array.isArray(value)) throw invalidField('crowd', value, 'an object such as { "count": 50, "layout": "grid" }', TypeError);@@ -58,7 +64,7 @@ export function normalizeCrowd(value) {const result = {clip,count: value.count,- seed: numberWithin(value.seed ?? 1, -2147483648, 2147483647, 'seed'),+ seed: wholeSeed(value.seed ?? 1),layout,spacing: numberWithin(value.spacing ?? 1.5, 0.05, 1000, 'spacing'),rateJitter: numberWithin(value.rateJitter ?? 0.15, 0, 0.9, 'rateJitter'),diff --git a/tests/agent-scene-crowd.test.js b/tests/agent-scene-crowd.test.jsindex b3eaf992..e0709a98 100644--- a/tests/agent-scene-crowd.test.js+++ b/tests/agent-scene-crowd.test.js@@ -100,6 +100,7 @@ test('crowd settings are validated and the clip must exist', async () => {await assert.rejects(crowdScene({ bogus: 1 }), /crowd\.bogus: got 1; expected a known field/);await assert.rejects(crowdScene({ farDistance: 5 }), /crowd\.farRate: got undefined; expected both farDistance and farRate, or neither/);await assert.rejects(crowdScene({ clip: 99 }), /nodes\.people\.asset\.crowd\.clip: got 99; expected a clip index from 0 to 13/);+ await assert.rejects(crowdScene({ seed: 1.5 }), /crowd\.seed: got 1\.5; expected a whole number from -2147483648 to 2147483647/);});test('a crowd keeps its baked parts across an edit that does not touch it', async () => {