How to make appropriate calculation of bone rotation?

Hi,

I’m trying to realize how to make appropriate rotation calculation for one of an instance of InstancedMesh with respect to some bone of a SkinnedMesh that is rotated and moved (i.e. I’m trying to “attach” that instance to certain bone)… localToWorld helps a lot with position, but rotation is quite complicated. In my case bone is a hand and I need to rotate hammer in an apropriate way with respect of rotation of a hand. If there is a way to attach instance of an instanced mesh to a bone it will be wonderful, but I doubt it Just apply rotation of a bone rotates hammer incorrectly…I think it is due to different translate settings.

1 Like

What you want is to get world transform (rotation, position,scale) of the bone, not just the position.

In three.js, and in majority of other libraries, such transform is represented by a 4d matrix (Matrix4). What you want to do is to obtain world transform matrix of the bone, and then de-compose it into principle components (rotation, position, scale). That should solve your problem.

You can get all of the remaining info from reading the documentation. Good luck!

Thanks for an answer! I’ve tried updated matrixWorld before but it seems that scale of bone that was applied hides the hammer inside of a hand and I didn’t saw the result correctly :)… I’ve found it only when multiplyScalar(3)… and realized also that there is wierd things in animation with scale…it’s changing during animation like jumping and also my hammer jumps in scale… if I put scale of a hammer not world scale of a bone then my hammer increases in scale continuously to giant scales… I don’t know why…

worldMatrix of a bone works fine, but there is a need to change position/rotation of a hammer a little bit to get right position near the bone… and if modify position/rotation incremently hammer is moving/rotating not same with bone… how to get this worlds point near the bone ?

UPD Finally, All works fine. just get local position of a bone and change it as needed then localToWorld()