Skip to content

Commit 37fb6d8

Browse files
committed
feat: export animation
1 parent f0a5477 commit 37fb6d8

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/lib/babylon/export.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,21 @@ function restructureForVrm(json: any): void {
297297
}
298298
}
299299

300+
/**
301+
* Removes any embedded animations from the glTF. Babylon's serializer often
302+
* includes the avatar's current animation track, but our mergeSkeletons remaps
303+
* joint indices and leaves animation channels pointing at the original nodes —
304+
* UniVRM and UniGLTF then crash with IndexOutOfRangeException on import.
305+
*
306+
* The VRM is meant as a static rig that animation hosts (VMagicMirror,
307+
* VSeeFace, Unity etc) drive with their own motion data, so dropping the
308+
* embedded animations is the correct choice and matches the juanma reference,
309+
* which ships with no animations either.
310+
*/
311+
function stripAnimations(json: any): void {
312+
if (json.animations) delete json.animations
313+
}
314+
300315
/**
301316
* Tags every material as KHR_materials_unlit so VRM viewers render the avatar
302317
* with the flat / cartoon look DCL uses, instead of PBR metallic shading.
@@ -505,6 +520,7 @@ export async function exportVRM(scene: Scene): Promise<Blob> {
505520
rebakeBindPose(json, binChunk, snapshotByName, boneParentNameByName)
506521
mergeSkeletons(json)
507522
restructureForVrm(json)
523+
stripAnimations(json)
508524
applyUnlitMaterials(json)
509525
injectVRMExtension(json)
510526

0 commit comments

Comments
 (0)