[name]

A 4x4 Matrix.

Example

// Simple rig for rotating around 3 axes var m = new THREE.Matrix4(); var m1 = new THREE.Matrix4(); var m2 = new THREE.Matrix4(); var m3 = new THREE.Matrix4(); var alpha = 0; var beta = Math.PI; var gamma = Math.PI/2; m1.makeRotationX( alpha ); m2.makeRotationY( beta ); m3.makeRotationZ( gamma ); m.multiplyMatrices( m1, m2 ); m.multiply( m3 );

Constructor

[name]( [page:Float n11], [page:Float n12], [page:Float n13], [page:Float n14], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n24], [page:Float n31], [page:Float n32], [page:Float n33], [page:Float n34], [page:Float n41], [page:Float n42], [page:Float n43], [page:Float n44] )

Initialises the matrix with the supplied row-major values n11..n44, or just creates an identity matrix if no values are passed.

Properties

.[page:Float32Array elements]

A column-major list of matrix values.

Methods

.set( [page:Float n11], [page:Float n12], [page:Float n13], [page:Float n14], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n24], [page:Float n31], [page:Float n32], [page:Float n33], [page:Float n34], [page:Float n41], [page:Float n42], [page:Float n43], [page:Float n44] ) [page:Matrix4 this]

Sets all fields of this matrix to the supplied row-major values n11..n44.

.identity() [page:Matrix4 this]

Resets this matrix to identity.

.copy( [page:Matrix4 m] ) [page:Matrix4 this]

Copies a matrix *m* into this matrix.

.copyPosition( [page:Matrix4 m] ) [page:Matrix4 this]

Copies the translation component of the supplied matrix *m* into this matrix translation component.

.extractRotation( [page:Matrix4 m] ) [page:Matrix4 this]

Extracts the rotation of the supplied matrix *m* into this matrix rotation component.

.lookAt( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], ) [page:Matrix4 this]

Constructs a rotation matrix, looking from *eye* towards *center* with defined *up* vector.

.multiply( [page:Matrix4 m] ) [page:Matrix4 this]

Multiplies this matrix by *m*.

.multiplyMatrices( [page:Matrix4 a], [page:Matrix4 b] ) [page:Matrix4 this]

Sets this matrix to *a x b*.

.multiplyToArray( [page:Matrix4 a], [page:Matrix4 b], [page:Array r] ) [page:Matrix4 this]

Sets this matrix to *a x b* and stores the result into the flat array *r*.
*r* can be either a regular Array or a TypedArray.

.multiplyScalar( [page:Float s] ) [page:Matrix4 this]

Multiplies this matrix by *s*.

.determinant() [page:Float]

Computes determinant of this matrix.
Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm]

.transpose() [page:Matrix4 this]

Transposes this matrix.

.flattenToArray( [page:Array flat] ) [page:Array]

Flattens this matrix into supplied *flat* array.

.flattenToArrayOffset( [page:Array flat], [page:Integer offset] ) [page:Array]

Flattens this matrix into supplied *flat* array starting from *offset* position in the array.

.setPosition( [page:Vector3 v] ) [page:Matrix4 this]

Sets the position component for this matrix from vector *v*.

.getInverse( [page:Matrix4 m] ) [page:Matrix4 this]

Sets this matrix to the inverse of matrix *m*.
Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm].

.makeRotationFromEuler( [page:Vector3 v], [page:String order] ) [page:Matrix4 this]

v — Rotation vector. order — The order of rotations. Eg. "XYZ".
Sets the rotation submatrix of this matrix to the rotation specified by Euler angles, the rest of the matrix is identity.
Default order is *"XYZ"*.

.makeRotationFromQuaternion( [page:Quaternion q] ) [page:Matrix4 this]

Sets the rotation submatrix of this matrix to the rotation specified by *q*. The rest of the matrix is identity.

.scale( [page:Vector3 v] ) [page:Matrix4 this]

Multiplies the columns of this matrix by vector *v*.

.compose( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] ) [page:Matrix4 this]

Sets this matrix to the transformation composed of *translation*, *quaternion* and *scale*.

.decompose( [page:Vector3 translation], [page:Quaternion quaternion], [page:Vector3 scale] ) [page:Array]

Decomposes this matrix into the *translation*, *quaternion* and *scale* components.
If parameters are not passed, new instances will be created.

.makeTranslation( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4 this]

Sets this matrix as translation transform.

.makeRotationX( [page:Float theta] ) [page:Matrix4 this]

theta — Rotation angle in radians.
Sets this matrix as rotation transform around x axis by *theta* radians.

.makeRotationY( [page:Float theta] ) [page:Matrix4 this]

theta — Rotation angle in radians.
Sets this matrix as rotation transform around y axis by *theta* radians.

.makeRotationZ( [page:Float theta] ) [page:Matrix4 this]

theta — Rotation angle in radians.
Sets this matrix as rotation transform around z axis by *theta* radians.

.makeRotationAxis( [page:Vector3 axis], [page:Float theta] ) [page:Matrix4 this]

axis — Rotation axis, should be normalized. theta — Rotation angle in radians.
Sets this matrix as rotation transform around *axis* by *angle* radians.
Based on [link:http://www.gamedev.net/reference/articles/article1199.asp].

.makeScale( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4 this]

Sets this matrix as scale transform.

.makeFrustum( [page:Float left], [page:Float right], [page:Float bottom], [page:Float top], [page:Float near], [page:Float far] ) [page:Matrix4 this]

Creates a [page:Frustum frustum] matrix.

.makePerspective( [page:Float fov], [page:Float aspect], [page:Float near], [page:Float far] ) [page:Matrix4 this]

Creates a perspective projection matrix.

.makeOrthographic( [page:Float left], [page:Float right], [page:Float bottom], [page:Float top], [page:Float near], [page:Float far] ) [page:Matrix4 this]

Creates an orthographic projection matrix.

.clone() [page:Matrix4]

Clones this matrix.

.multiplyVector3Array([page:Array a]) [page:Array]

array -- An array in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...]
Multiply (apply) this matrix against every vector3 in the array.

.getMaxScaleOnAxis() [page:Float]

Gets the max scale value of the 3 axes.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]