Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/threejs_4_deno/src/math/Quaternion.d.ts>Quaternion

A simple transformation of three.js for use within a Deno workflow
Go to Latest
class Quaternion
import { Quaternion } from "https://deno.land/x/threejs_4_deno@v121/src/math/Quaternion.d.ts";

Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages.

Examples

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 );

Constructors

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

Properties

_onChangeCallback: Function
readonly
isQuaternion: true
w: number
x: number
y: number
z: number

Methods

_onChange(callback: Function): Quaternion
angleTo(q: Quaternion): number
clone(): this

Clones this quaternion.

copy(q: Quaternion): this

Copies values of q to this quaternion.

dot(v: Quaternion): number
equals(v: Quaternion): boolean
fromArray(array: number[], offset?: number): this

Sets this quaternion's x, y, z and w value from the provided array.

fromArray(array: ArrayLike<number>, offset?: number): this

Sets this quaternion's x, y, z and w value from the provided array-like.

Inverts this quaternion.

length(): number

Computes length of this quaternion.

lengthSq(): number

Multiplies this quaternion by b.

deprecated
multiplyVector3(v: any): any

Normalizes this quaternion.

set(
x: number,
y: number,
z: number,
w: number,
): Quaternion

Sets values of this quaternion.

setFromAxisAngle(axis: Vector3, angle: number): Quaternion

Sets this quaternion from rotation specified by axis and angle. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm. Axis have to be normalized, angle is in radians.

Sets this quaternion from rotation specified by Euler angles.

slerp(qb: Quaternion, t: number): Quaternion
toArray(array?: number[], offset?: number): number[]

Returns an array [x, y, z, w], or copies x, y, z and w into the provided array.

toArray(array: ArrayLike<number>, offset?: number): ArrayLike<number>

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

Static Methods

multiplyQuaternionsFlat(
dst: number[],
dstOffset: number,
src0: number[],
srcOffset: number,
src1: number[],
stcOffset1: number,
): number[]
slerpFlat(
dst: number[],
dstOffset: number,
src0: number[],
srcOffset: number,
src1: number[],
stcOffset1: number,
t: number,
): Quaternion