Constructor
new Mat4()
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
Array containing all 16 matrix values.
this can be passed to ShaderProgram as uniform.
Type:
- Float32Array
Methods
copy(other)
Copy data values from other matrix
Parameters:
Name | Type | Description |
---|---|---|
other |
Mat4 |
identity()
Sets matrix values to identity
invert()
Inverts a matrix transformation.
turn a worldToLocal transformation into localToWorld one for example.
turn a worldToLocal transformation into localToWorld one for example.
multiply(other)
Multiply this matrix with another.
Parameters:
Name | Type | Description |
---|---|---|
other |
Mat4 |
orthogonal(left, right, bottom, top, near, far)
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)
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)
Set this matrix to transformation matrix from position, rotation and scale.
Parameters:
Name | Type | Description |
---|---|---|
pos |
Vec3 | |
rot |
Quat | |
scale |
Vec3 |
zero()
Sets matrix values to 0