So I’ve always wondered if there was a simpler way to rotate a vector by Euler angles (for example to make moveWithCollisions behave like Space.LOCAL) than the Rube Goldberg contraption I like to use:
const vec = new Vector3(0, 0, velocity); const quat = Quaternion.FromEulerAngles(0, mesh.rotation.y, 0); let mat = Matrix.Zero(); quat.toRotationMatrix(mat); const newVec = Vector3.TransformCoordinates(vec, mat); mesh.moveWithCollisions(newVec);
I do this because neither Vector3.rotateByEulerAngles nor Matrix.FromEulerAngles are a thing.
It works and is still pretty fast, but is there any simpler way I’ve simply overlooked? Of course you can tuck it in a function, but it still bothers me somehow. There must be a better way to go about it, right?
edit: and of course you can build the rotation matrix yourself, with sines and cosines (IIRC), but that’s not really simpler!