Shaku

Shaku JS

Back To Table of Content

Matrix

Matrix

Implements a matrix.

Kind: global class

new Matrix(values, cloneValues)

Create the matrix.

Param Description
values matrix values array.
cloneValues if true or undefined, will clone values instead of just holding a reference to them.

matrix.set()

Set the matrix values.

Kind: instance method of Matrix

matrix.clone() ⇒ Matrix

Clone the matrix.

Kind: instance method of Matrix
Returns: Matrix - Cloned matrix.

matrix.equals(other) ⇒ Boolean

Compare this matrix to another matrix.

Kind: instance method of Matrix
Returns: Boolean - If matrices are the same.

Param Type Description
other Matrix Matrix to compare to.

matrix.inverted() ⇒ Matrix

Clone and invert the matrix.

Kind: instance method of Matrix
Returns: Matrix - Clonsed inverted matrix.

matrix.invertSelf() ⇒ Matrix

Invert this matrix.

Kind: instance method of Matrix
Returns: Matrix - Self.

matrix.transform(target) ⇒ Vector2 | Vector3 | Vector3

Transform a target.

Kind: instance method of Matrix
Returns: Vector2 | Vector3 | Vector3 - Transformed result.

Param Type Description
target Vector2 | Vector3 | Vertex Transforms a target, that can be vector2, vector3, or vertex.

matrix.multiplySelfWith(other) ⇒ Matrix

Multiply this matrix with another matrix, putting results in self.

Kind: instance method of Matrix
Returns: Matrix - This.

Param Type Description
other Matrix Matrix to multiply with.

matrix.multiplyWith(other) ⇒ Matrix

Multiply this matrix with another matrix and return a new result matrix.

Kind: instance method of Matrix
Returns: Matrix - New result matrix.

Param Type Description
other Matrix Matrix to multiply with.

Matrix.identity

An identity matrix.

Kind: static property of Matrix

Matrix.createOrthographic() ⇒ Matrix

Create an orthographic projection matrix.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.createPerspective() ⇒ Matrix

Create a perspective projection matrix.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.createTranslation() ⇒ Matrix

Create a translation matrix.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.createScale() ⇒ Matrix

Create a scale matrix.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.createRotationX() ⇒ Matrix

Create a rotation matrix around X axis.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.createRotationY() ⇒ Matrix

Create a rotation matrix around Y axis.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.createRotationZ() ⇒ Matrix

Create a rotation matrix around Z axis.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.multiply() ⇒ Matrix

Multiply two matrices.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Matrix.createLookAt(eyePosition, targetPosition, [upVector]) ⇒ Matrix

Creates a look-at matrix - a matrix rotated to look at a given position.

Kind: static method of Matrix
Returns: Matrix - a new matrix with result.

Param Type Description
eyePosition Vector3 Eye position.
targetPosition Vector3 Position the matrix should look at.
[upVector] Vector3 Optional vector representing ‘up’ direction.

Matrix.multiplyMany(matrices) ⇒ Matrix

Multiply an array of matrices.

Kind: static method of Matrix
Returns: Matrix - new matrix with multiply result.

Param Type Description
matrices Array.<Matrix> Matrices to multiply.

Matrix.multiplyIntoFirst() ⇒ Matrix

Multiply two matrices and put result in first matrix.

Kind: static method of Matrix
Returns: Matrix - matrixA, after it was modified.

Matrix.multiplyManyIntoFirst(matrices) ⇒ Matrix

Multiply an array of matrices into the first matrix in the array.

Kind: static method of Matrix
Returns: Matrix - first matrix in array, after it was modified.

Param Type Description
matrices Array.<Matrix> Matrices to multiply.

Matrix.transformVertex(matrix, vertex) ⇒ Vertex

Transform a 2d vertex.

Kind: static method of Matrix
Returns: Vertex - A transformed vertex (cloned, not the original).

Param Type Description
matrix Matrix Matrix to use to transform vector.
vertex Vertex Vertex to transform.

Matrix.transformVector2(matrix, vector) ⇒ Vector2

Transform a 2d vector.

Kind: static method of Matrix
Returns: Vector2 - Transformed vector.

Param Type Description
matrix Matrix Matrix to use to transform vector.
vector Vector2 Vector to transform.

Matrix.transformVector3(matrix, vector) ⇒ Vector3

Transform a 3d vector.

Kind: static method of Matrix
Returns: Vector3 - Transformed vector.

Param Type Description
matrix Matrix Matrix to use to transform vector.
vector Vector3 Vector to transform.