I created a model in blender, rigged it and created some simple animation, after which i exported to .dae. The animation looks fine when i open the .dae file, however after i loaded it into browser using three.js, the animation is not working.
The model is still loaded, but it looks like the one in blender edit mode. (with arm stretched out and standing straight), and there is no animation at all even though there is no error in console port.
new THREE.ColladaLoader().load('../models/myworkblend3.dae',
function(collada) {
monster = collada.scene;
monster.scale.set(100, 100, 100);
monster.rotation.x = -Math.PI/2;
monster.rotation.z = Math.PI/2;
skin = collada.skins[ 0 ];
monster.updateMatrix();
scene.add(monster);
// enable shadows for an object
monster.castShadow = true;
monster.receiveShadow = true;
});
and the animation code is
function animate() {
requestAnimationFrame( animate );
if ( t > 60 ) t = 0;
if ( skin ) {
for ( var i = 0; i < skin.morphTargetInfluences.length; i++ ) { // length is 101
skin.morphTargetInfluences[ i ] = 0;
}
// enable the keyframe one by one
skin.morphTargetInfluences[ Math.floor( t ) ] = 1;
t += 0.5; //this prolongs the waiting time
}
render();
}
Any help would be sincerely appreciated! Thanks