Search code examples
javascriptthree.jsquaternions

three.js: how do you rotate a mesh that has already been created?


I would like to rotate a mesh by applying a quaternion.

The Vector3 prototype has a method named applyQuaternion (api link), so one could in theory map this function over all the vertices of the geometry inside the mesh. Is this the way to do it?

Why don't the Mesh constructor have a function like applyQuaternion? That would make a lot of sense, to me at least.


Solution

  • Good day, as a Mesh is based off an Object3D we see the applyMatrix method therein. Digging into the Matrix we find a makeRotationFromQuaternion method. This chain should get the results you desire.