3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Give scene_look the post pass clock of the pose it draws (#2315)
Nguyen Xuan An25e3178fe46f
diff --git a/changes/2315.md b/changes/2315.mdnew file mode 100644index 00000000..eada77a3--- /dev/null+++ b/changes/2315.md@@ -0,0 +1 @@+- `scene_look` at a `motionTime` gives post passes that time as their clock, like a render job frame, so a beam anchored to a moving part no longer draws detached in the look (#2315)diff --git a/docs/agent-scene.md b/docs/agent-scene.mdindex bebfa0e2..ae5559b0 100644--- a/docs/agent-scene.md+++ b/docs/agent-scene.md@@ -228,7 +228,7 @@ and the geometry UVs.- `frames` lists 2 to 4096 IDs from `scene_asset_catalog`. The `--assets` folder takes PNG, JPEG and WebP files next to GLBs, with the same 64 MiB file budget, content-bound SHA-256 IDs and no links. An extension that does not match the file signature rejects the catalog. Entries report `kind: "image"` and `mimeType`; GLBs report `kind: "glb"`. No remote URLs are read.- All frames share one size, at most 2048 pixels a side (16 MiB decoded), and a scene keeps at most 64 MiB of decoded frames at once. Frames are read without colour conversion and should be opaque. The catalog reads each image's header and skips one over these limits, or one whose header gives no readable size (a JPEG whose frame header cannot be found), so the page never decodes it.- `fps` is above 0 and at most 60. The frame at scene time `t` is `floor(t * fps)`: wrapped around the list when `loop` is true (the default), held on the last frame when `loop` is false. Frame 0 shows before any motion time is set.-- The clock is `motionTime`, the one `scene_look`, `scene_review` and `motion` use. A seek is deterministic: the same time gives the same frame and the same PNG bytes. `scene_render_submit` reads it from `settings.motion.start` plus the elapsed time (or a timeline shot), so a still or video frame shows the frame that `scene_look` shows at that time. A recipe with a sequence and no authored `motion` accepts `settings.motion`.+- The clock is `motionTime`, the one `scene_look`, `scene_review` and `motion` use. A seek is deterministic: the same time gives the same frame and the same PNG bytes. `scene_render_submit` reads it from `settings.motion.start` plus the elapsed time (or a timeline shot), so a still or video frame shows the frame that `scene_look` shows at that time. The same time is also the clock a post pass reads in both, so a pass anchored to a moving part stays on it in a look. A recipe with a sequence and no authored `motion` accepts `settings.motion`.- The renderer uploads a frame with `updateTexture` only when the frame index changes. `scene_inspect` reports `textureSequences`: material, frame count, `fps`, `loop`, current `index` and its asset ID.- A sequence of up to 64 frames loads whole with the scene. A longer one streams: the scene starts with its first frame, and the host reads and decodes the frame of each requested time from the catalog, keeping that frame and the one before it (two decoded frames per sequence, 32 MiB at 2048 pixels). A video job walks the frames in order and decodes each once, so the limit is per frame and for the frames kept at once, not for the list; the same frame gives the same pixels whole or streamed. The catalog takes up to 4096 image files besides its 64 other files. Streaming serves `scene_look` with `motionTime` and raster still and video jobs. `scene_review` (every shot in one call) and path traced or native jobs (`settings.renderer`, which a streamed sequence refuses with an error that says so) need a sequence of at most 64 frames; a frame that was not decoded is an error, never a silent stale frame.- A folder of more than 256 consecutively numbered images (`frame_0001.png` to `frame_2700.png`, one prefix, one digit width, no gap) is not listed per frame. `scene_asset_catalog` lists it once under `sequences`: `{ kind: "sequence", name: "frame_####.png", first, last, frames, width, height }`. Write `map: { sequence: { catalog: "frame_####.png", fps } }` instead of `frames`; pass exactly one of the two. The server swaps in the frame IDs when the call arrives, so the scene, its checkpoints and its render jobs stay pinned to the hashes. The catalog reads only the first frame at startup and hashes the rest on the first recipe that names the sequence (or the first frame ID it does not know yet, such as one from an earlier run). An unknown pattern is refused with the nearest ones; a frame over the limits above is refused with its name. Shorter folders keep one entry per frame.diff --git a/scripts/agent-preview-browser.js b/scripts/agent-preview-browser.jsindex 3f5462fc..c088f08b 100644--- a/scripts/agent-preview-browser.js+++ b/scripts/agent-preview-browser.js@@ -1344,7 +1344,9 @@ window.__agentPreview = {}sampleMotionTime(record.scene, motionTime);}- draw(record);+ // The post pass clock is the pose's motion time, as in a render job frame, so a pass anchored to a moving part stays on it.+ const poseTime = record.scene.motionTime ?? undefined;+ draw(record, 0, record.scene.camera, poseTime === undefined ? {} : { passTime: poseTime });const render = renderInfo(record.renderer, viewProblems(record, record.scene.camera, record.scene.effects.exposure, { placement: true }));record.lastRender = render;const labels = withLabels ? collectLabels(record, record.scene.camera, canvas.width, canvas.height) : undefined;diff --git a/tests/agent-preview.test.js b/tests/agent-preview.test.jsindex 021bf29c..f233ec9a 100644--- a/tests/agent-preview.test.js+++ b/tests/agent-preview.test.js@@ -231,3 +231,24 @@ test('a frame at a motion time gives the renderer that time as the post pass clopreview.frame({ sessionId });assert.deepEqual(renders.slice(1).map(frame => frame.camera.passTime), [2, 6.5, 0, undefined]);});++test('a look at a motion time gives the post pass the same clock as a frame at that time', () => {+ const { preview, renders } = previewHarness();+ const sessionId = 'look-pass-clock';+ const input = recipe();+ input.motion = { duration: 8, tracks: [{ kind: 'node', id: 'cube', property: 'translation',+ keyframes: [{ time: 0, value: [0, 0, 0] }, { time: 8, value: [4, 0, 0] }] }] };+ preview.create({ recipe: input, sessionId, backend: 'cpu', memoryBudgetMiB: 192 });+ const lookClocks = [];+ const frameClocks = [];+ for (const motionTime of [5.65, 2]) {+ preview.look({ sessionId, motionTime });+ lookClocks.push({ passTime: renders.at(-1).camera.passTime, anchorX: renders.at(-1).parts[0].matrix[12] });+ preview.frame({ sessionId, motionTime });+ frameClocks.push({ passTime: renders.at(-1).camera.passTime, anchorX: renders.at(-1).parts[0].matrix[12] });+ }+ assert.deepEqual(lookClocks, frameClocks);+ assert.equal(lookClocks[0].passTime, 5.65);+ preview.look({ sessionId, motionTime: null });+ assert.equal(renders.at(-1).camera.passTime, undefined);+});