Constructor
new Matrix4(mopt)
Create a matrix, identity by default
| Name | Type | Attributes | Description |
|---|---|---|---|
m | Float32Array | | <optional> | 16 column major values |
- Source
const m = buildMatrix(vec3(0, 1, 0), vec3(0, PI/2, 0)); // rotate then move up
const p = m.transformPoint(vec3(1, 0, 0));Members
m
Properties| Type | Description |
|---|---|
| Float32Array | The 16 column major values |
- Source
Methods
copy() → {Matrix4}
Returns a new matrix that is a copy of this
- Source
- Type:
- Matrix4
getTranslation() → {Vector3}
Returns the translation part of this matrix
- Source
- Type:
- Vector3
invert() → {Matrix4}
Flip this matrix so it undoes itself, returns this and does nothing if it cannot be inverted
- Source
- Type:
- Matrix4
multiply(matrix) → {Matrix4}
Multiply this matrix by another and return this, the other happens first
| Name | Type | Description |
|---|---|---|
matrix | Matrix4 |
- Source
- Type:
- Matrix4
rotate(euler) → {Matrix4}
Append a rotation, returns self
| Name | Type | Description |
|---|---|---|
euler | Vector3 | vec3(pitch, yaw, roll) in radians |
- Source
- Type:
- Matrix4
scale(v) → {Matrix4}
Append a scale, returns self
| Name | Type | Description |
|---|---|---|
v | Vector3 |
- Source
- Type:
- Matrix4
toString() → {string}
Returns a string representation of this matrix for debugging
- Source
- Type:
- string
transformDirection(v) → {Vector3}
Transform a direction, rotation and scale only
| Name | Type | Description |
|---|---|---|
v | Vector3 |
- Source
- Type:
- Vector3
transformPoint(v) → {Vector3}
Transform a point, translation included
| Name | Type | Description |
|---|---|---|
v | Vector3 |
- Source
- Type:
- Vector3
translate(v) → {Matrix4}
Append a translation, returns self
| Name | Type | Description |
|---|---|---|
v | Vector3 |
- Source
- Type:
- Matrix4
transpose() → {Matrix4}
Transpose this matrix in place, returns self
- Source
- Type:
- Matrix4
(static) identity() → {Matrix4}
Returns a new identity matrix
- Source
- Type:
- Matrix4
(static) lookAt(eye, target, upopt) → {Matrix4}
Returns the transform of something at eye turned to face target
- Invert it to get a view matrix for a camera there
| Name | Type | Attributes | Description |
|---|---|---|---|
eye | Vector3 | ||
target | Vector3 | ||
up | Vector3 | <optional> |
- Source
- Type:
- Matrix4
(static) orthographic(left, right, bottom, top, near, far) → {Matrix4}
Returns a new orthographic projection, camera looks down -Z
| Name | Type | Description |
|---|---|---|
left | number | Edge of the visible box |
right | number | Edge of the visible box |
bottom | number | Edge of the visible box |
top | number | Edge of the visible box |
near | number | Closest visible distance |
far | number | Furthest visible distance, Infinity is not allowed here |
- Source
- Type:
- Matrix4
(static) perspective(fov, aspect, near, far) → {Matrix4}
Returns a new perspective projection, camera looks down -Z
| Name | Type | Description |
|---|---|---|
fov | number | Vertical field of view in radians |
aspect | number | Width divided by height |
near | number | Closest visible distance |
far | number | Furthest visible distance, Infinity is allowed |
- Source
- Type:
- Matrix4
(static) rotation(euler) → {Matrix4}
Returns a new rotation matrix, rolled first, then pitched, then yawed
| Name | Type | Description |
|---|---|---|
euler | Vector3 | vec3(pitch, yaw, roll) in radians |
- Source
- Type:
- Matrix4
(static) scaling(v) → {Matrix4}
Returns a new scale matrix
| Name | Type | Description |
|---|---|---|
v | Vector3 |
- Source
- Type:
- Matrix4
(static) translation(v) → {Matrix4}
Returns a new translation matrix
| Name | Type | Description |
|---|---|---|
v | Vector3 |
- Source
- Type:
- Matrix4