Reputation: 149
I'm working on a 3D project using THREE.JS and I want to animate a simple minecraft like character.
To do so, I exported one from Blender (with bones) and I render it with THREE.JS using the SkinnedMesh class.
I tried everything to make the arm of the mesh to move but I can't figure out how to do it. I tried changing rotation, position, matrix and also setting all flag to true (like matrixWorldNeedsUpdate but the arm did not move).
Here is a sample code:
var meshBody = new THREE.SkinnedMesh( geometry, materialTexture );
...
animate = function(){
meshBody.bones[3].rotation.z += 0.1
meshBody.bones[3].matrixAutoUpdate = true;
meshBody.bones[3].matrixWorldNeedsUpdate = true;
}
Upvotes: 10
Views: 5585
Reputation: 131
It uses quaternion rotations by default. Try to set meshBody.bones[i].useQuaternion = false;
and then change rotation's params or use quaternions instead.
Upvotes: 0
Reputation: 71
While constructing your mesh, make sure the skinning property of your material is set to true
, e.g.:
mesh = new THREE.SkinnedMesh (geometry,
new THREE.MeshBasicMaterial ({color: 0xaaaa00, skinning: true})
);
Upvotes: 6