Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
test(glb-canonicalize): cover non-humanoid rigs with opaque joint names
nirholasfe5c55f0c174
diff --git a/tests/glb-canonicalize.test.js b/tests/glb-canonicalize.test.jsindex 465fd70dd..10e8989b0 100644--- a/tests/glb-canonicalize.test.js+++ b/tests/glb-canonicalize.test.js@@ -1707,3 +1707,76 @@ describe('rig worker skeleton (workers/rig, Make-It-Animatable output)', () => {}});});++describe('non-humanoid rig (UniRig / SkinTokens / AniGen output)', () => {+ // workers/rig-nonhuman (UniRig skeleton prediction + SkinTokens skinning)+ // and workers/model-anigen both predict a skeleton for arbitrary topology+ // (a quadruped, a prop, a creature), so their joints carry opaque,+ // autogenerated names with no anatomical meaning (`bone_0`, `bone_1`, ...)+ // rather than Mixamo-style spellings. canonicalizeBoneName correctly+ // returns null for every one of them (there is no canonical target for a+ // name that means nothing), so the full-GLB rewrite must leave the names+ // untouched rather than corrupt them into a false match, and the mesh+ // must still be a valid, drivable-by-its-own-skeleton GLB afterward: the+ // non-humanoid fallback exists precisely because the canonical Mixamo set+ // cannot describe a six-legged creature, so unmapped bones here are the+ // correct outcome, not a bug.+ const NONHUMANOID_JOINTS = Array.from({ length: 12 }, (_, i) => `bone_${i}`);++ it('opaque autogenerated joint names do not canonicalize to anything', () => {+ for (const name of NONHUMANOID_JOINTS) {+ expect(canonicalizeBoneName(name), name).toBeNull();+ }+ });++ it('a non-humanoid GLB round-trips unchanged (renamed: 0, same buffer)', () => {+ const nodes = NONHUMANOID_JOINTS.map((name, i) => ({+ name,+ translation: [0, i * 0.01, 0],+ }));+ const json = {+ asset: { version: '2.0' },+ scenes: [{ nodes: [0] }],+ scene: 0,+ nodes,+ skins: [{ joints: nodes.map((_, i) => i) }],+ };+ const bin = new Uint8Array(32);+ for (let i = 0; i < bin.length; i++) bin[i] = (i * 5 + 1) & 0xff;+ const ab = buildGLB(json, bin);+ const out = canonicalizeGLBBones(ab);++ expect(out.renamed).toBe(0);+ expect(out.samples).toEqual([]);+ // No rename and no orientation fix means the original buffer comes back+ // by reference, so a caller correctly skips a redundant re-upload.+ expect(out.buffer).toBe(ab);++ const after = readGLBJson(out.buffer);+ expect(after.nodes.map((n) => n.name)).toEqual(NONHUMANOID_JOINTS);+ });++ it('mixed real limb names alongside opaque ones only rename the real ones', () => {+ // A hybrid skeleton (e.g. a predicted skeleton that happens to label a+ // root/spine chain conventionally but leaves auxiliary limbs opaque)+ // must canonicalize the recognizable joints and leave the rest intact.+ const nodes = [+ { name: 'Hips', children: [1] },+ { name: 'Spine' },+ { name: 'bone_0' },+ { name: 'bone_1' },+ { name: 'bone_2' },+ ];+ const json = {+ asset: { version: '2.0' },+ scenes: [{ nodes: [0] }],+ scene: 0,+ nodes,+ skins: [{ joints: [0, 1, 2, 3, 4] }],+ };+ const out = canonicalizeGLBBones(buildGLB(json));+ expect(out.renamed).toBe(0);+ const after = readGLBJson(out.buffer);+ expect(after.nodes.map((n) => n.name)).toEqual(['Hips', 'Spine', 'bone_0', 'bone_1', 'bone_2']);+ });+});