Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Merge remote-tracking branch 'origin/main' into 979-fracture-recipe-merge

Nguyen Xuan Anf0bd1b15c883
diff --cc scripts/mcp-server.mjs
index 9bf1bfef,e2a07318..bd94ae3d
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@@ -735,10 -734,7 +735,11 @@@ const otherOperations =
z.strictObject({ type: z.literal('set-camera'), ...cameraFields }),
z.strictObject({ type: z.literal('set-motion'), motion: recipeMotionReference.nullable() }),
z.strictObject({ type: z.literal('bake-motion'), nodes: z.array(identifier).min(1).max(32), start: nonnegative.optional(), end: nonnegative.optional(), step: positive.optional(), tolerance: z.record(z.string(), z.number()).optional() }),
+ z.strictObject({
+ type: z.literal('fracture-node'), node: identifier, cells: z.number().int().min(2).max(64), strength: positive,
+ seed: detail(0, 4294967295), impact: vector3.optional(), impactRadius: positive.optional(), density: positive.optional(), friction: nonnegative.optional(),
+ }).describe('Break a convex root node into glued physics pieces. Fields: scene_capabilities physics.'),
+ z.strictObject({ type: z.literal('settle'), settle: z.record(z.string(), z.unknown()).describe('See scene_capabilities topic settle.') }),
z.strictObject({ type: z.literal('set-armatures'), armatures: armaturesReference.nullable() }),
z.strictObject({ type: z.literal('set-physics'), physics: z.record(z.string(), z.unknown()).nullable().describe('Same object as recipe.physics in scene_create.') }),
z.strictObject({ type: z.literal('set-cloth'), cloth: z.record(z.string(), z.unknown()).nullable() }),
diff --cc src/agent-apply-report.js
index a55aec2c,225b56bd..77a92b9b
--- a/src/agent-apply-report.js
+++ b/src/agent-apply-report.js
@@@ -108,9 -108,9 +108,12 @@@ function describeOperation(working, ope
else working[name] = structuredClone(next);
return { changed: operation[name] === null ? `cleared ${name}` : `set ${name}` };
}
+ if (type === 'fracture-node') {
+ return { changed: `fractured ${operation.node} into ${operation.cells} pieces with glue` };
+ }
+ if (type === 'settle') {
+ return { changed: `settled props under ${operation.settle?.id}; scene_inspect lists them` };
+ }
if (type === 'bake-motion') {
return { changed: `baked ${shortList(operation.nodes ?? [], maxText)} to keys` };
}
diff --cc src/agent-scene-capabilities.js
index 018631a0,b140925c..abd837e9
--- a/src/agent-scene-capabilities.js
+++ b/src/agent-scene-capabilities.js
@@@ -227,7 -227,7 +227,7 @@@ export const AGENT_SCENE_CAPABILITIES
operations: Object.freeze([
'set-node', 'set-material', 'set-camera', 'add-node', 'remove-node',
'add-geometry', 'remove-geometry', 'add-material', 'remove-material',
- 'set-environment', 'set-effects', 'set-shadow', 'set-motion', 'set-armatures', 'set-physics', 'set-cloth', 'set-timeline', 'set-particles', 'set-bake', 'set-post-passes', 'set-game', 'edit-mesh', 'set-mesh-stack', 'bake-motion', 'fracture-node',
- 'set-environment', 'set-effects', 'set-shadow', 'set-motion', 'set-armatures', 'set-physics', 'set-cloth', 'set-timeline', 'set-particles', 'set-bake', 'set-post-passes', 'set-game', 'edit-mesh', 'set-mesh-stack', 'bake-motion', 'settle',
++ 'set-environment', 'set-effects', 'set-shadow', 'set-motion', 'set-armatures', 'set-physics', 'set-cloth', 'set-timeline', 'set-particles', 'set-bake', 'set-post-passes', 'set-game', 'edit-mesh', 'set-mesh-stack', 'bake-motion', 'fracture-node', 'settle',
]),
materialTags: Object.freeze(['surface', 'unlit', 'liquid', 'foam', 'foliage', 'grass', 'water']),
// A flat water sheet; the largest sets the level. A bed d metres down keeps exp(-absorption * d) per channel (RGB per metre).
diff --cc src/agent-scene-modules.js
index b36b8ab3,be7528a9..802d9a6f
--- a/src/agent-scene-modules.js
+++ b/src/agent-scene-modules.js
@@@ -9,9 -9,9 +9,10 @@@ const MODULE_LOADERS =
text: () => import('./text-geometry.js'),
motion: () => import('./agent-motion.js'),
motionBake: () => import('./agent-motion-bake.js'),
+ settle: () => import('./agent-settle.js'),
drive: () => import('./agent-drive.js'),
physics: () => import('./agent-physics.js'),
+ fracture: () => import('./agent-fracture.js'),
cloth: () => import('./agent-cloth.js'),
particles: () => import('./agent-particles.js'),
bake: () => import('./agent-bake.js'),
@@@ -55,9 -55,9 +56,10 @@@ const MODULE_MARKERS =
text: ['"type":"text"'],
motion: ['"motion":{', '"bake-motion"'],
motionBake: ['"bake-motion"'],
+ settle: ['"type":"settle"'],
drive: ['"drive":{'],
- physics: ['"physics":{'],
+ physics: ['"physics":{', '"fracture-node"'],
+ fracture: ['"type":"fragment"', '"fracture-node"'],
cloth: ['"cloth":{'],
particles: ['"particles":{'],
bake: ['"bake":{'],
@@@ -103,10 -103,10 +105,10 @@@ export function needsMeshBooleans(value
return JSON.stringify(value ?? null).includes('"op":"boolean"');
}
- /** True when a recipe or an operation list carries a physics section, so the host loads the solver first. */
+ /** True when a recipe or an operation list carries a physics section or a settle operation, so the host loads the solver first. */
export function needsPhysics(value) {
const text = JSON.stringify(value ?? null);
- return text.includes('"physics":{') || text.includes('"fracture-node"');
- return text.includes('"physics":{') || text.includes('"type":"settle"');
++ return text.includes('"physics":{') || text.includes('"fracture-node"') || text.includes('"type":"settle"');
}
/** Names of the on-demand modules a recipe, or a list of edit operations, needs. */
diff --cc src/agent-scene.js
index aa53f19f,83752d9e..93b822d3
--- a/src/agent-scene.js
+++ b/src/agent-scene.js
@@@ -1958,12 -1909,10 +1958,16 @@@ export function createAgentScene(input
agentSceneModule('motionBake').bakeMotion(candidate, operation, motionBakeSource(state));
continue;
}
+ if (operation.type === 'fracture-node') {
+ const { id: fracturedId } = candidate.nodes.find(node => node.id === operation.node) ?? {};
+ agentSceneModule('fracture').fractureNode(candidate, operation, geometryId => generateOperationGeometry(candidate, geometryId, limits));
+ if (fracturedId !== undefined) removedNodes.add(fracturedId);
+ continue;
+ }
+ if (operation.type === 'settle') {
+ agentSceneModule('settle').applySettle(candidate, operation);
+ continue;
+ }
if (operation.type === 'edit-mesh') {
knownKeys(operation, ['type', 'geometry', 'edits', 'replace'], 'operation');
const target = meshGeometryTarget(candidate, operation, type => `Add a mesh geometry with base: { type: '${type}', ... } to edit it.`);