Hello,
I’m trying to put 2 collada objects and animate them at the same time but it doesn’t work.
Can someone tell me why, with my code, only one collada is animated ?
Here is my function to add an animated object :
function createObjectAnimate(object,src,size1, size2, size3, posX,posY, posZ, rotation,audio){
var loader = new THREE.ColladaLoader();
loader.load( src, function ( collada ) {
var animations = collada.animations;
var object = collada.scene;
object.scale.set(size1,size2,size3);
object.position.x = posX;
object.position.y = posY;
object.position.z = posZ;
object.rotation.y = rotation;
if(audio)
object.add(audio);
object.traverse( function ( node ) {
if ( node.isSkinnedMesh ) {
node.frustumCulled = false;
}
} );
mixer = new THREE.AnimationMixer( object );
mixer.clipAction( animations[0] ).play();
scene.add( object );
object.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.castShadow = true;
child.receiveShadow = true;
}
});
});
}
and here is my call function code :
createObjectAnimate(boy,'boy.dae',1, 1, 1, 0,20,310, Math.PI,createSound('cry.mp3'));
createObjectAnimate(monster,'monster.dae',2, 2, 2, 0, 20, 0, 0,createSound('hit.mp3'));
So, there is only the monster who is animated.
Any idea ?
Thank you.