3D engine that AI agents drive
Merge remote-tracking branch 'origin/main' into lead-911
Nguyen Xuan And624c5f880f0
diff --cc docs/game.mdindex 5ea9203b,0ee88b2a..9f307f1e--- a/docs/game.md+++ b/docs/game.md@@@ -37,13 -37,12 +37,14 @@@ A scene recipe can carry a `game` secti| Field | Default | Meaning || --- | --- | --- || `player.node` | required | A node of the scene. The rules part with the same id follows the player |- | `player.controller` | `character` | The [character controller](player.md) |+ | `player.controller` | `character` | `character` ([character controller](player.md)) or `vehicle` ([arcade car](player.md#vehicle-and-flight-controllers): W throttle, S reverse, A/D steer, Space brakes; `walkSpeed`, `runSpeed` and `jumpSpeed` are ignored) || `player.walkSpeed`, `runSpeed`, `jumpSpeed` | 3, 6, 7 | Metres per second, 0 to 100 |+ | `player.maximumSpeed` | 20 | Top speed of a `vehicle`, metres per second, 0 to 100 || `player.footOffset` | 0 | Metres from the node origin down to the feet. Zone checks use the feet |- | `camera` | `follow` | `follow`, `first-person` or `top-down`, the [camera rigs](player.md#camera-rigs) |+ | `camera` | `follow` | `follow`, `first-person`, `top-down` or `chase` (behind the player, swinging round to its heading: use it with a `vehicle`), the [camera rigs](player.md#camera-rigs) || `input` | `keyboard` | `keyboard` (WASD move, arrows look, Space jump, Shift run), `gamepad` (adds the first pad) or `touch` (adds a left-half stick and tap to jump) |+| `player.animation` | none | An [animation graph](animation-graph.md) for the player, see [Animation and NPCs](#animation-and-npcs) |+| `npcs` | none | Up to 16 characters that walk a path through their own graph, see [Animation and NPCs](#animation-and-npcs) || `physics` | `false` | Accepted. The web export refuses `true` until the physics engine can be bundled || `ground` | 0 | Height of the walkable ground in metres || `rules` | none | A [game rules](game-rules.md) document, checked when it is set |@@@ -54,7 -53,7 +55,7 @@@ A rules part named like a scene node i`scene_export_web` writes one folder: `index.html`, `game.json` (the recipe) and `engine/` (the built 67js modules, found by following the imports from `build/game.js`). It runs from any static host with no server code, and the folder is bounded: the engine stays under 12 MiB, the recipe under 1 MiB, and the newest four builds are kept. Procedural scenes only; placed catalog assets and vegetation are refused with the fix. The page shows the variables and the verdict in a corner label and exposes the running game as `window.__game` (`rules.state`, `controller.state`, `scene`, `runtime`).- `index.html?replay=name.json` plays a recording (`recordInput`, see [input](input.md#custom-and-scripted-input)) from the same folder instead of the keyboard. `scripts/smoke-game-web.mjs` builds a creature that collects 3 coins and reaches a goal through the MCP tools, exports it, and wins it from a replay in headless Chrome, with a head-bob animation graph that the page must play.-`index.html?replay=name.json` plays a recording (`recordInput`, see [input](input.md#custom-and-scripted-input)) from the same folder instead of the keyboard. `scripts/smoke-game-web.mjs` builds a creature that collects 3 coins and reaches a goal through the MCP tools, exports it, and wins it from a replay in headless Chrome. `node scripts/smoke-game-web.mjs bin/67js-mcp.mjs drive` does the same for a car that passes 3 gates and reaches a finish line under a `chase` camera.++`index.html?replay=name.json` plays a recording (`recordInput`, see [input](input.md#custom-and-scripted-input)) from the same folder instead of the keyboard. `scripts/smoke-game-web.mjs` builds a creature that collects 3 coins and reaches a goal through the MCP tools, exports it, and wins it from a replay in headless Chrome, with a head-bob animation graph that the page must play. `node scripts/smoke-game-web.mjs bin/67js-mcp.mjs drive` does the same for a car that passes 3 gates and reaches a finish line under a `chase` camera.## From codediff --cc scripts/smoke-game-web.mjsindex a208ca54,ade53abe..6c043e20--- a/scripts/smoke-game-web.mjs+++ b/scripts/smoke-game-web.mjs@@@ -34,59 -35,87 +35,101 @@@ async function callExpectingError(namereturn result.content.find(item => item.type === 'text').text;}- const COINS = [[0, 0.5, -3], [0, 0.5, -6], [0, 0.5, -9]];- const GOAL = [0, 1, -12];- const recipe = {- format: '67js.scene', schemaVersion: 1,- geometries: [{ id: 'block', type: 'box', bevel: 0 }, { id: 'ball', type: 'sphere' }],- materials: [- { id: 'grass', color: [0.2, 0.45, 0.2] }, { id: 'fur', color: [0.85, 0.45, 0.2] },- { id: 'gold', color: [0.95, 0.75, 0.1], metallic: 0.8, roughness: 0.3 }, { id: 'flag', color: [0.2, 0.4, 0.9] },- ],- nodes: [- { id: 'floor', geometry: 'block', material: 'grass', translation: [0, -0.1, -6], scale: [12, 0.2, 24] },- { id: 'creature', translation: [0, 0.5, 0] },- { id: 'body', parent: 'creature', geometry: 'block', material: 'fur', scale: [0.8, 0.8, 1.2] },- { id: 'head', parent: 'creature', geometry: 'ball', material: 'fur', translation: [0, 0.35, -0.6], scale: [0.5, 0.5, 0.5] },- ...COINS.map((translation, index) => ({ id: `coin-${index + 1}`, geometry: 'ball', material: 'gold', translation, scale: [0.4, 0.4, 0.4] })),- { id: 'goal', geometry: 'block', material: 'flag', translation: GOAL, scale: [1.5, 2, 0.2] },- ],- camera: { eye: [4, 4, 6], target: [0, 0.5, -3], fov: 50 },- };- const coinRules = COINS.map((center, index) => ({- id: `collect-${index + 1}`, once: true,- when: { type: 'enter', zone: `coin-zone-${index + 1}`, tag: 'player' },- do: [{ type: 'add', variable: 'score', value: 1 }, { type: 'hide', part: `coin-${index + 1}` }],- }));- // The head bobs while the creature moves: the exported page must play this graph, not only carry it.- const HEAD_REST = [0, 0.35, -0.6];- const HEAD_BOB_HEIGHT = 0.2;- const animation = {- clips: {- idle: { duration: 1, loop: true, tracks: [{ target: 'head', property: 'translation', keyframes: [{ time: 0, value: HEAD_REST }, { time: 1, value: HEAD_REST }] }] },- bob: {- duration: 0.5, loop: true,- tracks: [{ target: 'head', property: 'translation', keyframes: [{ time: 0, value: HEAD_REST }, { time: 0.25, value: [0, HEAD_REST[1] + HEAD_BOB_HEIGHT, HEAD_REST[2]] }, { time: 0.5, value: HEAD_REST }] }],+ function creatureSample() {+ const COINS = [[0, 0.5, -3], [0, 0.5, -6], [0, 0.5, -9]];+ const GOAL = [0, 1, -12];+ const recipe = {+ format: '67js.scene', schemaVersion: 1,+ geometries: [{ id: 'block', type: 'box', bevel: 0 }, { id: 'ball', type: 'sphere' }],+ materials: [+ { id: 'grass', color: [0.2, 0.45, 0.2] }, { id: 'fur', color: [0.85, 0.45, 0.2] },+ { id: 'gold', color: [0.95, 0.75, 0.1], metallic: 0.8, roughness: 0.3 }, { id: 'flag', color: [0.2, 0.4, 0.9] },+ ],+ nodes: [+ { id: 'floor', geometry: 'block', material: 'grass', translation: [0, -0.1, -6], scale: [12, 0.2, 24] },+ { id: 'creature', translation: [0, 0.5, 0] },+ { id: 'body', parent: 'creature', geometry: 'block', material: 'fur', scale: [0.8, 0.8, 1.2] },+ { id: 'head', parent: 'creature', geometry: 'ball', material: 'fur', translation: [0, 0.35, -0.6], scale: [0.5, 0.5, 0.5] },+ ...COINS.map((translation, index) => ({ id: `coin-${index + 1}`, geometry: 'ball', material: 'gold', translation, scale: [0.4, 0.4, 0.4] })),+ { id: 'goal', geometry: 'block', material: 'flag', translation: GOAL, scale: [1.5, 2, 0.2] },+ ],+ camera: { eye: [4, 4, 6], target: [0, 0.5, -3], fov: 50 },+ };+ const coinRules = COINS.map((center, index) => ({+ id: `collect-${index + 1}`, once: true,+ when: { type: 'enter', zone: `coin-zone-${index + 1}`, tag: 'player' },+ do: [{ type: 'add', variable: 'score', value: 1 }, { type: 'hide', part: `coin-${index + 1}` }],+ }));++ // The head bobs while the creature moves: the exported page must play this graph, not only carry it.++ const HEAD_REST = [0, 0.35, -0.6];++ const HEAD_BOB_HEIGHT = 0.2;++ const animation = {++ clips: {++ idle: { duration: 1, loop: true, tracks: [{ target: 'head', property: 'translation', keyframes: [{ time: 0, value: HEAD_REST }, { time: 1, value: HEAD_REST }] }] },++ bob: {++ duration: 0.5, loop: true,++ tracks: [{ target: 'head', property: 'translation', keyframes: [{ time: 0, value: HEAD_REST }, { time: 0.25, value: [0, HEAD_REST[1] + HEAD_BOB_HEIGHT, HEAD_REST[2]] }, { time: 0.5, value: HEAD_REST }] }],++ },+ },- },- parameters: { speed: { type: 'number' } },- layers: [{ name: 'base', states: [{ name: 'move', blend: { parameter: 'speed', motions: [{ clip: 'idle', threshold: 0 }, { clip: 'bob', threshold: 1 }] } }] }],- };- const game = {- player: { node: 'creature', footOffset: 0.5, animation },- camera: 'follow',- input: 'keyboard',- rules: {- version: 1,- variables: { score: 0 },- zones: [...COINS.map((center, index) => ({ id: `coin-zone-${index + 1}`, shape: 'sphere', center: [center[0], 0.5, center[2]], radius: 1.2 })),- { id: 'goal-zone', shape: 'box', center: [0, 1, GOAL[2]], size: [3, 4, 2] }],- parts: [{ id: 'creature', tags: ['player'] }, ...COINS.map((center, index) => ({ id: `coin-${index + 1}`, tags: ['coin'] }))],- rules: [...coinRules, { id: 'reach-goal', when: { type: 'enter', zone: 'goal-zone', tag: 'player' }, if: ['>=', 'score', 3], do: [{ type: 'win' }] }],- },- };- // Hold forward and run from sample 1, press jump at sample 40, and let go at sample 240.- const replay = { version: 1, samples: 260, truncated: false, events: [[1, 'keyboard/KeyW', 1], [1, 'keyboard/ShiftLeft', 1], [40, 'keyboard/Space', 1], [42, 'keyboard/Space', 0], [240, 'keyboard/KeyW', 0], [240, 'keyboard/ShiftLeft', 0]] };++ parameters: { speed: { type: 'number' } },++ layers: [{ name: 'base', states: [{ name: 'move', blend: { parameter: 'speed', motions: [{ clip: 'idle', threshold: 0 }, { clip: 'bob', threshold: 1 }] } }] }],++ };+ const game = {- player: { node: 'creature', footOffset: 0.5 },++ player: { node: 'creature', footOffset: 0.5, animation },+ camera: 'follow',+ input: 'keyboard',+ rules: {+ version: 1,+ variables: { score: 0 },+ zones: [...COINS.map((center, index) => ({ id: `coin-zone-${index + 1}`, shape: 'sphere', center: [center[0], 0.5, center[2]], radius: 1.2 })),+ { id: 'goal-zone', shape: 'box', center: [0, 1, GOAL[2]], size: [3, 4, 2] }],+ parts: [{ id: 'creature', tags: ['player'] }, ...COINS.map((center, index) => ({ id: `coin-${index + 1}`, tags: ['coin'] }))],+ rules: [...coinRules, { id: 'reach-goal', when: { type: 'enter', zone: 'goal-zone', tag: 'player' }, if: ['>=', 'score', 3], do: [{ type: 'win' }] }],+ },+ };+ // Hold forward and run from sample 1, press jump at sample 40, and let go at sample 240.+ const replay = { version: 1, samples: 260, truncated: false, events: [[1, 'keyboard/KeyW', 1], [1, 'keyboard/ShiftLeft', 1], [40, 'keyboard/Space', 1], [42, 'keyboard/Space', 0], [240, 'keyboard/KeyW', 0], [240, 'keyboard/ShiftLeft', 0]] };- return { recipe, game, replay, title: 'Creature run', expectedScore: 3 };++ return { recipe, game, replay, title: 'Creature run', expectedScore: 3, headRestHeight: HEAD_REST[1] };+ }++ function driveSample() {+ const checkpointZs = [-10, -20, -30];+ const finishZ = -40;+ const recipe = {+ format: '67js.scene', schemaVersion: 1,+ geometries: [{ id: 'block', type: 'box', bevel: 0 }],+ materials: [{ id: 'asphalt', color: [0.2, 0.2, 0.22] }, { id: 'paint', color: [0.8, 0.15, 0.1] }, { id: 'gate', color: [0.95, 0.75, 0.1] }],+ nodes: [+ { id: 'road', geometry: 'block', material: 'asphalt', translation: [0, -0.1, -22], scale: [8, 0.2, 52] },+ { id: 'car', translation: [0, 0.4, 0] },+ { id: 'car-body', parent: 'car', geometry: 'block', material: 'paint', scale: [1.2, 0.5, 2.4] },+ ...checkpointZs.map((z, index) => ({ id: `gate-${index + 1}`, geometry: 'block', material: 'gate', translation: [0, 0.6, z], scale: [5, 1.2, 0.2] })),+ ],+ camera: { eye: [5, 5, 8], target: [0, 0.5, -6], fov: 50 },+ };+ const game = {+ player: { node: 'car', controller: 'vehicle', maximumSpeed: 20, footOffset: 0.4 },+ camera: 'chase',+ input: 'keyboard',+ rules: {+ version: 1,+ variables: { score: 0 },+ zones: [...checkpointZs.map((z, index) => ({ id: `gate-zone-${index + 1}`, shape: 'box', center: [0, 1, z], size: [6, 3, 3] })),+ { id: 'finish-zone', shape: 'box', center: [0, 1, finishZ], size: [8, 3, 3] }],+ parts: [{ id: 'car', tags: ['player'] }, ...checkpointZs.map((z, index) => ({ id: `gate-${index + 1}`, tags: ['gate'] }))],+ rules: [...checkpointZs.map((z, index) => ({ id: `pass-${index + 1}`, once: true, when: { type: 'enter', zone: `gate-zone-${index + 1}`, tag: 'player' }, do: [{ type: 'add', variable: 'score', value: 1 }, { type: 'hide', part: `gate-${index + 1}` }] })),+ { id: 'finish', when: { type: 'enter', zone: 'finish-zone', tag: 'player' }, if: ['>=', 'score', 3], do: [{ type: 'win' }] }],+ },+ };+ // Hold the throttle for the whole run; the car takes about 3 s to cover 40 m.+ const replay = { version: 1, samples: 400, truncated: false, events: [[1, 'keyboard/KeyW', 1], [380, 'keyboard/KeyW', 0]] };+ return { recipe, game, replay, title: 'Drive', expectedScore: 3 };+ }++ const SAMPLES = { creature: creatureSample, drive: driveSample };+ const sampleName = process.argv[3] ?? 'creature';+ assert.ok(SAMPLES[sampleName], `Unknown sample "${sampleName}". Use one of: ${Object.keys(SAMPLES).join(', ')}.`);-const { recipe, game, replay, title, expectedScore } = SAMPLES[sampleName]();++const { recipe, game, replay, title, expectedScore, headRestHeight } = SAMPLES[sampleName]();function serveFolder(folder) {const server = createServer(async (request, response) => {@@@ -131,21 -160,14 +174,25 @@@ trypage.on('pageerror', error => problems.push(error.message));page.on('console', message => { if (message.type() === 'error') problems.push(message.text()); });await page.goto(`http://127.0.0.1:${server.address().port}/?replay=replay.json`);- // While the replay runs, the speed parameter rises and the bob clip lifts the head off its rest height.- await page.waitForFunction(restHeight => {- const head = window.__game?.scene.exportRecipe().nodes.find(node => node.id === 'head');- return head && Math.abs(head.translation[1] - restHeight) > 0.02;- }, HEAD_REST[1], { timeout: 60000, polling: 'raf' });++ if (headRestHeight !== undefined) {++ // While the replay runs, the speed parameter rises and the bob clip lifts the head off its rest height.++ await page.waitForFunction(restHeight => {++ const head = window.__game?.scene.exportRecipe().nodes.find(node => node.id === 'head');++ return head && Math.abs(head.translation[1] - restHeight) > 0.02;++ }, headRestHeight, { timeout: 60000, polling: 'raf' });++ }await page.waitForFunction(() => window.__game?.rules?.state.status === 'won', null, { timeout: 60000 }).catch(async error => {const snapshot = await page.evaluate(() => ({ rules: window.__game?.rules?.state, player: window.__game?.controller?.state?.position })).catch(() => null);throw new Error(`${error.message}\npage problems: ${problems.join(' | ')}\nstate: ${JSON.stringify(snapshot)}`);});const state = await page.evaluate(() => ({ ...window.__game.rules.state, y: window.__game.controller.state.position[1] }));assert.equal(state.status, 'won');- assert.equal(state.variables.score, 3);+ assert.equal(state.variables.score, expectedScore);assert.deepEqual(problems, []);- const speed = await page.evaluate(() => window.__game.animation.get('speed'));- assert.ok(speed >= 0, 'the exported page has a live animation graph with a speed parameter');++ if (game.player.animation) {++ const speed = await page.evaluate(() => window.__game.animation.get('speed'));++ assert.ok(speed >= 0, 'the exported page has a live animation graph with a speed parameter');++ }await page.screenshot({ path: join(directory, 'won.png') });console.log(JSON.stringify({ ok: true, bytes: exported.bytes, files: exported.files, step: state.step, screenshot: join(directory, 'won.png') }));} catch (error) {diff --cc src/game-setup-notes.jsindex f0b2c7c9,0402d0e4..956faf92--- a/src/game-setup-notes.js+++ b/src/game-setup-notes.js@@@ -1,31 -1,11 +1,31 @@@// What scene_capabilities topic game says. It sits beside game-setup.js, not in the agent scene capabilities, so the core agent-scene bundle does not carry it; the MCP runtime adds it to the scene capabilities. A test keeps the names in step with game-setup.js.export const GAME_CAPABILITIES = Object.freeze({field: 'recipe.game, set with set-game (null clears). Plain data, never code.',- fields: 'player {node (a node id; its children move with it), controller character, walkSpeed 3, runSpeed 6, jumpSpeed 7 (0-100 m/s), footOffset 0 (m from the node origin down to the feet)}, camera, input, physics (bool, false), ground (height in m, 0), rules (game rules document).',- cameras: Object.freeze(['follow', 'first-person', 'top-down']),+ fields: 'player {node (a node id; its children move with it), controller character|vehicle (an arcade car: W throttle, S reverse, A/D steer, Space brakes), walkSpeed 3, runSpeed 6, jumpSpeed 7 (0-100 m/s), maximumSpeed 20 (vehicle top speed, 0-100 m/s), footOffset 0 (m from the node origin down to the feet)}, camera, input, physics (bool, false), ground (height in m, 0), rules (game rules document).',+ cameras: Object.freeze(['follow', 'first-person', 'top-down', 'chase']),inputPresets: Object.freeze({ keyboard: 'WASD and arrows move and look, Space jumps, Shift runs', gamepad: 'keyboard plus the first gamepad (stick 0, jump on button 0)', touch: 'keyboard plus a left-half virtual stick and tap to jump' }),rules: 'version 1, variables, zones {id, shape sphere|box, center, radius|size}, parts {id, tags, position}, prefabs, rules [{id, once, when, if, do}]. The rules part named like the player node follows the player; a part named like a node is hidden or shown with it. Triggers enter|exit|contact|input|timer|variable (input actions: jump, run); actions set|add|show|hide|spawn|animation|sound|win|lose|restart. Full list: docs/game-rules.md.',+ animation: 'player.animation, or npcs[].animation: { clips, parameters, boneGroups, layers, rootMotion, drive }. clips {name: {duration s, loop true, tracks [{target (a CHILD node id of the character, never the character), property translation|rotation, keyframes [{time, value}]}]}}, 1 to 16 clips. parameters, boneGroups, layers (states with clip or 1D/2D blend, transitions, masks) and rootMotion {bone, facing, scale} are the animation graph definition of docs/animation-graph.md, with clip names from clips. drive maps a graph parameter to a controller value (speed|intentSpeed|airborne); default is speed from intentSpeed with rootMotion, else speed. With rootMotion the clips move the player.',+ npcs: 'npcs [{node, path [[x, z] ...] up to 256 points, cruiseSpeed 2.2 m/s, footOffset 0, yaw 0, animation}], up to 16. Each NPC node is separate from the player and from other NPCs. Its animation needs rootMotion and a number parameter "speed": the path follower sets speed to blend idle, walk and run, moves by the root motion, turns at corners and stops at the last point.',- notes: 'Yaw 0 faces -Z; W moves forward. Zone checks use the feet position. physics true is accepted but the web export refuses it for now. scene_export_web writes the playable folder.',+ notes: 'Use camera chase with a vehicle. Yaw 0 faces -Z; W moves forward. Zone checks use the feet position. physics true is accepted but the web export refuses it for now. scene_export_web writes the playable folder.',+ animationExample: Object.freeze({+ type: 'set-game',+ game: Object.freeze({+ player: Object.freeze({+ node: 'walker',+ walkSpeed: 1.4,+ animation: Object.freeze({+ clips: Object.freeze({+ idle: Object.freeze({ duration: 1, tracks: Object.freeze([Object.freeze({ target: 'body', property: 'translation', keyframes: Object.freeze([Object.freeze({ time: 0, value: Object.freeze([0, 0, 0]) }), Object.freeze({ time: 1, value: Object.freeze([0, 0, 0]) })]) })]) }),+ walk: Object.freeze({ duration: 1, tracks: Object.freeze([Object.freeze({ target: 'body', property: 'translation', keyframes: Object.freeze([Object.freeze({ time: 0, value: Object.freeze([0, 0, 0]) }), Object.freeze({ time: 1, value: Object.freeze([0, 0, 1.4]) })]) })]) }),+ }),+ parameters: Object.freeze({ speed: Object.freeze({ type: 'number' }) }),+ rootMotion: Object.freeze({ bone: 'body' }),+ layers: Object.freeze([Object.freeze({ name: 'base', states: Object.freeze([Object.freeze({ name: 'move', blend: Object.freeze({ parameter: 'speed', motions: Object.freeze([Object.freeze({ clip: 'idle', threshold: 0 }), Object.freeze({ clip: 'walk', threshold: 1.4 })]) }) })]) })]),+ }),+ }),+ }),+ }),example: Object.freeze({type: 'set-game',game: Object.freeze({diff --cc src/game-setup.jsindex fe1c3a38,a89413e7..c88ec58b--- a/src/game-setup.js+++ b/src/game-setup.js@@@ -11,15 -10,13 +11,16 @@@ export const GAME_CONTROLLERS = Object.export const GAME_SETUP_LIMITS = Object.freeze({maxSpeed: 100,maxJumpSpeed: 100,+ maxVehicleSpeed: 100,maxFootOffset: 100,maxGround: 10000,+ maxNpcs: 16,+ maxPathPoints: 256,});-const SETUP_FIELDS = ['player', 'camera', 'input', 'physics', 'ground', 'rules'];-const PLAYER_FIELDS = ['node', 'controller', 'walkSpeed', 'runSpeed', 'jumpSpeed', 'maximumSpeed', 'footOffset'];+const SETUP_FIELDS = ['player', 'camera', 'input', 'physics', 'ground', 'rules', 'npcs'];- const PLAYER_FIELDS = ['node', 'controller', 'walkSpeed', 'runSpeed', 'jumpSpeed', 'footOffset', 'animation'];++const PLAYER_FIELDS = ['node', 'controller', 'walkSpeed', 'runSpeed', 'jumpSpeed', 'maximumSpeed', 'footOffset', 'animation'];+const NPC_FIELDS = ['node', 'path', 'cruiseSpeed', 'footOffset', 'yaw', 'animation'];function fail(path, problem) {throw new RangeError(`Game setup ${path} ${problem}`);@@@ -62,9 -59,9 +63,10 @@@ function normalizePlayer(player, nodeIdwalkSpeed: boundedNumber(player.walkSpeed, 3, 0, GAME_SETUP_LIMITS.maxSpeed, 'player.walkSpeed'),runSpeed: boundedNumber(player.runSpeed, 6, 0, GAME_SETUP_LIMITS.maxSpeed, 'player.runSpeed'),jumpSpeed: boundedNumber(player.jumpSpeed, 7, 0, GAME_SETUP_LIMITS.maxJumpSpeed, 'player.jumpSpeed'),+ maximumSpeed: boundedNumber(player.maximumSpeed, 20, 0, GAME_SETUP_LIMITS.maxVehicleSpeed, 'player.maximumSpeed'),footOffset: boundedNumber(player.footOffset, 0, -GAME_SETUP_LIMITS.maxFootOffset, GAME_SETUP_LIMITS.maxFootOffset, 'player.footOffset'),};+ if (player.animation !== undefined) normalized.animation = normalizeGameAnimation(player.animation, nodes, player.node, { path: 'player.animation' });return normalized;}diff --cc src/game.jsindex 4c605a2c,d870480d..8e8b26c1--- a/src/game.js+++ b/src/game.js@@@ -153,22 -134,20 +154,25 @@@ async function buildGame(canvas, recipeconst start = nodeTranslation(recipe.nodes, game.player.node);const body = { position: [0, 0, 0], rotationY: 0 };let rig = null;+ // The animation graph runtime loads only for a recipe that declares an animation or an NPC, so other games do not carry it.+ const hasAnimation = Boolean(game.player.animation) || (game.npcs?.length ?? 0) > 0;+ const { createGameAnimation, createPathFollower } = hasAnimation ? await loadAnimationRuntime() : {};+ const playerAnimation = game.player.animation ? createGameAnimation(game.player.animation, recipe.nodes, game.player.node) : null;- const controller = createCharacterController({- input,- position: [start[0], start[1] - footOffset, start[2]],- ground: game.ground,- walkSpeed: game.player.walkSpeed,- runSpeed: game.player.runSpeed,- jumpSpeed: game.player.jumpSpeed,- faceCamera: game.camera === 'first-person',- cameraYaw: () => rig?.yaw ?? 0,- node: body,- ...(playerAnimation?.hasRootMotion ? { rootMotion: () => playerAnimation.graph.rootMotion.delta } : {}),- });+ const startPosition = [start[0], start[1] - footOffset, start[2]];+ const controller = game.player.controller === 'vehicle'+ ? createVehicleController({ input, position: startPosition, ground: game.ground, maximumSpeed: game.player.maximumSpeed, node: body })+ : createCharacterController({+ input,+ position: startPosition,+ ground: game.ground,+ walkSpeed: game.player.walkSpeed,+ runSpeed: game.player.runSpeed,+ jumpSpeed: game.player.jumpSpeed,+ faceCamera: game.camera === 'first-person',+ cameraYaw: () => rig?.yaw ?? 0,+ node: body,++ ...(playerAnimation?.hasRootMotion ? { rootMotion: () => playerAnimation.graph.rootMotion.delta } : {}),+ });rig = cameraRigFor(game.camera, controller, input);const nodeIds = new Set(recipe.nodes.map(node => node.id));