I’m working on some open source code and this is working version. There is a comment says parent the Blender mesh to an empty so it can be moved around
. Basically wrapped with an empty Mesh.
What I’m trying to do is - not wrapping with an empty mesh just directly add the model to the scene and play animation on it. With my version animation does NOT work. I’d like to understand why it does not work.
Working version;
// parent the Blender mesh to an empty so it can be moved around
function animator( gltf, scene, meshName ) {
const container = new THREE.Mesh();
const model = gltf.scene;
const mesh = model.getObjectByName( meshName ).clone();
const mixer = new THREE.AnimationMixer( model );
container.add( mesh );
container.mixer = mixer;
scene.add( container );
return container;
}
My version;
function animator( gltf, scene, meshName ) {
const model = gltf.scene;
const mesh = model.getObjectByName( meshName ).clone();
const mixer = new THREE.AnimationMixer( model );
mesh.mixer = mixer;
scene.add( mesh );
return mesh;
}