Mat4

Mat4

4 x 4 Matrix

Constructor

new Mat4()

Source:
Creates new identity matrix.
Example
// creates a transformation matrix with translation (3,5,4)
let modelMatrix = new Mat4();
modelMatrix.trs(
     new Vec3(3,5,4),
     new Quat(),
     new Vec3(1,1,1)
);

Members

data :Float32Array

Source:
Array containing all 16 matrix values. this can be passed to ShaderProgram as uniform.
Type:
  • Float32Array

Methods

copy(other)

Source:
Copy data values from other matrix
Parameters:
Name Type Description
other Mat4

identity()

Source:
Sets matrix values to identity

invert()

Source:
Inverts a matrix transformation.
turn a worldToLocal transformation into localToWorld one for example.

multiply(other)

Source:
Multiply this matrix with another.
Parameters:
Name Type Description
other Mat4

orthogonal(left, right, bottom, top, near, far)

Source:
Sets this matrix to represent orthogonal(parallel) projection.
Parameters:
Name Type Description
left Number left boundary of the frustum box
right Number right boundary of the frustum box
bottom Number bottom boundary of the frustum box
top Number top boundary of the frustum box
near Number near boundary of the frustum box
far Number far boundary of the frustum box

perspective(fov, aspect, near, far)

Source:
Sets this matrix to represent perspective projection.
Parameters:
Name Type Description
fov Number field of view
aspect Number aspect ratio (resolution width/height)
near Number near clipping plane
far Number far clipping plane

trs(pos, rot, scale)

Source:
Set this matrix to transformation matrix from position, rotation and scale.
Parameters:
Name Type Description
pos Vec3
rot Quat
scale Vec3

zero()

Source:
Sets matrix values to 0