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;
}
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})
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With