Options
All
• Public
• Public/Protected
• All

# Namespace mat4

## Functions

#### Parameters

• ##### out: mat4

the receiving matrix

the first operand

the second operand

#### Returns mat4

out

• Calculates the adjugate of a mat4

#### Parameters

• ##### out: mat4

the receiving matrix

the source matrix

out

### clone

• Creates a new mat4 initialized with values from an existing matrix

#### Parameters

matrix to clone

#### Returns mat4

a new 4x4 matrix

### copy

• copy(out: mat4, a: ReadonlyMat4): mat4
• Copy the values from one mat4 to another

#### Parameters

• ##### out: mat4

the receiving matrix

the source matrix

out

### create

• Creates a new identity mat4

#### Returns mat4

a new 4x4 matrix

### determinant

• Calculates the determinant of a mat4

#### Parameters

the source matrix

#### Returns number

determinant of a

### equals

• Returns whether or not the matrices have approximately the same elements in the same position.

#### Parameters

The first matrix.

The second matrix.

#### Returns boolean

True if the matrices are equal, false otherwise.

### exactEquals

• Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)

#### Parameters

The first matrix.

The second matrix.

#### Returns boolean

True if the matrices are equal, false otherwise.

### frob

• Returns Frobenius norm of a mat4

#### Parameters

the matrix to calculate Frobenius norm of

#### Returns number

Frobenius norm

### fromQuat

• fromQuat(out: mat4, q: ReadonlyQuat): mat4
• Calculates a 4x4 matrix from the given quaternion

#### Parameters

• ##### out: mat4

mat4 receiving operation result

Quaternion to create matrix from

out

### fromQuat2

• fromQuat2(out: mat4, a: ReadonlyQuat2): mat4
• Creates a new mat4 from a dual quat.

#### Parameters

• ##### out: mat4

Matrix

Dual Quaternion

#### Returns mat4

mat4 receiving operation result

### fromRotation

• Creates a matrix from a given angle around a given axis This is equivalent to (but much faster than):

``````mat4.identity(dest);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

the angle to rotate the matrix by

the axis to rotate around

out

### fromRotationTranslation

• fromRotationTranslation(out: mat4, q: any, v: ReadonlyVec3): mat4
• Creates a matrix from a quaternion rotation and vector translation This is equivalent to (but much faster than):

``````mat4.identity(dest);
mat4.translate(dest, vec);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

• ##### q: any

Rotation quaternion

Translation vector

out

### fromRotationTranslationScale

• Creates a matrix from a quaternion rotation, vector translation and vector scale This is equivalent to (but much faster than):

``````mat4.identity(dest);
mat4.translate(dest, vec);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

• ##### q: any

Rotation quaternion

Translation vector

Scaling vector

out

### fromRotationTranslationScaleOrigin

• Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin This is equivalent to (but much faster than):

``````mat4.identity(dest);
mat4.translate(dest, vec);
mat4.translate(dest, origin);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
mat4.translate(dest, negativeOrigin);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

• ##### q: any

Rotation quaternion

Translation vector

Scaling vector

The origin vector around which to scale and rotate

out

### fromScaling

• fromScaling(out: mat4, v: ReadonlyVec3): mat4
• Creates a matrix from a vector scaling This is equivalent to (but much faster than):

``````mat4.identity(dest);
mat4.scale(dest, dest, vec);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

Scaling vector

out

### fromTranslation

• fromTranslation(out: mat4, v: ReadonlyVec3): mat4
• Creates a matrix from a vector translation This is equivalent to (but much faster than):

``````mat4.identity(dest);
mat4.translate(dest, dest, vec);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

Translation vector

out

### fromValues

• fromValues(m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): mat4
• Create a new mat4 with the given values

#### Parameters

• ##### m00: number

Component in column 0, row 0 position (index 0)

• ##### m01: number

Component in column 0, row 1 position (index 1)

• ##### m02: number

Component in column 0, row 2 position (index 2)

• ##### m03: number

Component in column 0, row 3 position (index 3)

• ##### m10: number

Component in column 1, row 0 position (index 4)

• ##### m11: number

Component in column 1, row 1 position (index 5)

• ##### m12: number

Component in column 1, row 2 position (index 6)

• ##### m13: number

Component in column 1, row 3 position (index 7)

• ##### m20: number

Component in column 2, row 0 position (index 8)

• ##### m21: number

Component in column 2, row 1 position (index 9)

