Skip to content

Instantly share code, notes, and snippets.

@clavis-magna
Created November 25, 2012 10:49
Show Gist options
  • Save clavis-magna/4143073 to your computer and use it in GitHub Desktop.
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)
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