Skip to main content

mat4

Class

A 4x4 matrix.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Index

Constructors

Constructor

new mat4(): mat4

Returns

mat4

Properties

column0

column0: vec4

The first column of the matrix.


column1

column1: vec4

The second column of the matrix.


column2

column2: vec4

The third column of the matrix.


column3

column3: vec4

The fourth column of the matrix.


description

description: string

Returns a string representation of the matrix.

Methods

add()

add(mat): mat4

Returns the result of adding the two matrices together.

Parameters

ParameterType
matmat4

Returns

mat4


compMult()

static compMult(a, b): mat4

Returns the two matrices multiplied component-wise.

Parameters

ParameterType
amat4
bmat4

Returns

mat4


compose()

static compose(translation, rotation, scale): mat4

Returns a new matrix with translation translation, rotation rotation, and scale scale.

Parameters

ParameterType
translationvec3
rotationquat
scalevec3

Returns

mat4


determinant()

determinant(): number

Returns the determinant of the matrix.

Returns

number


div()

div(mat): mat4

Returns the result of dividing the two matrices.

Parameters

ParameterType
matmat4

Returns

mat4


equal()

equal(mat): boolean

Returns whether the two matrices are equal.

Parameters

ParameterType
matmat4

Returns

boolean


extractEulerAngles()

extractEulerAngles(): vec3

Returns an euler angle representation of this matrix's rotation, in radians.

Returns

vec3


fromColumns()

static fromColumns(column0, column1, column2, column3): mat4

Create a 4x4 matrix from four column vectors.

Parameters

ParameterType
column0vec4
column1vec4
column2vec4
column3vec4

Returns

mat4


fromEulerAngles()

static fromEulerAngles(angles): mat4

Returns a new matrix with the specified euler angles (in radians).

Parameters

ParameterType
anglesvec3

Returns

mat4


fromEulerX()

static fromEulerX(angle): mat4

Returns a new matrix with x euler angle xAngle (in radians).

Parameters

ParameterType
anglenumber

Returns

mat4


fromEulerY()

static fromEulerY(angle): mat4

Returns a new matrix with y euler angle yAngle (in radians).

Parameters

ParameterType
anglenumber

Returns

mat4


fromEulerZ()

static fromEulerZ(angle): mat4

Returns a new matrix with z euler angle zAngle (in radians).

Parameters

ParameterType
anglenumber

Returns

mat4


fromRotation()

static fromRotation(rotation): mat4

Returns a new matrix with rotation rotation.

Parameters

ParameterType
rotationquat

Returns

mat4


fromRows()

static fromRows(row0, row1, row2, row3): mat4

Create a 4x4 matrix from four row vectors.

Parameters

ParameterType
row0vec4
row1vec4
row2vec4
row3vec4

Returns

mat4


fromScale()

static fromScale(scale): mat4

Returns a new matrix with scale scale.

Parameters

ParameterType
scalevec3

Returns

mat4


fromTranslation()

static fromTranslation(translation): mat4

Returns a new matrix with the translation translation.

Parameters

ParameterType
translationvec3

Returns

mat4


identity()

static identity(): mat4

Returns the identity matrix.

Returns

mat4


inverse()

inverse(): mat4

Returns the inverse of the matrix.

Returns

mat4


lookAt()

static lookAt(eye, center, up): mat4

Returns a new matrix generated using the provided arguments.

Parameters

ParameterType
eyevec3
centervec3
upvec3

Returns

mat4


makeBasis()

static makeBasis(x, y, z): mat4

Returns a new matrix using the provided vectors.

Parameters

ParameterType
xvec3
yvec3
zvec3

Returns

mat4


mult()

mult(mat): mat4

Returns the result of multiplying the two matrices.

Parameters

ParameterType
matmat4

Returns

mat4


multiplyDirection()

multiplyDirection(direction): vec3

Returns the direction vector multiplied by this matrix.

Parameters

ParameterType
directionvec3

Returns

vec3


multiplyPoint()

multiplyPoint(point): vec3

Returns the point point multiplied by this matrix.

Parameters

ParameterType
pointvec3

Returns

vec3


multiplyScalar()

multiplyScalar(scalar): mat4

Returns the result of scalar multiplying the matrix.

Parameters

ParameterType
scalarnumber

Returns

mat4


multiplyVector()

multiplyVector(vector): vec4

Returns the vector multiplied by this matrix.

Parameters

ParameterType
vectorvec4

Returns

vec4


orthographic()

static orthographic(left, right, bottom, top, near, far): mat4

Returns a new matrix generated using the provided arguments.

Parameters

ParameterType
leftnumber
rightnumber
bottomnumber
topnumber
nearnumber
farnumber

Returns

mat4


outerProduct()

static outerProduct(a, b): mat4

Returns the outer product of the two matrices.

Parameters

ParameterType
avec4
bvec4

Returns

mat4


perspective()

static perspective(fov, aspect, near, far): mat4

Returns a new matrix generated using the provided arguments.

Parameters

ParameterType
fovnumber
aspectnumber
nearnumber
farnumber

Returns

mat4


sub()

sub(mat): mat4

Returns the result of subtracting the two matrices.

Parameters

ParameterType
matmat4

Returns

mat4


toString()

toString(): string

Returns a string representation of the matrix.

Returns

string


transpose()

transpose(): mat4

Returns the transpose of this matrix.

Returns

mat4


zero()

static zero(): mat4

Returns a matrix with all zero values.

Returns

mat4