3D engine that AI agents drive
MCP: light caps from light-limits, camera projection, focal length, shift and f-stop (issues #604, #607)
Nguyen Xuan And1f400619adb
diff --git a/changes/604-607.size.md b/changes/604-607.size.mdnew file mode 100644index 00000000..cbe9c521--- /dev/null+++ b/changes/604-607.size.md@@ -0,0 +1,18 @@+- entry:core: orthoScale, focal length with sensor width and lens shift in applyProjection (about 245 bytes gzip); the renderer already drew orthographic, and agents could not reach it.+- entry:core+lazy: the same projection code.+- entry:camera-effects: effectsWithFStop maps a camera f-stop onto the existing depth of field blur and focus, so no second depth of field path exists.+- scene:lit-box: the projection code in the core bundle.+- scene:lit-box+lazy: the projection code in the core bundle.+- scene:gltf-box: the projection code in the core bundle.+- scene:gltf-box+lazy: the projection code in the core bundle.+- scene:agent-scene: camera lens validation (projection, orthoScale, focalLength, sensorWidth, shift, fStop) and the fov or focalLength rule; validated in the scene so a bad lens fails at create and set-camera.+- scene:agent-scene+lazy: the same validation.+- goal:lit-box: 265 bytes for the agent-reachable lens; the scene gains orthographic and shifted cameras, which agents could not set before.+- goal:gltf-box: 246 bytes for the same lens code.+- goal:agent-scene: 1.3 KB for lens validation and motion that keeps the lens; an agent-facing capability.+- tool:scene_create: six camera fields (about 990 bytes) shared by every tool that takes a camera.+- tool:scene_apply: the same six camera fields on set-camera.+- tool:scene_create_asset: the same six camera fields.+- tool:scene_review: the same six camera fields on shot cameras.+- tool-total: four tools carry the six new camera fields, with short descriptions; the 16 point and 7 area light caps add no bytes.+- result:scene_capabilities: one camera note that holds the rules the field descriptions leave out.diff --git a/changes/604.md b/changes/604.mdnew file mode 100644index 00000000..9588bf7c--- /dev/null+++ b/changes/604.md@@ -0,0 +1,2 @@+---+- MCP scene_create and set-environment now accept the 16 point, 8 spot and 7 area lights the engine renders, read from one limits file, not 8 point and 4 area (#604)diff --git a/changes/607.md b/changes/607.mdnew file mode 100644index 00000000..4958378a--- /dev/null+++ b/changes/607.md@@ -0,0 +1,2 @@+---+- Scene cameras take projection orthographic with orthoScale, focalLength with sensorWidth (instead of fov), shift [x, y] and fStop for depth of field, in recipes and set-camera (#607)diff --git a/docs/agent-scene.md b/docs/agent-scene.mdindex 85f67e90..b878b548 100644--- a/docs/agent-scene.md+++ b/docs/agent-scene.md@@ -66,7 +66,7 @@ Call `loadAgentSceneModules(operations)` before `apply` when the operations add## Recipe contractThe recipe must contain `format`, `schemaVersion`, `geometries`, `materials`, and `nodes`.-The optional `camera` object supplies a perspective camera.+The optional `camera` object supplies a perspective camera, or an orthographic one with `projection: 'orthographic'` and `orthoScale` (view height in metres, default 4). The lens is `fov` (vertical degrees) or `focalLength` in millimetres with `sensorWidth` (default 36); giving both is an error. `shift: [x, y]` moves the frame by a fraction of its width and height, positive right and up. `fStop` (0.7 to 64) turns on depth of field focused on `target` (1.4 or lower is full blur) and cannot be combined with `effects.depthOfField.blur`. The path tracer draws perspective cameras without shift.All objects reject unknown keys.Inputs must contain plain, finite, acyclic JSON data without accessors, sparse arrays, or executable values.JSON nesting has a fixed maximum of 64 levels.@@ -225,7 +225,7 @@ Normal transforms must also remain finite.Cached local geometry bounds provide a conservative world Float32 check from eight corners per mesh.The check bounds the sum of absolute matrix products, so intermediate shader arithmetic cannot overflow before cancellation.-The camera contains `eye`, `target`, `up`, `fov`, `near`, and `far`.+The camera contains `eye`, `target`, `up`, `fov`, `near`, and `far`, plus the optional `projection`, `orthoScale`, `focalLength`, `sensorWidth`, `shift` and `fStop` when the recipe sets them.Its defaults are `[4, 3, 5]`, `[0, 0, 0]`, `[0, 1, 0]`, `45`, `0.1`, and `1000`.FOV uses degrees and ranges between zero and 180.The clipping range must satisfy `0 < near < far` at Float32 precision.@@ -354,7 +354,7 @@ Final resource references and hierarchy must be valid before publication.| --- | --- || `set-node` | `id`, optional `translation`, `rotation`, `scale`, `parent`, `label`, `geometry`, `material` || `set-material` | `id`, optional `color`, `metallic`, `roughness`, `emission`, `emissiveColor`, `pattern`, `map` |-| `set-camera` | Optional `eye`, `target`, `up`, `fov`, `near`, `far` directly on the command |+| `set-camera` | Optional `eye`, `target`, `up`, `fov`, `near`, `far`, `projection`, `orthoScale`, `focalLength`, `sensorWidth`, `shift`, `fStop` directly on the command; `focalLength` replaces `fov` and `fov` replaces `focalLength` || `add-geometry` | `geometry`, containing a complete geometry record || `remove-geometry` | `id` || `add-material` | `material`, containing a complete material record |diff --git a/scripts/agent-preview-browser.js b/scripts/agent-preview-browser.jsindex 904f29b9..c064fd13 100644--- a/scripts/agent-preview-browser.js+++ b/scripts/agent-preview-browser.js@@ -1,9 +1,9 @@import { buildWithKernels, kernelWorkersAvailable, kernelStats, resetKernelStats } from '../src/kernel-offload.js';-import { createAgentScene, loadAllAgentSceneModules, allAgentSceneModulesLoaded, needsMeshBooleans, loadMeshBooleans, meshBooleansLoaded, setManifoldModuleLoader, needsPhysics, loadPhysicsEngine, physicsEngineLoaded, setPhysicsModuleLoader } from '../src/agent-scene.js';+import { createAgentScene, applyCameraFields, loadAllAgentSceneModules, allAgentSceneModulesLoaded, needsMeshBooleans, loadMeshBooleans, meshBooleansLoaded, setManifoldModuleLoader, needsPhysics, loadPhysicsEngine, physicsEngineLoaded, setPhysicsModuleLoader } from '../src/agent-scene.js';import { Renderer67 } from '../src/renderer.js';import { skyOpenness } from '../src/closed-room.js';import { fogSkyVisibility } from '../src/fog-sky-visibility.js';-import { installCameraEffects } from '../src/camera-effects.js';+import { installCameraEffects, effectsWithFStop } from '../src/camera-effects.js';import { installRenderPasses } from '../src/render-passes.js';import { installMeshBlend, normalizeBlend } from '../src/mesh-blend.js';import { installDepthPrecision } from '../src/reversed-depth.js';@@ -73,11 +73,7 @@ function candidateCamera(record, operations) {const camera = record.scene.exportRecipe().camera;for (const operation of operations) {if (operation.type === 'set-camera') {- for (const field of ['eye', 'target', 'up', 'fov', 'near', 'far']) {- if (Object.hasOwn(operation, field)) {- camera[field] = operation[field];- }- }+ applyCameraFields(camera, operation);}}return createAgentScene({ format: '67js.scene', schemaVersion: 1, geometries: [], materials: [], nodes: [], camera }).camera;@@ -249,7 +245,7 @@ function draw(record, time = 0, camera = record.scene.camera, frameOptions = {})syncMeshBlend(record);record.renderer.userPasses?.set(record.scene.postPasses ?? []);applyRecipeWindHeading(record.renderer, environment);- record.renderer.render({ ...camera, environment: litEnvironment(record.scene.parts, environment, Boolean(record.renderer.groundPart)), effects, exposure: effects.exposure, time, lines: environment.lines, ...windFrame(environment), ...frameOptions });+ record.renderer.render({ ...camera, environment: litEnvironment(record.scene.parts, environment, Boolean(record.renderer.groundPart)), effects, exposure: effects.exposure, time, lines: environment.lines, ...windFrame(environment), ...frameOptions, effects: effectsWithFStop(frameOptions.effects ?? effects, camera) });const error = record.renderer.context.getError();if (error !== 0) {throw new Error(`WebGL render failed with error ${error}.`);diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjsindex fca6ec92..fbfc7fca 100644--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@ -11,6 +11,7 @@ import { VIEW_TRANSFORM_NAMES, LOOK_NAMES } from '../src/view-transform-names.jsimport { MATERIAL_PATTERN_TYPES, MATERIAL_MAPPINGS, LIGHTING_SETUP_NAMES, RENDER_PASS_NAMES, VIDEO_ENCODERS, MAXIMUM_JOB_SIDE, MAXIMUM_MEMORY_MIB } from '../src/agent-scene-capabilities.js';import { MATERIAL_LAYER_SCALAR_RANGES, MATERIAL_LAYER_COLOR_RANGES } from '../src/material-layers.js';import { SUBSURFACE_RANGES } from '../src/subsurface-limits.js';+import { MAX_POINT_LIGHTS, MAX_SPOT_LIGHTS, MAX_AREA_LIGHTS } from '../src/light-limits.js';const finite = z.number().min(-3.4028234663852886e38).max(3.4028234663852886e38);const positive = finite.positive();@@ -154,9 +155,15 @@ const cameraFields = {eye: vector3.optional().describe('Camera position in world coordinates.'),target: vector3.optional().describe('World point toward which the camera looks.'),up: vector3.optional().describe('Nonzero camera up direction, not collinear with the view direction.'),- fov: finite.gt(0).lt(180).optional().describe('Vertical perspective field of view in degrees.'),+ fov: finite.gt(0).lt(180).optional().describe('Vertical perspective field of view in degrees. Not with focalLength.'),near: positive.optional().describe('Near clipping distance. Must be less than far.'),far: positive.optional().describe('Far clipping distance. Must exceed near.'),+ projection: z.enum(['perspective', 'orthographic']).optional().describe('Defaults to perspective.'),+ orthoScale: positive.optional().describe('Orthographic view height in metres (default 4); needs projection orthographic.'),+ focalLength: positive.max(10000).optional().describe('Lens in mm, instead of fov.'),+ sensorWidth: positive.max(1000).optional().describe('Sensor width in mm with focalLength; default 36.'),+ shift: z.tuple([z.number().min(-1).max(1), z.number().min(-1).max(1)]).optional().describe('Lens shift [x, y] as a fraction of the frame; positive moves the frame right and up.'),+ fStop: z.number().min(0.7).max(64).optional().describe('Depth of field focused on target; 1.4 is full blur. Not with effects.depthOfField.blur above 0.'),};const bounded = (minimum, maximum) => z.number().min(minimum).max(maximum);const boundedVector = (minimum, maximum) => z.tuple([bounded(minimum, maximum), bounded(minimum, maximum), bounded(minimum, maximum)]);@@ -204,7 +211,7 @@ const environment = z.strictObject({range: z.union([z.literal(0), bounded(0.001, 1e6)]).optional(),castShadow: z.boolean().optional().describe('Casts a shadow; 6 atlas tiles.'),affects,- })).max(8).optional().describe('Replaces the list; [] clears. Intensity in candela.'),+ })).max(MAX_POINT_LIGHTS).optional().describe('Replaces the list; [] clears. Intensity in candela.'),spotLights: z.array(z.strictObject({position: boundedVector(-1e6, 1e6),direction: boundedVector(-1e6, 1e6).describe('Nonzero direction the cone points along.'),@@ -216,7 +223,7 @@ const environment = z.strictObject({range: z.union([z.literal(0), bounded(0.001, 1e6)]).optional(),castShadow: z.boolean().optional().describe('Casts a shadow; 1 atlas tile.'),affects,- })).max(8).optional().describe('Replaces the list; [] clears.'),+ })).max(MAX_SPOT_LIGHTS).optional().describe('Replaces the list; [] clears.'),areaLights: z.array(z.strictObject({position: boundedVector(-1e6, 1e6).describe('Center of the rectangle.'),direction: boundedVector(-1e6, 1e6).describe('Direction the rectangle faces; emits that side only.'),@@ -226,7 +233,7 @@ const environment = z.strictObject({color: color.optional(),intensity: bounded(0, 1e5).optional().describe('Candela head on.'),affects,- })).max(4).optional().describe('Replaces the list; [] clears. No shadow.'),+ })).max(MAX_AREA_LIGHTS).optional().describe('Replaces the list; [] clears. No shadow.'),skyTop: color.optional(),skyBottom: color.optional(),fogColor: color.optional(),diff --git a/src/agent-motion.js b/src/agent-motion.jsindex af9ad921..c307231a 100644--- a/src/agent-motion.js+++ b/src/agent-motion.js@@ -1,5 +1,6 @@import { createAnimationClip, compileAnimationSampler } from './animation.js';import { createCameraPath } from './camera-path.js';+import { CAMERA_LENS_FIELDS } from './camera.js';import { createSkeletonPose } from './skeleton-pose.js';import { createNodeConstraintEvaluator, normalizeConstraints, normalizeDrivers } from './node-constraints.js';import { normalizeClipLayers } from './agent-clip-layers.js';@@ -602,9 +603,14 @@ export function compileAgentMotion(input, recipe) {const cameraPath = cameraTracks.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 new RangeError('A camera with a focalLength cannot have a fov track. Give the camera a fov, or leave fov out of the motion.');+ }output.camera = {eye: new Float32Array(3), target: new Float32Array(3), up: new Float32Array(3),- fov: 45, near: cameraInput.near, far: cameraInput.far, projection: 'perspective',+ fov: 45, near: cameraInput.near, far: cameraInput.far,+ // The lens the recipe camera sets (projection, focal length, shift, f-stop) stays while the tracks move the camera.+ ...Object.fromEntries(CAMERA_LENS_FIELDS.filter(field => cameraInput[field] !== undefined).map(field => [field, cameraInput[field]])),};}const materialSamples = new Map([...output.materials.keys()].map(id => [id, { ...baselines.get(id) }]));diff --git a/src/agent-scene-capabilities.js b/src/agent-scene-capabilities.jsindex 982a9f3d..0c25737a 100644--- a/src/agent-scene-capabilities.js+++ b/src/agent-scene-capabilities.js@@ -162,6 +162,7 @@ export const MESH_SCULPT_NOTES = Object.freeze({export const AGENT_SCENE_CAPABILITIES = Object.freeze({format: '67js.scene', schemaVersion: 1,geometryTypes: Object.freeze(['box', 'cylinder', 'sphere', 'torus', 'lathe', 'extrude', 'tube', 'curve', 'text', 'grid', 'terrain', 'mesh']),+ camera: 'eye, target, up, near, far, then fov (vertical degrees) or focalLength (mm, with sensorWidth mm, default 36; not both). projection orthographic with orthoScale (view height in m, default 4). shift [x, y] moves the frame by a fraction of its width and height. fStop (0.7 to 64) turns on depth of field focused on target; 1.4 or lower is full blur, and effects.depthOfField.blur must stay 0. Orthographic and shifted cameras render with the rasterizer, not the path tracer.',terrain: 'One mesh, x and z from -size/2 to size/2, hills about y = 0. size 40 m (1-2000), resolution 64 cells (2-256), seed 1, amplitude 1 m (0-200), holes up to 16 of {center:[x,z],radius} with no surface inside; radius a few cells or more.',placedAssets: 'Node field asset:{id,materials?,clip?,drive?} turns a group node into a catalog GLB (id from asset_catalog; scene_create_asset is one asset alone). Its transform places it. materials:[{name,color,metallic,roughness,opacity,emission,emissiveColor}] override source materials by name. clip:{index,start=0,speed=1,loop=true} plays that clip from scene time start, on a decoded copy of its own; scene_apply set-motion tracks move the node as usual and scene time seeks the clip. Copies of one asset share geometry and materials and draw as one batch. drive:{path | legs, cruiseSpeed | speed, wheels, lights} drives a car along a path in the placement frame on a decoded copy of its own (fields as motion.drive in an asset recipe, docs/vehicle.md; no tail-light glow). scene_inspect assets adds its wheels, rejectedNames and light signals. At most 512 placements, 16 assets, 16 playing a clip or driving. Render jobs do not draw placed assets yet; scene_look does.',navigation: 'scene_inspect path:{ground,from:[x,z],to:[x,z]} returns a route over the ground node around its holes, steep slopes and the nodes in avoid:[ids] (box footprints), as keyframes [{time,value:[x,y,z]}] for a node translation track with interpolation LINEAR. radius 0.3 m is how far the walker position stays from holes and avoided nodes; maxSlope 40 degrees; cellSize defaults to radius; give seconds for the whole walk or speed (1.4 m/s); lift raises y, such as half the walker height. Ground and avoided nodes are read at their authored pose. Errors name an unwalkable start or goal, or one that cannot be reached.',diff --git a/src/agent-scene.js b/src/agent-scene.jsindex cdf54644..e3f83d64 100644--- a/src/agent-scene.js+++ b/src/agent-scene.js@@ -1,7 +1,7 @@import { mat4, mat3 } from 'gl-matrix';import { box, cylinder, grid, sphere, torus } from './geometry.js';import { createSceneGraph } from './scene-graph.js';-import { applyProjection } from './camera.js';+import { applyProjection, validateCameraShift, CAMERA_LENS_FIELDS } from './camera.js';import { normalizeAgentLook, environmentPatchWithSetup, environmentLinksLights, agentEnvironmentMap } from './agent-look.js';import { agentSceneModule, agentSceneModuleLoaded } from './agent-scene-modules.js';import { MESH_SMOOTH_ANGLE_DEFAULT, CURVE_TEXT_LIMITS, AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS, MAX_MATERIAL_PATTERNS, RECIPE_ALPHA_MODES } from './agent-scene-capabilities.js';@@ -26,7 +26,7 @@ const CAMERA_DEFAULTS = Object.freeze({ eye: [4, 3, 5], target: [0, 0, 0], up: [const NODE_FIELDS = ['translation', 'rotation', 'scale', 'parent', 'label', 'geometry', 'material', 'skin', 'relations', 'asset', 'vegetation', 'decal', 'depthLayer', 'blend'];const MATERIAL_FIELDS = ['color', 'metallic', 'roughness', 'emission', 'emissiveColor', 'opacity', 'alphaMode', 'doubleSided', 'pattern', 'map', 'subsurface', 'snippet', 'waterPreset', 'absorption', 'turbidity', ...MATERIAL_LAYER_FIELDS];const PATTERN_TEXTURE_FIELDS = ['map', 'normalMap', 'metallicRoughnessMap', 'emissiveMap', 'boxMapScale', 'boxMapAxis'];-const CAMERA_FIELDS = Object.keys(CAMERA_DEFAULTS);+const CAMERA_FIELDS = [...Object.keys(CAMERA_DEFAULTS), ...CAMERA_LENS_FIELDS];const LOOK_OPERATION_FIELDS = Object.freeze({'set-environment': 'environment','set-effects': 'effects',@@ -325,9 +325,55 @@ function nodeFrom(value) {return result;}+/** Sets the given camera fields on a camera; a focal length replaces fov and a fov replaces focal length and sensor, never both. */+export function applyCameraFields(camera, fields) {+ rejectFovWithFocalLength(fields);+ for (const field of CAMERA_FIELDS) {+ if (Object.hasOwn(fields, field)) camera[field] = fields[field];+ }+ if (Object.hasOwn(fields, 'focalLength')) delete camera.fov;+ // Back to a perspective view: the old orthographic size no longer applies.+ if (fields.projection === 'perspective' && !Object.hasOwn(fields, 'orthoScale')) delete camera.orthoScale;+ if (Object.hasOwn(fields, 'fov')) {+ delete camera.focalLength;+ delete camera.sensorWidth;+ }+ return camera;+}++function rejectFovWithFocalLength(fields) {+ if (fields.fov !== undefined && fields.focalLength !== undefined) {+ throw new RangeError('Give a camera fov or a focalLength, not both. Use focalLength (with sensorWidth) for a lens in millimetres, fov for degrees.');+ }+}++function checkCameraLens(camera) {+ if (camera.projection !== undefined && camera.projection !== 'perspective' && camera.projection !== 'orthographic') {+ throw new RangeError('Camera projection must be perspective or orthographic.');+ }+ const orthographic = camera.projection === 'orthographic';+ if (camera.orthoScale !== undefined) {+ if (!orthographic) throw new RangeError('Camera orthoScale needs projection orthographic.');+ if (!Number.isFinite(camera.orthoScale) || camera.orthoScale <= 0) throw new RangeError('Camera orthoScale is the view height in metres and must be positive.');+ }+ if (camera.sensorWidth !== undefined && camera.focalLength === undefined) throw new RangeError('Camera sensorWidth needs focalLength.');+ if (camera.focalLength !== undefined) {+ if (orthographic) throw new RangeError('Camera focalLength needs a perspective projection; an orthographic camera is sized by orthoScale.');+ if (!Number.isFinite(camera.focalLength) || camera.focalLength <= 0 || camera.focalLength > 10000) throw new RangeError('Camera focalLength must be between 0 and 10000 millimetres.');+ if (camera.sensorWidth !== undefined && !(Number.isFinite(camera.sensorWidth) && camera.sensorWidth > 0 && camera.sensorWidth <= 1000)) throw new RangeError('Camera sensorWidth must be between 0 and 1000 millimetres.');+ }+ if (camera.shift !== undefined) validateCameraShift(camera.shift);+ if (camera.fStop !== undefined && !(Number.isFinite(camera.fStop) && camera.fStop >= 0.7 && camera.fStop <= 64)) {+ throw new RangeError('Camera fStop must be between 0.7 and 64. Smaller numbers blur more.');+ }+}+function cameraFrom(value = {}) {knownKeys(value, CAMERA_FIELDS, 'camera');+ rejectFovWithFocalLength(value);const result = { ...CAMERA_DEFAULTS, ...value };+ if (result.focalLength !== undefined) delete result.fov;+ checkCameraLens(result);result.eye = vector(result.eye, 3, 'eye');result.target = vector(result.target, 3, 'target');result.up = vector(result.up, 3, 'up');@@ -337,9 +383,10 @@ function cameraFrom(value = {}) {}result.up = result.up.map(component => component / upLength);for (const field of ['fov', 'near', 'far']) {- finite(result[field], field);+ if (result[field] !== undefined) finite(result[field], field);}- if (Math.fround(result.fov) <= 0 || Math.fround(result.fov) >= 180 || Math.fround(result.near) <= 0 || Math.fround(result.far) <= Math.fround(result.near)) {+ // Without fov the lens is a focal length, which gives a valid angle at any positive size.+ if ((result.fov !== undefined && (Math.fround(result.fov) <= 0 || Math.fround(result.fov) >= 180)) || Math.fround(result.near) <= 0 || Math.fround(result.far) <= Math.fround(result.near)) {throw new RangeError('Camera needs 0 < fov < 180 and 0 < near < far at Float32 precision.');}if (result.eye.every((component, axis) => Math.fround(component) === Math.fround(result.target[axis]))) {@@ -715,6 +762,9 @@ function normalizeRecipe(input, limits) {}}Object.assign(recipe, normalizeAgentLook(look));+ if (recipe.camera.fStop !== undefined && recipe.effects?.depthOfField.blur > 0) {+ throw new RangeError('Camera fStop drives depth of field; set effects.depthOfField.blur to 0 or remove fStop.');+ }checkLightLinkNames(recipe);if (Object.hasOwn(recipe, 'motion')) {recipe.motion = recipe.motion === null || recipe.motion === undefined ? null : agentSceneModule('motion').normalizeAgentMotion(recipe.motion, recipe);@@ -820,7 +870,8 @@ function retainedMatrices(parts) {function cameraPoseFrom(pose) {const camera = cameraFrom({eye: Array.from(pose.eye), target: Array.from(pose.target), up: Array.from(pose.up),- fov: pose.fov, near: pose.near, far: pose.far,+ ...(pose.focalLength === undefined ? { fov: pose.fov } : {}), near: pose.near, far: pose.far,+ ...Object.fromEntries(CAMERA_LENS_FIELDS.filter(field => pose[field] !== undefined).map(field => [field, pose[field]])),});const view = mat4.lookAt(mat4.create(), camera.eye, camera.target, camera.up);for (const aspect of [1 / 16, 16]) {@@ -1520,9 +1571,13 @@ export function createAgentScene(input, inputLimits = {}, options = {}) {if (!target) {throw new RangeError(`${operation.type} target was not found: ${operation.id}. scene_inspect lists the IDs; add it first with an add operation.`);}- for (const field of fields) {- if (Object.hasOwn(operation, field)) {- target[field] = operation[field];+ if (operation.type === 'set-camera') {+ applyCameraFields(target, operation);+ } else {+ for (const field of fields) {+ if (Object.hasOwn(operation, field)) {+ target[field] = operation[field];+ }}}}diff --git a/src/camera-effects.js b/src/camera-effects.jsindex 59aa0e03..d27e86a1 100644--- a/src/camera-effects.js+++ b/src/camera-effects.js@@ -210,3 +210,16 @@ export function installCameraEffects(renderer) {}return renderer;}++// A lens at this f-stop or wider (smaller number) gets the full blur setting; narrower stops scale it down in proportion.+const FULL_BLUR_F_STOP = 1.4;++/**+ * The effects of one frame when the camera carries an f-stop: depth of field with the blur that stop gives (1.4 / fStop, at most+ * 1), focused on the camera's target. Effects with their own blur (a timeline shot's) are left as they are.+ */+export function effectsWithFStop(effects, camera) {+ if (camera.fStop === undefined || effects.depthOfField.blur > 0) return effects;+ const focusDistance = Math.max(0.01, Math.hypot(...camera.target.map((component, axis) => component - camera.eye[axis])));+ return { ...effects, depthOfField: { blur: Math.min(1, FULL_BLUR_F_STOP / camera.fStop), focusDistance } };+}diff --git a/src/camera.js b/src/camera.jsindex e8ffcfbd..c5483038 100644--- a/src/camera.js+++ b/src/camera.js@@ -1,8 +1,18 @@import { mat4, vec3 } from 'gl-matrix';+/** Lens fields a camera may carry on top of eye, target, up, fov, near and far; each is absent unless the scene sets it. */+export const CAMERA_LENS_FIELDS = Object.freeze(['projection', 'orthoScale', 'focalLength', 'sensorWidth', 'shift', 'fStop']);++/** Image-centre shift as fractions of the frame width and height, like Blender's lens shift; positive moves the frame right and up. */+export function validateCameraShift(shift) {+ if (!Array.isArray(shift) || shift.length !== 2 || !shift.every(component => Number.isFinite(component) && Math.abs(component) <= 1)) {+ throw new RangeError('Camera shift must be [x, y], each between -1 and 1 as a fraction of the frame.');+ }+}+export function applyProjection(matrix, frame, aspect, { world = false } = {}) {if (!Number.isFinite(aspect) || aspect <= 0) throw new RangeError('Camera aspect must be positive and finite');- const hasLens = frame.projection !== undefined || frame.fov !== undefined;+ const hasLens = frame.projection !== undefined || frame.fov !== undefined || frame.focalLength !== undefined;const hasClipping = frame.near !== undefined || frame.far !== undefined;if (!hasLens && !hasClipping) return matrix;const near = frame.near ?? 0.1;@@ -16,16 +26,39 @@ export function applyProjection(matrix, frame, aspect, { world = false } = {}) {matrix[8] = shift;return matrix;}+ if (frame.shift !== undefined) validateCameraShift(frame.shift);if (frame.projection === 'orthographic') {- const height = frame.orthographicHeight ?? 4;+ const height = frame.orthographicHeight ?? frame.orthoScale ?? 4;if (!Number.isFinite(height) || height <= 0) throw new RangeError('Orthographic height must be positive and finite');const halfHeight = height / 2;- return mat4.ortho(matrix, -halfHeight * aspect, halfHeight * aspect, -halfHeight, halfHeight, near, far);+ mat4.ortho(matrix, -halfHeight * aspect, halfHeight * aspect, -halfHeight, halfHeight, near, far);+ // An orthographic window moves sideways in clip space: x' = x + translation.+ if (frame.shift) {+ matrix[12] -= 2 * frame.shift[0];+ matrix[13] -= 2 * frame.shift[1];+ }+ return matrix;}if (frame.projection && frame.projection !== 'perspective') throw new RangeError(`Unsupported camera projection: ${frame.projection}`);+ mat4.perspective(matrix, cameraFieldOfView(frame, aspect) * Math.PI / 180, aspect, near, far);+ // The z column of x and y moves the image centre by -matrix / depth in clip space, so +2 per frame fraction.+ if (frame.shift) {+ matrix[8] += 2 * frame.shift[0];+ matrix[9] += 2 * frame.shift[1];+ }+ return matrix;+}++/** Vertical field of view in degrees: `fov`, or a focal length on a sensor `sensorWidth` wide (default 36, full frame) across the image. */+export function cameraFieldOfView(frame, aspect) {+ if (frame.focalLength !== undefined) {+ const { focalLength, sensorWidth = 36 } = frame;+ if (!Number.isFinite(focalLength) || focalLength <= 0 || !Number.isFinite(sensorWidth) || sensorWidth <= 0) throw new RangeError('Focal length and sensor width must be positive and finite');+ return 2 * Math.atan(sensorWidth / aspect / focalLength / 2) * 180 / Math.PI;+ }const fov = frame.fov ?? 45;if (!Number.isFinite(fov) || fov <= 0 || fov >= 180) throw new RangeError('Camera field of view must be between 0 and 180 degrees');- return mat4.perspective(matrix, fov * Math.PI / 180, aspect, near, far);+ return fov;}const viewDirections = { front: [0, 0, 1], right: [1, 0, 0], top: [0, 1, 0], perspective: [0.58, 0.34, 0.74] };diff --git a/src/path-tracer.js b/src/path-tracer.jsindex 06976be3..4b7a44f7 100644--- a/src/path-tracer.js+++ b/src/path-tracer.js@@ -1,3 +1,4 @@+import { cameraFieldOfView } from './camera.js';import { pointLightFalloff } from './ray-query.js';import { buildTraceScene, SUN_ANGULAR_RADIUS } from './path-tracer-scene.js';import { denoiseRadiance } from './path-tracer-denoise.js';@@ -119,7 +120,9 @@ export function createCamera(camera, width, height) {const eye = finiteVector(camera.eye, 'eye');const target = finiteVector(camera.target, 'target');const up = finiteVector(camera.up ?? [0, 1, 0], 'up');- if (typeof camera.fov !== 'number' || !(camera.fov > 1 && camera.fov < 170)) throw new RangeError('Path tracer camera fov must be between 1 and 170 degrees.');+ if (camera.projection === 'orthographic' || camera.shift) throw new RangeError('The path tracer draws perspective cameras without lens shift. Render those without the renderer option.');+ const fov = camera.focalLength === undefined ? camera.fov : cameraFieldOfView(camera, width / height);+ if (typeof fov !== 'number' || !(fov > 1 && fov < 170)) throw new RangeError('Path tracer camera fov must be between 1 and 170 degrees.');const forward = [target[0] - eye[0], target[1] - eye[1], target[2] - eye[2]];const forwardLength = Math.hypot(...forward);if (forwardLength === 0) throw new RangeError('Path tracer camera eye and target must differ.');@@ -129,7 +132,7 @@ export function createCamera(camera, width, height) {if (rightLength === 0) throw new RangeError('Path tracer camera up must not be parallel to its view.');for (let axis = 0; axis < 3; axis++) right[axis] /= rightLength;const above = [right[1] * forward[2] - right[2] * forward[1], right[2] * forward[0] - right[0] * forward[2], right[0] * forward[1] - right[1] * forward[0]];- const halfHeight = Math.tan(camera.fov * Math.PI / 360);+ const halfHeight = Math.tan(fov * Math.PI / 360);return { eye, forward, right, above, halfHeight, halfWidth: halfHeight * width / height };}diff --git a/tests/agent-review.test.js b/tests/agent-review.test.jsindex f15d53aa..dafcf1ba 100644--- a/tests/agent-review.test.js+++ b/tests/agent-review.test.js@@ -24,7 +24,7 @@ test('review rejects unknown fields, nonfinite values and unbounded inputs befor{ ...request(), shots: [{ rendererTime: Infinity }] }, { ...request(), shots: [{ motionTime: NaN }] },{ ...request(), shots: [{ animation: { clip: 0, time: 0, url: 'https://example.com' } }] },{ ...request(), shots: [{ animation: { clip: 0, time: Infinity } }] },- { ...request(), shots: [{ camera: { projection: 'orthographic' } }] },+ { ...request(), shots: [{ camera: { projection: 'fisheye' } }] },{ ...request(), shots: [{ camera: { eye: [Infinity, 0, 0] } }] },{ ...request(), shots: [{ camera: { fov: 1e100 } }] },{ ...request(), shots: [{ camera: { fov: NaN } }] },diff --git a/tests/mcp-camera-lights.test.js b/tests/mcp-camera-lights.test.jsnew file mode 100644index 00000000..af0667be--- /dev/null+++ b/tests/mcp-camera-lights.test.js@@ -0,0 +1,197 @@+import './support/load-agent-scene-modules.mjs';+import test from 'node:test';+import assert from 'node:assert/strict';+import { Client } from '@modelcontextprotocol/client';+import { InMemoryTransport } from '@modelcontextprotocol/server';+import { mat4, vec3 } from 'gl-matrix';+import { createAgentMcpServer } from '../scripts/mcp-server.mjs';+import { createAgentScene } from '../src/agent-scene.js';+import { applyProjection } from '../src/camera.js';+import { effectsWithFStop } from '../src/camera-effects.js';+import { previewHarness } from './support/preview-harness.mjs';+import { MAX_POINT_LIGHTS, MAX_SPOT_LIGHTS, MAX_AREA_LIGHTS } from '../src/light-limits.js';++function baseRecipe(extra = {}) {+ return {+ format: '67js.scene', schemaVersion: 1,+ geometries: [{ id: 'cube', type: 'box' }],+ materials: [{ id: 'blue', color: [0.1, 0.3, 0.8] }],+ nodes: [{ id: 'mesh', geometry: 'cube', material: 'blue' }],+ ...extra,+ };+}++async function connect(context) {+ let scene;+ const runtime = {+ async capabilities() { return {}; },+ async create({ recipe }) {+ scene = createAgentScene(recipe);+ return { revision: scene.revision };+ },+ async apply({ expectedRevision, operations }) {+ scene.apply(operations, { expectedRevision });+ return { revision: scene.revision };+ },+ async close() {},+ activeSessionId() { return null; },+ };+ const server = createAgentMcpServer(runtime);+ const client = new Client({ name: 'camera-lights-test', version: '1' });+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();+ await server.connect(serverTransport);+ await client.connect(clientTransport);+ context.after(async () => {+ await client.close();+ await server.close();+ });+ return { client, scene: () => scene };+}++function lightArray(count, make) {+ return Array.from({ length: count }, (_, index) => make(index));+}++function findProperty(node, name) {+ if (!node || typeof node !== 'object') return null;+ if (node.properties?.[name]) return node.properties[name];+ for (const child of Object.values(node)) {+ const found = findProperty(child, name);+ if (found) return found;+ }+ return null;+}++test('the MCP light caps are the engine light limits', async context => {+ const { client } = await connect(context);+ const { tools } = await client.listTools();+ const create = tools.find(tool => tool.name === 'scene_create');+ const limits = { pointLights: MAX_POINT_LIGHTS, spotLights: MAX_SPOT_LIGHTS, areaLights: MAX_AREA_LIGHTS };+ for (const [field, limit] of Object.entries(limits)) {+ assert.equal(findProperty(create.inputSchema, field).maxItems, limit, `${field} cap in scene_create`);+ }+});++test('scene_create accepts a full set of lights and rejects one more', async context => {+ const { client, scene } = await connect(context);+ const position = index => [index, 2, 0];+ const environment = {+ pointLights: lightArray(MAX_POINT_LIGHTS, index => ({ position: position(index), intensity: 50 })),+ spotLights: lightArray(MAX_SPOT_LIGHTS, index => ({ position: position(index), direction: [0, -1, 0] })),+ areaLights: lightArray(MAX_AREA_LIGHTS, index => ({ position: position(index), direction: [0, -1, 0], width: 1, height: 1 })),+ };+ const created = await client.callTool({ name: 'scene_create', arguments: { recipe: baseRecipe({ environment }) } });+ assert.notEqual(created.isError, true);+ assert.equal(scene().exportRecipe().environment.pointLights.length, MAX_POINT_LIGHTS);+ assert.equal(scene().exportRecipe().environment.areaLights.length, MAX_AREA_LIGHTS);+ const tooMany = { ...environment, areaLights: lightArray(MAX_AREA_LIGHTS + 1, index => ({ position: position(index), direction: [0, -1, 0], width: 1, height: 1 })) };+ const rejected = await client.callTool({ name: 'scene_create', arguments: { recipe: baseRecipe({ environment: tooMany }) } }).catch(error => ({ isError: true, error }));+ assert.equal(rejected.isError, true);+});++test('scene_create and set-camera take orthographic, shift, focal length and f-stop', async context => {+ const { client, scene } = await connect(context);+ const camera = { eye: [0, 0, 5], target: [0, 0, 0], projection: 'orthographic', orthoScale: 6, shift: [0.1, -0.2], fStop: 2.8 };+ const created = await client.callTool({ name: 'scene_create', arguments: { recipe: baseRecipe({ camera }) } });+ assert.notEqual(created.isError, true);+ assert.deepEqual(scene().camera.shift, [0.1, -0.2]);+ assert.equal(scene().camera.orthoScale, 6);+ const applied = await client.callTool({ name: 'scene_apply', arguments: { sessionId: '00000000-0000-4000-8000-000000000000', expectedRevision: scene().revision,+ operations: [{ type: 'set-camera', projection: 'perspective', focalLength: 50, sensorWidth: 36 }] } });+ assert.notEqual(applied.isError, true, JSON.stringify(applied.content));+ assert.equal(scene().camera.focalLength, 50);+ assert.equal(scene().camera.fov, undefined, applied.content?.[0]?.text);+});++test('a camera takes fov or focalLength, never both, and checks each lens field', () => {+ const make = camera => createAgentScene(baseRecipe({ camera }));+ assert.throws(() => make({ fov: 40, focalLength: 50 }), /fov or a focalLength, not both/);+ assert.throws(() => make({ sensorWidth: 36 }), /sensorWidth needs focalLength/);+ assert.throws(() => make({ projection: 'orthographic', focalLength: 50 }), /perspective projection/);+ assert.throws(() => make({ orthoScale: 4 }), /needs projection orthographic/);+ assert.throws(() => make({ projection: 'orthographic', orthoScale: 0 }), /must be positive/);+ assert.throws(() => make({ projection: 'fisheye' }), /perspective or orthographic/);+ assert.throws(() => make({ shift: [2, 0] }), /shift/);+ assert.throws(() => make({ fStop: 0.1 }), /fStop/);+ assert.throws(() => createAgentScene(baseRecipe({ camera: { fStop: 2 }, effects: { depthOfField: { blur: 0.5 } } })), /fStop drives depth of field/);+ const scene = createAgentScene(baseRecipe({ camera: { fov: 40 } }));+ assert.throws(() => scene.apply([{ type: 'set-camera', fov: 40, focalLength: 50 }], { expectedRevision: 0 }), /not both/);+ scene.apply([{ type: 'set-camera', focalLength: 85 }], { expectedRevision: 0 });+ assert.equal(scene.camera.fov, undefined);+ scene.apply([{ type: 'set-camera', fov: 30 }], { expectedRevision: 1 });+ assert.equal(scene.camera.focalLength, undefined);+});++test('a scene without the new fields keeps its camera exactly', () => {+ const scene = createAgentScene(baseRecipe());+ assert.deepEqual(Object.keys(scene.camera).sort(), ['eye', 'far', 'fov', 'near', 'target', 'up']);+});++function projectToScreen(point, camera, aspect = 1) {+ const projection = applyProjection(mat4.create(), camera, aspect);+ const view = mat4.lookAt(mat4.create(), camera.eye, camera.target, camera.up);+ return vec3.transformMat4(vec3.create(), point, mat4.multiply(mat4.create(), projection, view));+}++test('orthographic orthoScale is the view height and ignores depth', () => {+ const camera = createAgentScene(baseRecipe({ camera: { eye: [0, 0, 8], target: [0, 0, 0], projection: 'orthographic', orthoScale: 4 } })).camera;+ const near = projectToScreen([1, 1, 3], camera);+ const far = projectToScreen([1, 1, -3], camera);+ assert.ok(Math.abs(near[1] - 0.5) < 1e-6);+ assert.ok(Math.abs(near[0] - far[0]) < 1e-6);+ assert.ok(Math.abs(projectToScreen([1, 1, 0], camera, 2)[0] - 0.25) < 1e-6);+});++test('lens shift moves the image by a frame fraction in both projections', () => {+ for (const projection of ['perspective', 'orthographic']) {+ const flat = createAgentScene(baseRecipe({ camera: { eye: [0, 0, 8], target: [0, 0, 0], projection } })).camera;+ const shifted = createAgentScene(baseRecipe({ camera: { eye: [0, 0, 8], target: [0, 0, 0], projection, shift: [0.25, 0.1] } })).camera;+ const before = projectToScreen([0, 0, 0], flat);+ const after = projectToScreen([0, 0, 0], shifted);+ // A fraction of the frame is 2 in clip space, and the frame moves right and up, so the image moves left and down.+ assert.ok(Math.abs(after[0] - before[0] + 0.5) < 1e-6, projection);+ assert.ok(Math.abs(after[1] - before[1] + 0.2) < 1e-6, projection);+ }+});++test('focal length with a sensor width gives the matching field of view at any aspect', () => {+ const lens = createAgentScene(baseRecipe({ camera: { eye: [0, 0, 8], target: [0, 0, 0], focalLength: 36, sensorWidth: 36 } })).camera;+ // A 36 mm lens on a 36 mm sensor sees 53.13 degrees across the width: half width 1 at distance 2.+ const edge = projectToScreen([1, 0, 6], lens, 1);+ assert.ok(Math.abs(edge[0] - 1) < 1e-6);+ const wide = projectToScreen([1, 0, 6], lens, 2);+ assert.ok(Math.abs(wide[0] - 1) < 1e-6);+});++test('an f-stop gives depth of field focused on the target, and an explicit blur wins', () => {+ const effects = { depthOfField: { blur: 0, focusDistance: 5 } };+ const camera = { eye: [0, 0, 8], target: [0, 0, 0], fStop: 2.8 };+ const result = effectsWithFStop(effects, camera);+ assert.equal(result.depthOfField.focusDistance, 8);+ assert.ok(Math.abs(result.depthOfField.blur - 0.5) < 1e-9);+ assert.equal(effectsWithFStop(effects, { ...camera, fStop: 1 }).depthOfField.blur, 1);+ assert.equal(effectsWithFStop(effects, { eye: [0, 0, 8], target: [0, 0, 0] }), effects);+ const shot = { depthOfField: { blur: 0.3, focusDistance: 2 } };+ assert.equal(effectsWithFStop(shot, camera), shot);+});++test('the preview draws the lens fields and the f-stop depth of field, and set-camera reaches them', () => {+ const harness = previewHarness();+ const { preview, renders } = harness;+ const sessionId = 'lens';+ const camera = { eye: [0, 0, 8], target: [0, 0, 0], projection: 'orthographic', orthoScale: 6, shift: [0.1, 0], fStop: 2.8 };+ preview.create({ recipe: baseRecipe({ camera }), sessionId, backend: 'cpu', memoryBudgetMiB: 64 });+ preview.frame({ sessionId });+ const frame = renders.at(-1).camera;+ assert.equal(frame.projection, 'orthographic');+ assert.equal(frame.orthoScale, 6);+ assert.deepEqual(frame.shift, [0.1, 0]);+ assert.equal(frame.effects.depthOfField.focusDistance, 8);+ assert.ok(Math.abs(frame.effects.depthOfField.blur - 0.5) < 1e-9);+ preview.apply({ sessionId, expectedRevision: 0, operations: [{ type: 'set-camera', projection: 'perspective', focalLength: 50 }] });+ preview.frame({ sessionId });+ const lens = renders.at(-1).camera;+ assert.equal(lens.focalLength, 50);+ assert.equal(lens.fov, undefined);+ assert.equal(lens.orthoScale, undefined);+});diff --git a/tests/mcp-tools.test.js b/tests/mcp-tools.test.jsindex 3a7b2671..ad00e622 100644--- a/tests/mcp-tools.test.js+++ b/tests/mcp-tools.test.js@@ -153,7 +153,7 @@ test('SDK advertises the complete strict JSON contract and truthful annotations'assert.deepEqual(variants.map(variant => variant.properties.type.const), ['box', 'cylinder', 'sphere', 'torus', 'lathe', 'extrude', 'tube', 'curve', 'text', 'terrain', 'grid', 'mesh']);assert.ok(variants.every(variant => variant.additionalProperties === false));assert.equal(recipeSchema.properties.environment.additionalProperties, false);- assert.equal(recipeSchema.properties.environment.properties.pointLights.maxItems, 8);+ assert.equal(recipeSchema.properties.environment.properties.pointLights.maxItems, 16);assert.equal(recipeSchema.properties.effects.additionalProperties, false);assert.equal(recipeSchema.properties.shadow.additionalProperties, false);const look = tools.find(tool => tool.name === 'scene_look');@@ -200,7 +200,7 @@ test('review SDK exposes one image and rejects unknown or unbounded shot fieldsconst before = calls();for (const invalid of [{ ...input, width: 481 }, { ...input, shots: [] }, { ...input, shots: Array(5).fill({}) },- { ...input, code: 'console.log(1)' }, { ...input, shots: [{ camera: { projection: 'orthographic' } }] },+ { ...input, code: 'console.log(1)' }, { ...input, shots: [{ camera: { projection: 'fisheye' } }] },{ ...input, shots: [{ animation: { clip: 0, time: 0, url: 'https://example.com' } }] },{ ...input, shots: [{ label: 'x'.repeat(49) }] }, { ...input, shots: [{ motionTime: -1 }] },{ ...input, shots: [{ rendererTime: 3601 }] }, { ...input, expectedRevision: -1 },diff --git a/tests/support/preview-harness.mjs b/tests/support/preview-harness.mjsindex bbd9a08c..20d1228c 100644--- a/tests/support/preview-harness.mjs+++ b/tests/support/preview-harness.mjs@@ -1,9 +1,10 @@import { readFile } from 'node:fs/promises';import { Script, createContext } from 'node:vm';import { mat4 } from 'gl-matrix';-import { createAgentScene, needsMeshBooleans, loadMeshBooleans, meshBooleansLoaded, needsPhysics, loadPhysicsEngine, physicsEngineLoaded, loadAllAgentSceneModules, allAgentSceneModulesLoaded } from '../../src/agent-scene.js';+import { createAgentScene, applyCameraFields, needsMeshBooleans, loadMeshBooleans, meshBooleansLoaded, needsPhysics, loadPhysicsEngine, physicsEngineLoaded, loadAllAgentSceneModules, allAgentSceneModulesLoaded } from '../../src/agent-scene.js';import { normalizeBlend } from '../../src/mesh-blend.js';import { applyProjection } from '../../src/camera.js';+import { effectsWithFStop } from '../../src/camera-effects.js';import { resolveAgentShadow, agentEnvironmentMap } from '../../src/agent-look.js';import { agentSceneModule, agentSceneModuleLoaded } from '../../src/agent-scene-modules.js';import { createAgentAssetScene } from '../../src/agent-asset.js';@@ -79,14 +80,14 @@ export function previewHarness() {setManifoldModuleLoader: () => {},needsPhysics, loadPhysicsEngine, physicsEngineLoaded, setPhysicsModuleLoader: () => {},sceneQueryFor, summarizeWalkMap, walkOptionsFor, createQueryOnlyCache, parseGltf, hasPatternTextures, Uint8Array, atob, sessionProblem, assetCopyKey, recipeAssetNeeds, agentAssetDecodeOptions, withCatalogLimitAdvice,- applyProjection, mat4, resolveAgentShadow, agentEnvironmentMap, BRANCH_LIMITS,+ applyProjection, applyCameraFields, mat4, resolveAgentShadow, agentEnvironmentMap, BRANCH_LIMITS,// Line art needs a real renderer with render passes, so the fault-injected one gets a no-op install.agentSceneModule: name => (name === 'lineArt' ? { installLineArt: renderer => renderer } : name === 'userPass' ? { ...agentSceneModule(name), installUserPasses: renderer => renderer } : agentSceneModule(name)), agentSceneModuleLoaded, createBranchStore, printableLabel,Renderer67: FaultInjectedRenderer, skyOpenness: () => 1, fogSkyVisibility: () => null,// The fault-injected renderer has no floor part; the automatic floor is covered by agent-ground.test.js and the live smokes.agentGroundPlacement: () => null, createAgentGround: () => null, placeAgentGround: () => {}, FLOOR_COLOR: [0.22, 0.22, 0.21], groundBounceEnvironment: (parts, environment) => environment,// The optional addons only plug stages into a real renderer; the fault-injected one needs none.- installCameraEffects: renderer => renderer, installRenderPasses: renderer => renderer, installDepthPrecision: renderer => renderer,+ installCameraEffects: renderer => renderer, effectsWithFStop, installRenderPasses: renderer => renderer, installDepthPrecision: renderer => renderer,installMeshBlend: renderer => Object.assign(renderer, { meshBlend: { radii: new Map() } }), normalizeBlend,});// Evaluate only trusted repository adapter code; inject the driver boundary for failure cases.