module:extras/matrixstack.MatrixStack
### new module:extras/matrixstack.MatrixStack()
This class implements a stack of 4 × 4 transformation matrices.
When the constructor is called, it will create a stack whose only element is the identity matrix.
Methods
- frustum
Modifies the matrix at the top of this stack by multiplying it by a frustum matrix. - get
Gets a copy of the matrix at the top of this stack. - loadIdentity
Modifies the matrix at the top of this stack by replacing it with the identity matrix. - loadMatrix
Modifies the matrix at the top of this stack by replacing it with the given matrix. - loadTransposeMatrix
Modifies the matrix at the top of this stack by replacing it with the transpose of the given matrix. - lookAt
Modifies the matrix at the top of this stack by multiplying it by a matrix representing a “camera” view. - multMatrix
Modifies the matrix at the top of this stack by multiplying it by another matrix. - multTransposeMatrix
Modifies the matrix at the top of this stack by multiplying it by the transpose of another matrix. - ortho
Modifies the matrix at the top of this stack by multiplying it by an orthographic projection matrix. - ortho2d
Modifies the matrix at the top of this stack by multiplying it by a 2D orthographic projection matrix. - perspective
Modifies the matrix at the top of this stack by multiplying it by a matrix that defines a perspective projection. - pickMatrix
Modifies the matrix at the top of this stack by multiplying it by a matrix that transforms the view to a portion of the viewport. - popMatrix
Removes the matrix at the top of this stack, making the matrix beneath it the new top matrix. - pushMatrix
Makes a copy of the matrix at the top of this stack and puts the copy on top of the stack. - rotate
Modifies the matrix at the top of this stack by multiplying it by a rotation transformation matrix. - scale
Modifies the matrix at the top of this stack by multiplying it by a scaling transformation. - translate
Modifies the matrix at the top of this stack by multiplying it by a translation transformation.
### module:extras/matrixstack~MatrixStack#frustum(l, r, b, t, n, f)
Modifies the matrix at the top of this stack by multiplying it by a frustum matrix.
For more information on the frustum matrix and the parameters, see MathUtil.mat4frustum.
Parameters
l
(Type: number)
X coordinate of the point where the left clipping plane meets the near clipping plane.r
(Type: number)
X coordinate of the point where the right clipping plane meets the near clipping plane.b
(Type: number)
Y coordinate of the point where the bottom clipping plane meets the near clipping plane.t
(Type: number)
Y coordinate of the point where the top clipping plane meets the near clipping plane.n
(Type: number)
The distance from the camera to the near clipping plane.f
(Type: number)
The distance from the camera to the far clipping plane.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#get()
Gets a copy of the matrix at the top of this stack.
Return Value
. (Type: Array.<number>)
### module:extras/matrixstack~MatrixStack#loadIdentity()
Modifies the matrix at the top of this stack by replacing it with the identity matrix.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#loadMatrix(mat)
Modifies the matrix at the top of this stack by replacing it with the given matrix.
Parameters
mat
(Type: Array.<number>)
A matrix to replace the top of the stack with.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#loadTransposeMatrix(mat)
Modifies the matrix at the top of this stack by replacing it with the transpose of the given matrix.
Parameters
mat
(Type: Array.<number>)
A matrix whose transpose will replace the top of the stack.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#lookAt(ex, ey, ez, cx, cy, cz, ux, uy, uz)
Modifies the matrix at the top of this stack by multiplying it by a matrix representing a “camera” view.
For more information on that matrix and the parameters, see MathUtil.mat4lookat.
Parameters
ex
(Type: number)
X coordinate of the “camera” position in world space.ey
(Type: number)
Y coordinate of the “camera” position.ez
(Type: number)
Z coordinate of the “camera” position.cx
(Type: number)
X coordinate of the position in world space that the “camera” is “looking at”.cy
(Type: number)
Y coordinate of the position “looked at”.cz
(Type: number)
Z coordinate of the position “looked at”.ux
(Type: number)
X coordinate of the up direction vector.uy
(Type: number)
Y coordinate of the up vector.uz
(Type: number)
Z coordinate of the up vector.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#multMatrix(mat)
Modifies the matrix at the top of this stack by multiplying it by another matrix. The matrices are multiplied such that the transformations they describe happen in reverse order. For example, if the matrix at the top of the stack describes a translation and the matrix passed to this method describes a scaling, the multiplied matrix will describe the effect of scaling then translation.
Parameters
mat
(Type: Array.<number>)
A matrix to multiply the current one by.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#multTransposeMatrix(mat)
Modifies the matrix at the top of this stack by multiplying it by the transpose of another matrix. Both matrices are multiplied such that the transformation described by the top matrix “happens before” the transformation described by the matrix passed to this method. For example, if the matrix at the top of the stack describes a translation and the matrix passed to this method describes a scaling, the multiplied matrix will describe the effect of translation than scaling.
Parameters
mat
(Type: Array.<number>)
A matrix whose transpose the current matrix is to be multiplied.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#ortho(l, r, b, t, n, f)
Modifies the matrix at the top of this stack by multiplying it by an orthographic projection matrix.
For more information on the projection matrix and the parameters, see MathUtil.mat4ortho.
Parameters
l
(Type: number)
Leftmost coordinate of the orthographic view.r
(Type: number)
Rightmost coordinate of the orthographic view.b
(Type: number)
Bottommost coordinate of the orthographic view.t
(Type: number)
Topmost coordinate of the 3D view.n
(Type: number)
Distance from the camera to the near clipping plane.f
(Type: number)
Distance from the camera to the far clipping plane.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#ortho2d(l, r, b, t)
Modifies the matrix at the top of this stack by multiplying it by a 2D orthographic projection matrix.
For more information on that matrix and the parameters, see MathUtil.mat4ortho2d.
Parameters
l
(Type: number)
Leftmost coordinate of the orthographic view.r
(Type: number)
Rightmost coordinate of the orthographic view.b
(Type: number)
Bottommost coordinate of the orthographic view.t
(Type: number)
Topmost coordinate of the orthographic view.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#perspective(fov, aspect, n, f)
Modifies the matrix at the top of this stack by multiplying it by a matrix that defines a perspective projection.
For more information on that matrix and the parameters, see MathUtil.mat4perspective.
Parameters
fov
(Type: number)
Vertical field of view, in degrees.aspect
(Type: number)
The ratio of width to height of the viewport, usually the scene’s aspect ratio.n
(Type: number)
The distance from the camera to the near clipping plane.f
(Type: number)
The distance from the camera to the far clipping plane.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#pickMatrix(wx, wy, ww, wh, vp)
Modifies the matrix at the top of this stack by multiplying it by a matrix that transforms the view to a portion of the viewport.
For more information on that matrix and the parameters, see MathUtil.mat4pickMatrix.
Parameters
wx
(Type: number)
X coordinate of the center of the desired viewport portion.wy
(Type: number)
Y coordinate of the center of the desired viewport portion.ww
(Type: number)
Width of the desired viewport portion.wh
(Type: number)
Height of the desired viewport portion.vp
(Type: Array.<number>)
A 4-element array giving the X and Y coordinates of the current viewport’s origin followed by the width and height of a rectangle indicating the current viewport.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#popMatrix()
Removes the matrix at the top of this stack, making the matrix beneath it the new top matrix. Has no effect if the stack has only one matrix.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#pushMatrix()
Makes a copy of the matrix at the top of this stack and puts the copy on top of the stack.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#rotate(angle, x, y, z)
Modifies the matrix at the top of this stack by multiplying it by a rotation transformation matrix. For more information on that matrix and the parameters, see MathUtil.mat4rotate.
Parameters
angle
(Type: number)
The desired angle to rotate, in degrees.x
(Type: number)
X-component of the axis of rotation.y
(Type: number)
Y-component of the axis of rotation.z
(Type: number)
Z-component of the axis of rotation.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#scale(x, y, z)
Modifies the matrix at the top of this stack by multiplying it by a scaling transformation.
Parameters
x
(Type: number)
Scale factor along the X axis.y
(Type: number)
Scale factor along the Y axis.z
(Type: number)
Scale factor along the Z axis.
Return Value
This object. (Type: MatrixStack)
### module:extras/matrixstack~MatrixStack#translate(x, y, z)
Modifies the matrix at the top of this stack by multiplying it by a translation transformation.
Parameters
x
(Type: number)
Translation along the X axis.y
(Type: number)
Translation along the Y axis.z
(Type: number)
Translation along the Z axis.
Return Value
This object. (Type: MatrixStack)