new Mat4( [m] [, m01] [, m02] [, m03] [, m10] [, m11] [, m12] [, m13] [, m20] [, m21] [, m22] [, m23] [, m30] [, m31] [, m32] [, m33])
Without parameters, initializes the vector to (0, 0, 0, 1).
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
m |
Mat4 | Array | number |
<optional> |
identity | Matrix to copy elements from, or array of elements in row-major format, or matrix element in row 0, column 0. |
m01 |
number |
<optional> |
0 | Matrix element in the row 0, column 1. |
m02 |
number |
<optional> |
0 | Matrix element in the row 0, column 2. |
m03 |
number |
<optional> |
0 | Matrix element in the row 0, column 3. |
m10 |
number |
<optional> |
0 | Matrix element in the row 1, column 0. |
m11 |
number |
<optional> |
1 | Matrix element in the row 1, column 1. |
m12 |
number |
<optional> |
0 | Matrix element in the row 1, column 2. |
m13 |
number |
<optional> |
0 | Matrix element in the row 1, column 3. |
m20 |
number |
<optional> |
0 | Matrix element in the row 2, column 0. |
m21 |
number |
<optional> |
0 | Matrix element in the row 2, column 1. |
m22 |
number |
<optional> |
1 | Matrix element in the row 2, column 2. |
m23 |
number |
<optional> |
0 | Matrix element in the row 2, column 3. |
m30 |
number |
<optional> |
0 | Matrix element in the row 3, column 0. |
m31 |
number |
<optional> |
0 | Matrix element in the row 3, column 1. |
m32 |
number |
<optional> |
0 | Matrix element in the row 3, column 2. |
m33 |
number |
<optional> |
1 | Matrix element in the row 3, column 3. |
Members
-
p :undefined
-
When this property is accessed, it pretty prints the matrix contents on the console. Intended for quick debugging.
Type:
- undefined
-
storage :Float32Array
-
16-element typed array for matrix storage.
Type:
- Float32Array
Methods
-
commit(gl, uniformLocation)
-
Sets the value of the matrix to a WebGL mat4 uniform variable.
Parameters:
Name Type Description gl
WebGLRenderingContext rendering context uniformLocation
WebGLUniformLocation location of the uniform variable in the currently used WebGL program -
invert()
-
Inverts the matrix in place, overwriting this matrix with the result.
Returns:
this- Type
- Mat4
-
mul(m)
-
Multiplies the matrix with another matrix from the right, overwriting this matrix with the result.
Parameters:
Name Type Description m
Mat4 Matrix to multiply with. Returns:
this- Type
- Mat4
-
premul(m)
-
Multiplies the matrix with another matrix from the left, overwriting this matrix with the result.
Parameters:
Name Type Description m
Mat4 Matrix to multiply with. Returns:
this- Type
- Mat4
-
rotate(angle [, u] [, v] [, s])
-
Multiplies the matrix with a scaling transformation matrix from the right, overwriting this matrix with the result. Rotates around z if no axis is given.
Parameters:
Name Type Argument Default Description angle
Number Rotation angle in radians. A right-handed coordinate system is assumed, meaning positive rotation around axis z rotates counterclockwise in the plane where x points right and y points up. u
Vec3 | Object | Number <optional>
0 Any object (properties x, y, z are interpreted as rotation axis elements, if given), or a numerical value for rotation axis element x. v
Number <optional>
0 Ignored if u.y is defined. Otherwise, the value for rotation axis element y. Defaults to the value of parameter u, if it is a number. s
Number <optional>
0 Ignored if u.z is defined. Otherwise, the value for rotation axis element z. Defaults to the value of parameter u, if it is a number. Returns:
this- Type
- Mat4
-
scale( [u] [, v] [, s])
-
Multiplies the matrix with a scaling transformation matrix from the right, overwriting this matrix with the result.
Parameters:
Name Type Argument Default Description u
Vec3 | Object | Number <optional>
1 Any object (properties x, y, z are interpreted as scaling factors along the respective axes, if given), or a numerical value for scaling factor along x. v
Number <optional>
1 Ignored if u.y is defined. Otherwise, the value for the scaling factor along y. Defaults to the value of parameter u, if it is a number. s
Number <optional>
1 Ignored if u.z is defined. Otherwise, the value for the scaling factor along z. Defaults to the value of parameter u, if it is a number. Returns:
this- Type
- Mat4
-
set( [m] [, m01] [, m02] [, m03] [, m10] [, m11] [, m12] [, m13] [, m20] [, m21] [, m22] [, m23] [, m30] [, m31] [, m32] [, m33])
-
Sets the matrix elements from another matrix or array, given in row-major format. Without parameters, sets the indentity matrix.
Parameters:
Name Type Argument Default Description m
Mat4 | Array | number <optional>
identity Matrix to copy elements from, or array of elements in row-major format, or matrix element in row 0, column 0. m01
number <optional>
0 Matrix element in the row 0, column 1. m02
number <optional>
0 Matrix element in the row 0, column 2. m03
number <optional>
0 Matrix element in the row 0, column 3. m10
number <optional>
0 Matrix element in the row 1, column 0. m11
number <optional>
1 Matrix element in the row 1, column 1. m12
number <optional>
0 Matrix element in the row 1, column 2. m13
number <optional>
0 Matrix element in the row 1, column 3. m20
number <optional>
0 Matrix element in the row 2, column 0. m21
number <optional>
0 Matrix element in the row 2, column 1. m22
number <optional>
1 Matrix element in the row 2, column 2. m23
number <optional>
0 Matrix element in the row 2, column 3. m30
number <optional>
0 Matrix element in the row 3, column 0. m31
number <optional>
0 Matrix element in the row 3, column 1. m32
number <optional>
0 Matrix element in the row 3, column 2. m33
number <optional>
1 Matrix element in the row 3, column 3. Returns:
this- Type
- Mat4
-
translate( [u] [, v] [, s])
-
Multiplies the matrix with a transation transformation matrix from the right, overwriting this matrix with the result.
Parameters:
Name Type Argument Default Description u
Vec3 | Object | Number <optional>
0 Any object (properties x, y, z are interpreted as trnalstion vector elmeents, if given), or a numerical value for translation along x. v
Number <optional>
0 Ignored if u.y is defined. Otherwise, the value for translation along y. Defaults to the value of parameter u, if it is a number. s
Number <optional>
0 Ignored if u.z is defined. Otherwise, the value for translation along z. Defaults to the value of parameter u, if it is a number. Returns:
this- Type
- Mat4
-
transpose()
-
Transposes the matrix in place, overwriting this matrix with the result.
Returns:
this- Type
- Mat4