3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Play motion tracks from 0 and hint for them too (#2052)
Nguyen Xuan Anff2c5a9512de
diff --git a/changes/2052.md b/changes/2052.mdindex 036b3eb5..6635b4a5 100644--- a/changes/2052.md+++ b/changes/2052.md@@ -1,2 +1,2 @@-- A stills or video job of a recipe whose only moving content is particles, physics or cloth now plays the motion clock from 0 when `settings.motion` is left out, instead of rendering frozen frames.-- `scene_look` and `scene_review` add a `motion-not-set` hint when the scene has particles, physics or cloth and no `motionTime` was given.+- A stills or video job of a recipe whose only moving content is motion tracks, particles, physics or cloth now plays the motion clock from 0 when `settings.motion` is left out, instead of rendering frozen frames.+- `scene_look` and `scene_review` add a `motion-not-set` hint when the scene has motion tracks, particles, physics or cloth and no `motionTime` was given.diff --git a/scripts/agent-render-jobs.mjs b/scripts/agent-render-jobs.mjsindex d7c47e16..2620d361 100644--- a/scripts/agent-render-jobs.mjs+++ b/scripts/agent-render-jobs.mjs@@ -7,6 +7,7 @@ import { RENDER_PASS_NAMES, RENDER_OUTPUT_FORMATS, MAXIMUM_JOB_FPS, MAXIMUM_JOB_import { parseQuality } from './agent-render-quality.mjs';import { estimateFrameBytes } from '../src/budget.js';import { recipeAssetNeeds } from '../src/agent-scene-assets.js';+import { recipePlaysSimulation } from '../src/motion-hint.js';import { normalizeFilmTimeline, filmTimelineDuration, videoFrameCount } from '../src/film-timeline.js';import { OIDN_DEFAULT_SAMPLES, PATH_TRACER_DENOISERS, PATH_TRACER_JOB_LIMITS } from '../src/path-tracer-capabilities.js';import { AGENT_ASSET_LIMITS, describeAssetBytes } from '../src/agent-asset-limits.js';@@ -104,12 +105,12 @@ function playsPhysics(recipe) {}/**- * Whether a job with no `motion` setting should still play the recipe's particles, physics or cloth from second 0.+ * Whether a job with no `motion` setting should still play the recipe's motion tracks, particles, physics or cloth from second 0.* Without a motion clock every frame is frame 0, so such a stills or video job would come out frozen with no warning.*/function playsSimulationFromStart(input, recipe, timelineStart) {return input.kind !== 'image' && timelineStart === undefined && input.animation === undefined- && recipe?.format === 'crucible.scene' && playsPhysics(recipe);+ && recipe?.format === 'crucible.scene' && recipePlaysSimulation(recipe);}/** The settings of a job as the store keeps them: every default filled in, every limit checked. */diff --git a/src/motion-hint.js b/src/motion-hint.jsindex d2973df4..6bd3fcf7 100644--- a/src/motion-hint.js+++ b/src/motion-hint.js@@ -1,11 +1,12 @@-/** The hint a preview carries when it shows frame 0 of a scene whose particles, physics or cloth only move on the motion clock. */+/** The hint a preview carries when it shows frame 0 of a scene whose motion tracks, particles, physics or cloth only move on the motion clock. */export const MOTION_NOT_SET_HINT = {kind: 'motion-not-set',- message: 'This scene has particles, physics or cloth, and no motionTime was given, so the picture is frame 0.',- fix: 'Pass motionTime (seconds from 0) to see the simulation at that moment, such as motionTime 1.',+ message: 'This scene has motion tracks, particles, physics or cloth, and no motionTime was given, so the picture is frame 0.',+ fix: 'Pass motionTime (seconds from 0) to see the scene at that moment, such as motionTime 1.',};-/** Whether a recipe has simulated content that moves only when a motion time is sampled. */+/** Whether a recipe has motion tracks or simulated content that moves only when a motion time is sampled. */export function recipePlaysSimulation(recipe) {- return Boolean(recipe?.physics || recipe?.cloth || recipe?.particles);+ const hasTracks = Array.isArray(recipe?.motion?.tracks) && recipe.motion.tracks.length > 0;+ return Boolean(hasTracks || recipe?.physics || recipe?.cloth || recipe?.particles);}diff --git a/tests/render-job-simulation-motion.test.js b/tests/render-job-simulation-motion.test.jsindex 69304507..415827f8 100644--- a/tests/render-job-simulation-motion.test.js+++ b/tests/render-job-simulation-motion.test.js@@ -44,3 +44,27 @@ nodeTest('the motion-not-set hint says what to pass', async () => {assert.equal(recipePlaysSimulation(particleRecipe), true);assert.equal(recipePlaysSimulation({ format: 'crucible.scene' }), false);});++const tracksRecipe = {+ format: 'crucible.scene',+ camera: { eye: [0, 1, 5], target: [0, 0, 0] },+ motion: { duration: 2, tracks: [{ kind: 'camera', property: 'eye', keyframes: [{ time: 0, value: [0, 1, 5] }, { time: 2, value: [5, 1, 0] }] }] },+};++nodeTest('a recipe whose only motion is tracks plays the motion clock from 0 without a motion setting', () => {+ assert.deepEqual(normalizeJobSettings(videoJob, [], tracksRecipe).motion, { start: 0 });+ assert.deepEqual(normalizeJobSettings(stillsJob, [], tracksRecipe).motion, { start: 0 });+});++nodeTest('a tracks job longer than the authored motion keeps the held pose instead of failing', () => {+ const longVideo = { ...videoJob, duration: 5 };+ assert.equal(normalizeJobSettings(longVideo, [], tracksRecipe).motion, undefined);+ assert.throws(() => normalizeJobSettings({ ...longVideo, motion: { start: 0 } }, [], tracksRecipe), /authored duration/);+});++nodeTest('the motion-not-set hint covers motion tracks, and an empty track list does not count', async () => {+ const { MOTION_NOT_SET_HINT, recipePlaysSimulation } = await import('../src/motion-hint.js');+ assert.match(MOTION_NOT_SET_HINT.message, /motion tracks/);+ assert.equal(recipePlaysSimulation(tracksRecipe), true);+ assert.equal(recipePlaysSimulation({ format: 'crucible.scene', motion: { duration: 2, tracks: [] } }), false);+});