new Matrix4(opt_src)
Constructor of Matrix4.
If opt_src is specified, new matrix is initialized by opt_src.Otherwise, new matrix is initialized by identity matrix.
Parameters:
Name | Type | Description |
---|---|---|
opt_src |
Array.<Number> | source matrix (optional). |
- Source:
Members
elements :Float32Array
Matrix container.
Type:
- Float32Array
- Source:
Methods
concat(other) → {Matrix4}
Right multiply this matrix by other.
Parameters:
Name | Type | Description |
---|---|---|
other |
Matrix4 | a matrix. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
dropShadow(plane, light) → {Matrix4}
Right multiply this matrix by a matrix for projecting a vertex onto a plane.
Parameters:
Name | Type | Description |
---|---|---|
plane |
Array.<Number> | coefficients [A, B, C, D] of the plane equation: "Ax + By + Cz + D = 0". |
light |
Array.<Number> | array holding the coordinates of the light source. If light[3] == 0, consider light source at infinity (parallel rays). |
- Source:
Returns:
this matrix.
- Type
- Matrix4
dropShadowDirectionally(normX, normY, normZ, planeX, planeY, planeZ, lightX, lightY, lightZ) → {Matrix4}
Right multiply this matrix by the matrix for projecting a vertex onto a plane.
(Projected by parallel light.)Parameters:
Name | Type | Description |
---|---|---|
normX |
Number | X coordinate of the normal vector of the plane. |
normY |
Number | Y coordinate of the normal vector of the plane. |
normZ |
Number | Z coordinate of the normal vector of the plane. (Not necessary to be normalized.) |
planeX |
Number | X coordinate of an arbitrary point on the plane. |
planeY |
Number | Y coordinate of an arbitrary point on the plane. |
planeZ |
Number | Z coordinate of an arbitrary point on the plane. |
lightX |
Number | X coordinate of the light direction. |
lightY |
Number | Y coordinate of the light direction. |
lightZ |
Number | Z coordinate of the light direction. (Not necessary to be normalized.) |
- Source:
Returns:
this matrix.
- Type
- Matrix4
frustum(left, right, bottom, top, near, far) → {Matrix4}
Right multiply this matrix by a perspective projection matrix.
Parameters:
Name | Type | Description |
---|---|---|
left |
Number | coordinate of the left clipping plane. |
right |
Number | coordinate of the right clipping plane. |
bottom |
Number | coordinate of the bottom clipping plane. |
top |
Number | coordinate of the top clipping plane. |
near |
Number | distance to the near clipping plane. This value must be positive. |
far |
Number | distance to the far clipping plane. This value must be positive. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
invert() → {Matrix4}
Invert this matrix.
- Source:
Returns:
this matrix.
- Type
- Matrix4
lookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ) → {Matrix4}
Right multiply this matrix by the viewing matrix.
Parameters:
Name | Type | Description |
---|---|---|
eyeX |
Number | X coordinate of the eye position. |
eyeY |
Number | Y coordinate of the eye position. |
eyeZ |
Number | Z coordinate of the eye position. |
centerX |
Number | X coordinate of the reference point. |
centerY |
Number | Y coordinate of the reference point. |
centerZ |
Number | Z coordinate of the reference point. |
upX |
Number | X coordinate of the view up vector. |
upY |
Number | Y coordinate of the view up vector. |
upZ |
Number | Z coordinate of the view up vector. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
multiply(other) → {Matrix4}
Right multiply this matrix by other.
Parameters:
Name | Type | Description |
---|---|---|
other |
Matrix4 | a matrix. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
multiplyVector3(pos) → {Float32Array}
Multiply this 3D vector by pos.
Parameters:
Name | Type | Description |
---|---|---|
pos |
Vector3 | a 3D vector. |
- Source:
Returns:
result of multiplication.
- Type
- Float32Array
multiplyVector4(pos) → {Float32Array}
Multiply this 4D vector by pos.
Parameters:
Name | Type | Description |
---|---|---|
pos |
Vector4 | a 4D vector. |
- Source:
Returns:
result of multiplication.
- Type
- Float32Array
ortho(left, right, bottom, top, near, far) → {Matrix4}
Right multiply this matrix by an orthographic projection matrix.
Parameters:
Name | Type | Description |
---|---|---|
left |
Number | coordinate of the left clipping plane. |
right |
Number | coordinate of the right clipping plane. |
bottom |
Number | coordinate of the bottom clipping plane. |
top |
Number | coordinate of the top clipping plane. |
near |
Number | distance to the near clipping plane. This value is negative if the plane is behind the viewer. |
far |
Number | distance to the far clipping plane. This value is negative if the plane is behind the viewer. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
perspective(fovy, aspect, near, far) → {Matrix4}
Right multiply this matrix by a perspective projection matrix.
Parameters:
Name | Type | Description |
---|---|---|
fovy |
Number | field of view angle between the upper and lower sides of the view frustum. |
aspect |
Number | aspect ratio of the view frustum (width/height). |
near |
Number | distance to the near clipping plane. This value must be positive. |
far |
Number | distance to the far clipping plane. This value must be positive. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
rotate(angle, x, y, z) → {Matrix4}
Right multiply this matrix by a rotation matrix.
The rotation axis vector may not be normalized.Parameters:
Name | Type | Description |
---|---|---|
angle |
Number | angle of rotation (degrees) |
x |
Number | X coordinate of rotation axis vector. |
y |
Number | Y coordinate of rotation axis vector. |
z |
Number | Z coordinate of rotation axis vector. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
scale(x, y, z) → {Matrix4}
Right multiply this matrix by a scale matrix.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | scale factor along the X axis. |
y |
Number | scale factor along the Y axis. |
z |
Number | scale factor along the Z axis. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
set(src) → {Matrix4}
Copy src to this matrix.
Parameters:
Name | Type | Description |
---|---|---|
src |
Matrix4 | source matrix |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setFrustum(left, right, bottom, top, near, far) → {Matrix4}
Set the perspective projection matrix.
Parameters:
Name | Type | Description |
---|---|---|
left |
Number | coordinate of the left clipping plane. |
right |
Number | coordinate of the right clipping plane. |
bottom |
Number | coordinate of the bottom clipping plane. |
top |
Number | coordinate of the top clipping plane. |
near |
Number | distance to the near clipping plane. This value must be positive. |
far |
Number | distance to the far clipping plane. This value must be positive. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setIdentity() → {Matrix4}
Set the identity matrix.
- Source:
Returns:
this matrix.
- Type
- Matrix4
setInverseOf(other) → {Matrix4}
Set this matrix to the inverse of other.
Parameters:
Name | Type | Description |
---|---|---|
other |
Matrix4 | source matrix. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ) → {Matrix4}
Set the viewing matrix.
Parameters:
Name | Type | Description |
---|---|---|
eyeX |
Number | X coordinate of the eye position. |
eyeY |
Number | Y coordinate of the eye position. |
eyeZ |
Number | Z coordinate of the eye position. |
centerX |
Number | X coordinate of the reference point. |
centerY |
Number | Y coordinate of the reference point. |
centerZ |
Number | Z coordinate of the reference point. |
upX |
Number | X coordinate of the view up vector. |
upY |
Number | Y coordinate of the view up vector. |
upZ |
Number | Z coordinate of the view up vector. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setOrtho(left, right, bottom, top, near, far) → {Matrix4}
Set the orthographic projection matrix.
Parameters:
Name | Type | Description |
---|---|---|
left |
Number | coordinate of the left clipping plane. |
right |
Number | coordinate of the right clipping plane. |
bottom |
Number | coordinate of the bottom clipping plane. |
top |
Number | coordinate of the top clipping plane. |
near |
Number | distance to the near clipping plane. This value is negative if the plane is behind the viewer. |
far |
Number | distance to the far clipping plane. This value is negtive if the plane is behind the viewer. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setPerspective(fovy, aspect, near, far) → {Matrix4}
Set the perspective projection matrix.
Parameters:
Name | Type | Description |
---|---|---|
fovy |
Number | field of view angle between the upper and lower sides of the view frustum. |
aspect |
Number | aspect ratio of the view frustum (width/height). |
near |
Number | distance to the near clipping plane. This value must be positive. |
far |
Number | distance to the far clipping plane. This value must be positive. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setRotate(angle, x, y, z) → {Matrix4}
Set the matrix for rotation.
The rotation axis vector may not be normalized.Parameters:
Name | Type | Description |
---|---|---|
angle |
Number | angle of rotation (degrees). |
x |
Number | X coordinate of rotation axis vector. |
y |
Number | Y coordinate of rotation axis vector. |
z |
Number | Z coordinate of rotation axis vector. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setScale(x, y, z) → {Matrix4}
Set the matrix for scaling.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | scale factor along the X axis. |
y |
Number | scale factor along the Y axis. |
z |
Number | scale factor along the Z axis. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
setTranslate(x, y, z) → {Matrix4}
Set the matrix for translation.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | translation in the X direction. |
y |
Number | translation in the Y direction. |
z |
Number | translation in the Z direction. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
translate(x, y, z) → {Matrix4}
Right multiply this matrix by a translation matrix.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | translation in the X direction. |
y |
Number | translation in the Y direction. |
z |
Number | translation in the Z direction. |
- Source:
Returns:
this matrix.
- Type
- Matrix4
transpose() → {Matrix4}
Transpose this matrix.
- Source:
Returns:
this matrix.
- Type
- Matrix4