A specific object in my program is utilizing a quaternion for rotation. Whenever a user presses a key, the quaternion is updated to rotate the object along its internal axis. The rotations are working flawlessly. In its default state, before any user input, the quaternion values are w:1, x:0, y:0, z:0
My goal is to ensure that this object always moves forward in space according to its internal z-axis - THREE.Vector3(0,0,-1). How can I utilize the quaternion to determine the position of its z-axis and facilitate forward movement?
For instance, when the quaternion reads w:0.7, x:0.7, y:0, z:0, the object's z-axis is oriented upwards due to rotation. Is there a method to move an object based on its internal axis orientation?
You can view an example on jsfiddle: . My objective is for the square to consistently move forward relative to its z-axis.
I would greatly appreciate any guidance or assistance. Thank you!