Created
November 25, 2012 10:49
-
-
Save clavis-magna/4143073 to your computer and use it in GitHub Desktop.
Find World Vector3 from Local Vector3 of rotated object (for example, to cast a ray forward of a moving and rotating object)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var X_AXIS = new THREE.Vector3(1,0,0); //arbitrary vector local to object | |
var focusVector = new THREE.Vector3(); | |
var localRot = new THREE.Quaternion(); | |
//convert local rotation from Euler to Quaternion and store it in localRot | |
localRot.setFromEuler(object.mesh.rotation); | |
//multiply to quat by the vector we want to cast the ray towards (locally to the casting object) | |
//store resulting vector in focusVector | |
localRot.multiplyVector3(X_AXIS, focusVector); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment