Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Name the camera plainly in the track and driver clash error (#842)

Nguyen Xuan Ane16f418d2bbf
diff --git a/src/agent-motion.js b/src/agent-motion.js
index 30f6192b..9aaf4f23 100644
--- a/src/agent-motion.js
+++ b/src/agent-motion.js
@@ -580,7 +580,8 @@ export function normalizeAgentMotion(input, recipe) {
result.drivers = normalizeDrivers(input.drivers, { nodes, materials, lights, morphs: morphTargets, visible: visibleIds, properties: propertyKinds(result.properties) });
for (const { target } of result.drivers) {
if (identities.has(JSON.stringify([target.kind, target.id ?? null, target.property]))) {
- throw invalidField('motion.drivers', `${target.id} ${target.property}`, `a property no track animates, since a track on ${target.kind} ${target.id ?? ''} already moves ${target.property}; drop the track or the driver`);
+ const targetName = target.id === undefined ? target.kind : `${target.kind} ${target.id}`;
+ throw invalidField('motion.drivers', `${targetName} ${target.property}`, `a property no track animates, since a track on ${targetName} already moves ${target.property}; drop the track or the driver`);
}
}
}
diff --git a/tests/agent-motion-camera-drivers.test.js b/tests/agent-motion-camera-drivers.test.js
index 4821caf0..7cae2221 100644
--- a/tests/agent-motion-camera-drivers.test.js
+++ b/tests/agent-motion-camera-drivers.test.js
@@ -95,7 +95,7 @@ test('camera driver and influence errors name the field and what to pass', () =>
assert.throws(build([{ target: { kind: 'camera', property: 'fov', component: 'x' }, expression: 40 }]), /camera fov takes no component/);
assert.throws(
build([{ target: { kind: 'camera', property: 'fov' }, expression: 40 }], { tracks: [{ kind: 'camera', property: 'fov', keyframes: [{ time: 0, value: 40 }, { time: 2, value: 50 }] }] }),
- /already moves fov/,
+ error => /a track on camera already moves fov/.test(error.message) && !/undefined/.test(error.message),
);
assert.throws(
() => createAgentScene(recipeWith({ duration: 2, tracks: [], constraints: [{ type: 'copy_location', node: 'follower', target: 'lead', influence: customRead('missing') }] })),