I have an object that is using a quaternion. This quaternion gets updated on a user’s keypress to allow the object to rotate it’s internal axis. The rotations are working fantastic. When in it’s default state (before a user adjusts the rotation) my quaternion reads w:1, x:0, y:0, z:0
I want this object to always move forward in space via it’s internal z-axis – THREE.Vector3(0,0,-1). How can I use the quat to know where it’s z-axis is and move it forward?
For example – when my quaternion reads w:0.7, x:0.7, y:0, z:0 – the object is rotated to have it’s z-axis pointed upward. Is there a way to move an object via it’s internal axis?
Here’s a jsfiddle example: http://bitly.com/RXPy5w – I want the square to always move forward in relation to it’s z-axis
Any help would be greatly appreciated.
All you have to do is add the following line in your render loop:
Updated Fiddle: http://jsfiddle.net/Lc8gH/21/ Enjoy!
And by the way, you can’t “translate a quaternion”. Keep studying until you understand what this code is doing.