3D engine that AI agents drive
Merge origin/main into feat/vegetation-mcp
Nguyen Xuan An5d37d9727591
diff --cc scripts/mcp-server.mjsindex 7373b180,cf0ced70..509d3c6f--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@@ -28,8 -28,7 +28,8 @@@ const skinSpec = z.strictObject(maxDistance: positive.optional().describe('Metres from the nearest bone beyond which a vertex counts as unweighted in scene_inspect rig. Defaults to a quarter of the rig size.'),}).describe('Bind this mesh node to an armature with automatic weights: each vertex follows its nearest bones, by distance to the bone segments. Needs the armature at rest where the mesh is.');const relationList = z.array(z.record(z.string(), z.unknown())).max(8).describe('Relations against other mesh nodes; fields in scene_capabilities relations. [] removes them.').meta({ id: 'Relations' });- const placedAsset = z.record(z.string(), z.unknown()).describe('Catalog GLB placed at this group node: {id,materials,clip}; see scene_capabilities placedAssets.').meta({ id: 'PlacedAsset' });+ const placedAsset = z.record(z.string(), z.unknown()).describe('Catalog GLB placed at this group node: {id,materials,clip,drive}; see scene_capabilities placedAssets.').meta({ id: 'PlacedAsset' });+const placedVegetation = z.record(z.string(), z.unknown()).describe('Trees at this group node: {species} for one, or {mix, scatter:{ground,...}} over a terrain node; see scene_capabilities vegetation.').meta({ id: 'PlacedVegetation' });const nodeFields = {relations: relationList.optional(),asset: placedAsset.optional(),diff --cc src/agent-scene-capabilities.jsindex 2cc3e92a,7409067c..35b4b304--- a/src/agent-scene-capabilities.js+++ b/src/agent-scene-capabilities.js@@@ -155,8 -155,7 +155,8 @@@ export const AGENT_SCENE_CAPABILITIESformat: '67js.scene', schemaVersion: 1,geometryTypes: Object.freeze(['box', 'cylinder', 'sphere', 'torus', 'lathe', 'extrude', 'tube', 'curve', 'text', 'grid', 'terrain', 'mesh']),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?} 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. scene_inspect assets lists id, bounds, clips and material names. At most 512 placements, 16 assets, 16 playing a clip. Render jobs do not draw placed assets yet; scene_look does.',+ 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.',+ vegetation: "Node field vegetation turns a group node into trees (src/vegetation.js). One tree: {species: broadleaf|birch|conifer|palm|bush, seed=1, height?, leaves: cards|mesh}, grown at the node transform. A scatter: {mix:{species:weight, also grass and flowers}, seed, leaves, scatter:{ground: terrain node ID, density=0.012 per m2, slopeLimit=32 degrees, area?:{min:[x,z],max:[x,z]}, exclude?:[{center:[x,z],radius}|{min,max}|{node,radius}], variants=3 (1-4), scale?:[min,max]}}; terrain holes stay clear. Instances sit in the ground node frame, so give the group the ground transform. Levels (0 full to 3 far) come from the recipe camera eye at each edit, never from a frame, plus optional cullDistance m and distanceScale, so a seek cannot change them. season 0 summer, 0.35 gold, 0.6 orange, 0.85 brown, 0.9 and up bare for broadleaf, birch and bush (conifer and palm stay green). scatterVegetation from 67js/addons/vegetation gives the same instances for the same options. At most 1000 instances. scene_inspect vegetation lists instances per species and level, culled and triangles. Tags foliage and grass sway with environment.wind {strength 0-4 (0.3), direction degrees, 0 toward +x and 90 toward +z}; a recipe material may use them, and asset materials:[{name, tag:\"foliage\"}] makes the leaves of an imported tree sway and cast moving shadows.",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.',meshEdits: Object.freeze({ operations: Object.freeze(Object.keys(MESH_EDIT_OPERATIONS)), maxEdits: MAX_MESH_EDITS }),meshStack: Object.freeze({ operations: STACK_OPERATIONS, maxNodes: MAX_STACK_NODES }),diff --cc src/agent-scene.jsindex 140d51d5,e4382ed1..3ab2af2f--- a/src/agent-scene.js+++ b/src/agent-scene.js@@@ -1031,14 -1015,9 +1031,14 @@@ export function createAgentScene(inputfunction stage(inputRecipe, preferred = null, removedNodes = new Set(), removedMaterials = new Set()) {const recipe = normalizeRecipe(inputRecipe, limits);- const assetRuntime = recipe.nodes.some(node => node.asset)+ const placedRuntime = recipe.nodes.some(node => node.asset)- ? agentSceneModule('assets').expandAssetPlacements(recipe, options.assets, limits, assetOutputCache)+ ? agentSceneModule('assets').expandAssetPlacements(recipe, options.assets, limits, assetOutputCache, recipe.nodes.some(node => node.asset?.drive) ? agentSceneModule('drive').createAssetDrive : null): NO_ASSETS;+ // Grown vegetation travels the placed-asset channel: generated geometries, materials and part nodes.+ const vegetationRuntime = recipe.nodes.some(node => node.vegetation)+ ? agentSceneModule('vegetation').expandVegetation(recipe, limits, vegetationCache ??= agentSceneModule('vegetation').createVegetationCache())+ : null;+ const assetRuntime = vegetationRuntime ? mergedRuntime(placedRuntime, vegetationRuntime) : placedRuntime;if (state) {retainedMatrices(state.parts);}