Class: Matrix4
math 4*4 matrix
Constructors
Properties
- blockBytes
- allocCount
- allocOnceCount
- maxCount
- useCount
- dynamicMatrixBytes
- dynamicGlobalMatrixRef
- help_matrix_0
- help_matrix_1
- help_matrix_2
- helpMatrix
- helpMatrix2
- index
- rawData
Accessors
Methods
- allocMatrix
- fromToRotation
- getAxisRotation
- sanitizeEuler
- makePositive
- matrixToEuler
- matrixMultiply
- matrixAppend
- matrixRotateY
- matrixRotate
- lookAt
- multiply
- multiplyMatrices
- multiplyPoint3
- multiplyVector4
- transformVector4
- perspectiveMultiplyPoint3
- perspective
- perspective3
- frustum
- ortho
- orthoZO
- orthoOffCenter
- transformDir
- append
- add
- sub
- mult
- appendRotation
- createByRotation
- appendScale
- createByScale
- appendTranslation
- clone
- copyRowFrom
- copyRowTo
- copyFrom
- copyRawDataTo
- copyColFrom
- copyColTo
- copyToMatrix3D
- makeRotationFromQuaternion
- decompose
- getEuler
- compose
- deltaTransformVector
- identity
- fill
- invers33
- invert
- transformPoint
- transformVector
- transpose
- getPosition
- toString
- lerp
- get
- set
- getMaxScaleOnAxis
- translate
- setTRInverse
- setScale
- makeBasis
- makeRotationAxis
Constructors
constructor
• new Matrix4(doMatrix?
): Matrix4
Parameters
Name | Type | Default value |
---|---|---|
doMatrix | boolean | false |
Returns
Defined in
Properties
blockBytes
▪ Static
blockBytes: number
matrix44 bytes block size
Defined in
allocCount
▪ Static
allocCount: number
= 1000
matrix do total count
Defined in
allocOnceCount
▪ Static
allocOnceCount: number
= 1000
quantity allocated for each capacity expansion
Defined in
maxCount
▪ Static
maxCount: number
matrix has max limit count
Defined in
useCount
▪ Static
useCount: number
= 0
current matrix use count
Defined in
dynamicMatrixBytes
▪ Static
dynamicMatrixBytes: Float32Array
matrix do use share bytesArray
Defined in
dynamicGlobalMatrixRef
▪ Static
dynamicGlobalMatrixRef: Matrix4
[]
cache all use do matrix
Defined in
help_matrix_0
▪ Static
help_matrix_0: Matrix4
help fix global matrix 0
Defined in
help_matrix_1
▪ Static
help_matrix_1: Matrix4
help fix global matrix 1
Defined in
help_matrix_2
▪ Static
help_matrix_2: Matrix4
help fix global matrix 2
Defined in
helpMatrix
▪ Static
helpMatrix: Matrix4
help fix global matrix 3
Defined in
helpMatrix2
▪ Static
helpMatrix2: Matrix4
help fix global matrix 4
Defined in
index
• index: number
= 0
matrix index at global matrix list
Defined in
rawData
• rawData: Float32Array
matrix raw data format Float32Array
See
Float32Array
Version
Orillusion3D 0.5.1
Defined in
Accessors
determinant
• get
determinant(): number
Returns the matrix determinant
Returns
number
number determinant
Version
Orillusion3D 0.5.1
Defined in
position
• get
position(): Vector3
Return translation
Returns
Vector3 Position of translation
Version
Orillusion3D 0.5.1
Defined in
• set
position(value
): void
Set Position of translation
Parameters
Name | Type | Description |
---|---|---|
value | Vector3 | Position of translation |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
scale
• get
scale(): Vector3
get Component of scale
Returns
Vector3 scale
Version
Orillusion3D 0.5.1
Defined in
• set
scale(value
): void
Set component of scale
Parameters
Name | Type |
---|---|
value | Vector3 |
Returns
void
Defined in
Methods
allocMatrix
▸ allocMatrix(allocCount
): void
alloc web runtime cpu memory totalCount * 4(float) * 4 init matrix memory by totalCount * 4(float) * 4
Parameters
Name | Type |
---|---|
allocCount | number |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
fromToRotation
▸ fromToRotation(fromDirection
, toDirection
, target?
): Matrix4
create matrix from two direction
Parameters
Name | Type | Description |
---|---|---|
fromDirection | Vector3 | first direction |
toDirection | Vector3 | second direction |
target? | Matrix4 | ref matrix |
Returns
return new one matrix
Version
Orillusion3D 0.5.1
Defined in
getAxisRotation
▸ getAxisRotation(x
, y
, z
, degrees
): Matrix4
Generate a matrix (rotate degrees with x,y,z as the center axis)
Parameters
Name | Type | Description |
---|---|---|
x | number | x on the central axis |
y | number | y on the central axis |
z | number | z on the central axis |
degrees | number | rotation angle |
Returns
Matrix4 result
Version
Orillusion3D 0.5.1
Defined in
sanitizeEuler
▸ sanitizeEuler(euler
): void
Arrange the Euler values
Parameters
Name | Type | Description |
---|---|---|
euler | Vector3 | Euler values |
Returns
void
Defined in
makePositive
▸ makePositive(euler
): void
Parameters
Name | Type |
---|---|
euler | Vector3 |
Returns
void
Defined in
matrixToEuler
▸ matrixToEuler(matrix
, v
): boolean
Convert the matrix to Euler angles
Parameters
Name | Type | Description |
---|---|---|
matrix | Matrix4 | Matrix to be transformed |
v | Vector3 | euler angle |
Returns
boolean
Defined in
matrixMultiply
▸ matrixMultiply(aMat
, bMat
, target_Mat
): void
Multiply the world matrix, specifying parameters and results according to the index
Parameters
Name | Type | Description |
---|---|---|
aMat | Matrix4 | Matrix to be multiplied (please specify index) |
bMat | Matrix4 | Matrix to be multiplied (please specify index) |
target_Mat | Matrix4 | Result matrix (get results based on index) |
Returns
void
Defined in
matrixAppend
▸ matrixAppend(aMat
, bMat
, target_Mat
): void
World matrix extension, according to the index to specify parameters and results
Parameters
Name | Type | Description |
---|---|---|
aMat | Matrix4 | Matrix to be multiplied (please specify index) |
bMat | Matrix4 | Matrix to be multiplied (please specify index) |
target_Mat | Matrix4 | Result matrix (get results based on index) |
Returns
void
Defined in
matrixRotateY
▸ matrixRotateY(rad
, target_Mat
): void
The Y-axis is rotated between the world matrix, and the parameters and results are specified according to the index
Parameters
Name | Type | Description |
---|---|---|
rad | number | - |
target_Mat | Matrix4 | Result matrix (get results based on index) |
Returns
void
Defined in
matrixRotate
▸ matrixRotate(rad
, axis
, target_Mat
): void
Rotate the world matrix, specifying parameters and results according to the index
Parameters
Name | Type | Description |
---|---|---|
rad | number | - |
axis | Vector3 | - |
target_Mat | Matrix4 | Result matrix (get results based on index) |
Returns
void
Defined in
lookAt
▸ lookAt(eye
, at
, up?
): void
current matrix move position and rotation to target
Parameters
Name | Type | Default value | Description |
---|---|---|---|
eye | Vector3 | undefined | eye position |
at | Vector3 | undefined | target position |
up | Vector3 | Vector3.Y_AXIS | normalize axis way |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
multiply
▸ multiply(mat4
): void
matrix multiply
Parameters
Name | Type | Description |
---|---|---|
mat4 | Matrix4 | multiply target |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
multiplyMatrices
▸ multiplyMatrices(a
, b
): Matrix4
Parameters
Name | Type |
---|---|
a | Matrix4 |
b | Matrix4 |
Returns
Defined in
multiplyPoint3
▸ multiplyPoint3(v
, output?
): Vector3
convert a vector3 to this matrix space if output not set , return a new one
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | target vector3 |
output? | Vector3 | save target |
Returns
save target
Defined in
multiplyVector4
▸ multiplyVector4(a
, out?
): Vector3
Parameters
Name | Type |
---|---|
a | Vector3 |
out? | Vector3 |
Returns
Defined in
transformVector4
▸ transformVector4(v
, target?
): Vector3
convert a vector3 to this matrix space if output not set , return a new one
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | convert target |
target? | Vector3 | ref one vector3 |
Returns
Vector3
Version
Orillusion3D 0.5.1
Defined in
perspectiveMultiplyPoint3
▸ perspectiveMultiplyPoint3(v
, output
): boolean
Convert projection coordinates to 3D coordinates
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | vector3 target |
output | Vector3 | ref vector3d |
Returns
boolean
Defined in
perspective
▸ perspective(fov
, aspect
, zn
, zf
): void
set matrix perspective
Parameters
Name | Type | Description |
---|---|---|
fov | number | perspective angle 0 ~ 90 |
aspect | number | aspect ratio |
zn | number | near plane |
zf | number | far plane |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
perspective3
▸ perspective3(fov
, aspect
, near
, far
): void
Parameters
Name | Type |
---|---|
fov | number |
aspect | number |
near | number |
far | number |
Returns
void
Defined in
frustum
▸ frustum(l
, r
, b
, t
, n
, f
): void
Parameters
Name | Type |
---|---|
l | number |
r | number |
b | number |
t | number |
n | number |
f | number |
Returns
void
Defined in
ortho
▸ ortho(w
, h
, zn
, zf
): Matrix4
Parameters
Name | Type | Description |
---|---|---|
w | number | screen width |
h | number | screen height |
zn | number | camera near plane |
zf | number | camera far plane |
Returns
this matrix
Version
Orillusion3D 0.5.1 set matrix orthogonal projection
Defined in
orthoZO
▸ orthoZO(left
, right
, bottom
, top
, near
, far
): Matrix4
set matrix orthogonal projection by view side
Parameters
Name | Type | Description |
---|---|---|
left | number | orthogonal view left |
right | number | orthogonal view right |
bottom | number | orthogonal view bottom |
top | number | orthogonal view top |
near | number | camera near plane |
far | number | camera far plane |
Returns
this matrix
Defined in
orthoOffCenter
▸ orthoOffCenter(l
, r
, b
, t
, zn
, zf
): void
set matrix orthogonal projection by view center
Parameters
Name | Type |
---|---|
l | number |
r | number |
b | number |
t | number |
zn | number |
zf | number |
Returns
void
Defined in
transformDir
▸ transformDir(fromDirection
, toDirection
): this
set matrix from two direction
Parameters
Name | Type | Description |
---|---|---|
fromDirection | Vector3 | first direction |
toDirection | Vector3 | second direction |
Returns
this
Version
Orillusion3D 0.5.1
Defined in
append
▸ append(lhs
): void
multiply matrix a b
Parameters
Name | Type | Description |
---|---|---|
lhs | Matrix4 | target matrix |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
add
▸ add(lhs
): Matrix4
matrix a add matrix b
Parameters
Name | Type | Description |
---|---|---|
lhs | Matrix4 | target matrix. |
Returns
Matrix4 result.
Version
Orillusion3D 0.5.1
Defined in
sub
▸ sub(lhs
): Matrix4
matrix a sub matrix b
Parameters
Name | Type | Description |
---|---|---|
lhs | Matrix4 | target matrix b. |
Returns
Matrix4 .
Version
Orillusion3D 0.5.1
Defined in
mult
▸ mult(v
): Matrix4
Matrix times components.
Parameters
Name | Type | Description |
---|---|---|
v | number | This matrix is going to be multiplied by this value |
Returns
Matrix4 Returns a multiplicative result matrix.
Version
Orillusion3D 0.5.1
Defined in
appendRotation
▸ appendRotation(degrees
, axis
): void
Add a direction Angle rotation to the current matrix (the matrix created by rotating degrees according to axis)
Parameters
Name | Type | Description |
---|---|---|
degrees | number | Angle of rotation. |
axis | Vector3 | Angle of rotation around axis axis |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
createByRotation
▸ createByRotation(degrees
, axis
): this
Create a matrix based on the axis and rotation Angle (the matrix created by rotating the degrees according to the axis)
Parameters
Name | Type | Description |
---|---|---|
degrees | number | Angle of rotation. |
axis | Vector3 | Rotation Angle around axis axis. Axis needs to be specified as the orientation of an axis between x/y/z |
Returns
this
Version
Orillusion3D 0.5.1
Defined in
appendScale
▸ appendScale(xScale
, yScale
, zScale
): void
Append the triaxial scaling value
Parameters
Name | Type | Description |
---|---|---|
xScale | number | x axis scaling |
yScale | number | y axis scaling |
zScale | number | z axis scaling |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
createByScale
▸ createByScale(xScale
, yScale
, zScale
): void
A scaling matrix is generated and other properties are reset
Parameters
Name | Type | Description |
---|---|---|
xScale | number | x axis scaling |
yScale | number | y axis scaling |
zScale | number | z axis scaling |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
appendTranslation
▸ appendTranslation(x
, y
, z
): void
Plus a translation matrix
Parameters
Name | Type | Description |
---|---|---|
x | number | x axis scaling |
y | number | y axis scaling |
z | number | z axis scaling |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
clone
▸ clone(): Matrix4
Returns a clone of the current matrix
Returns
Matrix4 The cloned matrix
Version
Orillusion3D 0.5.1
Defined in
copyRowFrom
▸ copyRowFrom(row
, Vector3
): void
Assigns a value to one row of the current matrix
Parameters
Name | Type | Description |
---|---|---|
row | number | Row of copy |
Vector3 | Vector3 | Value of copy |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
copyRowTo
▸ copyRowTo(row
, Vector3
): void
One of the rows in the copy matrix stores the values in Vector3.
Parameters
Name | Type | Description |
---|---|---|
row | number | Row of copy |
Vector3 | Vector3 | Copy the storage target |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
copyFrom
▸ copyFrom(sourceMatrix3D
): Matrix4
Assigns the value of a matrix to the current matrix.
Parameters
Name | Type | Description |
---|---|---|
sourceMatrix3D | Matrix4 | source Matrix |
Returns
Returns the current matrix
Version
Orillusion3D 0.5.1
Defined in
copyRawDataTo
▸ copyRawDataTo(vector
, index?
, transpose?
): void
CoMath.PIes the value of the current matrix to a float array.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
vector | Float32Array | undefined | The target array. |
index | number | 0 | copy from the index of the array. |
transpose | boolean | false | Whether to transpose the current matrix. |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
copyColFrom
▸ copyColFrom(col
, Vector3
): void
Assigns a value to a column of the current matrix
Parameters
Name | Type | Description |
---|---|---|
col | number | column |
Vector3 | Vector3 | Source of value |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
copyColTo
▸ copyColTo(col
, Vector3
): void
Copy a column of the current matrix
Parameters
Name | Type | Description |
---|---|---|
col | number | column |
Vector3 | Vector3 | Target of copy |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
copyToMatrix3D
▸ copyToMatrix3D(dest
): void
Copy the current matrix
Parameters
Name | Type | Description |
---|---|---|
dest | Matrix4 | Target of copy |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
makeRotationFromQuaternion
▸ makeRotationFromQuaternion(quaternion
): Matrix4
Calculate rotation matrix
Parameters
Name | Type | Description |
---|---|---|
quaternion | Quaternion | Rotate the quaternion |
Returns
Defined in
decompose
▸ decompose(orientationStyle?
, target?
): Vector3
[]
Decompose the current matrix
Parameters
Name | Type | Default value | Description |
---|---|---|---|
orientationStyle | string | 'eulerAngles' | The default decomposition type is Orientation3D.EULER_ANGLES |
target? | Vector3 [] | undefined | - |
Returns
Vector3
[]
Vector3[3] pos rot scale
See
- Orientation3D.AXIS_ANGLE
- Orientation3D.EULER_ANGLES
- Orientation3D.QUATERNION
Version
Orillusion3D 0.5.1
Defined in
getEuler
▸ getEuler(target
, quaternion
, isDegree?
, order?
): Vector3
Get the Euler vector
Parameters
Name | Type | Default value | Description |
---|---|---|---|
target | Vector3 | undefined | Vector of results |
quaternion | Quaternion | undefined | Rotate the quaternion |
isDegree | boolean | true | Whether to convert to Angle |
order? | string | undefined | convert order |
Returns
Defined in
compose
▸ compose(position
, quaternion
, scale
): Matrix4
Calculate the combined matrix of displacement, rotation and scaling
Parameters
Name | Type | Description |
---|---|---|
position | Vector3 | translation |
quaternion | Quaternion | rotation |
scale | Vector3 | scale |
Returns
Defined in
deltaTransformVector
▸ deltaTransformVector(v
, target?
): Vector3
The current matrix transforms a vector
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | Vector to transform |
target? | Vector3 | The default is null and if the current argument is null then a new Vector3 will be returned |
Returns
Vector3 The transformed vector
Version
Orillusion3D 0.5.1
Defined in
identity
▸ identity(): Matrix4
Unifies the current matrix
Returns
Version
Orillusion3D 0.5.1
Defined in
fill
▸ fill(value
): void
Fill the current matrix
Parameters
Name | Type | Description |
---|---|---|
value | number | The filled value |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
invers33
▸ invers33(): void
Invert the current matrix
Returns
void
Version
Orillusion3D 0.5.1
Defined in
invert
▸ invert(): boolean
Invert the current matrix
Returns
boolean
boolean Whether can invert it
Version
Orillusion3D 0.5.1
Defined in
transformPoint
▸ transformPoint(v
, target?
): Vector3
Converts the current coordinates to the world coordinates
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | Current coordinates |
target? | Vector3 | world coordinate |
Returns
world coordinate
Defined in
transformVector
▸ transformVector(v
, target?
): Vector3
Transforming a 3D vector with the current matrix does not deal with displacement
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | Vector of transformation |
target? | Vector3 | If the current argument is null then a new Vector3 will be returned |
Returns
Vector3 The transformed vector
Version
Orillusion3D 0.5.1
Defined in
transpose
▸ transpose(): void
The current matrix transpose
Returns
void
Version
Orillusion3D 0.5.1
Defined in
getPosition
▸ getPosition(out?
): Vector3
Return matrix displacement
Parameters
Name | Type | Description |
---|---|---|
out? | Vector3 | Position of translation |
Returns
Position of translation
Defined in
toString
▸ toString(): string
Returns the value of the matrix as a string
Returns
string
string
Version
Orillusion3D 0.5.1
Defined in
lerp
▸ lerp(m0
, m1
, t
): void
Interpolate between two matrices
Parameters
Name | Type | Description |
---|---|---|
m0 | Matrix4 | Matrix 0 |
m1 | Matrix4 | Matrix 1 |
t | number | Factor of interpolation 0.0 - 1.0 |
Returns
void
Version
Orillusion3D 0.5.1
Defined in
get
▸ get(row
, column
): number
Read matrix element values
Parameters
Name | Type | Description |
---|---|---|
row | number | row |
column | number | column |
Returns
number
Defined in
set
▸ set(row
, column
, v
): void
Sets the matrix element values
Parameters
Name | Type | Description |
---|---|---|
row | number | row |
column | number | column |
v | number | value |
Returns
void
Defined in
getMaxScaleOnAxis
▸ getMaxScaleOnAxis(): number
Get the maximum value of the matrix scaled on each axis
Returns
number
Version
Orillusion3D 0.5.1 4.0
Defined in
translate
▸ translate(inTrans
): Matrix4
Calculate the displacement from the vector
Parameters
Name | Type | Description |
---|---|---|
inTrans | Vector3 | Vector |
Returns
current matrix
Defined in
setTRInverse
▸ setTRInverse(pos
, q
): void
from unity AMath.PI
Parameters
Name | Type |
---|---|
pos | Vector3 |
q | Quaternion |
Returns
void
Defined in
setScale
▸ setScale(inScale
): Matrix4
Set scale value
Parameters
Name | Type | Description |
---|---|---|
inScale | Vector3 | scale value |
Returns
this matrix
Defined in
makeBasis
▸ makeBasis(xAxis
, yAxis
, zAxis
): Matrix4
Generate the matrix according to the three axes
Parameters
Name | Type |
---|---|
xAxis | Vector3 |
yAxis | Vector3 |
zAxis | Vector3 |
Returns
Defined in
makeRotationAxis
▸ makeRotationAxis(axis
, angle
): Matrix4
Parameters
Name | Type |
---|---|
axis | Vector3 |
angle | number |