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.

fix(motion-glb): rebase pre-fix clips off the generator's basis before baking

nirholasc5aa9f543a85
diff --git a/api/_lib/motion-glb.js b/api/_lib/motion-glb.js
index 4dba7f9c9..a75dc9cdd 100644
--- a/api/_lib/motion-glb.js
+++ b/api/_lib/motion-glb.js
@@ -53,7 +53,7 @@ import { AnimationClip, Quaternion } from 'three';
import { canonicalizeBoneName } from '../../src/glb-canonicalize.js';
import { clipHipBaselineY, retargetClip } from '../../src/animation-retarget.js';
-import { flattenRootDrift } from './motion-seed.js';
+import { flattenRootDrift, needsRebase, rebaseToCanonicalRest } from './motion-seed.js';
const GLB_MAGIC = 0x46546c67; // 'glTF'
const CHUNK_JSON = 0x4e4f534a; // 'JSON'
@@ -266,7 +266,12 @@ export function bakeMotionGlb({ rig, clip: input, name, flatten = true, retarget
if (!input || !Array.isArray(input.tracks) || input.tracks.length === 0) {
throw new Error('clip has no tracks');
}
- const drift = flatten ? flattenRootDrift(input) : { clip: input, removed: 0 };
+ // Clips published before the rest-basis fix carry the generator's identity
+ // basis and would bake with the legs folded over the body, so they are
+ // converted here. A clip stamped with the library basis is left alone, which
+ // keeps this idempotent once the repair pass has republished the set.
+ const rebased = needsRebase(input) ? rebaseToCanonicalRest(input).clip : input;
+ const drift = flatten ? flattenRootDrift(rebased) : { clip: rebased, removed: 0 };
const { json, bin } = readGlbChunks(rig);
const nodes = Array.isArray(json.nodes) ? json.nodes : [];
if (nodes.length === 0) throw new Error('rig has no nodes');