three.js get right hand vector

Viewed 256

This gives me the forward vector of a Object3d

var forward = new THREE.Vector3();
object.getWorldDirection(forward); 

How do I get the right-hand side vector of the object (using Three.JS)?

1 Answers

My best advice is to NOT include 'three.js' in your Google search when looking help regarding three.js.

I excluded 'three.js' from my searches and found similar questions by people in a Unity community...

Knowing this I found a very simple (admittedly very hacky) solution which works in three.js.

Take a plain-old right-hand vector

var right = new THREE.Vector3( 1, 0,  0 );

And just "turn it" by the object's .quaternion value...

right.applyQuaternion( object.quaternion );

Any (normalized) direction relative to the object's rotation can be gleamed in this fashion

Example: http://jsfiddle.net/9Lzx683v/

Picture of a Cube, with six smaller cubes orbiting around it's XYZ axis directions

Related