Hi guys.I’m working on a scene that may needs large amount of animating models.So I have to use instancedMesh.But i’ve encountered some transforming issues.Below is a instancing ferrari demo, i tried to make the wheel rotating normally( around it’s center) but failed.since the sub-meshes are already instanced, the origin of itself is unaccessable.So the typical “pivot” way cannot work.Is there any chance to solve this?Thanks.
Instancing Ferrari Demo
Just figured that out.The instancedMesh’s sub-instance is already “pivoted”, so the solution is to “unPivot”.Based on some soucecode in InstancedMesh: Add bounding volumes. by Mugen87 · Pull Request #21507 · mrdoob/three.js · GitHub
that it is possible to get the sub-instance’s volume center as offset
.And the “unpivot” way is adding a parent pivot to the dummy object,and:
- sub the dummy’s position with
offset
- add the parentDummy’s position with
offset
- update parentDummy’s rotation in the loop
- updating instanceMatrix with dummy’s matrixWorld
here is a working example:
Instancing Ferrari Demo Justified
It would be nice if anyone has other better solution…