3D engine that AI agents drive
Merge origin/main into feat/texture-sequence
Nguyen Xuan Anf1e855a5ddec
diff --cc docs/agent-scene.mdindex 32447bc2,2dad3862..a3511d0a--- a/docs/agent-scene.md+++ b/docs/agent-scene.md@@@ -100,9 -100,9 +100,9 @@@ Modeling point inputs have a maximum oAn extrusion has at most 128 holes and 4096 total contour points.Shared resource IDs generate geometry once, regardless of the number of mesh nodes.-Materials contain `id`, `tag`, `color`, `metallic`, `roughness`, `emission`, optional `emissiveColor`, `opacity`, `alphaMode`, `doubleSided` and `pattern`.+Materials contain `id`, `tag`, `color`, `metallic`, `roughness`, `emission`, optional `emissiveColor`, `opacity`, `alphaMode`, `doubleSided`, `pattern` and `map`.The defaults are `surface`, `[0.5, 0.5, 0.5]`, `0`, `0.5`, `0`, opacity `1`, `opaque` and `false`.- The tag can be `surface`, `unlit`, `liquid` or `foam` and remains fixed during editing.+ The tag can be `surface`, `unlit`, `liquid`, `foam`, `foliage` or `grass` (the last two sway in `environment.wind`) and remains fixed during editing.`liquid` refracts and tints what lies behind it: its color is the light one metre lets through, so `[0.56, 0.84, 0.88]` is clear water. `foam` draws soft blended droplets.Any `opacity` below one draws the material blended after opaque geometry, which suits glass, windows and visors. `alphaMode` accepts `opaque` or `blend`; cutout masking needs a texture and is not available in procedural recipes.`doubleSided` draws and lights both faces of thin sheets.diff --cc package.jsonindex e28363e4,8ce9db30..57fe4020--- a/package.json+++ b/package.json@@@ -128,8 -128,8 +128,9 @@@"smoke:agent-look": "node scripts/smoke-agent-look.mjs","smoke:view-transform": "node scripts/smoke-view-transform.mjs","smoke:agent-assets": "node scripts/smoke-agent-assets.mjs",+ "smoke:agent-vegetation": "node scripts/smoke-agent-vegetation.mjs","smoke:agent-render-jobs": "node scripts/smoke-agent-render-jobs.mjs",+ "smoke:agent-texture-sequence": "node scripts/smoke-agent-texture-sequence.mjs","smoke:render-passes": "node scripts/smoke-render-passes.mjs","smoke:path-tracer": "node scripts/smoke-path-tracer.mjs","smoke:film-timeline": "node scripts/smoke-film-timeline.mjs",diff --cc scripts/agent-runtime.mjsindex f7339f95,4bd1bc2c..d45fa1ae--- a/scripts/agent-runtime.mjs+++ b/scripts/agent-runtime.mjs@@@ -571,7 -563,7 +572,7 @@@ export function createAgentRuntime({ kereturn Object.freeze({async capabilities() {return {- scene: { ...AGENT_SCENE_CAPABILITIES, textureSequence: TEXTURE_SEQUENCE_CAPABILITIES },- scene: { ...AGENT_SCENE_CAPABILITIES, vegetation: VEGETATION_CAPABILITY_NOTE },++ scene: { ...AGENT_SCENE_CAPABILITIES, vegetation: VEGETATION_CAPABILITY_NOTE, textureSequence: TEXTURE_SEQUENCE_CAPABILITIES },sceneLimits: SCENE_LIMITS,preview: { backend, memoryBudgetMiB: memory, maximumWidth: 1024, maximumHeight: 1024, maximumImageBytes: MAXIMUM_IMAGE_BYTES, maximumActiveScenes: 1, maximumQueuedCalls: MAXIMUM_QUEUED_CALLS, evaluationTimeoutMs: EVALUATION_TIMEOUT_MS },review: { ...REVIEW_LIMITS, backend, memoryBudgetMiB: memory, evaluationTimeoutMs: EVALUATION_TIMEOUT_MS,diff --cc scripts/measure-tool-cost.mjsindex d008a4ee,264c4656..dfad11dd--- a/scripts/measure-tool-cost.mjs+++ b/scripts/measure-tool-cost.mjs@@@ -3,8 -3,8 +3,9 @@@ import { resolve } from 'node:path'import { Client } from '@modelcontextprotocol/client';import { InMemoryTransport } from '@modelcontextprotocol/server';import { createAgentMcpServer } from './mcp-server.mjs';+ import { VEGETATION_CAPABILITY_NOTE } from '../src/agent-vegetation-notes.js';import { createAgentScene, AGENT_SCENE_CAPABILITIES } from '../src/agent-scene.js';+import { TEXTURE_SEQUENCE_CAPABILITIES } from '../src/texture-sequence-limits.js';import { loadAgentSceneModules } from '../src/agent-scene-modules.js';// JSON is dense in tokens: about 3.5 characters each for schemas and recipes (an estimate, not a tokenizer count).@@@ -69,7 -69,7 +70,7 @@@ async function typicalResults(recipe)const meshReport = scene.inspectMeshes({ geometries: ['seat'] });const { inspection, ...statusWithoutInspection } = status;return {- scene_capabilities: { ...AGENT_SCENE_CAPABILITIES, textureSequence: TEXTURE_SEQUENCE_CAPABILITIES },- scene_capabilities: { ...AGENT_SCENE_CAPABILITIES, vegetation: VEGETATION_CAPABILITY_NOTE },++ scene_capabilities: { ...AGENT_SCENE_CAPABILITIES, vegetation: VEGETATION_CAPABILITY_NOTE, textureSequence: TEXTURE_SEQUENCE_CAPABILITIES },scene_create: status,scene_inspect: { sessionId: SAMPLE_SESSION, ...scene.inspect() },mesh_inspect: { sessionId: SAMPLE_SESSION, ...meshReport },diff --cc src/agent-scene-modules.jsindex 2564ddfa,0702a502..23579441--- a/src/agent-scene-modules.js+++ b/src/agent-scene-modules.js@@@ -26,7 -26,7 +26,8 @@@ const MODULE_LOADERS =lightLinking: () => import('./light-linking.js'),cascades: () => import('./cascaded-shadows.js'),assets: () => import('./agent-scene-assets.js'),+ sequences: () => import('./agent-texture-sequence.js'),+ vegetation: () => import('./agent-vegetation.js'),lineArt: () => import('./line-art.js'),viewTransform: () => import('./view-transform-shader.js'),coplanar: () => import('./coplanar-overlap.js'),@@@ -63,7 -63,7 +64,8 @@@ const MODULE_MARKERS =lightLinking: ['"affects"', '"keyAffects"'],cascades: ['"shadowCascades"'],assets: ['"asset":{'],+ sequences: ['"sequence":{'],+ vegetation: ['"vegetation":{', '"wind":{'],lineArt: ['"lines":{', '"toon":'],viewTransform: ['"viewTransform":"agx"', '"viewTransform":"neutral"', '"look":"'],// The coplanar-overlap warning in scene_inspect appears only once this is loaded, which loadAllAgentSceneModules does; a recipe with resolveCoplanar needs it.diff --cc src/agent-scene.jsindex dac3da35,b17356c0..b7fab067--- a/src/agent-scene.js+++ b/src/agent-scene.js@@@ -23,10 -23,8 +23,10 @@@ const MAX_MESH_REPORTS = 16// Terrain meshes carry one more float for each vertex (sky visibility) than the 56 bytes the budget estimates.const TERRAIN_SKY_VISIBILITY_BYTES = 4;const CAMERA_DEFAULTS = Object.freeze({ eye: [4, 3, 5], target: [0, 0, 0], up: [0, 1, 0], fov: 45, near: 0.1, far: 1000 });- const NODE_FIELDS = ['translation', 'rotation', 'scale', 'parent', 'label', 'geometry', 'material', 'skin', 'relations', 'asset', 'decal', 'depthLayer'];+ const NODE_FIELDS = ['translation', 'rotation', 'scale', 'parent', 'label', 'geometry', 'material', 'skin', 'relations', 'asset', 'vegetation', 'decal', 'depthLayer'];const MATERIAL_FIELDS = ['color', 'metallic', 'roughness', 'emission', 'emissiveColor', 'opacity', 'alphaMode', 'doubleSided', 'pattern', 'subsurface', ...MATERIAL_LAYER_FIELDS];+// `map` is an image sequence (src/agent-texture-sequence.js). It is a recipe field, and the handle builds its descriptor.+const RECIPE_MATERIAL_FIELDS = [...MATERIAL_FIELDS, 'map'];const PATTERN_TEXTURE_FIELDS = ['map', 'normalMap', 'metallicRoughnessMap', 'emissiveMap', 'boxMapScale', 'boxMapAxis'];const CAMERA_FIELDS = Object.keys(CAMERA_DEFAULTS);const LOOK_OPERATION_FIELDS = Object.freeze({@@@ -1621,8 -1608,8 +1626,9 @@@ export function createAgentScene(inputphysics: state.physicsSampler ? state.physicsSampler.report() : null,...(state.clothSampler ? { cloth: state.clothSampler.report() } : {}),...(state.particleSampler ? { particles: state.particleSampler.report() } : {}),+ ...(state.assetRuntime.vegetation ? { vegetation: state.assetRuntime.vegetation } : {}),...(state.assetRuntime.placements.length ? { assets: agentSceneModule('assets').describeAssetPlacements(state.assetRuntime, state.graph, geometry => state.localBounds.get(geometry)) } : {}),+ ...(hasSequences(state) ? { textureSequences: [...state.materialHandles.values()].filter(handle => handle.holder.sequence).map(handle => handle.holder.sequence.describe()) } : {}),...(state.bakeReport ? { bake: state.bakeReport } : {}),...(state.reflectionReport ? { reflections: state.reflectionReport } : {}),...(state.recipe.armatures ? { rig: rigReport(state.recipe, state.skinBindings) } : {}),