Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Let motion drivers move the camera and constraint influence read custom properties (#842)

Nguyen Xuan Anf7f3d874cb92
diff --git a/changes/842-camera-drivers.md b/changes/842-camera-drivers.md
new file mode 100644
index 00000000..d5d8363b
--- /dev/null
+++ b/changes/842-camera-drivers.md
@@ -0,0 +1 @@
+- Motion drivers can now set the camera eye, target, fov and roll after the camera tracks, and a constraint `influence` expression can read custom properties, so one property can dolly the camera or fade a constraint in and out (#842)
diff --git a/changes/842-camera-drivers.size.md b/changes/842-camera-drivers.size.md
new file mode 100644
index 00000000..54c66a63
--- /dev/null
+++ b/changes/842-camera-drivers.size.md
@@ -0,0 +1 @@
+- scene:agent-scene+lazy: 370 bytes gzip lets a driver move the camera and a constraint influence read a custom property, so one property can dolly a shot or fade a constraint, which agents had to key by hand
diff --git a/docs/agent-motion.md b/docs/agent-motion.md
index 706222e5..48f7458f 100644
--- a/docs/agent-motion.md
+++ b/docs/agent-motion.md
@@ -323,7 +323,7 @@ XYZ in degrees) or `{ "kind": "material", "id", "property" }` for `emission`, `m
`component` for `color` and `emissiveColor` (`x`, `y`, `z` for red, green, blue). Two more targets set a look value:
`{ "kind": "light", "id": "point:0", "property": "intensity" }` (or `color` with a `component`, where the other components keep the
recipe colour) and `{ "kind": "morph", "id": "<shape key>", "property": "weight" }`. A driven property cannot also have a track.
-Camera fields are not driven yet.
+The camera is a target too: `{ "kind": "camera", "property": "eye" | "target", "component": "x" | "y" | "z" }` or `{ "kind": "camera", "property": "fov" | "roll" }` (fov in degrees, roll in radians, as in the camera tracks). A camera target has no `id`. Drivers apply after the camera tracks: the driver value replaces that eye or target component, fov or roll, and the other fields keep their track or recipe value. A camera property with a track cannot also have a driver, and a camera with a `focalLength` takes no fov driver. With no camera track, the recipe camera is the base.
An expression is JSON data and is never run as code. It is the motion context of the one expression language described in
[field expressions](mesh.md#field-expressions): the same operators with the same results, the same syntax, and limits of 64
@@ -356,8 +356,9 @@ property can drive several parts:
] }
```
-Only driver expressions read properties; a constraint `influence` expression does not yet. A property is a pure function of the
-time, so seeking gives the same value as playing to it.
+Driver expressions and constraint `influence` expressions both read properties, so one property can fade a constraint in and out:
+`{ "type": "copy_location", "node": "follower", "target": "lead", "influence": { "custom": { "node": "lead", "name": "fade" } } }`.
+An influence is clamped to 0 to 1. A property is a pure function of the time, so seeking gives the same value as playing to it.
### Evaluation order
@@ -366,7 +367,7 @@ to that time:
1. For an asset, the selected clip, then `motion.layers`, then tracks.
2. IK, in list order.
-3. Drivers. They read the pose from steps 1 and 2, so one driver never sees another's result.
+3. Drivers. They read the pose from steps 1 and 2, so one driver never sees another's result. Camera drivers replace fields of the pose the camera tracks sampled at the same time.
4. Constraints, in list order. Each reads the pose the ones before it left. Expressions in `influence` read the pose from
step 2.
diff --git a/docs/camera-path.md b/docs/camera-path.md
index bae34ad2..f5de87b9 100644
--- a/docs/camera-path.md
+++ b/docs/camera-path.md
@@ -45,6 +45,7 @@ The path copies input vectors and keyframes. The returned `clip` is immutable. `
## Tracking and retained frames
The optional `targetMatrix` transforms the sampled target from local coordinates into world coordinates.
+The optional `overrides` (`{ eye, target, fov, roll }`, where `eye` and `target` hold a number or `undefined` per axis) replace sampled values before the up vector is built; motion drivers use it, see [agent motion](agent-motion.md#drivers).
The eye remains in world coordinates. The caller supplies the current matrix explicitly, so seeking has no hidden playback state.
```js
diff --git a/src/agent-motion.js b/src/agent-motion.js
index 867e3f93..30f6192b 100644
--- a/src/agent-motion.js
+++ b/src/agent-motion.js
@@ -569,24 +569,35 @@ export function normalizeAgentMotion(input, recipe) {
}
}
const visibleIds = new Set(ikHierarchy(recipe).map(node => node.id));
- if (input.constraints !== undefined) {
- result.constraints = normalizeConstraints(input.constraints, nodes, visibleIds);
- }
if (input.properties !== undefined) {
result.properties = normalizeProperties(input.properties, duration, visibleIds);
}
+ if (input.constraints !== undefined) {
+ result.constraints = normalizeConstraints(input.constraints, nodes, visibleIds, propertyKinds(result.properties));
+ }
if (input.drivers !== undefined) {
const lights = new Set(recipe.environment ? lightIds(recipe.environment) : []);
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, 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`);
+ 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`);
}
}
}
return result;
}
+/** The camera components drivers set, in the shape createCameraPath.sample takes: eye and target by axis, fov and roll alone. */
+function cameraOverrides(looks = []) {
+ const overrides = {};
+ for (const { target, value } of looks) {
+ if (target.kind !== 'camera') continue;
+ if (target.component === undefined) overrides[target.property] = value;
+ else (overrides[target.property] ??= [])[COMPONENT_INDEX[target.component]] = value;
+ }
+ return overrides;
+}
+
/** A rig of just the nodes IK needs: chains, the nodes their targets follow, and all their ancestors. */
function ikRig(ik, recipe) {
const hierarchy = ikHierarchy(recipe);
@@ -896,11 +907,12 @@ export function compileAgentMotion(input, recipe) {
for (const track of cameraTracks) {
cameraInput[track.property] = { interpolation: track.interpolation, keyframes: track.keyframes, extrapolation: track.extrapolation, modifiers: track.modifiers };
}
- const cameraPath = cameraTracks.length ? createCameraPath(cameraInput) : null;
+ const cameraDrivers = (motion.drivers ?? []).filter(driver => driver.target.kind === 'camera');
+ const cameraPath = cameraTracks.length || cameraDrivers.length ? createCameraPath(cameraInput) : null;
const stagedCamera = cameraPath ? { eye: new Float32Array(3), target: new Float32Array(3), up: new Float32Array(3) } : null;
if (cameraPath) {
- if (cameraInput.focalLength !== undefined && cameraTracks.some(track => track.property === 'fov')) {
- throw invalidField('motion.tracks.property', 'camera.fov', 'a camera track other than fov, since the camera has a focalLength; give the camera a fov instead, or leave fov out of the motion');
+ if (cameraInput.focalLength !== undefined && (cameraTracks.some(track => track.property === 'fov') || cameraDrivers.some(driver => driver.target.property === 'fov'))) {
+ throw invalidField('motion.tracks.property', 'camera.fov', 'a camera track or driver other than fov, since the camera has a focalLength; give the camera a fov instead, or leave fov out of the motion');
}
output.camera = {
eye: new Float32Array(3), target: new Float32Array(3), up: new Float32Array(3),
@@ -1001,7 +1013,7 @@ export function compileAgentMotion(input, recipe) {
validateRadiance(material, materialId);
}
if (cameraPath) {
- cameraPath.sample(time, stagedCamera);
+ cameraPath.sample(time, stagedCamera, { overrides: cameraOverrides(evaluated?.looks) });
for (const field of ['fov', 'near', 'far']) {
finite(stagedCamera[field], `Camera ${field}`);
}
@@ -1043,6 +1055,7 @@ export function compileAgentMotion(input, recipe) {
else materialPatch[target.property].set(value);
}
for (const { target, value } of evaluated?.looks ?? []) {
+ if (target.kind === 'camera') continue;
const patch = (target.kind === 'light' ? output.lights : output.morphs).get(target.id);
if (target.component === undefined) patch[target.property] = value;
else patch[target.property][COMPONENT_INDEX[target.component]] = value;
diff --git a/src/agent-scene-capabilities.js b/src/agent-scene-capabilities.js
index d6b6ea1b..1dceee82 100644
--- a/src/agent-scene-capabilities.js
+++ b/src/agent-scene-capabilities.js
@@ -297,7 +297,7 @@ export const AGENT_SCENE_CAPABILITIES = Object.freeze({
}),
rigging: Object.freeze({ presets: Object.freeze(['humanoid', 'quadruped']), maxArmatures: 16, maxBones: 128, maxInfluences: 4, weights: 'bone-distance' }),
motionConstraints: Object.freeze(['copy_location', 'copy_rotation', 'copy_scale', 'limit_location', 'limit_rotation', 'track_to', 'child_of', 'floor', 'copy_transforms', 'limit_distance', 'limit_scale', 'stretch_to', 'locked_track', 'transformation', 'action', 'maintain_volume', 'damped_track', 'pivot', 'follow_path', 'clamp_to', 'shrinkwrap', 'armature']),
- motionDrivers: Object.freeze({ maxDrivers: 32, maxConstraints: 32, maxProperties: 32, maxPropertyKeys: 16, targets: Object.freeze(['node', 'material', 'light', 'morph']), variables: Object.freeze(['time', 'node', 'custom', 'distance', 'rotationDifference']), maxExpressionParts: 64, maxExpressionDepth: 8 }),
+ motionDrivers: Object.freeze({ maxDrivers: 32, maxConstraints: 32, maxProperties: 32, maxPropertyKeys: 16, targets: Object.freeze(['node', 'material', 'light', 'morph', 'camera']), variables: Object.freeze(['time', 'node', 'custom', 'distance', 'rotationDifference']), maxExpressionParts: 64, maxExpressionDepth: 8 }),
// Recipe physics: Rapier (an optional peer) bakes bodies on nodes offline; playback is a seek into the bake.
physics: Object.freeze({
bodyTypes: Object.freeze(['dynamic', 'fixed', 'kinematic']),
diff --git a/src/camera-path.js b/src/camera-path.js
index 4af5edab..860f3264 100644
--- a/src/camera-path.js
+++ b/src/camera-path.js
@@ -81,6 +81,14 @@ export function fovFromFocalLength(focalLength, { sensorHeight = 24 } = {}) {
return fov;
}
+// A driver replaces single components after the tracks: `overrides.eye[1]` is a number, or undefined to keep the track.
+function applyVectorOverrides(vector, components) {
+ if (!components) return;
+ for (let axis = 0; axis < 3; axis++) {
+ if (components[axis] !== undefined) vector[axis] = components[axis];
+ }
+}
+
/** Absolute-time camera channels reuse the same interpolation as animation clips. */
export function createCameraPath({ duration, loop = false, eye, target = [0, 0, 0], fov = 45, roll = 0, up = [0, 1, 0], near = 0.1, far = 100 } = {}) {
validateVector(up, 'Camera up');
@@ -102,7 +110,7 @@ export function createCameraPath({ duration, loop = false, eye, target = [0, 0,
const stagedUp = new Float64Array(3);
const direction = new Float64Array(3);
- function sample(time, output = { eye: [0, 0, 0], target: [0, 0, 0], up: [0, 0, 0] }, { targetMatrix } = {}) {
+ function sample(time, output = { eye: [0, 0, 0], target: [0, 0, 0], up: [0, 0, 0] }, { targetMatrix, overrides } = {}) {
const destinations = [output.eye, output.target, output.up];
for (const destination of destinations) {
if (!(Array.isArray(destination) || destination instanceof Float32Array || destination instanceof Float64Array) || destination.length !== 3) {
@@ -134,11 +142,13 @@ export function createCameraPath({ duration, loop = false, eye, target = [0, 0,
const tracks = sampler.sample(time);
stagedEye.set(tracks[0].output);
stagedTarget.set(tracks[1].output);
+ applyVectorOverrides(stagedEye, overrides?.eye);
+ applyVectorOverrides(stagedTarget, overrides?.target);
if (targetMatrix !== undefined) transformTarget(stagedTarget, targetMatrix);
validatePose(stagedEye, stagedTarget, baseUp);
- const fieldOfView = tracks[2].output[0];
+ const fieldOfView = overrides?.fov ?? tracks[2].output[0];
validateLens(fieldOfView, near, far);
- const angle = tracks[3].output[0];
+ const angle = overrides?.roll ?? tracks[3].output[0];
const directionLength = Math.hypot(stagedTarget[0] - stagedEye[0], stagedTarget[1] - stagedEye[1], stagedTarget[2] - stagedEye[2]);
for (let axis = 0; axis < 3; axis++) direction[axis] = (stagedTarget[axis] - stagedEye[axis]) / directionLength;
const cosine = Math.cos(angle);
diff --git a/src/node-constraints.js b/src/node-constraints.js
index 252384a4..17369b08 100644
--- a/src/node-constraints.js
+++ b/src/node-constraints.js
@@ -27,6 +27,8 @@ const LIGHT_DRIVEN = { intensity: false, color: true };
const MORPH_DRIVEN = { weight: false };
const SCALAR_TARGET_KINDS = ['light', 'morph'];
const TARGET_PROPERTIES = { light: LIGHT_DRIVEN, morph: MORPH_DRIVEN };
+// The camera has no ID. eye and target take a component; fov (degrees) and roll (radians) take none.
+const CAMERA_DRIVEN = { eye: true, target: true, fov: false, roll: false };
const RADIANS_TO_DEGREES = 180 / Math.PI;
const COMMON_FIELDS = ['type', 'node', 'influence'];
@@ -90,10 +92,10 @@ function axisRanges(input, limit, label) {
return ranges;
}
-function influenceFrom(value, nodeIds, label) {
+function influenceFrom(value, nodeIds, label, properties) {
if (value === undefined) return 1;
if (typeof value === 'number') return bounded(value, 0, 1, `${label} influence`);
- compileMotionExpression(value, nodeIds, `${label} influence`);
+ compileMotionExpression(value, nodeIds, `${label} influence`, properties);
return structuredClone(value);
}
@@ -109,7 +111,7 @@ function withArguments(input, label) {
return { ...rest, ...args };
}
-function normalizeConstraint(rawInput, position, movableIds, visibleIds) {
+function normalizeConstraint(rawInput, position, movableIds, visibleIds, properties) {
const label = `Motion constraint ${position}`;
const input = withArguments(rawInput, label);
if (!input || !Object.hasOwn(CONSTRAINT_FIELDS, input.type)) {
@@ -117,7 +119,7 @@ function normalizeConstraint(rawInput, position, movableIds, visibleIds) {
}
knownKeys(input, [...COMMON_FIELDS, ...CONSTRAINT_FIELDS[input.type]], label);
if (!movableIds.has(input.node)) throw new RangeError(`${label} node must be a node ID in this recipe; got ${JSON.stringify(input.node)}.`);
- const result = { type: input.type, node: input.node, influence: influenceFrom(input.influence, visibleIds, label) };
+ const result = { type: input.type, node: input.node, influence: influenceFrom(input.influence, visibleIds, label, properties) };
if (CONSTRAINT_FIELDS[input.type].includes('target') && (input.type !== 'pivot' || input.target !== undefined)) {
if (!visibleIds.has(input.target)) throw new RangeError(`${label} target must be a node ID in this recipe; got ${JSON.stringify(input.target)}.`);
if (input.target === input.node) throw new RangeError(`${label} target cannot be the constrained node itself.`);
@@ -280,9 +282,20 @@ function normalizeActionConstraint(input, result, label) {
}
/** Validate a constraint list against the node IDs a motion may move and the ones it may read. Returns plain data. */
-export function normalizeConstraints(input, movableIds, visibleIds) {
+export function normalizeConstraints(input, movableIds, visibleIds, properties = new Map()) {
denseArray(input, MAX_CONSTRAINTS, 'Motion constraints');
- return input.map((constraint, position) => normalizeConstraint(constraint, position, movableIds, visibleIds));
+ return input.map((constraint, position) => normalizeConstraint(constraint, position, movableIds, visibleIds, properties));
+}
+
+function normalizeCameraDriver(input, label, visibleIds, properties) {
+ const { id, property, component } = input.target;
+ if (id !== undefined) throw new RangeError(`${label} camera target takes no id; leave it out, such as { "kind": "camera", "property": "fov" }.`);
+ const takesComponent = CAMERA_DRIVEN[property];
+ if (takesComponent === undefined) throw new RangeError(`${label} camera property must be one of ${Object.keys(CAMERA_DRIVEN).join(', ')}.`);
+ if (takesComponent && !AXES.includes(component)) throw new RangeError(`${label}: camera ${property} needs a component, x, y or z.`);
+ if (!takesComponent && component !== undefined) throw new RangeError(`${label}: camera ${property} takes no component.`);
+ compileMotionExpression(input.expression, visibleIds, `${label} expression`, properties);
+ return { target: { kind: 'camera', property, ...(component === undefined ? {} : { component }) }, expression: structuredClone(input.expression) };
}
function normalizeDriver(input, position, ids) {
@@ -291,6 +304,7 @@ function normalizeDriver(input, position, ids) {
knownKeys(input, ['target', 'expression'], label);
knownKeys(input.target, ['kind', 'id', 'property', 'component'], `${label} target`);
const { kind, id, property, component } = input.target;
+ if (kind === 'camera') return normalizeCameraDriver(input, label, visibleIds, ids.properties);
if (component !== undefined && !AXES.includes(component)) throw new RangeError(`${label} component must be x, y or z.`);
if (kind === 'node') {
if (!movableIds.has(id)) throw new RangeError(`${label} node must be a node ID in this recipe; got ${JSON.stringify(id)}.`);
@@ -308,7 +322,7 @@ function normalizeDriver(input, position, ids) {
if (isVector === undefined) throw new RangeError(`${label} property must be one of ${Object.keys(TARGET_PROPERTIES[kind]).join(', ')} for a ${kind}.`);
if (isVector !== (component !== undefined)) throw new RangeError(`${label}: ${isVector ? 'a light color needs a component (x, y, z for red, green, blue)' : `${property} takes no component`}.`);
} else {
- throw new RangeError(`${label} target kind must be node, material, light or morph.`);
+ throw new RangeError(`${label} target kind must be node, material, light, morph or camera.`);
}
compileMotionExpression(input.expression, visibleIds, `${label} expression`, ids.properties);
return { target: { kind, id, property, ...(component === undefined ? {} : { component }) }, expression: structuredClone(input.expression) };
@@ -808,7 +822,7 @@ export function createNodeConstraintEvaluator({ hierarchy, rootMatrix, constrain
const value = driver.compiled.evaluate(context);
const { kind, id, property, component } = driver.target;
const index = AXES.indexOf(component);
- if (SCALAR_TARGET_KINDS.includes(kind)) {
+ if (SCALAR_TARGET_KINDS.includes(kind) || kind === 'camera') {
drivenLooks.push({ target: driver.target, value });
return;
}
diff --git a/tests/agent-motion-camera-drivers.test.js b/tests/agent-motion-camera-drivers.test.js
new file mode 100644
index 00000000..4821caf0
--- /dev/null
+++ b/tests/agent-motion-camera-drivers.test.js
@@ -0,0 +1,104 @@
+import './support/load-agent-scene-modules.mjs';
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { mat4 } from 'gl-matrix';
+import { createAgentScene } from '../src/agent-scene.js';
+
+const close = (actual, expected, tolerance = 1e-4) => assert.ok(Math.abs(actual - expected) <= tolerance, `${actual} vs ${expected}`);
+const customRead = name => ({ custom: { node: 'lead', name } });
+
+function recipeWith(motion) {
+ return {
+ format: '67js.scene', schemaVersion: 1,
+ geometries: [{ id: 'box', type: 'box', bevel: 0 }],
+ materials: [{ id: 'paint', color: [0.6, 0.6, 0.6] }],
+ nodes: [
+ { id: 'lead', geometry: 'box', material: 'paint', translation: [4, 0, 0] },
+ { id: 'follower', geometry: 'box', material: 'paint' },
+ ],
+ camera: { eye: [0, 1, 8], target: [0, 0, 0], fov: 50 },
+ effects: {},
+ motion,
+ };
+}
+
+const DOLLY = { node: 'lead', name: 'dolly', min: 0, max: 1, keys: [{ time: 0, value: 0 }, { time: 2, value: 1 }] };
+const FADE = { node: 'lead', name: 'fade', min: 0, max: 1, keys: [{ time: 0, value: 0 }, { time: 1, value: 1 }, { time: 2, value: 0 }] };
+
+function cameraMotion() {
+ return {
+ duration: 2,
+ tracks: [{ kind: 'camera', property: 'target', keyframes: [{ time: 0, value: [0, 0, 0] }, { time: 2, value: [2, 0, 0] }] }],
+ properties: [DOLLY],
+ drivers: [
+ { target: { kind: 'camera', property: 'eye', component: 'z' }, expression: { sub: [8, { mul: [customRead('dolly'), 4] }] } },
+ { target: { kind: 'camera', property: 'fov' }, expression: { sub: [50, { mul: [customRead('dolly'), 20] }] } },
+ ],
+ };
+}
+
+function cameraAt(scene, time) {
+ scene.sampleMotion(time);
+ const { eye, target, fov } = scene.camera;
+ return { eye: Array.from(eye), target: Array.from(target), fov };
+}
+
+test('one property dollies the camera and narrows its fov after the camera tracks, and seek equals play', () => {
+ const scene = createAgentScene(recipeWith(cameraMotion()));
+ const played = [0, 0.5, 1, 1.5, 2].map(time => cameraAt(scene, time));
+ close(played[2].eye[2], 6);
+ close(played[2].fov, 40);
+ close(played[4].eye[2], 4);
+ close(played[4].fov, 30);
+ close(played[2].eye[1], 1);
+ close(played[2].target[0], 1);
+ const seekScene = createAgentScene(recipeWith(cameraMotion()));
+ assert.deepEqual(cameraAt(seekScene, 1.5), played[3]);
+ assert.deepEqual(cameraAt(seekScene, 0.5), played[1]);
+});
+
+test('a camera driver without any camera track moves the recipe camera, and roll turns the up vector', () => {
+ const scene = createAgentScene(recipeWith({
+ duration: 2, tracks: [], properties: [DOLLY],
+ drivers: [{ target: { kind: 'camera', property: 'roll' }, expression: { mul: [customRead('dolly'), Math.PI / 2] } }],
+ }));
+ scene.sampleMotion(0);
+ close(scene.camera.up[0], 0);
+ close(scene.camera.up[1], 1);
+ scene.sampleMotion(2);
+ close(Math.abs(scene.camera.up[0]), 1, 0.01);
+ close(scene.camera.up[1], 0, 0.15);
+ close(scene.camera.eye[2], 8);
+});
+
+test('a property fades a constraint in and out through its influence', () => {
+ const scene = createAgentScene(recipeWith({
+ duration: 2, tracks: [], properties: [FADE],
+ constraints: [{ type: 'copy_location', node: 'follower', target: 'lead', influence: customRead('fade') }],
+ }));
+ const followerX = time => {
+ scene.sampleMotion(time);
+ return mat4.getTranslation(new Float64Array(3), scene.parts.find(part => part.name === 'follower').matrix)[0];
+ };
+ close(followerX(0), 0);
+ close(followerX(0.5), 2);
+ close(followerX(1), 4);
+ close(followerX(1.5), 2);
+ close(followerX(2), 0);
+});
+
+test('camera driver and influence errors name the field and what to pass', () => {
+ const build = (drivers, extra = {}) => () => createAgentScene(recipeWith({ duration: 2, tracks: [], properties: [DOLLY], drivers, ...extra }));
+ assert.throws(build([{ target: { kind: 'camera', id: 'main', property: 'fov' }, expression: 40 }]), /camera target takes no id/);
+ assert.throws(build([{ target: { kind: 'camera', property: 'zoom' }, expression: 40 }]), /camera property must be one of eye, target, fov, roll/);
+ assert.throws(build([{ target: { kind: 'camera', property: 'eye' }, expression: 1 }]), /camera eye needs a component/);
+ 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/,
+ );
+ assert.throws(
+ () => createAgentScene(recipeWith({ duration: 2, tracks: [], constraints: [{ type: 'copy_location', node: 'follower', target: 'lead', influence: customRead('missing') }] })),
+ /no custom property "missing"/,
+ );
+});
diff --git a/tests/agent-motion-properties.test.js b/tests/agent-motion-properties.test.js
index eacf7ea6..6853406c 100644
--- a/tests/agent-motion-properties.test.js
+++ b/tests/agent-motion-properties.test.js
@@ -146,7 +146,7 @@ test('light and morph driver targets are checked against the scene', () => {
assert.throws(() => build({ kind: 'light', id: 'point:0', property: 'color' }), /needs a component/);
assert.throws(() => build({ kind: 'morph', id: 'nope', property: 'weight' }), /morph was not found.*lift/);
assert.throws(() => build({ kind: 'morph', id: 'lift', property: 'weight', component: 'x' }), /takes no component/);
- assert.throws(() => build({ kind: 'sun', id: 'x', property: 'intensity' }), /node, material, light or morph/);
+ assert.throws(() => build({ kind: 'sun', id: 'x', property: 'intensity' }), /node, material, light, morph or camera/);
const clash = rigRecipe({
duration: 1, tracks: [{ kind: 'light', id: 'point:0', property: 'intensity', keyframes: [{ time: 0, value: 1 }] }],
drivers: [{ target: { kind: 'light', id: 'point:0', property: 'intensity' }, expression: 1 }],
@@ -158,6 +158,6 @@ test('light and morph driver targets are checked against the scene', () => {
test('the capabilities list the property limits', () => {
assert.equal(AGENT_SCENE_CAPABILITIES.motionDrivers.maxProperties, 32);
- assert.deepEqual(AGENT_SCENE_CAPABILITIES.motionDrivers.targets, ['node', 'material', 'light', 'morph']);
+ assert.deepEqual(AGENT_SCENE_CAPABILITIES.motionDrivers.targets, ['node', 'material', 'light', 'morph', 'camera']);
assert.deepEqual(AGENT_SCENE_CAPABILITIES.motionDrivers.variables, ['time', 'node', 'custom', 'distance', 'rotationDifference']);
});