Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Quaternion

Implementation of a quaternion. Quaternions are used in three.js to represent rotations. See the ngx3js docs page for details.

Examples

misc / animation / groups misc / animation / keys physics / ammo / break webgl / buffergeometry / instancing / interleaved webgl / custom / attributes / points3

Code Example

const quaternion = new THREE.Quaternion();
quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
const vector = new THREE.Vector3( 1, 0, 0 );
vector.applyQuaternion( quaternion );

Hierarchy

  • Quaternion

Index

Constructors

constructor

  • new Quaternion(x?: number, y?: number, z?: number, w?: number): I3JS.Quaternion

Properties

Readonly isQuaternion

isQuaternion: true

w

w: number

w coordinate

default

1

x

x: number

x coordinate

default

0

y

y: number

y coordinate

default

0

z

z: number

z coordinate

default

0

Methods

_onChange

_onChangeCallback

  • _onChangeCallback(): void

angleTo

clone

conjugate

copy

dot

equals

  • Compares the .x, .y, .z and .w properties of v to the equivalent properties of this quaternion to determine if they represent the same rotation.

    Parameters

    • v: I3JS.Quaternion

      Quaternion that this quaternion will be compared to.

    Returns boolean

fromBufferAttribute

identity

invert

length

  • length(): number

lengthSq

  • lengthSq(): number
  • Computes the squared Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector. This can be useful if you are comparing the lengths of two quaternions, as this is a slightly more efficient calculation than .length().

    Returns number

multiply

multiplyQuaternions

multiplyQuaternionsFlat

  • multiplyQuaternionsFlat(dst: number[], dstOffset: number, src0: number[], srcOffset: number, src1: number[], stcOffset1: number): number[]

normalize

premultiply

random

rotateTowards

set

setFromAxisAngle

setFromEuler

setFromRotationMatrix

setFromUnitVectors

slerp

  • Parameters

    • qb: I3JS.Quaternion

      interpolation factor in the closed interval [0, 1]. Handles the spherical linear interpolation between quaternions. t represents the amount of rotation between this quaternion (where t is 0) and qb (where t is 1). This quaternion is set to the result. Also see the static version of the slerp below. // rotate a mesh towards a target quaternion mesh.quaternion.slerp( endQuaternion, 0.01 );

    • t: number

    Returns I3JS.Quaternion

slerpFlat

  • slerpFlat(dst: number[], dstOffset: number, src0: number[], srcOffset: number, src1: number[], stcOffset1: number, t: number): I3JS.Quaternion
  • Parameters

    • dst: number[]

      The output array.

    • dstOffset: number

      An offset into the output array.

    • src0: number[]

      The source array of the starting quaternion.

    • srcOffset: number
    • src1: number[]

      The source array of the target quatnerion.

    • stcOffset1: number
    • t: number

      Normalized interpolation factor (between 0 and 1). Like the static slerp method above, but operates directly on flat arrays of numbers.

    Returns I3JS.Quaternion

slerpQuaternions

toArray

  • toArray(array?: number[], offset?: number): number[]
  • toArray(array: ArrayLike<number>, offset?: number): ArrayLike<number>
  • Sets this quaternion's .x, .y, .z and .w properties from an array.

    Parameters

    • Optional array: number[]

      array of format (x, y, z, w) used to construct the quaternion.

    • Optional offset: number

      an offset into the array.

    Returns number[]

  • Copies x, y, z and w into the provided array-like.

    Parameters

    • array: ArrayLike<number>

      array-like to store the quaternion to.

    • Optional offset: number

      (optional) optional offset into the array.

    Returns ArrayLike<number>

    The provided array-like.

Generated using TypeDoc