Skip to content

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.

Rigging: map five more skeleton conventions, found by auditing real avatars

nirholas5fadfe4512b6
diff --git a/docs/3d-asset-pipeline.md b/docs/3d-asset-pipeline.md
index d94604dcc..2992185a6 100644
--- a/docs/3d-asset-pipeline.md
+++ b/docs/3d-asset-pipeline.md
@@ -162,7 +162,7 @@ The build pipeline produces GLB + JSON; the browser stitches them back together.
| Stage | Module | What it does |
|---|---|---|
| Load a GLB | [src/viewer.js](../src/viewer.js) | `GLTFLoader` (with DRACO/KTX2 support) loads the model, frames the camera, builds raycasting BVH, emits the scene to the animation panel. |
-| Normalize an uploaded rig | [src/glb-canonicalize.js](../src/glb-canonicalize.js) | Rewrites bone names in the GLB JSON chunk to canonical form (handles Mixamo `mixamorig:`, Blender `Armature_`, Rigify `DEF-`/`ORG-`, Unreal `upperarm_l`, snake/kebab case), folds the Mixamo +90°X armature rotation into children, repacks the GLB. |
+| Normalize an uploaded rig | [src/glb-canonicalize.js](../src/glb-canonicalize.js) | Rewrites bone names in the GLB JSON chunk to canonical form (see [the supported conventions](#supported-rig-conventions) below), folds the Mixamo +90°X armature rotation into children, repacks the GLB. |
| Load a clip | [src/animation-manager.js](../src/animation-manager.js) | Fetches clip JSON, `AnimationClip.parse`, drives playback through a `THREE.AnimationMixer` with crossfades (0.35s default), one-shot + settle, and a "fallen pose" safety guard. |
| Retarget a clip to the loaded rig | [src/animation-retarget.js](../src/animation-retarget.js) | Renames canonical tracks to the rig's actual bone names, applies per-bone bind-pose correction (`C = targetRest · sourceRest⁻¹`), rescales hip translation by height ratio, drops the clip if coverage < 50%. |
| The pose/animation studio | `/pose` ([src/animation-library.js](../src/animation-library.js)) | Gallery of preset clips, live preview on the loaded rig, text-to-motion generation, and **export animated GLB**. |
@@ -172,6 +172,60 @@ Validation gates worth knowing: a rig needs **≥8 canonical bones** to be playa
---
+## Supported rig conventions
+
+There is **no rig allowlist**. [src/glb-canonicalize.js](../src/glb-canonicalize.js) maps bone names from every convention below onto the canonical set, so any humanoid GLB using one of them drives the whole clip library — idle, walk, legs included — the moment it is uploaded.
+
+| Family | Example bone names |
+|---|---|
+| Mixamo | `mixamorig:LeftArm`, `mixamorig1:Spine`, `mixamorigHead` |
+| Blender / Armature | `Armature_Hips`, `Armature/LeftLeg` |
+| Rigify | `DEF-forearm.L`, `ORG-Hips`, `MCH-RightLeg` |
+| MakeHuman / Blender `.L`/`.R` | `upperarm.L`, `UpperLeg.R`, `shin.L`, `Index2.L` |
+| Unreal mannequin | `pelvis`, `clavicle_l`, `upperarm_l`, `thigh_l`, `calf_l`, `ball_l` |
+| VRM 0.x / VRoid | `J_Bip_C_Hips`, `J_Bip_L_UpperArm`, `J_Bip_L_Little1` |
+| VRM 1.0 | `leftUpperArm`, `rightLowerLeg`, `upperChest`, `leftToes` |
+| UniGLTF / VRM converter | `5.joint_HipMaster`, `10.!joint_LeftToe` |
+| Daz3D / Genesis | `hip`, `abdomen`, `lShldr`, `lThigh`, `lShin`, `lCollar` |
+| Reallusion CC3 / CC4 | `CC_Base_Hip`, `CC_Base_L_Upperarm`, `CC_Base_NeckTwist01` |
+| 3ds Max Biped | `Bip01 Pelvis`, `Bip001 L UpperArm`, `Bip01 L Calf` |
+| CharacterStudio | `CH_Hips`, `CH_LeftUpLeg` |
+| Autodesk HumanIK / Maya / MotionBuilder | `Character1:Hips`, `subject:LeftArm`, `char:ns:Hips` |
+| Advanced Skeleton (Maya) | `Root_M`, `Spine1_M`, `Chest_M`, `Scapula_R`, `IndexFinger1_R` |
+| Sketchfab / Maya `j_` exports | `j_pelvis`, `j_L_hip`, `j_L_knee`, `j_spine_0` |
+| SMPL / SMPL-X (research, mocap) | `left_hip`, `left_knee`, `left_ankle`, `left_elbow`, `left_collar` |
+| Roblox R15 / R6 | `LowerTorso`, `UpperTorso`, `LeftUpperArm`, `Left Arm` |
+| Second Life / OpenSim | `mPelvis`, `mChest`, `mCollarLeft`, `mShoulderLeft`, `mKneeRight` |
+| Simple / generic rigs | `shoulderL`, `elbowL`, `wristL`, `hipL`, `kneeL`, `ankleL`, `chest` |
+| snake / kebab / lowercase | `left_arm`, `Left-Arm`, `leftarm` |
+
+Vendor prefixes (`mixamorig:`, `CC_Base_`, `Bip01 `, `j_`, Maya namespaces) and exporter de-dup suffixes (`_01`, `.001`) are stripped automatically and compose with everything above, so `CH_LeftLeg_03` and `DEF-upper_arm.L` both resolve.
+
+**What deliberately does *not* map**, because mapping it would be worse than falling back:
+
+- **Non-humanoid skeletons** (quadrupeds, prop rigs) — no safe correspondence exists.
+- **End effectors and leaf tips** (`HeadTop_End`, `LeftToe_End`, `LeftHandIndex4`) — the clip library drives no such bone.
+- **Metacarpals** (`Palm1.L`) — the canonical set has no metacarpal.
+- **Constraint-driven control rigs** (Auto-Rig-Pro / `cwf_` + `def_` + tracker families). Their deform bones are *leaves* hanging off tracker nodes — `def_arm_1.R` is not a child of `def_arm_0.R` — and glTF has no constraint system, so the Copy-Rotation/Damped-Track constraints that made the rig work in Blender are dropped at export. Rotating a mapped `def_` bone would move its own skin while the next segment stayed put, tearing the limb apart. These fall back to the default rig; the remedy is re-rigging through [workers/rig](../workers/rig), not name mapping.
+
+### Measuring coverage against real avatars
+
+Anticipating a convention is not the same as knowing it works. [scripts/audit-rig-coverage.mjs](../scripts/audit-rig-coverage.mjs) measures the canonicalizer against avatars actually stored in production and reports which rigs animate, which fall back, and — the actionable part — which unmapped bone names appear most often. Every name in that list is a candidate alias.
+
+It never downloads a whole GLB: the glTF JSON chunk always starts at byte 20, so an HTTP Range request for the first 256 KB yields the complete node and skin graph. A 40 MB avatar costs the same as a 2 MB one, which makes sweeping thousands of models practical.
+
+```bash
+node scripts/audit-rig-coverage.mjs # 300 newest avatars
+node scripts/audit-rig-coverage.mjs --source upload # one ingest lane
+node scripts/audit-rig-coverage.mjs --failing # dump every rig that does NOT animate,
+ # with the joint names it shipped
+node scripts/audit-rig-coverage.mjs --limit 2000 --json report.json
+```
+
+Needs `DATABASE_URL` and `S3_PUBLIC_DOMAIN` (both in `.env`). Output reports the share of skinned rigs that animate, the share with a complete leg chain, a per-ingest-lane breakdown, and the top unmapped joint names with a sample avatar for each. The Advanced Skeleton, Sketchfab `j_`, side-suffix leg, and Blender finger-chain mappings above were all found this way rather than guessed.
+
+---
+
## What we can do — capabilities
The same FBX/GLB/JSON plumbing is the foundation for the platform's generative 3D features. You don't need an FBX to start; you can generate the whole chain.
diff --git a/scripts/audit-rig-coverage.mjs b/scripts/audit-rig-coverage.mjs
index a54bcf259..577988cc2 100644
--- a/scripts/audit-rig-coverage.mjs
+++ b/scripts/audit-rig-coverage.mjs
@@ -19,6 +19,7 @@
* node scripts/audit-rig-coverage.mjs # 300 avatars, newest first
* node scripts/audit-rig-coverage.mjs --limit 2000 # bigger sweep
* node scripts/audit-rig-coverage.mjs --source upload # one ingest lane
+ * node scripts/audit-rig-coverage.mjs --failing # dump rigs that do NOT animate
* node scripts/audit-rig-coverage.mjs --json out.json # machine-readable report
*
* Requires DATABASE_URL and S3_PUBLIC_DOMAIN (both in .env).
@@ -44,12 +45,13 @@ const CONCURRENCY = 12;
const FETCH_TIMEOUT_MS = 20000;
function parseArgs(argv) {
- const out = { limit: 300, source: null, json: null };
+ const out = { limit: 300, source: null, json: null, failing: false };
for (let i = 2; i < argv.length; i++) {
const a = argv[i];
if (a === '--limit') out.limit = Number(argv[++i]);
else if (a === '--source') out.source = argv[++i];
else if (a === '--json') out.json = argv[++i];
+ else if (a === '--failing') out.failing = true;
else if (a === '--help' || a === '-h') out.help = true;
}
return out;
@@ -276,6 +278,23 @@ async function main() {
console.log('\n── canonical bones most often absent from production rigs ─');
console.table(topMissing.map(([bone, n]) => ({ bone, missingIn: n, of: skinned.length })));
+ // Every rig that still falls back to the default rig, with the joint names it
+ // actually shipped — the raw material for the next round of alias work.
+ if (args.failing) {
+ const failing = skinned.filter((r) => !r.score.animates);
+ console.log(`\n── rigs that do NOT animate (${failing.length}) ──────────────────────`);
+ for (const r of failing) {
+ const s = r.score;
+ console.log(
+ `\n${r.row.slug || r.row.id} [${r.row.source}] ` +
+ `${s.joints} joints, ${s.mapped} mapped, core ${s.core}/${CORE_BONES.length}` +
+ (s.generator ? ` — ${s.generator}` : ''),
+ );
+ console.log(` mapped: ${s.canonical.sort().join(', ') || '(none)'}`);
+ console.log(` unmapped: ${s.unmapped.slice(0, 24).join(', ')}${s.unmapped.length > 24 ? ` … +${s.unmapped.length - 24}` : ''}`);
+ }
+ }
+
if (errored.length) {
const byErr = new Map();
for (const r of errored) byErr.set(r.error, (byErr.get(r.error) || 0) + 1);
diff --git a/src/glb-canonicalize.js b/src/glb-canonicalize.js
index ee46ed134..9b631f796 100644
--- a/src/glb-canonicalize.js
+++ b/src/glb-canonicalize.js
@@ -25,6 +25,17 @@
// fall through unchanged — there's no safe automatic mapping for those, and
// callers fall back to a known-good rig rather than render a bind-pose T-pose.
//
+// Constraint-driven CONTROL RIGS also fall through on purpose. Blender rigs of
+// the Auto-Rig-Pro / "cwf_ + def_ + tracker" family export a deform layer whose
+// bones are LEAVES hanging off tracker nodes, not a chain: `def_arm_1.R` is not
+// a child of `def_arm_0.R`, it hangs off `c_arm_1_tracker.R`. In Blender those
+// trackers carry Copy-Rotation/Damped-Track constraints; glTF has no constraint
+// system, so they export as inert nodes. Rotating a mapped `def_` bone would move
+// its own skin while the next segment stayed put — the arm comes apart. Mapping
+// that layer is strictly worse than the default-rig fallback, so we do not.
+// Verified against real stored avatars; see scripts/audit-rig-coverage.mjs.
+// The remedy for these uploads is re-rigging (workers/rig), not name mapping.
+//
// This module is pure JS — works in Node (vitest) and in the browser. It
// rewrites the GLB JSON chunk in-place and repacks the binary container so
// the result is a valid GLB that swaps in 1:1 at the same R2 storage key.
@@ -141,6 +152,21 @@ const EXTRA_ALIASES = (() => {
// Second Life / OpenSim centre chain (`m`-prefixed body bones).
['mPelvis', 'Hips'], ['mTorso', 'Spine'], ['mChest', 'Spine1'],
['mNeck', 'Neck'], ['mHead', 'Head'],
+ // Advanced Skeleton (Maya) tags centre bones with an `_M` side token:
+ // `Root_M`, `Spine1_M`, `Spine2_M`, `Chest_M`, `Neck_M`, `Head_M`. Its LIMBS
+ // use `_L`/`_R` and already resolve through the sided table, which is why
+ // these rigs arrived with working arms and legs but no Hips — and no Hips
+ // means the retargeter has no root to anchor to, so nothing animated at all.
+ // AS numbers its spine from 1 at the base, one deeper than the canonical
+ // chain, hence the shift (`Spine1_M` → Spine, `Spine2_M` → Spine1).
+ ['root_M', 'Hips'], ['hip_M', 'Hips'], ['pelvis_M', 'Hips'],
+ ['spine1_M', 'Spine'], ['spine2_M', 'Spine1'], ['spine3_M', 'Spine2'],
+ ['chest_M', 'Spine2'], ['neck_M', 'Neck'], ['head_M', 'Head'],
+ // A zero-indexed spine base (`j_spine_0`, `spine_00`) is the first spine
+ // joint; the `_1`/`_2` links already resolve as Spine1/Spine2.
+ ['spine0', 'Spine'],
+ // UniGLTF/VRM-converter root joint.
+ ['hipMaster', 'Hips'],
]) put(v, c);
// Side-paired limb bones, given as the LEFT spelling + its canonical; the
@@ -196,6 +222,12 @@ const EXTRA_ALIASES = (() => {
['upperLegL', 'LeftUpLeg'], ['lowerLegL', 'LeftLeg'], ['lowerArmL', 'LeftForeArm'],
// The scapula is the clavicle in Advanced Skeleton / Daz-derived rigs.
['scapulaL', 'LeftShoulder'],
+ // Bare side-PREFIX anatomical joints (`j_L_hip`, `L_knee`, `R_ankle`). The
+ // suffix twins (`hipL`, `kneeL`, `ankleL`) exist above but never reach the
+ // prefix spelling. Same audit finding as the `j_` strip: Sketchfab-exported
+ // rigs using this convention mapped zero bones.
+ ['lHip', 'LeftUpLeg'], ['lKnee', 'LeftLeg'], ['lAnkle', 'LeftFoot'],
+ ['lElbow', 'LeftForeArm'], ['lWrist', 'LeftHand'], ['lToes', 'LeftToeBase'],
];
// Side-suffix finger chains, both conventions found in real uploaded avatars by
// scripts/audit-rig-coverage.mjs:
@@ -282,6 +314,17 @@ function _lookupBone(name) {
// tables below. Without this an entire CC export maps zero bones and lands in
// a bind-pose T-pose.
s = s.replace(/^CC_Base_/i, '');
+ // Sketchfab / Maya joint exports prefix every joint `j_` (`j_pelvis`, `j_L_hip`,
+ // `j_spine_0`). Stripping it leaves stems the canonical + sided tables resolve.
+ // The negative lookahead protects VRM/VRoid, whose `J_Bip_*` / `J_Sec_*` names
+ // are matched WHOLE by the alias table — stripping `J_` there would corrupt the
+ // key and drop an entire VRoid rig. Found by scripts/audit-rig-coverage.mjs:
+ // these rigs previously mapped ZERO bones and shipped a bind-pose T-pose.
+ s = s.replace(/^j_(?!bip|sec|adj)/i, '');
+ // UniGLTF / VRM-converter exports number every node and may flag it with `!`:
+ // `5.joint_HipMaster`, `10.!joint_LeftToe`, `95.!Root`. Strip the index, the
+ // flag, and the `joint_` noun so the residual bone name resolves.
+ s = s.replace(/^\d+\./, '').replace(/^!/, '').replace(/^joint[_:]/i, '');
// 3ds Max Biped names joints `Bip01 Pelvis`, `Bip001 L UpperArm`, … with a
// space- or underscore-separated `Bip<NN>` prefix (the digits identify the
// character). Strip it so `Pelvis`/`Spine`/`L UpperArm`/`L Thigh`/`L Calf`
diff --git a/tests/audit-rig-coverage.test.js b/tests/audit-rig-coverage.test.js
new file mode 100644
index 000000000..6f6f65f46
--- /dev/null
+++ b/tests/audit-rig-coverage.test.js
@@ -0,0 +1,150 @@
+/**
+ * Unit tests for the rig-coverage audit helpers (scripts/audit-rig-coverage.mjs).
+ *
+ * The audit is what turns "we think we support these rigs" into a measurement,
+ * so its two pure helpers need to be right: the Range-request GLB header parser
+ * (it must refuse anything it cannot fully read rather than report a truncated
+ * skeleton) and the rig scorer (it decides whether an avatar animates at all).
+ */
+
+import { describe, it, expect } from 'vitest';
+import { parseGlbJsonChunk, scoreRig } from '../scripts/audit-rig-coverage.mjs';
+
+const GLB_MAGIC = 0x46546c67;
+const CHUNK_TYPE_JSON = 0x4e4f534a;
+
+// Build just the leading bytes of a GLB — the audit only ever fetches this much.
+function buildHead(jsonObj, { magic = GLB_MAGIC, version = 2, chunkType = CHUNK_TYPE_JSON, truncate = 0 } = {}) {
+ let jsonBytes = new TextEncoder().encode(JSON.stringify(jsonObj));
+ const pad = (4 - (jsonBytes.length % 4)) % 4;
+ if (pad) {
+ const padded = new Uint8Array(jsonBytes.length + pad);
+ padded.set(jsonBytes);
+ for (let i = 0; i < pad; i++) padded[jsonBytes.length + i] = 0x20;
+ jsonBytes = padded;
+ }
+ const ab = new ArrayBuffer(20 + jsonBytes.length - truncate);
+ const dv = new DataView(ab);
+ const u8 = new Uint8Array(ab);
+ dv.setUint32(0, magic, true);
+ dv.setUint32(4, version, true);
+ dv.setUint32(8, 20 + jsonBytes.length, true);
+ dv.setUint32(12, jsonBytes.length, true);
+ dv.setUint32(16, chunkType, true);
+ u8.set(jsonBytes.subarray(0, jsonBytes.length - truncate), 20);
+ return ab;
+}
+
+// A skeleton with the given joint names, wired as one skin.
+function rigJson(names, extra = {}) {
+ return {
+ asset: { version: '2.0', ...(extra.generator ? { generator: extra.generator } : {}) },
+ nodes: names.map((name) => ({ name })),
+ skins: [{ joints: names.map((_, i) => i) }],
+ };
+}
+
+// A complete canonical humanoid — the shape every ingest lane should produce.
+const FULL_RIG = [
+ 'Hips', 'Spine', 'Spine1', 'Neck', 'Head',
+ 'LeftShoulder', 'LeftArm', 'LeftForeArm', 'LeftHand',
+ 'RightShoulder', 'RightArm', 'RightForeArm', 'RightHand',
+ 'LeftUpLeg', 'LeftLeg', 'LeftFoot', 'LeftToeBase',
+ 'RightUpLeg', 'RightLeg', 'RightFoot', 'RightToeBase',
+];
+
+describe('parseGlbJsonChunk', () => {
+ it('reads the JSON chunk out of a GLB head', () => {
+ const json = parseGlbJsonChunk(buildHead(rigJson(['Hips'])));
+ expect(json?.nodes?.[0]?.name).toBe('Hips');
+ });
+
+ it('returns null for anything that is not a GLB v2 JSON chunk', () => {
+ expect(parseGlbJsonChunk(null)).toBeNull();
+ expect(parseGlbJsonChunk(new ArrayBuffer(8))).toBeNull();
+ expect(parseGlbJsonChunk(buildHead(rigJson(['Hips']), { magic: 0xdeadbeef }))).toBeNull();
+ expect(parseGlbJsonChunk(buildHead(rigJson(['Hips']), { version: 1 }))).toBeNull();
+ expect(parseGlbJsonChunk(buildHead(rigJson(['Hips']), { chunkType: 0x004e4942 }))).toBeNull();
+ });
+
+ it('refuses a JSON chunk that runs past the fetched slice', () => {
+ // The whole point of the Range request is that we may not have the full
+ // chunk. Reporting a truncated skeleton would understate rig coverage, so
+ // a short read must be null (counted as an error) rather than parsed.
+ expect(parseGlbJsonChunk(buildHead(rigJson(FULL_RIG), { truncate: 40 }))).toBeNull();
+ });
+});
+
+describe('scoreRig', () => {
+ it('scores a complete canonical humanoid as animating with full legs', () => {
+ const s = scoreRig(rigJson(FULL_RIG, { generator: 'three.ws rig worker' }));
+ expect(s.skinned).toBe(true);
+ expect(s.animates).toBe(true);
+ expect(s.legs).toBe(6);
+ expect(s.core).toBe(9);
+ expect(s.unmapped).toEqual([]);
+ expect(s.generator).toBe('three.ws rig worker');
+ });
+
+ it('reports an unskinned model rather than throwing', () => {
+ const s = scoreRig({ asset: { version: '2.0' }, nodes: [{ name: 'Cube', mesh: 0 }] });
+ expect(s.skinned).toBe(false);
+ expect(s.animates).toBe(false);
+ expect(s.joints).toBe(0);
+ });
+
+ it('does not count a rig with no Hips as animating', () => {
+ // The Advanced Skeleton failure exactly: arms and legs resolve, but with no
+ // root the retargeter has nothing to anchor to and the avatar never moves.
+ const noHips = FULL_RIG.filter((b) => b !== 'Hips');
+ const s = scoreRig(rigJson(noHips));
+ expect(s.canonical).not.toContain('Hips');
+ expect(s.animates).toBe(false);
+ });
+
+ it('collects unmapped joint names for the alias-candidate report', () => {
+ const s = scoreRig(rigJson([...FULL_RIG, 'Weapon_R', '_rootJoint', 'Palm1.L']));
+ expect(s.unmapped.sort()).toEqual(['Palm1.L', 'Weapon_R', '_rootJoint']);
+ expect(s.animates).toBe(true); // scaffolding must not drag the score down
+ });
+
+ it('counts each canonical bone once even when two joints resolve to it', () => {
+ // `left_ankle` and `left_foot` both canonicalize to LeftFoot; the audit must
+ // not double-count and report more coverage than the rig actually has.
+ const s = scoreRig(rigJson(['Hips', 'left_ankle', 'left_foot']));
+ expect(s.canonical.filter((b) => b === 'LeftFoot')).toHaveLength(1);
+ });
+
+ it('scores the production rig families the audit unblocked', () => {
+ // Sketchfab j_ export: previously mapped zero bones.
+ const sketchfab = scoreRig(rigJson([
+ 'j_pelvis_05', 'j_spine_0_016', 'j_spine_1_017',
+ 'j_L_hip_06', 'j_L_knee_07', 'j_L_ankle_08',
+ 'j_R_hip_011', 'j_R_knee_012', 'j_R_ankle_013',
+ ]));
+ expect(sketchfab.canonical).toContain('Hips');
+ expect(sketchfab.canonical).toContain('LeftUpLeg');
+ expect(sketchfab.canonical).toContain('RightLeg');
+
+ // Advanced Skeleton: had limbs but no root, so it never animated.
+ const advSkel = scoreRig(rigJson([
+ 'Root_M_03', 'Spine1_M_04', 'Neck_M', 'Head_M',
+ 'Shoulder_L', 'Elbow_L', 'Wrist_L', 'Shoulder_R', 'Elbow_R', 'Wrist_R',
+ 'Hip_L', 'Knee_L', 'Ankle_L', 'Hip_R', 'Knee_R', 'Ankle_R',
+ ]));
+ expect(advSkel.canonical).toContain('Hips');
+ expect(advSkel.animates).toBe(true);
+ });
+
+ it('does not credit a constraint-driven control rig with coverage it cannot deliver', () => {
+ // Blender Auto-Rig-Pro style: the deform bones are leaves off tracker nodes,
+ // so driving them would tear the mesh. Falling back is correct — the score
+ // must reflect that, not claim the rig animates.
+ const s = scoreRig(rigJson([
+ 'cwf_pelvis_0', 'def_arm_0.R', 'def_arm_1.R', 'def_leg_0.L', 'def_leg_1.L',
+ 'fk_leg_0.L', 'c_arm_0_tracker.R', 'cwh_leg_softik_0.L',
+ ]));
+ expect(s.animates).toBe(false);
+ expect(s.core).toBe(0);
+ });
+});
diff --git a/tests/glb-canonicalize.test.js b/tests/glb-canonicalize.test.js
index df5bcc174..aa2c83794 100644
--- a/tests/glb-canonicalize.test.js
+++ b/tests/glb-canonicalize.test.js
@@ -482,6 +482,127 @@ describe('canonicalizeBoneName', () => {
expect(canonicalizeBoneName(input)).toBe(expected);
});
+ // Side-SUFFIX leg spellings. The arm twins (`forearm.L`, `upper_arm.L`) were
+ // covered by the Rigify fix; the LEG twins were not, and no side-PREFIX entry
+ // reaches `upperlegl`. Found in production by scripts/audit-rig-coverage.mjs:
+ // a Blender-exported rig lost both leg joints per side and glided on frozen legs.
+ it.each([
+ ['UpperLeg.L', 'LeftUpLeg'],
+ ['UpperLeg.R', 'RightUpLeg'],
+ ['LowerLeg.L', 'LeftLeg'],
+ ['LowerLeg.R', 'RightLeg'],
+ ['upper_leg.L', 'LeftUpLeg'],
+ ['lower_leg.R', 'RightLeg'],
+ ['LowerArm.L', 'LeftForeArm'],
+ ['Scapula_R', 'RightShoulder'],
+ ['Scapula_L', 'LeftShoulder'],
+ ])('maps side-suffix leg/arm spellings: %s → %s', (input, expected) => {
+ expect(canonicalizeBoneName(input)).toBe(expected);
+ });
+
+ // Side-suffix finger chains, both conventions seen in real uploaded avatars.
+ // The un-numbered spelling is the first phalanx; metacarpals (`Palm1.L`) stay
+ // unmapped because the canonical set has no metacarpal to drive.
+ it.each([
+ ['Index.L', 'LeftHandIndex1'],
+ ['Index2.L', 'LeftHandIndex2'],
+ ['Middle1.L', 'LeftHandMiddle1'],
+ ['Middle2.R', 'RightHandMiddle2'],
+ ['Thumb.L', 'LeftHandThumb1'],
+ ['Thumb2.L', 'LeftHandThumb2'],
+ ['Ring1.R', 'RightHandRing1'],
+ ['Pinky3.L', 'LeftHandPinky3'],
+ ['Little1.L', 'LeftHandPinky1'],
+ ['IndexFinger1_R', 'RightHandIndex1'],
+ ['MiddleFinger2_L', 'LeftHandMiddle2'],
+ ['ThumbFinger3_R', 'RightHandThumb3'],
+ ['RingFinger1_R', 'RightHandRing1'],
+ ['LittleFinger2_L', 'LeftHandPinky2'],
+ ['IndexFinger1_R_018', 'RightHandIndex1'], // + glTF de-dup suffix
+ ])('maps side-suffix finger chains: %s → %s', (input, expected) => {
+ expect(canonicalizeBoneName(input)).toBe(expected);
+ });
+
+ // Advanced Skeleton (Maya) tags centre bones `_M` and limbs `_L`/`_R`. The limbs
+ // already resolved through the sided table, so these rigs arrived with working
+ // arms and legs but NO Hips — and with no root to anchor, nothing animated.
+ it.each([
+ ['Root_M', 'Hips'],
+ ['Root_M_03', 'Hips'], // + glTF de-dup suffix
+ ['Spine1_M_04', 'Spine'], // AS numbers its spine one deeper than canonical
+ ['Spine2_M_05', 'Spine1'],
+ ['Spine3_M', 'Spine2'],
+ ['Neck_M', 'Neck'],
+ ['Head_M', 'Head'],
+ ['Hip_M', 'Hips'],
+ ])('maps Advanced Skeleton centre bones: %s → %s', (input, expected) => {
+ expect(canonicalizeBoneName(input)).toBe(expected);
+ });
+
+ // Sketchfab / Maya `j_`-prefixed joint exports. These previously mapped ZERO
+ // bones and shipped a bind-pose T-pose.
+ it.each([
+ ['j_pelvis_05', 'Hips'],
+ ['j_hips_00', 'Hips'],
+ ['j_L_hip_06', 'LeftUpLeg'],
+ ['j_L_knee_07', 'LeftLeg'],
+ ['j_L_ankle_08', 'LeftFoot'],
+ ['j_L_toe_010', 'LeftToeBase'],
+ ['j_R_hip_011', 'RightUpLeg'],
+ ['j_R_knee_012', 'RightLeg'],
+ ['j_spine_0_016', 'Spine'],
+ ['j_spine_1_017', 'Spine1'],
+ ['j_spine_2_018', 'Spine2'],
+ ])('maps Sketchfab j_-prefixed bones: %s → %s', (input, expected) => {
+ expect(canonicalizeBoneName(input)).toBe(expected);
+ });
+
+ // The `j_` strip must never touch VRM/VRoid, whose `J_Bip_*` names are matched
+ // WHOLE by the alias table — stripping `J_` there corrupts the key and drops the
+ // entire rig. This guards the negative lookahead.
+ it('does not let the j_ strip corrupt VRM J_Bip_ names', () => {
+ expect(canonicalizeBoneName('J_Bip_L_UpperArm')).toBe('LeftArm');
+ expect(canonicalizeBoneName('J_Bip_C_Hips')).toBe('Hips');
+ expect(canonicalizeBoneName('J_Bip_R_LowerLeg')).toBe('RightLeg');
+ expect(canonicalizeBoneName('J_Sec_Hair1_01')).toBeNull();
+ });
+
+ // UniGLTF / VRM-converter numbers every node and may flag it with `!`.
+ it.each([
+ ['5.joint_HipMaster', 'Hips'],
+ ['7.joint_LeftHip', 'LeftUpLeg'],
+ ['8.joint_LeftKnee', 'LeftLeg'],
+ ['9.joint_LeftFoot', 'LeftFoot'],
+ ['10.!joint_LeftToe', 'LeftToeBase'],
+ ])('maps UniGLTF numbered joint names: %s → %s', (input, expected) => {
+ expect(canonicalizeBoneName(input)).toBe(expected);
+ });
+
+ // Constraint-driven Blender control rigs (Auto-Rig-Pro / "cwf_ + def_ +
+ // tracker") MUST stay unmapped. Their deform bones are leaves hanging off
+ // tracker nodes — `def_arm_1.R` is not a child of `def_arm_0.R` — and glTF
+ // drops the constraints that made that work. Rotating a mapped def_ bone would
+ // move its own skin while the next segment stayed put, tearing the arm apart.
+ // The default-rig fallback is the correct outcome; re-rigging is the remedy.
+ it('leaves constraint-driven control-rig bones unmapped (mesh-tearing guard)', () => {
+ for (const name of [
+ 'def_arm_0.R', 'def_arm_1.R', 'def_leg_0.L', 'def_leg_1.L',
+ 'def_foot_0.L', 'def_toe_0.L', 'def_hand_0.R', 'def_shoulder_0.R',
+ 'cwf_leg_0.L', 'cwf_arm_1.R', 'fk_leg_0.L', 'c_arm_0_tracker.R',
+ 'cwh_leg_softik_0.L', 'cwf_arm_1_emulator.R',
+ ]) {
+ expect(canonicalizeBoneName(name), name).toBeNull();
+ }
+ });
+
+ it('leaves metacarpals and rig scaffolding unmapped', () => {
+ // Real unmapped names from the production audit that must STAY unmapped —
+ // mapping them would bind a clip track to the wrong joint.
+ for (const name of ['Palm1.L', 'Palm2.R', '_rootJoint', 'Bone', 'Body', 'Weapon_R', 'Hat_M']) {
+ expect(canonicalizeBoneName(name), name).toBeNull();
+ }
+ });
+
// Rigify / Blender anatomical arm chain: side is a `.L`/`.R` suffix and the
// forearm is spelled `forearm` (not `lowerarm`/`elbow`). The suffix normalises
// to `forearml`, which the side-prefix spellings never reach — so before the