Hello. I have a question. Can i load models with more than one animations? When i downloaded model from mixamo i have one animation, i can download other animations without skins but how add it to model? I see that model have array “animations” and i use index 0 for this one animation, can i add other animations to this array and use it for example with index 1, 2 ,3 … ? I want to have other animation when models standing other when i use arrow for example animation “run” and other… I saw loader md2 controls on three.js/examples but this models have array with a lot of animations, but i didnt find more models who have more than one animation. I want to use other animations when i use arrow. And sorry for my english but i still learning
Yes – Models can contain multiple animations, depending on the file format. Here’s another example: https://threejs.org/examples/#webgl_animation_skinning_morph
Ok, thanks. this is what i meant. But i have next questions. How to add controls to model. I try and i did controls forward and backward but i can’t add moveleft and moveright. I use model.position … and forward and backward is ok but left and right not, because i rotation model and when i press W the model goes straight because it has only rotations. And i try rotation camera but this doesnt work (i cant do this :/). three.js examples this is efect controls which i want to reach. But this is MD2CharacterCommplex and i don’t have a such model. Kai 'Opua so this is other controls efect which i would like to achive with camera rotations left and right. But how to do it?
But i have next questions.
Please just ask one question per post. Make a new post for new questions.
I see that model have array “animations” and i use index 0 for this one animation, can i add other animations to this array and use it for example with index 1, 2 ,3 … ?
Yes! Thats why its an array
Im not sure if FBX supports multiple animations, but GLTF sure does. Perhaps you could try this very neat guide for merging multiple keyframe animation files from mixamo into one skinned model in Blender. Then you can export it to GLTF and load it to Three.js
Ok i add animations to model as in the tutorial, in the gltf-viewier were error with load face textures, but model and animations work. And i add model to site but animations doesn’t work. Model is okey (without face but the rest is ok). I reading some artictle how to add animations but i cant. I use GLTFLoader first time. This is my code to add the model and animation, the console doesn’t display any errors:
var mesh;
var mesh2;
var loader = new THREE.GLTFLoader();
loader.load( ‘model.gltf’, handle_load);
function handle_load(gltf){
mesh = gltf.scene.children[0];
mesh2 = gltf.scene;
scene.add(mesh);
mesh.scale.set(0.5,0.5,0.5);
mixer = new THREE.AnimationMixer(mesh2);
action = mixer.clipAction( gltf.animations[0] );
action.play();
console.log(gltf);
}