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/Matrix4.d.ts>Matrix4

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

A 4x4 Matrix.

Examples

// Simple rig for rotating around 3 axes const m = new THREE.Matrix4(); const m1 = new THREE.Matrix4(); const m2 = new THREE.Matrix4(); const m3 = new THREE.Matrix4(); const alpha = 0; const beta = Math.PI; const gamma = Math.PI/2; m1.makeRotationX( alpha ); m2.makeRotationY( beta ); m3.makeRotationZ( gamma ); m.multiplyMatrices( m1, m2 ); m.multiply( m3 );

Constructors

new
Matrix4()

Properties

elements: number[]

Array with matrix values.

Methods

clone(): this
compose(
translation: Vector3,
rotation: Quaternion,
scale: Vector3,
): Matrix4

Sets this matrix to the transformation composed of translation, rotation and scale.

copy(m: Matrix4): this
deprecated
crossVector(v: any): void
decompose(
translation: Vector3,
rotation: Quaternion,
scale: Vector3,
): Matrix4

Decomposes this matrix into it's position, quaternion and scale components.

equals(matrix: Matrix4): boolean
extractBasis(
xAxis: Vector3,
yAxis: Vector3,
zAxis: Vector3,
): Matrix4

Copies the rotation component of the supplied matrix m into this matrix rotation component.

deprecated
flattenToArrayOffset(array: number[], offset: number): number[]
fromArray(array: number[], offset?: number): Matrix4

Sets the values of this matrix from the provided array.

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

Sets the values of this matrix from the provided array-like.

Resets this matrix to identity.

lookAt(
eye: Vector3,
target: Vector3,
up: Vector3,
): Matrix4

Constructs a rotation matrix, looking from eye towards center with defined up vector.

makeBasis(
xAxis: Vector3,
yAxis: Vector3,
zAxis: Vector3,
): Matrix4
makeOrthographic(
left: number,
right: number,
top: number,
bottom: number,
near: number,
far: number,
): Matrix4

Creates an orthographic projection matrix.

makePerspective(
left: number,
right: number,
bottom: number,
top: number,
near: number,
far: number,
): Matrix4

Creates a frustum matrix.

makePerspective(
fov: number,
aspect: number,
near: number,
far: number,
): Matrix4

Creates a perspective projection matrix.

makeRotationAxis(axis: Vector3, angle: number): Matrix4

Sets this matrix as rotation transform around axis by angle radians. Based on http://www.gamedev.net/reference/articles/article1199.asp.

makeRotationX(theta: number): Matrix4

Sets this matrix as rotation transform around x axis by theta radians.

makeRotationY(theta: number): Matrix4

Sets this matrix as rotation transform around y axis by theta radians.

makeRotationZ(theta: number): Matrix4

Sets this matrix as rotation transform around z axis by theta radians.

makeScale(
x: number,
y: number,
z: number,
): Matrix4

Sets this matrix as scale transform.

makeTranslation(
x: number,
y: number,
z: number,
): Matrix4

Sets this matrix as translation transform.

Multiplies this matrix by m.

Sets this matrix to a x b.

Multiplies this matrix by s.

deprecated
multiplyToArray(
r: number[],
): Matrix4

Sets this matrix to a x b and stores the result into the flat array r. r can be either a regular Array or a TypedArray.

deprecated
multiplyVector3(v: any): any
deprecated
multiplyVector3Array(array: number[]): number[]
deprecated
multiplyVector4(v: any): any
deprecated
rotateAxis(v: any): void

Multiplies the columns of this matrix by vector v.

set(
n11: number,
n12: number,
n13: number,
n14: number,
n21: number,
n22: number,
n23: number,
n24: number,
n31: number,
n32: number,
n33: number,
n34: number,
n41: number,
n42: number,
n43: number,
n44: number,
): Matrix4

Sets all fields of this matrix.

setPosition(
v: Vector3 | number,
y?: number,
z?: number,
): Matrix4

Sets the position component for this matrix from vector v.

toArray(array?: number[], offset?: number): number[]

Returns an array with the values of this matrix, or copies them into the provided array.

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

Copies he values of this matrix into the provided array-like.

Transposes this matrix.