JSPM

three-quaternion-from-normal

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q27082F
  • License MIT

Builds a ThreeJS quaternion from a normal vector

Package Exports

  • three-quaternion-from-normal

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (three-quaternion-from-normal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 = require('three-quaternion-from-normal');

// Say we want mesh to point from A to B point
const A = new THREE.Vector3(1, 0, 0);
const B = new THREE.Vector3(2, 5, -1);

// Get normal A->B
const normal = B.clone().sub(A).normalize();

// Get orientation
const quaternion = quaternionFromNormal(normal);

// Apply orientation to mesh
mesh.quaternion.copy(quaternion);

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.