• ##### m22: number

Component in column 2, row 2 position (index 10)

• ##### m23: number

Component in column 2, row 3 position (index 11)

• ##### m30: number

Component in column 3, row 0 position (index 12)

• ##### m31: number

Component in column 3, row 1 position (index 13)

• ##### m32: number

Component in column 3, row 2 position (index 14)

• ##### m33: number

Component in column 3, row 3 position (index 15)

A new mat4

### fromXRotation

• fromXRotation(out: mat4, rad: number): mat4
• Creates a matrix from the given angle around the X axis This is equivalent to (but much faster than):

``````mat4.identity(dest);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

the angle to rotate the matrix by

out

### fromYRotation

• fromYRotation(out: mat4, rad: number): mat4
• Creates a matrix from the given angle around the Y axis This is equivalent to (but much faster than):

``````mat4.identity(dest);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

the angle to rotate the matrix by

out

### fromZRotation

• fromZRotation(out: mat4, rad: number): mat4
• Creates a matrix from the given angle around the Z axis This is equivalent to (but much faster than):

``````mat4.identity(dest);
``````

#### Parameters

• ##### out: mat4

mat4 receiving operation result

the angle to rotate the matrix by

out

### frustum

• frustum(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): mat4
• Generates a frustum matrix with the given bounds

#### Parameters

• ##### out: mat4

mat4 frustum matrix will be written into

• ##### left: number

Left bound of the frustum

• ##### right: number

Right bound of the frustum

• ##### bottom: number

Bottom bound of the frustum

• ##### top: number

Top bound of the frustum

• ##### near: number

Near bound of the frustum

• ##### far: number

Far bound of the frustum

out

### getRotation

• getRotation(out: quat, mat: ReadonlyMat4): quat
• Returns a quaternion representing the rotational component of a transformation matrix. If a matrix is built with fromRotationTranslation, the returned quaternion will be the same as the quaternion originally supplied.

#### Parameters

• ##### out: quat

Quaternion to receive the rotation component

Matrix to be decomposed (input)

out

### getScaling

• getScaling(out: vec3, mat: ReadonlyMat4): vec3
• Returns the scaling factor component of a transformation matrix. If a matrix is built with fromRotationTranslationScale with a normalized Quaternion paramter, the returned vector will be the same as the scaling vector originally supplied.

#### Parameters

• ##### out: vec3

Vector to receive scaling factor component

Matrix to be decomposed (input)

out

### getTranslation

• getTranslation(out: vec3, mat: ReadonlyMat4): vec3
• Returns the translation vector component of a transformation matrix. If a matrix is built with fromRotationTranslation, the returned vector will be the same as the translation vector originally supplied.

#### Parameters

• ##### out: vec3

Matrix to be decomposed (input)

out

### identity

• Set a mat4 to the identity matrix

#### Parameters

• ##### out: mat4

the receiving matrix

out

### invert

• invert(out: mat4, a: ReadonlyMat4): mat4
• Inverts a mat4

#### Parameters

• ##### out: mat4

the receiving matrix

the source matrix

out

### lookAt

• Generates a look-at matrix with the given eye position, focal point, and up axis. If you want a matrix that actually makes an object look at another object, you should use targetTo instead.

#### Parameters

• ##### out: mat4

mat4 frustum matrix will be written into

Position of the viewer

Point the viewer is looking at

vec3 pointing up

out

### mul

• Multiplies two mat4s

#### Parameters

• ##### out: mat4

the receiving matrix

the first operand

the second operand

out

### multiply

• Multiplies two mat4s

#### Parameters

• ##### out: mat4

the receiving matrix

the first operand

the second operand

out

### multiplyScalar

• multiplyScalar(out: mat4, a: ReadonlyMat4, b: number): mat4
• Multiply each element of the matrix by a scalar.

#### Parameters

• ##### out: mat4

the receiving matrix

the matrix to scale

• ##### b: number

amount to scale the matrix's elements by

#### Returns mat4

out

• Adds two mat4's after multiplying each element of the second operand by a scalar value.

#### Parameters

• ##### out: mat4

the receiving vector

the first operand

the second operand

• ##### scale: number

the amount to scale b's elements by before adding

out

### ortho

• ortho(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): mat4
• Generates a orthogonal projection matrix with the given bounds

#### Parameters

• ##### out: mat4

mat4 frustum matrix will be written into

• ##### left: number

Left bound of the frustum

• ##### right: number

