Reputation: 1522
I am using the latest version (to post date) of ThreeJS. I am trying to import a ThreeJS Blender Model with rigged animations. All tutorials I have come across online have mentioned either THREE.AnimationHandler
or THREE.Animation
. But I get errors saying no such contructor exists.
When looking through the documentation online I can see them:
Neither states they are depricated. When looking through the src file I don't see them there either. Am I missing something here?
Upvotes: 1
Views: 2115
Reputation: 3431
I've faced same problem couple days ago. I found out that new animation system has been implemented in recent releases. This article helped me - New skinned mesh animation system in three.js. It seems like docs have not been updated yet.
So in my case I needed to import model in json
and launch animation, code looked like this:
var loader = new THREE.ObjectLoader(),
clock = new THREE.Clock(),
mixer;
loader.load('models.json', function (object) {
// Get object animation
var sceneAnimationClip = object.animations[0];
// Create animation mixer and pass object to it
mixer = new THREE.AnimationMixer(object);
// Create animation action and start it
var sceneAnimation = mixer.clipAction(sceneAnimationClip);
sceneAnimation.play();
scene.add(object);
render()
});
function render() {
requestAnimationFrame(render);
// Update animation
var delta = clock.getDelta();
if( mixer ) {
mixer.update( delta );
}
renderer.render(scene, camera);
}
Upvotes: 3