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
float x = 100; | |
float y = 100; | |
float xSpeed = 1; | |
float ySpeed = 3.3; | |
void setup(){ | |
size(200,200); | |
smooth(); | |
background(255); | |
} |
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); |
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
//following two rotation functions are updated versions of code from: https://github.com/mrdoob/three.js/issues/1219 | |
//updated to work in latest versions (r52 tested) of THREE.js | |
// Rotate an object around an axis in object space | |
var rotationMatrix | |
function rotateAroundObjectAxis( object, axis, radians ) { | |
rotationMatrix = new THREE.Matrix4(); | |
rotationMatrix.makeRotationAxis( axis.normalize(), radians ); | |
object.matrix.multiplySelf( rotationMatrix ); // post-multiply | |
object.rotation.setEulerFromRotationMatrix(object.matrix, object.order); |
NewerOlder