1
votes

I am having trouble animating in Three.js, I'm not sure if the problem is in my code or my blender file.

Here is the code I use to load and animate the model, please tell me if there is something wrong with it.

loader.load('model.js', function (geometry, materials) {
 var mesh, material;

mesh = new THREE.SkinnedMesh(
geometry,
new THREE.MeshFaceMaterial(materials)
);

material = mesh.material.materials;

for (var i = 0; i < materials.length; i++) {
  var mat = materials[i];

  mat.skinning = true;
}

scene.add(mesh);

THREE.AnimationHandler.add(mesh.geometry.animation);

animation = new THREE.Animation(
mesh,
'ArmatureAction',
THREE.AnimationHandler.CATMULLROM
);

animation.play();

Thanks in Advance!

1
What is the problem? Does the model not show? Animation not start? Is the animation completely wrong? Almost right but stuttering? - Paul-Jan

1 Answers

1
votes

You could compare your code to Stemkoski here:

http://stemkoski.github.io/Three.js/Model-Animation-Control.html

It's a model from Blender to Threejs using javascript.