three-quaternion-from-normal
Builds a ThreeJS quaternion from a normal vector.
This is useful for getting meshes to 'point' in the direction of a vector.
const quaternionFromNormal = ; // Say we want mesh to point from A to B pointconst A = 1 0 0;const B = 2 5 -1; // Get normal A->Bconst normal = B; // Get orientationconst quaternion = ; // Apply orientation to meshmeshquaternion;
Install
Use npm to install.
npm install three-quaternion-from-normal --save
Usage
quat = quaternionFromNormal(normal, [quaternionTarget])
Builds a quaternion from the normal
(a normalized THREE.Vector3), storing the result in quaternionTarget
(a THREE.Quaternion) or creating a new quaternion object if no target is specified.
The quaternion target is returned.
License
MIT, see LICENSE.md for details.