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.
title: "Animation retargeting for any humanoid skeleton: how one clip library drives Mixamo, VRM, Unreal, Daz and Blender rigs in three.js" venue: IBM Community, Three.ws User Group (blog post) account: nich (nich8) description: "A long technical write-up on playing one pre-baked animation library on any humanoid rig with no allowlist: bone-name normalization, rest-pose correction, the retarget math derived, root motion, gates, testing, a runnable three.js implementation, and known failure cases." status: draft, not yet posted meta_title: "Animation Retargeting for Any Humanoid Skeleton in three.js" meta_description: "Play one animation library on any humanoid rig: bone-name normalization, A-pose vs T-pose correction, quaternion retargeting and root motion, with three.js code." slug: animation-retargeting-for-any-humanoid-skeleton featured_image: "https://three.ws/api/page-og?v=carbon&f=group&s=learn&p=%2Fanimations&t=Any%20skeleton%2C%20one%20animation%20library&d=Bone-name%20normalization%20and%20quaternion%20retargeting%20that%20play%20one%20clip%20library%20on%20Mixamo%2C%20VRM%2C%20Unreal%2C%20Daz%20and%20Blender%20rigs" framing_notes: | docs/ibm.md applies: three.ws is an IBM Business Partner; nothing it built is an IBM product or endorsed by IBM. This feature has no IBM component, so IBM appears only in the affiliation lines. The featured card uses ?v=carbon&f=group, whose footer reads "Three.ws User Group" instead of "Built on IBM watsonx.ai" (api/page-og.js, CARBON_FOOTERS); an older revision ignores f=, so confirm the live card first. No crypto-cluster content. Links and counts verified 2026-10-08; re-check library and test totals before posting.
Animation retargeting for any humanoid skeleton: one clip library, every rig, no allowlist
Posted in the Three.ws User Group on IBM Community.
An agent with a body has to move. An avatar that loads and stands in its bind pose, arms straight out, does not read as "idle". It reads as broken.
Early on we made a decision that turned out to be harder than it sounded: no rig allowlist. Any humanoid that arrives on three.ws, whether uploaded, generated and auto-rigged a minute ago, or imported from another tool, should idle, walk and gesture from one shared, pre-baked animation library. No per-avatar authoring, no "supported skeletons" page.
The library is not small. The curated manifest that drives agent gestures holds 113 clips, and the full library behind the animation gallery holds 3,343: 2,874 motion-capture clips and 469 generated by our own text-to-motion model (live counts from /animations/manifest.json and /api/animations/library on the day of writing). Every one was authored against a single reference skeleton, and every one has to play on rigs that skeleton has never met.
This post is the technique, written so a reader who never visits three.ws can build it. Section 13 is a complete, runnable three.js implementation you can point at public avatar files; section 14 is where it still fails.
The affiliation, stated exactly. three.ws is an IBM Business Partner. Nothing in this post is an IBM product, uses IBM technology, or is endorsed by IBM. It is three.ws engineering, shared because real-time embodied agents in the browser are what this group is about.
Contents
- A clip is a list of bone names
- One canonical skeleton
- Bone-name normalization
- When spelling is not enough: the clavicle collision
- Why copying rotations fails
- The world-delta retarget, derived
- Stance: re-aiming A-pose limbs
- Hips, root motion, units and the floor
- Legs
- Generated motion is just another rig
- Knowing when to stop: gates and fallbacks
- How we test a claim like "any skeleton"
- Try it yourself: a runnable three.js implementation
- Known limits and failure cases
- What this buys an agent, and an invitation
1. A clip is a list of bone names
In three.js, as in glTF and most engines, an animation clip does not contain a body. It contains tracks, each naming the node it drives and the property it writes: Hips.quaternion, LeftForeArm.quaternion, Hips.position. Our idle clip, as served in production, has 53 tracks: a quaternion track for each of 52 joints plus one position track on the hips.
On playback, THREE.PropertyBinding searches the scene graph for a node literally named LeftForeArm. If the avatar calls it lowerarm_l, the track binds to nothing. No error, just a frozen limb.
That is the visible problem and the easy one. Three distinct things differ between rigs:
| Failure class | What differs | What you see |
|---|---|---|
| Names | Each exporter spells joints its own way | Limbs that never move |
| Rest pose | T-pose vs A-pose, local axis conventions, baked armature rotations | Arms behind the back or overhead, a body tipped onto its back |
| Proportions and units | Bone lengths, height, metres vs centimetres, where the floor is | Bodies crushed into a heap, sunk into the floor, or flung into the air |
Most write-ups solve the first and gesture at the other two, yet the second causes the most visible failures and the third the most confusing ones.
2. One canonical skeleton
The foundation is boring on purpose: pick one skeleton, author everything against it, and treat every other rig as a translation problem.
Our canonical set is 52 joints (CANONICAL_BONES in src/glb-canonicalize.js): six for spine and head (Hips, Spine, Spine1, Spine2, Neck, Head), and per side a clavicle (LeftShoulder), LeftArm, LeftForeArm, LeftHand, fifteen finger joints, and four leg joints (LeftUpLeg, LeftLeg, LeftFoot, LeftToeBase). The reference body the clips are baked on is a photo-avatar rig, public at https://three.ws/avatars/cz.glb. Measured from the file, both upper arms point exactly horizontal, so it rests in a T-pose, with its hips 0.984 m above the floor.
Two consequences recur throughout:
- Fingers dominate the track count. 30 of the 53 tracks address a finger. A rig whose body maps perfectly but whose hands do not scores about 40% coverage, which is why hands get as much naming attention as hips.
- The reference rest pose is data. A clip stores absolute local rotations, meaningful only relative to the reference rest. A generator script extracts each canonical bone's local rest rotation, world rest rotation and world rest position from the reference file into a module, and sections 5 to 8 depend on it.
Clips are retargeted onto the reference offline (scripts/build-animations.mjs), so the browser does exactly one retarget: canonical skeleton to the avatar it was handed.
3. Bone-name normalization
The first job reduces every joint name an exporter might produce to one of the 52, or to null. One elbow, as the repo's canonicalizeBoneName reads it:
| Spelling | Source | Canonical |
|---|---|---|
mixamorig:LeftForeArm |
Mixamo | LeftForeArm |
lowerarm_l |
Unreal mannequin | LeftForeArm |
J_Bip_L_LowerArm |
VRoid (VRM 0.x) | LeftForeArm |
leftLowerArm |
VRM 1.0 | LeftForeArm |
lForeArm |
Daz / Genesis | LeftForeArm |
forearm.L |
Blender / Rigify | LeftForeArm |
左ひじ |
MikuMikuDance | LeftForeArm |
The module header documents 22 naming families and the code handles several more (Reallusion, 3ds Max Biped, Maya Advanced Skeleton, UniGLTF). Its three alias tables hold 736 distinct normalized spellings resolving onto the 52 joints, before prefix stripping multiplies the raw names that reach them.
The pipeline is a fixed sequence:
- Strip namespaces (
Character1:,mixamorig:, nesteda:b:). - Strip vendor prefixes:
mixamorigwith optional digits,Armature_, Rigify'sDEF-/ORG-/MCH-,CC_Base_,Bip01,j_, UniGLTF's5.!joint_. - Collapse separators and case, so
Left_Arm,left-armandupperarm.Leach become one lowercase key. - Look up three tables in priority order (canonical, then Unreal, then the extended table), so a lower table can never shadow a higher one.
- Retry once without a trailing
_joint(Apple pipelines) or an exporter de-dup suffix (Hips_01,Spine.001).
The final lookup, from _lookupBone:
const key = s.replace(/[-_.\s]+/g, '').toLowerCase();
return LOOKUP.get(key) ?? UNREAL_ALIASES.get(key) ?? EXTRA_ALIASES.get(key) ?? null;
Side-paired joints are written once as the left spelling, and the right twin is derived by swapping the side token (left to right, a leading l to r, a trailing L to R).
Lessons the tables taught us
Each is pinned by a test, and most were found the hard way.
- Your loader renames bones first. three.js's
GLTFLoaderpasses node names throughPropertyBinding.sanitizeNodeName, removing[ ] . : /.mixamorig:LeftArmarrives asmixamorigLeftArm;upper_arm.Lasupper_armL. Normalize the name in memory, not just the one in the file. - Priority order prevents collisions. Unreal's
spine_02collapses tospine02, indistinguishable from Mixamo'sSpineplus a_02de-dup suffix. Rather than guess, the Unreal spine is left out; its torso rides onHipswhile every limb maps. - Prefix strips need guards. Stripping Sketchfab's
j_made a family of rigs animate and corrupted VRoid'sJ_Bip_*names until the strip gained a negative lookahead:^j_(?!bip|sec|adj). - Some joints should never map. MikuMikuDance IK targets and twist bones stay unmapped: driving an IK target fights the chain it solves, and rotating a twist bone as the limb tears the mesh.
- Duplicates lose, they do not tie. When two joints still resolve to one name, the first (parent-most) wins and the other stays unmapped. Two nodes with one name make the binding pick arbitrarily.
- Fingers are not cosmetic. An otherwise perfect Unreal mannequin arrived with 30 of 52 joints unmapped because its fingers are
index_01_l. At 40% coverage it fell under the floor in section 11 and stood in its bind pose.
4. When spelling is not enough: the clavicle collision
Some names cannot be resolved by any table, because one word means different bones on different rigs:
- Rigify names the clavicle
shoulder.Land the upper armupper_arm.L. Both normalize toLeftArm, so the arm swings from the shoulder blade. - SMPL names the clavicle
left_collarand the upper armleft_shoulder. Both normalize toLeftShoulder, leavingLeftArmvacant. - Hobby rigs spell the upper arm
shoulderLwith no clavicle at all, so re-pointing that spelling globally would freeze their arms.
The repo resolves this by contention, not spelling (resolveArmShoulderCollisions): a target is reassigned only when two joints contest it and the sibling target is free, and hierarchy breaks ties, because the clavicle is the ancestor of the upper arm. The rule: names are evidence, hierarchy is proof.
5. Why copying rotations fails
Suppose every track now finds a joint. The obvious next step is to rename tracks and play. We measured what that does on public avatars, at the first frame of the idle. The number is the upper arm's angle below the outward horizontal in the frontal plane: 0 is a T-pose, 90 hangs straight down, above 90 has swung past vertical into the body, negative is above the shoulder.
| Avatar (family, rest stance) | Rest upper arm | Copy rotations as-is |
|---|---|---|
cz (reference, T-pose) |
0.0 | 72.2 / 76.9 (correct by definition) |
michelle (Mixamo, T-pose) |
1.0 | body tipped 87.6 degrees, lying down |
xbot (Mixamo, T-pose) |
0.0 | 1.4 / -6.1, arms stay out |
parametric-base (MakeHuman-derived, A-pose) |
50.4 | -96.3 / -82.9, arms overhead |
selfie-girl (photo-avatar rig, A-pose) |
54.7 | 72.2 / 76.9, correct |
michelle is a Mixamo export with 90 degrees baked onto the armature and the opposite on the hips; writing the clip's absolute hip rotation deletes the counter-rotation and the body tips over (our codebase still calls it "the lying-down bug"). xbot shares the reference's stance but not its local axes. selfie-girl shares the reference's axis conventions, so the copy happens to work. Hold on to that row.
6. The world-delta retarget, derived
The idea: a keyframe tells you how far each bone has turned in world space from the reference's rest. Replay that world-space turn on the target, starting from the target's own rest. Bone lengths, local axes and armature bakes cancel out.
Notation, for one canonical bone: Rs, Rt are its local rest rotations on source and target; WS, WT its world rest rotations (measured inside the model, excluding any placement on the root). So the parent's world rest is WSp = WS * Rs^-1 and WTp = WT * Rt^-1. During playback, q is the clip's local keyframe, Gs the source bone's animated world rotation, Gt the one we want.
Derivation. The source's world delta from rest is Gs * WS^-1. Apply it to the target's rest: Gt = Gs * WS^-1 * WT. A local rotation is the parent's world inverse times the bone's world, qt = Gtp^-1 * Gt. Apply the same rule to the parent and note Gs = Gsp * q:
qt = (Gsp * WSp^-1 * WTp)^-1 * Gsp * q * WS^-1 * WT
= WTp^-1 * WSp * q * WS^-1 * WT
= (Rt * WT^-1) * (WS * Rs^-1) * q * WS^-1 * WT
The animated parent cancels: the correction depends only on rest poses, so it is computed once per bone and applied to every keyframe:
L = Rt * WT^-1 * WS * Rs^-1
R = WS^-1 * WT
qt = L * q * R
That is bindCorrections in src/animation-retarget.js, and retarget() in section 13. Properties worth checking in your own version:
- Identity on the reference. When the target is the source,
LandRare identity. Bones within1e-6of identity are skipped, so the reference round-trips byte for byte. Make that a regression test. - It fixes the armature bake for free. On
michellethe hips share the reference's world rest,Rcollapses to identity, andLis exactly the counter-rotation the naive copy destroyed. - It beats the local-only shortcut. An earlier
L = Rt * Rs^-1handled hips and, per the code's own comment, skewed an A-pose clip's limbs about 30 degrees on a T-pose rig. - Read rest at the right moment. We once built
LandRfrom a rig a preview mixer had left mid-animation, and the second clip played with limbs skewed 60 to 90 degrees. Capture rest at attach time, in bind pose (tests/animation-retarget-rest-pollution.test.jspins it).
7. Stance: re-aiming A-pose limbs
The world-delta retarget preserves the delta from rest, which is right only when both rigs rest in the same stance. The reference rests in a T-pose and the idle drops each upper arm roughly 72 to 77 degrees. Apply that delta to an arm already resting 50 degrees down and it goes past vertical into the torso: on parametric-base the hand ends at 63% of the shoulder's distance from the body's centre line, inside the silhouette.
selfie-girl, which the naive copy got right, breaks under the principled formula: it was missing a term. Our 2026-10-03 fix adds it. Before replaying motion, each target limb is turned in its own world frame from its rest direction onto the reference's. Call that turn C for a bone and Cp for its canonical parent:
Gt = Gs * WS^-1 * C * WT
L = Rt * WT^-1 * Cp^-1 * WS * Rs^-1
R = WS^-1 * C * WT
With every C at identity this is section 6 unchanged, so T-pose rigs are unaffected. The details carry the quality:
- Only limbs are re-aimed: upper arm, forearm, thigh, shin, each defined by the direction to its canonical child. Spine, neck, head and clavicles keep their rest; those angles are anatomy, not stance.
- Shortest arc on top of the parent's turn, so the elbow only adds the bend its parent did not already remove, and nothing picks up a spurious twist.
- Everything else inherits its parent's turn, so hands stay rigid with forearms and fingers with hands.
- Feet keep their world rest, so a sole flat at rest stays flat whatever the shin was turned by.
The same six avatars, same frame:
| Avatar | Copy as-is | World delta only | World delta + re-aim |
|---|---|---|---|
cz (reference) |
72.2 / 76.9 | 72.2 / 76.9 | 72.2 / 76.9 |
michelle |
lying down | 73.8 / 79.0 | 72.2 / 76.9 |
xbot |
1.4 / -6.1 | 72.7 / 77.9 | 72.2 / 76.9 |
parametric-base |
-96.3 / -82.9 | 121.6 / 124.2 | 72.2 / 76.9 |
selfie-girl |
72.2 / 76.9 | 125.4 / 127.8 | 72.2 / 76.9 |
realistic-male (arms 10 degrees up at rest) |
25.3 / 12.6 | 62.0 / 66.9 | 72.2 / 76.9 |
Every rig now holds its arms exactly where the reference does. Our production retargeter and the standalone version in section 13 agree on all six rigs to the tenth of a degree.
8. Hips, root motion, units and the floor
Retarget motion, not structure. 41 of our 113 curated clips carry position, rotation and scale tracks for every bone (156 tracks). A bone's local position is the reference's bone length; copying it folds a different body into a heap while coverage reports 100%. So only joint rotations and the hip translation cross over. The filter in retargetClip:
const retargetable =
property === 'quaternion' || (property === 'position' && canonical === 'Hips');
The hip track needs three corrections, each a real bug:
- Frame. A Mixamo armature bakes a rotation above the hips, so the track is rotated by the inverse of the target's hips-parent world rotation (equivalently, the hips'
L) to travel the same world direction. - Height and units. The track is scaled by the target's rest hip height over the clip's baseline, taken in the hips-parent's local units, because the track writes a local position. A Mixamo armature exported at scale 0.01 works in centimetres; on our two Mixamo samples the factor is 104 and 106. Match world heights instead and the hips collapse to a centimetre of motion. The runtime clamps the factor to 0.2 to 200.
- The floor. Clips author the ground at y = 0, but viewers re-centre content and some exports put the floor below zero. Measured from world zero, small rigs were flung a body-height into the air (fixed 2026-07-25). The fix measures hip height above the model's own bounding-box floor and offsets the track by it.
On the five rigs we measured, centimetre-scale Mixamo armatures included, the hips land at the same relative height: 1.033 times rest height at the first frame of the walk.
9. Legs
A rig with frozen arms looks stiff. A rig with frozen legs glides: the hip track carries it across the floor while the knees never bend. Most leg failures were naming gaps, several found only by auditing real avatars (section 12): side-suffix spellings like UpperLeg.L (the arm twins existed, the leg twins did not), SMPL's left_hip / left_knee / left_ankle, Unreal's thigh_l / calf_l / ball_l, and bare prefixed joints like L_knee from Sketchfab exports.
Beyond names: thighs are re-aimed like arms (our A-pose samples splay theirs to 83 to 85 degrees below horizontal against the reference's 89.7), feet keep their world rest, and an upper-body gesture overlay (waving while walking) has every hip and leg track stripped so locomotion owns the lower body.
10. Generated motion is just another rig
This one is for the ML engineers. 469 clips came from a text-to-motion model whose rotations come from a fit against the HumanML3D skeleton's raw joint offsets, where a joint at rest yields the identity quaternion. The names matched our canonical set (a strict 23-bone body subset, no fingers), so the clips looked compatible. They were not.
The basis was different. Library rotations are relative to the reference's rest, generated ones to the generator's. On the legs the gap is half a turn: about 176 degrees on each upper leg in an authored clip (the reference's leg bones rest flipped in their local frame), about 29 in a generated one. All 133 generated clips published before 2026-09-09 played with the feet folded over the body.
The rest shape was different too. HumanML3D's raw offsets are directions, not a posed human: arms hang straight down and the head sits straight forward of the neck. Every generated clip played with the head thrown back about 90 degrees and the arms raised. The 2026-09-18 conversion aligns the rest shapes joint by joint: a fixed rotation A_j carries the reference's rest directions for j's children onto the source's, and
q_t = (Wt_p^-1 * A_p^-1) * q_s * (A_j * Wt_j)
With every A at identity this is the plain basis change. It is section 6's family of correction, applied at ingest.
The quality gate could not see it, and that is the lesson. Every rule measured a clip against itself, and a clip in the wrong basis is perfectly self-consistent. The gate now checks the basis directly (head clearance over the feet plus the upper legs' angle from identity; either alone misfires on a push-up). Getting the basis right raised the honest accept rate: re-gating the same 882 takes moved acceptance from 47% to 71%, and frame-discontinuity rejections fell from 86 to 10. Evaluate a motion model in the basis it will be played in.
11. Knowing when to stop: gates and fallbacks
"No allowlist" does not mean "animate everything". A retargeter that animates a rig badly does more damage than one that declines. Each gate exists because its absence shipped something ugly.
Gate 1: is this a drivable humanoid? AnimationManager.supportsCanonicalClips() is true only for a model with a skinned mesh and at least eight canonical bones. From src/animation-manager.js:
function _modelSupportsCanonicalClips(model) {
let hasSkinnedMesh = false;
const canonical = new Set();
model.traverse((node) => {
if (node.isSkinnedMesh) hasSkinnedMesh = true;
if (node.name) {
const c = canonicalizeBoneName(node.name);
if (c) canonical.add(c);
}
});
return hasSkinnedMesh && canonical.size >= MIN_CANONICAL_BONES;
}
The skinned-mesh check stops a prop with a node named Head; eight bones is the least that reads as a performance.
Gate 2: coverage. A clip builds an action only when at least 50% of its retargetable tracks find a home.
Gate 3: did it tip the body over? Before an action plays, the runtime samples the hip orientation of its first frame. Healthy rigs rest within about 18 degrees of vertical; past 45 the clip is disabled for that rig and reported once, and the avatar keeps its current clip (or the looping fallback) instead.
Gate 4: body maps, arms do not. If neither upper arm maps, the clip still drives torso and legs while the arms stay out. relaxUndrivenArms finds those arms geometrically, with no names: a bone pointing mostly sideways and not steeply vertical is a stuck upper arm, swung down to rest. It never touches an arm the clip drives.
Gate 5: still pictures are checked too. Since 2026-10-01, thumbnails are posed with one held frame of the idle, then verified: both upper arms must end at least 30 degrees below horizontal, else the geometric swing is tried, else the model renders as authored and is reported. A dry run caught one production rig posed with both arms overhead.
What falls through on purpose:
- Non-humanoids. Quadrupeds and prop rigs have no safe mapping; the sample fox in section 13 maps zero bones and is shown as authored. A model with its own baked animation plays that instead.
- Constraint-driven control rigs. Some Blender rigging add-ons export deform bones as leaves hanging off tracker nodes. glTF has no constraints, so rotating a mapped deform bone moves its own skin while the next segment stays put and the arm comes apart. The remedy is re-rigging, not renaming.
- Humanoids with meaningless names. The glTF sample "Cesium Man" names joints like
Skeleton_arm_joint_L__4_, maps zero canonical bones, and falls back.
For a humanoid under the joint floor, the verdict from our browser-side checker Rig Doctor is that agent surfaces substitute the default avatar. The rule underneath: never play the library onto a skeleton it cannot drive.
Two lanes, one answer. At ingest, canonicalizeGLBBones rewrites joint names inside the GLB's JSON chunk and folds the Mixamo armature bake into the children, then verifies the fold by comparing every joint's world matrix and reverting if any element moved more than 1e-4. A GLB loaded straight into the viewer skips ingest, so the runtime rules must accept raw and loader-sanitized names alike.
12. How we test a claim like "any skeleton"
Spelling cases. tests/glb-canonicalize.test.js holds 477 cases, and the six retargeting suites 649 (as of 2026-10-08). The control-rig exclusion has a test that fails if someone "fixes" it.
A sweep that measures motion, not mapping. A rig can map its hips and still animate as a torso with four frozen sticks, and every unit test stays green. scripts/animation-dignity-sweep.mjs renames one synthetic skeleton ten ways (Mixamo, photo-avatar rig, Unreal, VRM 0.x / VRoid, VRM 1.0, Daz / Genesis 8, MakeHuman, Blender / Rigify, the simple shoulderL rig, anatomical Latin), so any difference is naming alone. It drives the real idle and walk through both lanes and measures limb swing and end-effector world travel, which catches a name-mapped bone whose parent chain broke. Run today: 10 of 10 conventions move both arms and both legs on both lanes.
An audit against real avatars. scripts/audit-rig-coverage.mjs sweeps stored avatars cheaply with a trick worth borrowing: a GLB's JSON chunk always starts at byte 20, so an HTTP Range request fetches the skeleton without the mesh. Its first run found five broken conventions, and fixing them moved avatars animating with a complete leg chain from 93.0% to 95.9% for uploads and 93.8% to 97.9% for imports, over 400 avatars per lane (2026-07-29).
The reference round-trip, the upright bound and the rest-pollution regression each have their own test too. What these layers caught, from the commit log:
| Date | What broke | What changed |
|---|---|---|
| 2026-07-21 | Rigify arms swung from the shoulder blade | Side-suffix forearms; clavicle collision pass |
| 2026-07-25 | Small rigs flung into the air | Hip height measured above the model's floor |
| 2026-07-29 | Five conventions broken on real avatars | Advanced Skeleton, j_, side-suffix legs, fingers, UniGLTF |
| 2026-08-21 | MikuMikuDance rigs mapped zero joints | Japanese names; IK and twist bones excluded |
| 2026-09-14 | Apple, Kinect, MediaPipe joints unmapped | _joint retry; Kinect and MediaPipe tables |
| 2026-09-18 | Generated clips: heads thrown back | Per-joint rest-shape conversion |
| 2026-10-01 | Thumbnails and embeds showed T-poses | Posed thumbnails with an arms-down check |
| 2026-10-03 | A-pose arms through the torso | Limb rest direction re-aimed |
13. Try it yourself: a runnable three.js implementation
Below is a standalone version of the technique, about 140 lines, depending only on three. It implements sections 3, 6, 7 and 8 with a deliberately small alias table, and omits fingers, the clavicle collision and the floor offset. It is not our production module, but on the six avatars above it produces the same arm angles to the tenth of a degree. Save it as retarget-lite.js.
// retarget-lite.js: play one clip library on many humanoid rigs (tested on three.js r184).
import { AnimationClip, Quaternion, Vector3 } from 'three';
// 1. Names. Every spelling is reduced to one key, then looked up.
const norm = (s) => s.replace(/[-_.\s]+/g, '').toLowerCase();
const CANONICAL = [
'Hips', 'Spine', 'Spine1', 'Spine2', 'Neck', 'Head',
'LeftShoulder', 'LeftArm', 'LeftForeArm', 'LeftHand',
'RightShoulder', 'RightArm', 'RightForeArm', 'RightHand',
'LeftUpLeg', 'LeftLeg', 'LeftFoot', 'LeftToeBase',
'RightUpLeg', 'RightLeg', 'RightFoot', 'RightToeBase',
];
const ALIASES = new Map(CANONICAL.map((c) => [norm(c), c]));
const alias = (spelling, canonical) => ALIASES.set(norm(spelling), canonical);
alias('pelvis', 'Hips'); // Unreal mannequin
alias('J_Bip_C_Hips', 'Hips'); // VRoid
for (const [S, s] of [['Left', 'l'], ['Right', 'r']]) {
const v = S.toLowerCase(), L = S[0];
// Unreal mannequin: upperarm_l, lowerarm_l, thigh_l, calf_l, ball_l
alias(`clavicle_${s}`, `${S}Shoulder`); alias(`upperarm_${s}`, `${S}Arm`);
alias(`lowerarm_${s}`, `${S}ForeArm`); alias(`hand_${s}`, `${S}Hand`);
alias(`thigh_${s}`, `${S}UpLeg`); alias(`calf_${s}`, `${S}Leg`);
alias(`foot_${s}`, `${S}Foot`); alias(`ball_${s}`, `${S}ToeBase`);
// VRM 1.0: leftUpperArm, leftLowerLeg, leftToes
alias(`${v}UpperArm`, `${S}Arm`); alias(`${v}LowerArm`, `${S}ForeArm`);
alias(`${v}UpperLeg`, `${S}UpLeg`); alias(`${v}LowerLeg`, `${S}Leg`);
alias(`${v}Toes`, `${S}ToeBase`);
// VRoid (VRM 0.x): J_Bip_L_UpperArm
alias(`J_Bip_${L}_Shoulder`, `${S}Shoulder`); alias(`J_Bip_${L}_UpperArm`, `${S}Arm`);
alias(`J_Bip_${L}_LowerArm`, `${S}ForeArm`); alias(`J_Bip_${L}_Hand`, `${S}Hand`);
alias(`J_Bip_${L}_UpperLeg`, `${S}UpLeg`); alias(`J_Bip_${L}_LowerLeg`, `${S}Leg`);
alias(`J_Bip_${L}_Foot`, `${S}Foot`); alias(`J_Bip_${L}_ToeBase`, `${S}ToeBase`);
// Blender / Rigify side suffix: upper_arm.L, forearm.L, shin.L
alias(`upper_arm.${L}`, `${S}Arm`); alias(`forearm.${L}`, `${S}ForeArm`);
alias(`shin.${L}`, `${S}Leg`); alias(`toe.${L}`, `${S}ToeBase`);
}
export function canonicalName(raw) {
const s = String(raw || '')
.replace(/^(?:[A-Za-z]\w*:)+/, '') // namespaces: mixamorig:, Character1:
.replace(/^mixamorig\d*_?/i, '') // GLTFLoader strips the colon: mixamorigHips
.replace(/^(DEF|ORG|MCH)[-_]/i, ''); // Rigify layers
const hit = ALIASES.get(norm(s));
if (hit) return hit;
const deduped = s.replace(/[._]\d+$/, ''); // exporter de-dup: Hips_01, Spine.001
return deduped !== s ? ALIASES.get(norm(deduped)) ?? null : null;
}
// 2. Rest pose. Read once, while the model is still in its bind pose.
const LIMB_CHILD = {
LeftArm: 'LeftForeArm', LeftForeArm: 'LeftHand', RightArm: 'RightForeArm', RightForeArm: 'RightHand',
LeftUpLeg: 'LeftLeg', LeftLeg: 'LeftFoot', RightUpLeg: 'RightLeg', RightLeg: 'RightFoot',
};
export function captureRest(root) {
root.updateMatrixWorld(true);
const bones = new Map(); // canonical name -> Bone, first (parent-most) wins
root.traverse((n) => {
const c = n.isBone && canonicalName(n.name);
if (c && !bones.has(c)) bones.set(c, n);
});
const nameOf = new Map([...bones].map(([c, b]) => [b, c]));
const local = new Map(), world = new Map(), parent = new Map(), dir = new Map();
for (const [c, bone] of bones) {
local.set(c, bone.quaternion.clone());
const w = bone.quaternion.clone(); // rotation in the model frame, root excluded
for (let n = bone.parent; n && n !== root; n = n.parent) w.premultiply(n.quaternion);
world.set(c, w);
for (let n = bone.parent; n && n !== root; n = n.parent) {
if (nameOf.has(n)) { parent.set(c, nameOf.get(n)); break; }
}
}
const at = (b) => root.worldToLocal(b.getWorldPosition(new Vector3()));
for (const [c, child] of Object.entries(LIMB_CHILD)) {
if (!bones.has(c) || !bones.has(child)) continue;
const d = at(bones.get(child)).sub(at(bones.get(c)));
if (d.lengthSq() > 1e-12) dir.set(c, d.normalize());
}
const hips = bones.get('Hips');
return { bones, local, world, parent, dir, hipLength: hips ? hips.position.length() : 0 };
}
// 3. Stance. Turn each target limb from its rest direction onto the source's.
function restTurns(src, tgt) {
const depth = (c) => { let d = 0; for (let p = tgt.parent.get(c); p; p = tgt.parent.get(p)) d++; return d; };
const turns = new Map();
for (const c of [...tgt.bones.keys()].sort((a, b) => depth(a) - depth(b))) {
if (c === 'LeftFoot' || c === 'RightFoot') continue; // a flat sole stays flat
const inherited = turns.get(tgt.parent.get(c)) || null;
const from = tgt.dir.get(c), to = src.dir.get(c);
if (!from || !to) { if (inherited) turns.set(c, inherited); continue; }
const d = from.clone();
if (inherited) d.applyQuaternion(inherited);
const own = d.dot(to) > 1 - 1e-6 ? null : new Quaternion().setFromUnitVectors(d, to);
const turn = own && inherited ? own.multiply(inherited) : own || inherited;
if (turn) turns.set(c, turn);
}
return turns;
}
// 4. The clip. Rotations and root translation only: bone offsets are structure.
export function retarget(clip, src, tgt, { reaim = true, minCoverage = 0.5 } = {}) {
const turns = reaim ? restTurns(src, tgt) : new Map();
const inv = (q) => q.clone().invert();
const tracks = [];
let total = 0;
for (const track of clip.tracks) {
const dot = track.name.lastIndexOf('.');
const c = canonicalName(track.name.slice(0, dot));
const prop = track.name.slice(dot + 1);
if (!c || !(prop === 'quaternion' || (prop === 'position' && c === 'Hips'))) continue;
total++;
const node = tgt.bones.get(c);
if (!node || !src.local.has(c)) continue;
const Rs = src.local.get(c), WS = src.world.get(c), Rt = tgt.local.get(c), WT = tgt.world.get(c);
const C = turns.get(c), Cp = turns.get(tgt.parent.get(c));
// L = Rt * WT^-1 * Cp^-1 * WS * Rs^-1 R = WS^-1 * C * WT
const L = Rt.clone().multiply(inv(WT));
if (Cp) L.multiply(inv(Cp));
L.multiply(WS).multiply(inv(Rs));
const out = track.clone();
out.name = `${node.name}.${prop}`;
const v = out.values;
if (prop === 'quaternion') {
const R = inv(WS);
if (C) R.multiply(C);
R.multiply(WT);
const q = new Quaternion();
for (let i = 0; i < v.length; i += 4) {
q.fromArray(v, i).premultiply(L).multiply(R).toArray(v, i);
}
} else {
// Root motion: re-express in the target hips-parent frame, then scale by
// the ratio of rest hip offsets (covers height and centimetre armatures).
const k = src.hipLength > 0 ? tgt.hipLength / src.hipLength : 1;
const p = new Vector3();
for (let i = 0; i < v.length; i += 3) {
p.fromArray(v, i).applyQuaternion(L).multiplyScalar(k).toArray(v, i);
}
}
tracks.push(out);
}
if (total === 0 || tracks.length / total < minCoverage) return null;
return new AnimationClip(`${clip.name}@${tgt.bones.get('Hips')?.name ?? 'rig'}`, clip.duration, tracks);
}
The hip correction reuses the hips' L (section 8's frame fix), and the hipLength ratio covers both height and centimetre armatures, assuming the hips' parent sits at floor level.
Step 1: check the names. In a folder with three installed (npm i three, and "type": "module" in package.json), run node names.mjs:
import { canonicalName } from './retarget-lite.js';
for (const raw of [
'mixamorig:LeftForeArm', // Mixamo, as authored
'mixamorigLeftForeArm', // the same bone after GLTFLoader sanitizes it
'lowerarm_l', // Unreal mannequin
'J_Bip_L_LowerArm', // VRoid (VRM 0.x)
'leftLowerArm', // VRM 1.0
'forearm.L', // Blender / Rigify
'DEF-forearm.L', // Rigify deform layer
'Character1:LeftForeArm', // Maya HumanIK namespace
'LeftForeArm_01', // exporter de-dup suffix
'b_Hip_01', // a fox: no humanoid meaning
]) console.log(raw.padEnd(24), '->', canonicalName(raw));
mixamorig:LeftForeArm -> LeftForeArm
mixamorigLeftForeArm -> LeftForeArm
lowerarm_l -> LeftForeArm
J_Bip_L_LowerArm -> LeftForeArm
leftLowerArm -> LeftForeArm
forearm.L -> LeftForeArm
DEF-forearm.L -> LeftForeArm
Character1:LeftForeArm -> LeftForeArm
LeftForeArm_01 -> LeftForeArm
b_Hip_01 -> null
Step 2: one idle, five bodies. The avatars and the idle clip are public on three.ws and served with Access-Control-Allow-Origin: *, so this page works from any static server (python3 -m http.server beside retarget-lite.js). It retargets one clip from the reference onto four humanoids and a fox.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>One idle, many skeletons</title>
<style>html, body { margin: 0; height: 100%; background: #f4f4f4; } canvas { display: block; }</style>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
}
}
</script>
</head>
<body>
<script type="module">
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';
import { captureRest, retarget } from './retarget-lite.js';
const BASE = 'https://three.ws';
const loader = new GLTFLoader().setMeshoptDecoder(MeshoptDecoder);
const load = (url) => loader.loadAsync(url).then((gltf) => gltf.scene);
// The source: the rig the clip was authored on, and the clip itself.
const [reference, idleJson] = await Promise.all([
load(`${BASE}/avatars/cz.glb`),
fetch(`${BASE}/animations/clips/idle.json`).then((r) => r.json()),
]);
const src = captureRest(reference);
const idle = THREE.AnimationClip.parse(idleJson);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(innerWidth, innerHeight);
document.body.append(renderer.domElement);
const scene = new THREE.Scene();
scene.add(new THREE.HemisphereLight(0xffffff, 0x666666, 3));
const camera = new THREE.PerspectiveCamera(35, innerWidth / innerHeight, 0.1, 100);
camera.position.set(0, 1.1, 7);
camera.lookAt(0, 0.9, 0);
const targets = ['michelle', 'xbot', 'parametric-base', 'selfie-girl', 'fox'];
const mixers = [];
window.results = [];
for (const [i, name] of targets.entries()) {
const model = await load(`${BASE}/avatars/${name}.glb`);
const tgt = captureRest(model); // in the bind pose, before anything plays
const clip = retarget(idle, src, tgt);
const height = new THREE.Box3().setFromObject(model).getSize(new THREE.Vector3()).y;
model.scale.setScalar(1.7 / height); // display only: the root is outside the rest frame
model.position.x = (i - (targets.length - 1) / 2) * 1.3;
scene.add(model);
window.results.push({ name, mapped: tgt.bones.size, drivable: !!clip });
if (!clip) continue; // not a humanoid we can drive: leave it exactly as authored
const mixer = new THREE.AnimationMixer(model);
mixer.clipAction(clip).play();
mixers.push(mixer);
}
const timer = new THREE.Timer();
renderer.setAnimationLoop((time) => {
timer.update(time);
const dt = timer.getDelta();
for (const m of mixers) m.update(dt);
renderer.render(scene, camera);
});
window.ready = true;
</script>
</body>
</html>
You should see four humanoids idling with arms relaxed (two Mixamo T-pose rigs with centimetre armatures, two A-pose rigs), and a fox standing exactly as authored. window.results reports 22 mapped bones per humanoid and zero for the fox. We ran this page in headless Chromium before publishing: no console errors or warnings, and the screenshot showed exactly that.
Then pass { reaim: false } to watch the A-pose bodies push their arms into their torsos, swap in walk.json for root motion and legs, or point it at your own rigs (the source must be the rig your clips were authored on, in bind pose). The full alias tables in src/glb-canonicalize.js are Apache-2.0.
Prefer no code? Rig Doctor runs the production canonicalizer on a GLB you drop in: it names the convention (it fingerprints 15), scores torso, arms, hands and legs against the 52-joint skeleton, repairs names, and previews the result, in the browser with nothing uploaded. The Animation Studio plays the rest of the library on a loaded avatar.
14. Known limits and failure cases
- Forward axis is assumed. Source and target must face the same way in model space. Most glTF exports agree; not all.
- A full name map is not a good performance. The stance turn aligns a bone's direction, not the roll around it, so unusual bone roll still shows. The mesh follows its skin weights: a sleeve weighted to the wrong bone bends with that bone.
- No inverse kinematics. Rotation retargeting preserves angles, not contacts: feet can slide on different leg proportions, and a clap can miss on a wide costume.
- Unmapped intermediate joints ride along. A five-joint spine bends only at mapped joints, and forearm twist bones do not twist.
- Fingers are fragile. Finger rest poses vary most (flat, curled, splayed), and the stance turn does not apply to them.
- Meaningless names and control rigs fall back (section 11). Correct, but some well-made characters need a re-export.
- Section 13 is a teaching implementation: no fingers, clavicle resolution, floor offset or fallen-pose guard. Correct for what it covers.
15. What this buys an agent, and an invitation
For an agent framework, a universal body changes what the runtime can promise. Every body is expressive on arrival: a generated, auto-rigged avatar's first frame is an idle, not a T-pose. Animation becomes a vocabulary: our agents express themselves through named slots (idle, wave, nod, think, point, celebrate and more) and tools declare animation hints, which only works if every clip plays on every body; the slots are in the animation runtime docs. Generated motion slots in: once converted into the library's basis, a prompt becomes a gesture every avatar can perform.
If your stack uses a convention our tables do not know, the first-contribution guide walks through teaching the retargeter a new rig, using the MikuMikuDance change as the worked example. Source is Apache-2.0 at github.com/nirholas/three.ws.
What we would most like this group to argue about:
- Names or geometry? Everything above starts from names and uses hierarchy and geometry only to break ties. Cesium Man has no usable names at all. Is anyone matching joints purely from topology and rest geometry robustly enough to trust in production?
- Where should IK enter? Rotation-only retargeting is cheap and runs once per rig; contact preservation needs a per-frame solve. For browser avatars, where would you draw the line: feet, feet and hands, or a learned retargeter?
- What basis does your motion model emit? Section 10 cost us a library's worth of clips. If you train text-to-motion models, how do you validate the output's rest basis before it reaches a renderer?
three.ws is an IBM Business Partner. The animation system described here is three.ws engineering; it is not an IBM product, uses no IBM technology, and is not endorsed by IBM.