Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Add scene_export_glb MCP tool and morph weight clips in exportGlb

Nguyen Xuan An37a8355214dc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d2373d0..62b0218d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## Unreleased
+- Add the `scene_export_glb` MCP tool (22 tools now) and morph weight clips in `exportGlb`. The tool writes the active recipe or imported asset scene as a GLB under `<jobs>/exports/` with a server-chosen name and returns the path, byte count and SHA-256; it takes no path, keeps the newest eight files and refuses more than 32 MiB. It exports the current pose (pattern textures, imported textures, skins, morph weights, IK as posed), `motionTime` seeks authored motion first, and `clip` adds an imported asset's source clip. Clip tracks with `property: 'weights'` write a SCALAR sampler of one weight per target. Checked in Blender 5.2: a patterned recipe opens with 2 meshes and 3 images, the robot with IK opens as 1 armature, 43 bones and 20 meshes, and its Walking clip as one action of 23 frames. Nothing in `src/index.js` changes, so no size budget moves
- Add ten cutting and repair edits: `fill_holes`, `dissolve_faces`, `dissolve_edges`, `dissolve_verts`, `dissolve_limited`, `bisect_plane` (with `fill`, `clearInner`, `clearOuter`), `bridge_edge_loops` (with `segments`), `subdivide_edges`, `grid_fill` and `knife_project`. Each tags what it makes, and the edge rule `{ "open": true }` picks boundary edges. The lint message for an open boundary now suggests `fill_holes`. 18 new cases match Blender in counts, face sizes, area, volume and positions; the knife is compared only with a straight plane cut and differs where a face runs along the projection direction
- Export textures, skeletons and clips to GLB: `exportGlb(parts, { nodes, clips, maxTextureSize })` now writes `map`, `normalMap`, `metallicRoughnessMap`, `occlusionMap` and `emissiveMap` as embedded PNG (limit 2048 px by default, with an error that names the option), skins with joint nodes and inverse bind matrices, and animation clips (translation, rotation and scale tracks; SMOOTH becomes cubic with zero tangents). Pattern materials export their baked textures with box projected UVs, so the picture matches without `uv_unwrap`. It previously threw on skins and on every texture channel. The `entry:core` size budget goes from 67,100 to 70,500 bytes gzip (+3,400)
- Make the first frame and the SwiftShader frame cost less, with the same pixels. The main fragment shader now compiles only the features that a scene uses (maps, splat layers, moss, alpha and the special material tags), and a part that needs another feature later recompiles it. All programs, with the environment prefilter, now start together and use `KHR_parallel_shader_compile`. On an RTX 3060 the first frame went from 3.7 to 4.4 seconds down to 0.5 to 1.0 seconds, and a SwiftShader frame costs 0.4 to 0.5 times what it did. `bench/runtime/PROFILE.md` has the profile
diff --git a/ROADMAP.md b/ROADMAP.md
index 16c5af14..f6297719 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -29,7 +29,7 @@ Version `0.8.0` adds source-node authoring on imported GLBs with retained rigs,
Version `0.9.0` adds isolated multi-angle and pose review with unchanged source revision and preview state.
-The stdio MCP server supplies twenty-one schema-backed tools and persistent CPU/GPU image previews.
+The stdio MCP server supplies twenty-two schema-backed tools and persistent CPU/GPU image previews.
Recipes retain lighting, volumetric fog, grading and directional shadow coverage with atomic edits and undo.
Imported asset sessions retain supported textures, rigs, morphs and clips from a configured local GLB catalog.
diff --git a/SECURITY.md b/SECURITY.md
index 5d8616f5..a8a866f0 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -14,7 +14,7 @@ The MCP server takes input from AI agents, and that input can come from a prompt
- It runs no code that a tool call supplies.
- It reads assets only from the configured catalog, and it fetches no remote URLs for assets.
-- It writes render output only to the configured jobs folder.
+- It writes render output and GLB exports (`scene_export_glb`, under `exports/`, server-chosen names) only to the configured jobs folder.
- It bounds every collection, count and size before it allocates memory.
`docs/mcp.md` describes each limit and its boundary tests.
diff --git a/docs/export-glb.md b/docs/export-glb.md
index c7e5aab8..4b6464f9 100644
--- a/docs/export-glb.md
+++ b/docs/export-glb.md
@@ -116,9 +116,26 @@ const clips = asset.animations.map(clipFromGltfAnimation);
const glb = exportGlb(asset.parts, { nodes: asset.nodes, clips });
```
+### Morph weight clips
+
+A track `{ target: 'Face', property: 'weights', keyframes: [{ time, value: [w0, w1] }] }` writes a `weights` channel with one SCALAR output per target and keyframe.
+Every keyframe needs the same nonzero count of finite weights, and the target is the node that carries the morph mesh.
+`clipFromGltfAnimation` skips weight tracks because the mixer samples fixed-size properties.
+`weightTracksFromGltfAnimation(animation)` in `src/export-skeleton.js` reads them from an imported animation, for linear and step keys; cubic weight keys fail.
+
+## MCP tool
+
+`scene_export_glb` exports the active MCP scene, recipe or imported asset, with `--jobs` configured.
+The file goes to `<jobs>/exports/<uuid>.glb`; the call takes no path and the result has the path, `bytes`, `sha256`, `parts` and `clips`.
+The newest eight files stay, the GLB is at most 32 MiB, and `maxTextureSize` goes up to 4096.
+Without `clip` it writes the current pose: pattern and imported textures, skins, morph weights and IK as posed.
+`motionTime` seeks authored motion first and leaves the preview there, like `scene_look`.
+With `clip` (imported assets) it writes that source clip, translation, rotation, scale and weights, on the source skeleton, so the scene must carry no animation, node overrides or motion.
+`node scripts/smoke-glb-export.mjs cpu` runs a patterned recipe, the robot with IK and its Walking clip through the real server and leaves the files in `artifacts/`.
+
## Limits
-Morph weight animation is not written; static weights are.
+Recipe motion tracks are not converted to clips, and an imported clip cannot be combined with IK or node overrides in the MCP tool.
A glTF mesh with several primitives comes back as one Blender object per part, so Blender counts more objects than the original, with the same bones, actions and materials.
Material tracks, IK and the camera are not exported; bake IK into rotation tracks first.
It stores opaque metallic roughness materials without renderer tags, procedural weathering, custom shaders, lighting, cameras, or postprocessing.
diff --git a/docs/guide.md b/docs/guide.md
index c4231526..35a1977e 100644
--- a/docs/guide.md
+++ b/docs/guide.md
@@ -476,7 +476,7 @@ Disconnect observers, cancel animation frames, release pointer state and call `d
## Models and AI agents
Version `0.5.0` includes [agent scene sessions](/agent-scene.md) and the `67js-mcp` command.
-Its [MCP server](/mcp.md) provides twenty-one tools for authoring, previewing and exporting scenes through a persistent browser runtime.
+Its [MCP server](/mcp.md) provides twenty-two tools for authoring, previewing and exporting scenes through a persistent browser runtime.
Release `0.7.0` adds [agent motion](/agent-motion.md) for deterministic joint, material and camera keyframes.
Read the MCP guide for npm installation, client configuration and CPU/GPU selection.
The [agent look contract](/agent-look.md) adds retained lighting, volumetric fog, grading and directional shadows to recipe edits and checkpoints.
diff --git a/docs/mcp.md b/docs/mcp.md
index 98a9d625..259dd051 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -111,6 +111,7 @@ Inspect or export the recipe before retrying. Context loss still permits recipe
| `scene_restore` | `sessionId`, `checkpointId`, `expectedRevision` | Updated revision, inspection, and render status |
| `scene_release_checkpoint` | `sessionId`, `checkpointId` | Release confirmation |
| `scene_export_recipe` | `sessionId` | Canonical recipe and revision |
+| `scene_export_glb` | `sessionId`, optional `clip`, `motionTime`, `maxTextureSize` | A GLB file under `<jobs>/exports/` with a server-chosen name: path, bytes, SHA-256. See [GLB export](export-glb.md) |
| `scene_dispose` | `sessionId` | Disposal confirmation |
| `scene_render_submit` | `sessionId`, `expectedRevision`, `settings` | Snapshot job ID and queued record |
| `scene_render_status` | `jobId` | State and durable frame progress |
@@ -204,6 +205,7 @@ The tools expose no arbitrary JavaScript execution, remote URLs or arbitrary cal
Release `0.8.0` supports [imported source-node tracks](agent-character-motion.md) through the bounded motion recipe.
Facial morph track authoring and rig creation remain unsupported.
Render jobs use a configured private store and fixed output filenames.
+`scene_export_glb` writes only to `exports/` inside that store, under a UUID name the server picks, with mode 0600; it keeps the newest eight files and caps each at 32 MiB.
See [render jobs](agent-render-jobs.md) for the snapshot workflow and storage limits.
Embedded texture decoding uses private browser blob URLs. Remote asset requests remain blocked.
diff --git a/docs/parity.md b/docs/parity.md
index c6223857..143116c3 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -225,7 +225,7 @@ To move to a new Blender release, run `node scripts/parity-manual-snapshot.mjs`.
| Assets, Files, & Data System > Importing & Exporting Files | out of scope | Decided in issue #23: GLB is the exchange format. | | |
| Add-ons > Node Wrangler | out of scope | Interface for a mouse. | | |
| Add-ons > Rigify | missing | No rig presets. | | #46 |
-| Add-ons > glTF 2.0 | partial | Import is broad. Export writes the five texture channels as PNG, skins with joints, morph targets and node clips, and bakes pattern materials with box projected UVs; Blender 5.2 and three.js open the RobotExpressive export with its 43 bones and 14 clips. Not yet: morph weight clips, an MCP export tool. | [gltf](../tests/gltf.test.js), [export](../tests/export.test.js), [round trip](../tests/export-roundtrip.test.js) | #49 |
+| Add-ons > glTF 2.0 | partial | Import is broad. Export writes the five texture channels as PNG, skins with joints, morph targets and node clips, and bakes pattern materials with box projected UVs; Blender 5.2 and three.js open the RobotExpressive export with its 43 bones and 14 clips. Morph weight clips export, and the `scene_export_glb` MCP tool writes the current pose or an imported clip as a GLB file, checked in Blender 5.2 for a patterned recipe, the robot with IK and its Walking action. Not yet: recipe motion tracks as clips, a clip together with IK or node overrides. | [gltf](../tests/gltf.test.js), [export](../tests/export.test.js), [round trip](../tests/export-roundtrip.test.js), [MCP contract](../tests/mcp-tools.test.js) | #49 |
| Add-ons > Manage UI Translations | out of scope | Blender interface work. | | |
| Add-ons > VR Scene Inspection | out of scope | Interface for a person. | | |
| Advanced | out of scope | Decided in issue #23: 67.js does not run agent code. MCP and the JavaScript API take the place of `bpy`. | | |
diff --git a/scripts/agent-preview-browser.js b/scripts/agent-preview-browser.js
index 1ab73ca0..4081b677 100644
--- a/scripts/agent-preview-browser.js
+++ b/scripts/agent-preview-browser.js
@@ -5,6 +5,9 @@ import { mat4 } from 'gl-matrix';
import { resolveAgentShadow } from '../src/agent-look.js';
import { createAgentAssetScene } from '../src/agent-asset.js';
import { parseGltf } from '../src/gltf.js';
+import { exportGlb } from '../src/export.js';
+import { weightTracksFromGltfAnimation } from '../src/export-skeleton.js';
+import { clipFromGltfAnimation } from '../src/skeleton-pose.js';
let active = null;
let canvas = document.querySelector('canvas');
@@ -195,6 +198,61 @@ function afterMeshBooleans(value, run) {
return loadMeshBooleans().then(run);
}
+function seekForExport(record, motionTime) {
+ if (record.asset) record.scene.sampleFrame({ motionTime });
+ else record.scene.sampleMotion(motionTime);
+}
+
+// The scene's parts already carry the current pose, including IK and node overrides, so skinned parts export it as is.
+function posedExport(record) {
+ return { parts: record.scene.parts.map(withoutRoundoffShear), options: {} };
+}
+
+// Chains of bone transforms leave world matrices with Float32 roundoff that the exporter reads as shear. Real shear
+// (dot products above the tolerance) still reaches the exporter and fails there.
+const ROUNDOFF_SHEAR_LIMIT = 1e-3;
+
+function withoutRoundoffShear(part) {
+ if (part.skin) return part;
+ const columns = [0, 4, 8].map(offset => {
+ const column = [part.matrix[offset], part.matrix[offset + 1], part.matrix[offset + 2]];
+ const length = Math.hypot(...column);
+ return length === 0 ? column : column.map(value => value / length);
+ });
+ const dots = [[0, 1], [0, 2], [1, 2]].map(([first, second]) => Math.abs(columns[first].reduce((sum, value, axis) => sum + value * columns[second][axis], 0)));
+ if (Math.max(...dots) > ROUNDOFF_SHEAR_LIMIT) return part;
+ const scale = mat4.getScaling([0, 0, 0], part.matrix);
+ const rotation = mat4.getRotation([0, 0, 0, 1], part.matrix);
+ const translation = mat4.getTranslation([0, 0, 0], part.matrix);
+ return { ...part, matrix: mat4.fromRotationTranslationScale(mat4.create(), rotation, translation, scale) };
+}
+
+// A source clip animates the source skeleton, so the scene must not carry a pose of its own that the clip would fight.
+function clipExport(record, clipIndex) {
+ const { asset, scene } = record;
+ if (!asset) throw new Error('clip needs an imported asset scene. Recipe scenes export their current pose.');
+ const animation = asset.animations[clipIndex];
+ if (!animation) throw new RangeError(`clip ${clipIndex} does not exist. The asset has ${asset.animations.length} clips.`);
+ const recipe = scene.exportRecipe();
+ if (recipe.animation || recipe.nodeOverrides.length || recipe.motion) {
+ throw new Error('Exporting a clip needs the unposed asset: remove animation, node overrides and motion first, or export without clip for the current pose.');
+ }
+ const sourceClip = clipFromGltfAnimation(animation);
+ const name = String(animation.name || `clip ${clipIndex}`);
+ const clip = { ...sourceClip, name, tracks: [...sourceClip.tracks, ...weightTracksFromGltfAnimation(animation)] };
+ return { parts: [...asset.parts], options: { nodes: asset.nodes, clips: [clip] } };
+}
+
+function bytesToBase64(bytes) {
+ if (typeof bytes.toBase64 === 'function') return bytes.toBase64();
+ const chunkSize = 0x8000;
+ let binary = '';
+ for (let offset = 0; offset < bytes.length; offset += chunkSize) {
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + chunkSize));
+ }
+ return btoa(binary);
+}
+
window.__agentPreview = {
reviewBegin({ sessionId, width, height }) {
const record = requireSession(sessionId);
@@ -403,6 +461,17 @@ window.__agentPreview = {
const record = requireSession(sessionId);
return { sessionId, revision: record.scene.revision, recipe: record.scene.exportRecipe() };
},
+ exportGlb({ sessionId, clip, motionTime, maxTextureSize, maximumBytes }) {
+ const record = requireSession(sessionId);
+ if (motionTime !== undefined) seekForExport(record, motionTime);
+ const { parts, options } = clip === undefined ? posedExport(record) : clipExport(record, clip);
+ const binary = exportGlb(parts, { ...options, ...(maxTextureSize === undefined ? {} : { maxTextureSize }) });
+ if (binary.byteLength > maximumBytes) {
+ throw new RangeError(`The GLB is ${binary.byteLength} bytes, above the ${maximumBytes} byte limit. Lower maxTextureSize or simplify the scene.`);
+ }
+ return { sessionId, revision: record.scene.revision, bytes: binary.byteLength,
+ parts: parts.length, clips: options.clips?.length ?? 0, data: bytesToBase64(new Uint8Array(binary)) };
+ },
dispose({ sessionId }) {
const record = requireSession(sessionId);
try {
diff --git a/scripts/agent-render-jobs.mjs b/scripts/agent-render-jobs.mjs
index 7ed61370..dd57f7a0 100644
--- a/scripts/agent-render-jobs.mjs
+++ b/scripts/agent-render-jobs.mjs
@@ -8,7 +8,10 @@ const TERMINAL = new Set(['completed', 'cancelled', 'failed', 'interrupted']);
const DEFAULT_LIMITS = Object.freeze({ maxRecords: 32, maxStoreBytes: 512 * 1024 ** 2, maxOutputBytes: 128 * 1024 ** 2, maxFrameBytes: 1024 ** 2, deadlineMs: 300000, cleanupMs: 5000 });
const MAXIMUM_JSON_BYTES = 1024 ** 2;
const MAXIMUM_ASSET_BYTES = 16 * 1024 ** 2;
-const INTERNAL_FILES = new Set(['owner.json', 'snapshot.json', 'asset.glb', 'status.json', 'status.json.pending']);
+/** Sibling folder of the job directories where the runtime keeps GLB exports; the store never reads or counts it. */
+export const EXPORT_DIRECTORY_NAME = 'exports';
+const STORE_FILES = ['store.json', 'store.lock', EXPORT_DIRECTORY_NAME];
+const INTERNAL_FILES =new Set(['owner.json', 'snapshot.json', 'asset.glb', 'status.json', 'status.json.pending']);
function objectKeys(value, allowed, label) {
if (!value || Object.getPrototypeOf(value) !== Object.prototype) throw new TypeError(`${label} must be a plain object.`);
@@ -207,6 +210,7 @@ export async function createAgentRenderJobs({ root, run, limits: inputLimits = {
async function storeBytes() {
let bytes = 0;
for (const name of await readdir(root)) {
+ if (name === EXPORT_DIRECTORY_NAME) continue;
if (['store.json', 'store.lock'].includes(name)) {
bytes += (await regularFile(join(root, name))).size;
} else {
@@ -257,7 +261,7 @@ export async function createAgentRenderJobs({ root, run, limits: inputLimits = {
async function recover() {
const names = await readdir(root);
if (!names.includes('store.json')) {
- if (names.some(name => name !== 'store.lock')) throw new Error('Job root contains foreign entries without store ownership.');
+ if (names.some(name => name !== 'store.lock' && name !== EXPORT_DIRECTORY_NAME)) throw new Error('Job root contains foreign entries without store ownership.');
storeId = randomUUID();
await writeFile(join(root, 'store.json'), JSON.stringify({ schemaVersion: 1, storeId }), { flag: 'wx', mode: 0o600 });
} else {
@@ -267,7 +271,7 @@ export async function createAgentRenderJobs({ root, run, limits: inputLimits = {
storeId = metadata.storeId;
}
for (const name of await readdir(root)) {
- if (['store.json', 'store.lock'].includes(name)) continue;
+ if (STORE_FILES.includes(name)) continue;
if (isPending(name)) {
const directory = await pendingDirectory(name);
if (!(await readdir(directory)).length) await rmdir(directory);
diff --git a/scripts/agent-runtime.mjs b/scripts/agent-runtime.mjs
index ad12dfae..53c0a5a1 100644
--- a/scripts/agent-runtime.mjs
+++ b/scripts/agent-runtime.mjs
@@ -1,13 +1,13 @@
import { createServer } from 'node:http';
-import { randomUUID } from 'node:crypto';
+import { createHash, randomUUID } from 'node:crypto';
import { existsSync } from 'node:fs';
-import { readFile, writeFile } from 'node:fs/promises';
+import { lstat, mkdir, readFile, unlink, writeFile } from 'node:fs/promises';
import { isAbsolute, join } from 'node:path';
import { createRequire } from 'node:module';
import packageMetadata from '../package.json' with { type: 'json' };
import { AGENT_SCENE_CAPABILITIES, AGENT_SCENE_DEFAULT_LIMITS } from '../src/agent-scene-capabilities.js';
import { createAgentAssetCatalog } from './agent-asset-catalog.mjs';
-import { createAgentRenderJobs } from './agent-render-jobs.mjs';
+import { createAgentRenderJobs, EXPORT_DIRECTORY_NAME } from './agent-render-jobs.mjs';
import { createFrameEncoder } from './frame-encoder.mjs';
import { isPreviewHost } from './preview-host.mjs';
import { normalizeReview, REVIEW_LIMITS } from './agent-review.mjs';
@@ -15,6 +15,8 @@ import { normalizeReview, REVIEW_LIMITS } from './agent-review.mjs';
const SCENE_LIMITS = AGENT_SCENE_DEFAULT_LIMITS;
const MAXIMUM_IMAGE_BYTES = 1024 * 1024;
const MAXIMUM_QUEUED_CALLS = 16;
+const MAXIMUM_GLB_BYTES = 32 * 1024 * 1024;
+const MAXIMUM_KEPT_GLBS = 8;
const EVALUATION_TIMEOUT_MS = 30000;
const html = '<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;height:100%;background:#182126}canvas{display:block;width:100vw;height:100vh}</style></head><body><canvas></canvas><script type="module" src="/preview.js"></script></body></html>';
@@ -57,12 +59,27 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memo
let closing;
let catalogPromise;
let jobsPromise;
+ const savedGlbPaths = [];
function jobs() {
if (!jobRoot) throw new Error('Configure --jobs with an absolute output directory before submitting render jobs.');
if (!jobsPromise && closing) throw new Error('The agent runtime is closing or closed.');
jobsPromise ??= createAgentRenderJobs({ root: jobRoot, run: runJob });
return jobsPromise;
}
+ // The caller never names a path: files get a server-chosen name in the jobs folder, and only the newest few are kept.
+ async function saveGlbExport(bytes) {
+ const directory = join(jobRoot, EXPORT_DIRECTORY_NAME);
+ await mkdir(directory, { recursive: true, mode: 0o700 });
+ const details = await lstat(directory);
+ if (!details.isDirectory() || details.isSymbolicLink()) throw new Error('The export folder must be a real directory without links.');
+ while (savedGlbPaths.length >= MAXIMUM_KEPT_GLBS) await unlink(savedGlbPaths.shift());
+ const filename = `${randomUUID()}.glb`;
+ const path = join(directory, filename);
+ await writeFile(path, bytes, { flag: 'wx', mode: 0o600 });
+ savedGlbPaths.push(path);
+ return { path, filename, mimeType: 'model/gltf-binary', bytes: bytes.length,
+ sha256: createHash('sha256').update(bytes).digest('hex'), keptExports: savedGlbPaths.length };
+ }
async function requirePreviewRenderer() {
if (phase !== 'rendering') return;
const terminal = ['completed', 'cancelled', 'failed', 'interrupted'];
@@ -364,6 +381,7 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memo
jobs: { configured: Boolean(jobRoot), kinds: ['image', 'stills', 'video'], maximumActiveJobs: 1,
maximumDuration: 30, maximumFps: 30, maximumFrames: 900, maximumStills: 8,
encoder: 'CPU H.264', audio: false, previewSuspendedDuringJob: true,
+ glbExport: { maximumBytes: MAXIMUM_GLB_BYTES, maximumKept: MAXIMUM_KEPT_GLBS, maximumTextureSize: 4096 },
records: jobRoot ? (await jobs()).list().map(record => ({ jobId: record.jobId, state: record.state,
sourceRevision: record.sourceRevision, progress: record.progress })) : [] },
unsupported: ['remote asset providers', 'arbitrary code execution', 'imported morph track authoring', 'job audio'],
@@ -591,6 +609,16 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memo
return result;
});
},
+ exportGlb({ sessionId, clip, motionTime, maxTextureSize }) {
+ return enqueue(async () => {
+ await requirePreviewRenderer();
+ await jobs();
+ const exported = await invoke('exportGlb', { sessionId, clip, motionTime, maxTextureSize, maximumBytes: MAXIMUM_GLB_BYTES });
+ const { data, ...summary } = exported;
+ const file = await saveGlbExport(Buffer.from(data, 'base64'));
+ return { ...summary, ...file };
+ });
+ },
submitJob({ sessionId, expectedRevision, settings }) {
return enqueue(async () => {
await requirePreviewRenderer();
diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjs
index 540218c0..8d7bb63c 100644
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@ -396,6 +396,7 @@ export function createAgentMcpServer(runtime, { version = packageMetadata.versio
register('scene_restore', 'Restore a checkpoint atomically using the current revision. The checkpoint remains available and revision increments.', z.strictObject({ ...checkpointFields, expectedRevision }), edit, async argumentsValue => jsonResult(await runtime.restore(argumentsValue)));
register('scene_release_checkpoint', 'Release one checkpoint slot. Released or foreign checkpoints fail.', z.strictObject(checkpointFields), edit, async argumentsValue => jsonResult(await runtime.releaseCheckpoint(argumentsValue)));
register('scene_export_recipe', 'Read a detached canonical JSON recipe for reproduction.', z.strictObject(sessionFields), readOnly, async argumentsValue => jsonResult(await runtime.exportRecipe(argumentsValue)));
+ register('scene_export_glb', 'Write the active scene as a GLB file in the configured jobs folder, under a server-chosen name (the result has the path, byte count and SHA-256). Needs --jobs. Exports the current pose with pattern and imported textures, skins, morph weights and IK as posed; motionTime seeks authored motion first. For an imported asset, clip adds that source clip (translation, rotation, scale and morph weight tracks) on the source skeleton, which needs no animation, node overrides or motion in the scene. At most eight files are kept, oldest removed first; the GLB is at most 32 MiB.', z.strictObject({ ...sessionFields, clip: z.number().int().min(0).max(255).optional().describe('Imported assets only: index of the source clip to write.'), motionTime: z.number().min(0).max(3600).optional().describe('Seek authored motion (and IK) to this time before exporting. Leaves the preview there, like scene_look.'), maxTextureSize: z.number().int().min(1).max(4096).optional().describe('Largest texture side in pixels. Defaults to 2048.') }), edit, async argumentsValue => jsonResult(await runtime.exportGlb(argumentsValue)));
register('scene_dispose', 'Dispose the active scene and its checkpoints, releasing renderer resources.', z.strictObject(sessionFields), edit, async argumentsValue => jsonResult(await runtime.dispose(argumentsValue)));
register('scene_render_submit', 'Start one asynchronous snapshot job in the configured private job store. Requires the current revision. Temporarily leases the preview renderer; does not change source revision or checkpoints.', z.strictObject({ ...sessionFields, expectedRevision, settings: renderSettings }), { ...edit, destructiveHint: false }, async argumentsValue => jsonResult(await runtime.submitJob(argumentsValue)));
register('scene_render_status', 'Read render job state and durable frame progress. Terminal states are completed, cancelled, failed and interrupted.', z.strictObject(jobFields), readOnly, async argumentsValue => jsonResult(await runtime.jobStatus(argumentsValue)));
diff --git a/scripts/smoke-agent-assets.mjs b/scripts/smoke-agent-assets.mjs
index ead4a397..a2e52392 100644
--- a/scripts/smoke-agent-assets.mjs
+++ b/scripts/smoke-agent-assets.mjs
@@ -35,7 +35,7 @@ async function look(sessionId, label) {
}
try {
await client.connect(transport, { timeout: 180000 });
- assert.equal((await client.listTools()).tools.length, 21);
+ assert.equal((await client.listTools()).tools.length, 22);
const catalog = (await call('scene_asset_catalog')).structuredContent;
assert.equal(catalog.configured, true);
assert.equal(catalog.assets.length, 2);
diff --git a/scripts/smoke-agent-render-jobs.mjs b/scripts/smoke-agent-render-jobs.mjs
index 48b54f7d..149dbf52 100644
--- a/scripts/smoke-agent-render-jobs.mjs
+++ b/scripts/smoke-agent-render-jobs.mjs
@@ -57,7 +57,7 @@ async function close() {
}
try {
await connect();
- assert.equal((await client.listTools()).tools.length, 21);
+ assert.equal((await client.listTools()).tools.length, 22);
const catalog = (await call('scene_asset_catalog')).structuredContent;
const created = (await call('scene_create_asset', { recipe: {
format: '67js.asset', schemaVersion: 1, assetId: catalog.assets[0].assetId,
diff --git a/scripts/smoke-agent-review.mjs b/scripts/smoke-agent-review.mjs
index 36f3ee87..8936772e 100644
--- a/scripts/smoke-agent-review.mjs
+++ b/scripts/smoke-agent-review.mjs
@@ -48,7 +48,7 @@ function pixels(bytes, crop) {
}
try {
await client.connect(transport);
- assert.equal((await client.listTools()).tools.length, 21);
+ assert.equal((await client.listTools()).tools.length, 22);
const created = (await call('scene_create_asset', { recipe: fixture.recipe })).structuredContent;
const sessionId = created.sessionId;
const checkpoint = (await call('scene_checkpoint', { sessionId })).structuredContent;
diff --git a/scripts/smoke-glb-export.mjs b/scripts/smoke-glb-export.mjs
new file mode 100644
index 00000000..3a6218e5
--- /dev/null
+++ b/scripts/smoke-glb-export.mjs
@@ -0,0 +1,117 @@
+// scene_export_glb through the real MCP server: a recipe with a pattern material, the robot posed by IK, and the robot's
+// walk clip. The files are copied to artifacts/glb-export-*.glb for opening in Blender. Run `npm run prepare:release` first.
+import assert from 'node:assert/strict';
+import { copyFile, mkdir, mkdtemp, readFile, readdir, rm } from 'node:fs/promises';
+import { constants, setPriority, tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { createHash } from 'node:crypto';
+import { Client } from '@modelcontextprotocol/client';
+import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
+
+setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);
+const backend = process.argv[2] ?? 'cpu';
+const directory = await mkdtemp(join(tmpdir(), '67js-glb-export-'));
+const assets = join(directory, 'assets');
+const jobs = join(directory, 'jobs');
+await mkdir(assets);
+await mkdir('artifacts', { recursive: true });
+await copyFile(resolve('tests/fixtures/RobotExpressive.glb'), join(assets, 'robot.glb'));
+
+const transport = new StdioClientTransport({
+ command: process.execPath,
+ args: [resolve('scripts/mcp-server.mjs'), '--backend', backend, '--memory', '192', '--assets', assets, '--jobs', jobs],
+ stderr: 'pipe',
+ cwd: process.cwd(),
+});
+let diagnostics = '';
+transport.stderr.on('data', chunk => {
+ diagnostics += chunk.toString();
+});
+const client = new Client({ name: '67js-glb-export-smoke', version: '1' });
+
+async function call(name, argumentsValue = {}) {
+ const result = await client.callTool({ name, arguments: argumentsValue }, { timeout: 180000 });
+ assert.ok(!result.isError, `${name}: ${JSON.stringify(result.content).slice(0, 700)}\n${diagnostics.slice(-500)}`);
+ return result.structuredContent;
+}
+
+async function failure(name, argumentsValue) {
+ const result = await client.callTool({ name, arguments: argumentsValue }, { timeout: 60000 });
+ assert.equal(result.isError, true, `${name} should have failed`);
+ return result.content[0].text;
+}
+
+async function keepExport(result, label) {
+ assert.match(result.filename, /^[0-9a-f-]{36}\.glb$/);
+ assert.ok(result.path.startsWith(join(jobs, 'exports')));
+ const bytes = await readFile(result.path);
+ assert.equal(bytes.length, result.bytes);
+ assert.equal(createHash('sha256').update(bytes).digest('hex'), result.sha256);
+ assert.equal(bytes.toString('latin1', 0, 4), 'glTF');
+ await copyFile(result.path, `artifacts/glb-export-${label}.glb`);
+ return JSON.parse(bytes.subarray(20, 20 + bytes.readUInt32LE(12)).toString('utf8'));
+}
+
+const report = {};
+try {
+ await client.connect(transport);
+
+ const recipe = {
+ format: '67js.scene', schemaVersion: 1,
+ geometries: [{ id: 'cube', type: 'box', bevel: 0.05 }, { id: 'ball', type: 'sphere' }],
+ materials: [{ id: 'oak', pattern: { type: 'wood', size: 0.6, axis: 'z' }, roughness: 0.8 }, { id: 'red', color: [0.8, 0.1, 0.1] }],
+ nodes: [{ id: 'crate', geometry: 'cube', material: 'oak' }, { id: 'ball', geometry: 'ball', material: 'red', translation: [1.6, 0, 0], scale: [0.5, 0.5, 0.5] }],
+ };
+ const scene = await call('scene_create', { recipe });
+ const patterned = await call('scene_export_glb', { sessionId: scene.sessionId, maxTextureSize: 1024 });
+ const patternedDocument = await keepExport(patterned, 'pattern');
+ assert.ok(patternedDocument.textures.length >= 1, 'the pattern material is written as textures');
+ assert.equal(patternedDocument.meshes.length, 2);
+ assert.match(await failure('scene_export_glb', { sessionId: scene.sessionId, clip: 0 }), /imported asset/);
+ report.pattern = { bytes: patterned.bytes, textures: patternedDocument.textures.length, images: patternedDocument.images.length };
+ await call('scene_dispose', { sessionId: scene.sessionId });
+
+ const catalog = await call('scene_asset_catalog');
+ const assetRecipe = { format: '67js.asset', schemaVersion: 1, assetId: catalog.assets[0].assetId };
+ const posed = await call('scene_create_asset', { recipe: assetRecipe });
+ const nodes = [];
+ for (let offset = 0; ; offset += 64) {
+ const page = await call('scene_inspect', { sessionId: posed.sessionId, kind: 'hierarchy', offset, limit: 64 });
+ nodes.push(...page.nodes);
+ if (!page.truncated) break;
+ }
+ const jointId = label => nodes.find(node => node.label === label && node.joint).id;
+ const motion = {
+ duration: 2, tracks: [],
+ ik: [{
+ type: 'two-bone', root: jointId('UpperArm.R'), middle: jointId('LowerArm.R'), end: jointId('Palm2.R'), keepEndRotation: false,
+ target: { interpolation: 'SMOOTH', keyframes: [{ time: 0, value: [-1.3, 2.6, 0.8] }, { time: 1, value: [-1, 1.7, 1.1] }, { time: 2, value: [-1.3, 2.6, 0.8] }] },
+ }],
+ };
+ const applied = await call('scene_apply', { sessionId: posed.sessionId, expectedRevision: posed.revision, operations: [{ type: 'set-motion', motion }] });
+ assert.equal(applied.renderSucceeded, true, applied.renderError);
+ const withIk = await call('scene_export_glb', { sessionId: posed.sessionId, motionTime: 1 });
+ const ikDocument = await keepExport(withIk, 'robot-ik');
+ assert.ok(ikDocument.skins.length >= 1);
+ assert.equal(ikDocument.animations, undefined, 'a posed export carries no clip');
+ assert.match(await failure('scene_export_glb', { sessionId: posed.sessionId, clip: 0 }), /unposed asset/);
+ report.ik = { bytes: withIk.bytes, skins: ikDocument.skins.length, joints: ikDocument.skins[0].joints.length };
+ await call('scene_dispose', { sessionId: posed.sessionId });
+
+ const plain = await call('scene_create_asset', { recipe: assetRecipe });
+ const clipIndex = plain.inspection.animations.findIndex(clip => /walking/i.test(clip.label));
+ assert.ok(clipIndex >= 0, 'the robot has a Walking clip');
+ const walk = await call('scene_export_glb', { sessionId: plain.sessionId, clip: clipIndex });
+ const walkDocument = await keepExport(walk, 'robot-walk');
+ assert.equal(walkDocument.animations.length, 1);
+ report.walk = { bytes: walk.bytes, channels: walkDocument.animations[0].channels.length };
+ assert.match(await failure('scene_export_glb', { sessionId: plain.sessionId, clip: 99 }), /does not exist/);
+ await call('scene_dispose', { sessionId: plain.sessionId });
+
+ const kept = await readdir(join(jobs, 'exports'));
+ assert.equal(kept.length, 3);
+ console.log(`GLB export passed on ${backend}: ${JSON.stringify(report)}`);
+} finally {
+ await client.close();
+ await rm(directory, { recursive: true, force: true, maxRetries: 10, retryDelay: 300 }).catch(error => console.warn(`Left ${directory}: ${error.code}`));
+}
diff --git a/scripts/smoke-mcp-package.mjs b/scripts/smoke-mcp-package.mjs
index 98abbdef..33398bb7 100644
--- a/scripts/smoke-mcp-package.mjs
+++ b/scripts/smoke-mcp-package.mjs
@@ -109,7 +109,7 @@ for (const era of ['modern', 'legacy']) {
const connectMs = performance.now() - start;
processId = transport.pid;
assert.equal(client.getServerVersion().version, metadata.version);
- assert.equal((await client.listTools()).tools.length, 21);
+ assert.equal((await client.listTools()).tools.length, 22);
const capabilities = (await call('scene_capabilities')).structuredContent;
assert.equal(capabilities.phase, 'idle');
assert.equal(capabilities.preview.maximumActiveScenes, 1);
diff --git a/scripts/smoke-mcp.mjs b/scripts/smoke-mcp.mjs
index 3358b57e..9c38040b 100644
--- a/scripts/smoke-mcp.mjs
+++ b/scripts/smoke-mcp.mjs
@@ -53,7 +53,7 @@ try {
await client.connect(transport);
processId = transport.pid;
const listing = await client.listTools();
- assert.equal(listing.tools.length, 21);
+ assert.equal(listing.tools.length, 22);
const capabilities = (await call('scene_capabilities')).structuredContent;
assert.equal(capabilities.phase, 'idle');
const fixture = createAgentPreviewFixture();
diff --git a/skills/build-67js-scene/SKILL.md b/skills/build-67js-scene/SKILL.md
index 1c7fe3b9..79b53299 100644
--- a/skills/build-67js-scene/SKILL.md
+++ b/skills/build-67js-scene/SKILL.md
@@ -46,6 +46,7 @@ Use `simplify-code` and `engineering-workflows` for implementation.
- Agent imported character motion uses `docs/agent-character-motion.md` from release `0.8.0`. Inspect source joints before authoring local tracks.
- Agent comparisons use `scene_review` from release `0.9.0`. Read `docs/agent-review.md` for isolated views and independent pose samples.
- An image or video export uses `render-67js-media`.
+- A GLB for Blender or another tool uses `scene_export_glb` (needs `--jobs`): it returns a file path under the jobs folder, takes no path of its own. Plain call for the current pose with textures, skins and IK; `motionTime` to pose authored motion first; `clip` on an unposed imported asset for its source animation. See `docs/export-glb.md`.
Read [scene-contract.md](references/scene-contract.md) before creating parts or changing materials.
diff --git a/src/export-skeleton.js b/src/export-skeleton.js
index 511f7cc8..77f226a2 100644
--- a/src/export-skeleton.js
+++ b/src/export-skeleton.js
@@ -1,7 +1,10 @@
import { mat4, quat, vec3 } from 'gl-matrix';
-const GLTF_PATHS = { translation: 'translation', rotation: 'rotation', scale: 'scale' };
+const GLTF_PATHS = { translation: 'translation', rotation: 'rotation', scale: 'scale', weights: 'weights' };
const COMPONENTS_BY_PATH = { translation: 3, rotation: 4, scale: 3 };
+const ACCESSOR_TYPE_BY_PATH = { translation: 'VEC3', rotation: 'VEC4', scale: 'VEC3', weights: 'SCALAR' };
+const GLTF_STEP_INTERPOLATION = 2300;
+const GLTF_LINEAR_INTERPOLATION = 2301;
const IDENTITY_ROTATION = [0, 0, 0, 1];
function transformFields(translation, rotation, scale) {
@@ -139,8 +142,19 @@ export function normalizedWeights(weights) {
return result;
}
+// A weights keyframe holds one value per morph target, so its width comes from the keyframes.
+function componentCount(track) {
+ if (track.property !== 'weights') return COMPONENTS_BY_PATH[track.property];
+ const count = track.keyframes[0].value.length;
+ const consistent = track.keyframes.every(keyframe => keyframe.value.length === count && Array.from(keyframe.value).every(Number.isFinite));
+ if (!count || !consistent) {
+ throw new RangeError(`GLB weights track on ${track.target} needs the same nonzero count of finite weights in every keyframe.`);
+ }
+ return count;
+}
+
function trackOutput(track) {
- const zero = new Array(COMPONENTS_BY_PATH[track.property]).fill(0);
+ const zero = new Array(componentCount(track)).fill(0);
const rows = [];
for (const keyframe of track.keyframes) {
const value = Array.isArray(keyframe.value) ? keyframe.value : Array.from(keyframe.value);
@@ -157,12 +171,12 @@ const GLTF_INTERPOLATION = { LINEAR: 'LINEAR', STEP: 'STEP', SMOOTH: 'CUBICSPLIN
function writeTrack(writer, animation, track, nodeIndex) {
const path = GLTF_PATHS[track.property];
if (!path) {
- throw new RangeError(`GLB export cannot write ${track.property} tracks (target ${track.target}). Only translation, rotation and scale tracks are exported; remove the others from the clip.`);
+ throw new RangeError(`GLB export cannot write ${track.property} tracks (target ${track.target}). Only translation, rotation, scale and weights tracks are exported; remove the others from the clip.`);
}
const times = Float32Array.from(track.keyframes, keyframe => keyframe.time);
animation.samplers.push({
input: writer.addAccessor(times, 'SCALAR', undefined, { bounds: true }),
- output: writer.addAccessor(trackOutput(track), COMPONENTS_BY_PATH[track.property] === 4 ? 'VEC4' : 'VEC3', undefined, { bounds: false }),
+ output: writer.addAccessor(trackOutput(track), ACCESSOR_TYPE_BY_PATH[track.property], undefined, { bounds: false }),
interpolation: GLTF_INTERPOLATION[track.interpolation ?? 'LINEAR'],
});
animation.channels.push({ sampler: animation.samplers.length - 1, target: { node: nodeIndex, path } });
@@ -185,3 +199,28 @@ export function writeAnimations(writer, clips, nodeIndexByName, prepareNodeForAn
writer.document.animations.push(animation);
});
}
+
+/**
+ * Morph weight tracks of an imported animation (`asset.animations[n]`) in clip form. clipFromGltfAnimation skips them,
+ * because the mixer samples only fixed-size properties. Cubic weight keys fail instead of silently changing shape.
+ */
+export function weightTracksFromGltfAnimation(animation) {
+ const tracks = [];
+ for (const track of animation.tracks) {
+ const separator = track.name.lastIndexOf('.');
+ if (track.name.slice(separator + 1) !== 'morphTargetInfluences') continue;
+ const target = track.name.slice(0, separator);
+ const interpolation = track.getInterpolation?.();
+ if (interpolation !== GLTF_LINEAR_INTERPOLATION && interpolation !== GLTF_STEP_INTERPOLATION) {
+ throw new RangeError(`GLB export cannot write cubic morph weights on ${target}. Re-key them as linear or step.`);
+ }
+ const width = track.values.length / track.times.length;
+ tracks.push({
+ target,
+ property: 'weights',
+ interpolation: interpolation === GLTF_STEP_INTERPOLATION ? 'STEP' : 'LINEAR',
+ keyframes: Array.from(track.times, (time, index) => ({ time, value: Array.from(track.values.subarray(index * width, (index + 1) * width)) })),
+ });
+ }
+ return tracks;
+}
diff --git a/tests/export-roundtrip.test.js b/tests/export-roundtrip.test.js
index 130c5b1e..e37fd259 100644
--- a/tests/export-roundtrip.test.js
+++ b/tests/export-roundtrip.test.js
@@ -6,6 +6,7 @@ import { mat4 } from 'gl-matrix';
import { exportGlb } from '../src/export.js';
import { parseGltf } from '../src/gltf.js';
import { box } from '../src/geometry.js';
+import { createMorphPose } from '../src/morph.js';
import { clipFromGltfAnimation } from '../src/skeleton-pose.js';
import { bakeMaterialPattern, normalizeMaterialPattern } from '../src/material-patterns.js';
@@ -187,6 +188,29 @@ test('skins built without a node list export derived joints and a clip can targe
assert.equal(copy.animations[0].tracks[0].name, 'tip.quaternion');
});
+test('morph weight clips round trip as one SCALAR sampler per track', async () => {
+ const geometry = box();
+ const positions = new Float32Array(geometry.positions.length).fill(0.1);
+ geometry.morphTargets = [{ positions }, { positions: positions.map(value => -value) }];
+ const morph = createMorphPose(2);
+ const part = { name: 'Face', geometry, matrix: mat4.create(), morph, material: { color: [1, 1, 1], metallic: 0, roughness: 1 } };
+ const keyframes = [{ time: 0, value: [0, 0] }, { time: 0.5, value: [1, 0.25] }, { time: 1, value: [0, 1] }];
+ const clip = { name: 'Blink', duration: 1, loop: false, tracks: [{ target: 'Face', property: 'weights', keyframes }] };
+ const binary = exportGlb([part], { clips: [clip] });
+ const view = new DataView(binary);
+ const document = JSON.parse(new TextDecoder().decode(new Uint8Array(binary, 20, view.getUint32(12, true))));
+ const sampler = document.animations[0].samplers[0];
+ assert.equal(document.animations[0].channels[0].target.path, 'weights');
+ assert.equal(document.accessors[sampler.input].count, 3);
+ assert.equal(document.accessors[sampler.output].type, 'SCALAR');
+ assert.equal(document.accessors[sampler.output].count, 6);
+ const copy = await parseGltf(binary);
+ assert.equal(copy.animations[0].tracks[0].name, 'Face.morphTargetInfluences');
+ assert.deepEqual(Array.from(copy.animations[0].tracks[0].values), [0, 0, 1, 0.25, 0, 1]);
+ const ragged = { ...clip, tracks: [{ target: 'Face', property: 'weights', keyframes: [{ time: 0, value: [0, 0] }, { time: 1, value: [1] }] }] };
+ assert.throws(() => exportGlb([part], { clips: [ragged] }), /same nonzero count/);
+});
+
test('a clip that targets a missing node names the fix', () => {
const part = texturedBox(0);
const clip = { duration: 1, loop: false, tracks: [{ target: 'ghost', property: 'translation', keyframes: [{ time: 0, value: [0, 0, 0] }] }] };
diff --git a/tests/mcp-tools.test.js b/tests/mcp-tools.test.js
index 4791e0cc..ba49150a 100644
--- a/tests/mcp-tools.test.js
+++ b/tests/mcp-tools.test.js
@@ -89,6 +89,11 @@ async function connect(context) {
return { released: true, sessionId, checkpointId };
},
async exportRecipe() { return { sessionId, revision: scene.revision, recipe: scene.exportRecipe() }; },
+ async exportGlb({ sessionId: requested, ...options }) {
+ calls++;
+ assert.equal(requested, sessionId);
+ return { sessionId, revision: scene.revision, bytes: 12, parts: 1, clips: 0, filename: `${randomUUID()}.glb`, options };
+ },
async dispose() {
scene = undefined;
return { disposed: true, sessionId };
@@ -123,7 +128,7 @@ test('SDK advertises the complete strict JSON contract and truthful annotations'
const { tools } = await client.listTools();
assert.deepEqual(tools.map(tool => tool.name).sort(), [
'mesh_edit', 'mesh_inspect', 'mesh_stack', 'scene_apply', 'scene_asset_catalog', 'scene_capabilities', 'scene_checkpoint', 'scene_create', 'scene_create_asset', 'scene_dispose',
- 'scene_export_recipe', 'scene_inspect', 'scene_look', 'scene_review', 'scene_release_checkpoint', 'scene_restore',
+ 'scene_export_glb', 'scene_export_recipe', 'scene_inspect', 'scene_look', 'scene_review', 'scene_release_checkpoint', 'scene_restore',
'scene_render_cancel', 'scene_render_release', 'scene_render_result', 'scene_render_status', 'scene_render_submit',
].sort());
for (const tool of tools) {
@@ -155,12 +160,31 @@ test('SDK advertises the complete strict JSON contract and truthful annotations'
assert.ok(look.inputSchema.properties.motionTime);
});
+test('GLB export takes no path or code and rejects unknown or unbounded fields before dispatch', async context => {
+ const { client, sessionId, calls } = await connect(context);
+ await client.callTool({ name: 'scene_create', arguments: { recipe: recipe() } });
+ const { tools } = await client.listTools();
+ const tool = tools.find(tool => tool.name === 'scene_export_glb');
+ assert.deepEqual(Object.keys(tool.inputSchema.properties).sort(), ['clip', 'maxTextureSize', 'motionTime', 'sessionId']);
+ assert.equal(tool.inputSchema.properties.maxTextureSize.maximum, 4096);
+ const result = await client.callTool({ name: 'scene_export_glb', arguments: { sessionId, clip: 0, maxTextureSize: 512 } });
+ assert.deepEqual(result.structuredContent.options, { clip: 0, maxTextureSize: 512 });
+ assert.match(result.structuredContent.filename, /^[0-9a-f-]{36}\.glb$/);
+ const before = calls();
+ for (const invalid of [
+ { sessionId, path: 'C:/out.glb' }, { sessionId, filename: 'x.glb' }, { sessionId, code: 'console.log(1)' },
+ { sessionId, clip: -1 }, { sessionId, clip: 256 }, { sessionId, maxTextureSize: 4097 }, { sessionId, motionTime: -1 },
+ { sessionId: 'not-a-uuid' },
+ ]) await rejected(client, 'scene_export_glb', invalid);
+ assert.equal(calls(), before);
+});
+
test('review SDK exposes one image and rejects unknown or unbounded shot fields before dispatch', async context => {
const { client, sessionId, calls } = await connect(context);
await client.callTool({ name: 'scene_create', arguments: { recipe: recipe() } });
const { tools } = await client.listTools();
const tool = tools.find(tool => tool.name === 'scene_review');
- assert.equal(tools.length, 21);
+ assert.equal(tools.length, 22);
assert.equal(tool.annotations.readOnlyHint, true);
assert.equal(tool.inputSchema.properties.shots.maxItems, 4);
assert.equal(tool.inputSchema.properties.shots.items.additionalProperties, false);