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.identity

An identity matrix.

Kind: static property of Matrix

Matrix.orthographic() ⇒ Matrix

Create an orthographic projection matrix.

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

Matrix.perspective() ⇒ Matrix

Create a perspective projection matrix.

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

Matrix.translate() ⇒ Matrix

Create a translation matrix.

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

Matrix.scale() ⇒ Matrix

Create a scale matrix.

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

Matrix.rotateX() ⇒ Matrix

Create a rotation matrix around X axis.

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

Matrix.rotateY() ⇒ Matrix

Create a rotation matrix around Y axis.

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

Matrix.rotateZ() ⇒ 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.lookAt(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.