Constructor
new L3D.Matrix4(…arguments)
Creates a new matrix.
// Creates an identity matrix.
new Matrix4()
// Creates a clone of the given matrix.
new Matrix4(Matrix4)
// Creates a Matrix4 from the given array.
new Matrix4(Array[16])
// Creates a zero matrix.
new Matarix4(0)
// Create a matrix from 16 individual elements in column major order
new Matrix4(m00, m01, m02, m03,
m10, m11, m12, m13,
m20, m21, m22, m23,
m30, m31, m32, m33)
arguments* |
* | Variable arguments for constructor overloading. |
Extends
- Float32Array
Properties
Methods
clone() → Matrix4
Make a copy of this matrix.
determinant() → number
Calculate the determinant of the matrix.
- number
getColumn(index, out) → Vector4
Get a column from the matrix.
index |
number | |
out |
Vector4 |
getColumn3(index, out) → Vector3
Get a column from the matrix.
index |
number | |
out |
Vector3 |
getEulerAngles(out) → Vector3
Extract the euler rotation angles, in degrees, from the matrix.
out |
Vector3 | Optional output storage for the results. |
getMatrix3(out) → Matrix3
Gets the upper 3x3 portion of this matrix.
out |
Matrix3 |
- Matrix3
The Matrix3 containing the upper 3x3 portion of this matrix.
getQuaternion(out) → Quaternion
Extract the rotation quaternion from the matrix.
out |
Quaternion |
getRow(index, out) → Vector4
Get a row from the matrix.
index |
number | |
out |
Vector4 |
getRow3(index, out) → Vector3
Get a row from the matrix.
index |
number | |
out |
Vector3 |
getScale(out) → Vector3
Extracts the scaling component of this matrix.
out |
Vector3 | optional storage for the results. |
getTranslation(out) → Vector3
Extracts the translational component of this matrix.
out |
Vector3 | optional storage for the results. |
getX(out) → Vector3
Extracts the x-axis from this matrix.
out |
Vector3 | optional storage for the results. |
getY(out) → Vector3
Extracts the y-axis from this matrix.
out |
Vector3 | optional storage for the results. |
getZ(out) → Vector3
Extracts the z-axis from this matrix.
out |
Vector3 | optional storage for the results. |
invert(out) → Matrix4
Invert the matrix.
out |
Matrix4 | Optional storage for the inverted matrix. If not provided, invert itself. |
invertToMatrix3(out) → Matrix3
Inverts the upper 3x3 portion of this matrix, returning it as a Matrix3.
out |
Matrix3 | optional storage for the results. |
isIdentity() → Boolean
Checks if this is an identity matrix.
- Boolean
true if this is an identity matrix.
normalizeScale() → Matrix4
Remove any scaling from the matrix.
- Matrix4
Returns this matrix.
rotateAxisAngle(angle, axis) → Matrix4
Rotate the matrix around an axis vector by an angle amount.
angle |
number | The angle to rotate, in degrees. |
axis |
Vector3 | The axis to rotate around. |
- Matrix4
Returns this matrix.
rotateEuler() → Matrix4
Rotate the matrix by the given euler angles. Angles are given in degrees.
rotateEuler(x, y, z, order = RotationOrder.Default)
rotateEuler(Vector3, order = RotationOrder.Default)
- Matrix4
Returns this matrix.
rotateQuaternion(arguments) → Matrix4
Rotate the matrix by a quaternion.
arguments |
* | Can either be a Quaternion, or 4 numbers. |
- Matrix4
Returns this matrix.
rotateX(angle) → Matrix4
Rotate the matrix around the X axis.
angle |
number | The amount to rotate, in degrees. |
- Matrix4
Returns this matrix.
rotateY(angle) → Matrix4
Rotate the matrix around the Y axis.
angle |
number | The amount to rotate, in degrees. |
- Matrix4
Returns this matrix.
rotateZ(angle) → Matrix4
Rotate the matrix around the Z axis.
angle |
number | The amount to rotate, in degrees. |
- Matrix4
Returns this matrix.
scale(arguments) → Matrix4
Scale the matrix
scale(Vector3)
scale(x, y, z)
arguments |
* | Can either be a Vector3 or 3 numbers. |
- Matrix4
Returns this matrix.
setAlignToVector(d, z, out)
Create a rotation matrix that aligns [v1] to [v2]. From https://iquilezles.org/articles/noacos/
d |
Vector3 | |
z |
Vector3 | |
out |
Matrix4 |
setAxisAngle()
setAxisAngle(angle, x, y, z)
setAxisAngle(angle, [x, y, z])
setAxisAngle(angle, Vector3)
setColumn()
setColumn(column, Vector3)
setColumn(column, Vector4)
setColumn(column, x, y, z)
setColumn(column, x, y, z, w)
setColumns(x, y, z, translate)
Set the matrix from a set of vector columns
x |
* | |
y |
* | |
z |
* | |
translate |
* |
setEulerAngles()
Set the matrix as an euler rotation. Angles are given in degrees.
setEulerAngles(x, y, z, order = RotationOrder.ZYX)
setEulerAngles(Vector3, order = RotationOrder.ZYX)
setFrom()
setFrom(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)
setFrom([m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33])
setFrom(Matrix4)
setIdentity()
Set the matrix as an identity matrix.
setLookAt(eye, center, up)
Set the matrix as a look-at transformation
eye |
* | |
center |
* | |
up |
* |
setOrtho(left, right, bottom, top, near, far)
Set as an orthographic projection matrix.
left |
* | |
right |
* | |
bottom |
* | |
top |
* | |
near |
* | |
far |
* |
setPerspective(fovx, aspect, near, far)
Set as a perspective projection matrix.
fovx |
number | Horizontal field of view, in radians |
aspect |
number | Aspect ratio |
near |
number | Distance to the near clipping plane |
far |
number | Distance to the far clipping plane |
setQuaternion()
setQuaternion(x, y, z, w)
setQuaternion([x, y, z, w])
setQuaternion(Quaternion)
setRotateX(angle)
Set the matrix as a rotation around the X axis.
angle |
number | Angle of the rotation, in radians. |
setRotateY(angle)
Set the matrix as a rotation around the Y axis.
angle |
number | Angle of the rotation, in degrees. |
setRotateZ(angle)
Set the matrix as a rotation around the Z axis.
angle |
Angle of the rotation, in degrees. |
setRow()
setRow(row, Vector3)
setRow(row, Vector4)
setRow(row, x, y, z)
setRow(row, x, y, z, w)
setScale()
setScale(x, y, z)
setScale([x, y, z])
setScale(Vector3)
setTransform(t, q, s)
Sets the matrix to the concatination of a translation, rotation by quaternion, and scale.
t |
Vector3 | The translation of the matrix. |
q |
Vector3 | The quaternion orientation of the matrix. |
s |
Vector3 | The scale of the matrix. |
setTranslate()
setTranslate(x, y, z)
setTranslate([x, y, z])
setTranslate(Vector3)
toArray() → Array
Convert the matrix to an array.
- Array
An array containing the values of the matrix.
transformVector3(v, w, out) → Vector3
Transform a Vector3
v |
Vector3 | The Vector3 to transform |
w |
number | The w coordinate of the vector. 0 for a vector, 1 for a point. Default 1. |
out |
Vector3 | Optional storage for the results. |
transformVector4(v, out) → Vector4
Transform a Vector4
v |
Vector4 | The Vector4 to transform |
out |
Vector4 | Optional storage for the results. |
translate(arguments) → Matrix4
Translate the matrix.
translate(Vector3)
translate(x, y, z)
arguments |
* | Can either be a Vector3 or 3 numbers. |
- Matrix4
Returns this matrix.
transpose() → Matrix4
Transpose the matrix.
- Matrix4
Returns this matrix.
static invert(m, out) → Matrix4
Invert a Matrix4.
m |
Matrix4 | |
out |
Matrix4 |
static multiply(a, b, out) → Matrix4
Multiply two Matrix4s.
a |
Matrix4 | |
b |
Matrix4 | |
out |
Matrix4 |
static scale(m, v, out) → Matrix4
Scale a Matrix4.
m |
Matrix4 | |
v |
Vector3 | |
out |
Matrix4 |
static translate(m, v, out) → Matrix4
Translate a Matrix4.
m |
Matrix4 | |
v |
Vector3 | |
out |
Matrix4 |
static transpose(m, out) → Matrix4
Transpose a Matrix4.
m |
Matrix4 | |
out |
Matrix4 |