Right bound of the frustum

• ##### bottom: number

Bottom bound of the frustum

• ##### top: number

Top bound of the frustum

• ##### near: number

Near bound of the frustum

• ##### far: number

Far bound of the frustum

out

### perspective

• perspective(out: mat4, fovy: number, aspect: number, near: number, far: number): mat4
• Generates a perspective projection matrix with the given bounds. Passing null/undefined/no value for far will generate infinite projection matrix.

#### Parameters

• ##### out: mat4

mat4 frustum matrix will be written into

• ##### fovy: number

Vertical field of view in radians

• ##### aspect: number

Aspect ratio. typically viewport width/height

• ##### near: number

Near bound of the frustum

• ##### far: number

Far bound of the frustum, can be null or Infinity

out

### perspectiveFromFieldOfView

• perspectiveFromFieldOfView(out: mat4, fov: any, near: number, far: number): mat4
• Generates a perspective projection matrix with the given field of view. This is primarily useful for generating projection matrices to be used with the still experiemental WebVR API.

#### Parameters

• ##### out: mat4

mat4 frustum matrix will be written into

• ##### fov: any

Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees

• ##### near: number

Near bound of the frustum

• ##### far: number

Far bound of the frustum

out

### rotate

• Rotates a mat4 by the given angle around the given axis

#### Parameters

• ##### out: mat4

the receiving matrix

the matrix to rotate

the angle to rotate the matrix by

the axis to rotate around

out

### rotateX

• Rotates a matrix by the given angle around the X axis

#### Parameters

• ##### out: mat4

the receiving matrix

the matrix to rotate

the angle to rotate the matrix by

out

### rotateY

• Rotates a matrix by the given angle around the Y axis

#### Parameters

• ##### out: mat4

the receiving matrix

the matrix to rotate

the angle to rotate the matrix by

out

### rotateZ

• Rotates a matrix by the given angle around the Z axis

#### Parameters

• ##### out: mat4

the receiving matrix

the matrix to rotate

the angle to rotate the matrix by

out

### scale

• Scales the mat4 by the dimensions in the given vec3 not using vectorization

#### Parameters

• ##### out: mat4

the receiving matrix

the matrix to scale

the vec3 to scale the matrix by

out

### set

• set(out: mat4, m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): mat4
• Set the components of a mat4 to the given values

#### Parameters

• ##### out: mat4

the receiving matrix

• ##### m00: number

Component in column 0, row 0 position (index 0)

• ##### m01: number

Component in column 0, row 1 position (index 1)

• ##### m02: number

Component in column 0, row 2 position (index 2)

• ##### m03: number

Component in column 0, row 3 position (index 3)

• ##### m10: number

Component in column 1, row 0 position (index 4)

• ##### m11: number

Component in column 1, row 1 position (index 5)

• ##### m12: number

Component in column 1, row 2 position (index 6)

• ##### m13: number

Component in column 1, row 3 position (index 7)

• ##### m20: number

Component in column 2, row 0 position (index 8)

• ##### m21: number

Component in column 2, row 1 position (index 9)

• ##### m22: number

Component in column 2, row 2 position (index 10)

• ##### m23: number

Component in column 2, row 3 position (index 11)

• ##### m30: number

Component in column 3, row 0 position (index 12)

• ##### m31: number

Component in column 3, row 1 position (index 13)

• ##### m32: number

Component in column 3, row 2 position (index 14)

• ##### m33: number

Component in column 3, row 3 position (index 15)

out

### str

• Returns a string representation of a mat4

#### Parameters

matrix to represent as a string

#### Returns string

string representation of the matrix

### sub

• Subtracts matrix b from matrix a

#### Parameters

• ##### out: mat4

the receiving matrix

the first operand

the second operand

out

### subtract

• Subtracts matrix b from matrix a

#### Parameters

• ##### out: mat4

the receiving matrix

the first operand

the second operand

out

### targetTo

• Generates a matrix that makes something look at something else.

#### Parameters

• ##### out: mat4

mat4 frustum matrix will be written into

Position of the viewer

• ##### target: any

vec3 pointing up

out

### translate

• Translate a mat4 by the given vector

#### Parameters

• ##### out: mat4

the receiving matrix

the matrix to translate

vector to translate by

out

### transpose

• transpose(out: mat4, a: ReadonlyMat4): mat4
• Transpose the values of a mat4

#### Parameters

• ##### out: mat4

the receiving matrix