My application has some animated GLTF body models and I have been asked to see if it’s possible to update the animation by loading a secondary GLTF file that only contains an animation and apply that to the body models. I came up with this pattern:
gltfLoader.load('body.glb', function (body_gltf) {
let body_model = SkeletonUtils.clone(body_gltf.scene);
scene.add(body_model);
gltfLoader.load('animation.glb', function (animation_gltf) {
let animation_model = SkeletonUtils.clone(animation_gltf.scene);
let animation_object_group = new THREE.AnimationObjectGroup(animation_model);
animationMixer = new THREE.AnimationMixer(animation_object_group);
animationMixer.clipAction(animation_gltf.animations[0]).play();
animation_object_group.add(body_model);
});
});
I.E. add the animation GLTF and body GLTF to an animation group and play both using the animation from the animation GLTF clip. My test appears to work as expected but before I declare victory and ask the content folk to make some real animations, can anyone confirm that this is correct approach? I’ve been bitten in the past where a test works but then fails when real-world content is introduced.