3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Fix two agent input errors in bake and texture sequence (#2508, #2509)
Nguyen Xuan An9315a534dfa0
diff --git a/changes/2508.md b/changes/2508.mdnew file mode 100644index 00000000..f741ed07--- /dev/null+++ b/changes/2508.md@@ -0,0 +1 @@+- Refuse a texture sequence frame list with holes at the missing frame, and give the whole-number error of bake counts an example inside the field range (#2508, #2509).diff --git a/src/agent-bake.js b/src/agent-bake.jsindex e6a413b4..06b2d186 100644--- a/src/agent-bake.js+++ b/src/agent-bake.js@@ -64,7 +64,7 @@ export function normalizeAgentBake(input) {}for (const field of ['samples', 'bounces']) {if (!Number.isInteger(resolved[field])) {- throw invalidField(`bake.${field}`, resolved[field], 'a whole number, such as 64');+ throw invalidField(`bake.${field}`, resolved[field], `a whole number, such as ${Math.ceil(resolved[field])}`);}}return resolved;diff --git a/src/agent-texture-sequence.js b/src/agent-texture-sequence.jsindex 4cc468c9..5fce3967 100644--- a/src/agent-texture-sequence.js+++ b/src/agent-texture-sequence.js@@ -33,11 +33,13 @@ export function normalizeMapSequence(value) {if (!Array.isArray(frames) || frames.length < 2 || frames.length > TEXTURE_SEQUENCE_LIMITS.maxFrames) {throw invalidField('map.sequence.frames', Array.isArray(frames) ? `${frames.length} frames` : frames, `a list of 2 to ${TEXTURE_SEQUENCE_LIMITS.maxFrames} catalog image asset IDs, such as [<asset id>, <asset id>]; for a longer film, split it into several sequences or lower the frame rate`);}- frames.forEach((frame, index) => {+ // A plain loop: forEach skips the holes of a sparse list.+ for (let index = 0; index < frames.length; index++) {+ const frame = frames[index];if (typeof frame !== 'string' || !ASSET_ID.test(frame.toLowerCase())) {throw invalidField(`map.sequence.frames[${index}]`, frame, 'the 64 hexadecimal characters of a catalog image asset ID; scene_asset_catalog lists them', TypeError);}- });+ }if (!Number.isFinite(fps) || fps <= 0 || fps > TEXTURE_SEQUENCE_LIMITS.maxFps) {throw invalidField('map.sequence.fps', fps, `a number above 0 and at most ${TEXTURE_SEQUENCE_LIMITS.maxFps}, such as 12`);}diff --git a/tests/hunt-agent-input-errors.test.js b/tests/hunt-agent-input-errors.test.jsnew file mode 100644index 00000000..739645b1--- /dev/null+++ b/tests/hunt-agent-input-errors.test.js@@ -0,0 +1,21 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { normalizeAgentBake } from '../src/agent-bake.js';+import { normalizeMapSequence } from '../src/agent-texture-sequence.js';+import { BAKE_RANGES } from '../src/agent-scene-capabilities.js';++test('a fractional bake count is refused with an example inside its own range', () => {+ for (const [field, value] of [['bounces', 2.5], ['samples', 63.5]]) {+ assert.throws(() => normalizeAgentBake({ [field]: value }), error => {+ const example = Number(/such as (\d+)/.exec(error.message)?.[1]);+ const [minimum, maximum] = BAKE_RANGES[field];+ return error.message.includes(`bake.${field}`) && example >= minimum && example <= maximum && Number.isInteger(example);+ }, field);+ }+});++test('a texture sequence frame list with holes is refused at the missing frame', () => {+ const sparse = new Array(3);+ sparse[0] = 'a'.repeat(64);+ assert.throws(() => normalizeMapSequence({ sequence: { frames: sparse, fps: 12 } }), /map\.sequence\.frames\[1\]/);+});