3D engine that AI agents drive
Document GLB export, raise the core size budget, update parity and changelog
Nguyen Xuan And088d01890ba
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 176439d7..8b7f945a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,7 @@## Unreleased+- 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)- Remove `67js/addons/film` from the npm package. It held the 187-second trailer demo with its baked physics recording, 75 KB gzip of the archive. Nothing else in the package used it. To keep using it, copy `src/film.js`, `src/film-rig.js`, `src/film-character.js`, `src/film-physics-definition.js` and `src/film-physics-clip.json` from the repository, or read the trailer on the site at `/film.html`. The archive goes from 901,314 to 829,085 bytes- Remove three.js from modeling and the agent scene: `lathe`, `extrude` and `tube` no longer import it, and `scene:agent-scene` drops from 185,681 to 117,290 bytes gzip. `lathe` and `tube` output is identical to before, vertex for vertex. `extrude` walls, bevels, UVs, normals and bounds are identical, and volume matches within 1e-4. Extrusion caps use a new ear-clipping triangulation, so a cap can split along other diagonals, and a cap with collinear points can add or drop a seam vertex. A clockwise hole under a clockwise contour is now flipped to face outward, where it used to keep inward walls- Load glTF without Three.js: the addon has its own GLB and glTF parser, node sampler and animation clips, so a box with the addon drops from 159,422 to 67,467 bytes gzip. Draco, meshopt and KTX2 still come from the decoders you pass in `options.decoders`. Only the default scene is decoded, and a node outside it is decoded only when a skin or an animation names itdiff --git a/bench/size/budgets.json b/bench/size/budgets.jsonindex 6c3a53dd..4ec336d5 100644--- a/bench/size/budgets.json+++ b/bench/size/budgets.json@@ -5,7 +5,7 @@"agent-scene": 100000},"budgets": {- "entry:core": 67100,+ "entry:core": 70500,"entry:model": 14400,"entry:nature": 13200,"entry:motion": 13600,diff --git a/docs/export-glb.md b/docs/export-glb.mdindex e952100f..c7e5aab8 100644--- a/docs/export-glb.md+++ b/docs/export-glb.md@@ -76,10 +76,51 @@ Negative scales remain valid.The exporter uses accessors because its callers already supply editable vertex data.A texture bake introduces a separate asset pipeline and cannot preserve the same source channels.+## Textures++`material.map`, `normalMap`, `metallicRoughnessMap`, `occlusionMap` and `emissiveMap` are renderer texture descriptors: `{ image, wrapS, wrapT, minFilter, magFilter, flipY }`.+Each distinct image is written once as an embedded PNG, as RGB when it has no transparent texel, and samplers and textures are shared between channels.+`normalScale[0]` and `occlusionStrength` are written with their textures.+`image` is `{ width, height, data }` with RGBA8 data, or a browser image, bitmap or canvas, which is read back through a canvas.+Rows are reversed for `flipY: true`.+The PNG is stored without compression so the export stays synchronous: a 2048 px RGBA map is about 16 MB.++Geometry with textures needs `uvs`.+Without them the export fails and names `uv_unwrap` (a mesh stack node) or `geometry.uvs`.+An image larger than `maxTextureSize` (default 2048, up to 16384) fails with that option's name.++### Pattern materials++A recipe `pattern` is box projected in the shader, and glTF has no box projection.+The export writes the same projection as `TEXCOORD_0`: each triangle takes the object axis its normal is closest to, using the pattern's `size` and `axis` and the part's scale, and vertices are split only where neighbouring triangles choose different axes.+The baked textures go out as the three channels above.+This keeps the picture closest and needs no authoring step, so it was chosen over requiring `uv_unwrap`.+It replaces any `uvs` the geometry has, because the renderer ignores those for a pattern too.+Differences: the shader blends the three projections across an edge and the export switches at the edge, and the importer computes tangents for the normal map from these UVs.++## Skeletons and clips++A skinned part (`part.skin` with `joints`, `inverseBindMatrices` and `jointWorldMatrices`) needs joint nodes.+Pass `options.nodes`, the `nodes` of the parsed asset, to keep the asset's hierarchy and mesh nodes.+Without it the exporter derives one node per joint from the current joint world matrices.+Weights are normalised to sum to one, the skin's `bindMatrix` is folded into the inverse bind matrices, and a skinned mesh sits at the origin.++`options.clips` takes clips in `createAnimationClip` form (`clipFromGltfAnimation` converts an imported one) whose track targets are node names.+Translation, rotation and scale tracks are written as LINEAR, STEP or CUBICSPLINE.+SMOOTH becomes CUBICSPLINE with zero tangents, which equals its scalar easing and approximates rotation slerp.+A track on another property, or on a node that is not exported, fails with the fix.++```js+const asset = await parseGltf(bytes);+const clips = asset.animations.map(clipFromGltfAnimation);+const glb = exportGlb(asset.parts, { nodes: asset.nodes, clips });+```+## Limits-Skinning and all material texture channels throw explicit unsupported errors.-The snapshot retains current morph weights but does not serialize animation clips or skeletons.+Morph weight animation is not written; static weights are.+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.It does not promise identical rendered pixels across tools.Materials tagged `unlit` still export through this documented metallic roughness snapshot contract.diff --git a/docs/parity.md b/docs/parity.mdindex bc84068b..f08ee10c 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 can not write textures, skeletons or clips. | [gltf](../tests/gltf.test.js), [export](../tests/export.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. 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 > 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/src/export.js b/src/export.jsindex 4e4a1861..ccb95884 100644--- a/src/export.js+++ b/src/export.js@@ -269,7 +269,9 @@ export function exportGlb(parts, options = {}) {const host = part.skin ? null : hostOfPart(partIndex, hierarchy, worldCache);// The mesh node of an imported asset is one of its nodes: keep the mesh on it instead of nesting a same-named node.const mergeIntoHost = host && hierarchy[host.index].name === part.name && hierarchy[host.index].meshIds.length === 1;- const node = mergeIntoHost ? document.nodes[host.index] : { name: part.name };+ // Clips address nodes by name, and loaders rename duplicates, so a mesh node never shares a joint's name.+ const meshNodeName = nodeIndexByName.has(part.name) ? `${part.name} mesh` : part.name;+ const node = mergeIntoHost ? document.nodes[host.index] : { name: meshNodeName };node.mesh = meshes.get(meshKey);if (part.morph) node.weights = Array.from(part.morph.weights);if (part.skin) {