Skip to content

Class: Matrix4

math 4*4 matrix

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Matrix4(doMatrix?): Matrix4

Parameters

NameTypeDefault value
doMatrixbooleanfalse

Returns

Matrix4

Defined in

src/math/Matrix4.ts:321

Properties

blockBytes

Static blockBytes: number

matrix44 bytes block size

Defined in

src/math/Matrix4.ts:17


allocCount

Static allocCount: number = 1000

matrix do total count

Defined in

src/math/Matrix4.ts:27


allocOnceCount

Static allocOnceCount: number = 1000

quantity allocated for each capacity expansion

Defined in

src/math/Matrix4.ts:32


maxCount

Static maxCount: number

matrix has max limit count

Defined in

src/math/Matrix4.ts:37


useCount

Static useCount: number = 0

current matrix use count

Defined in

src/math/Matrix4.ts:42


dynamicMatrixBytes

Static dynamicMatrixBytes: Float32Array

matrix do use share bytesArray

Defined in

src/math/Matrix4.ts:58


dynamicGlobalMatrixRef

Static dynamicGlobalMatrixRef: Matrix4[]

cache all use do matrix

Defined in

src/math/Matrix4.ts:63


help_matrix_0

Static help_matrix_0: Matrix4

help fix global matrix 0

Defined in

src/math/Matrix4.ts:73


help_matrix_1

Static help_matrix_1: Matrix4

help fix global matrix 1

Defined in

src/math/Matrix4.ts:78


help_matrix_2

Static help_matrix_2: Matrix4

help fix global matrix 2

Defined in

src/math/Matrix4.ts:83


helpMatrix

Static helpMatrix: Matrix4

help fix global matrix 3

Defined in

src/math/Matrix4.ts:88


helpMatrix2

Static helpMatrix2: Matrix4

help fix global matrix 4

Defined in

src/math/Matrix4.ts:93


index

index: number = 0

matrix index at global matrix list

Defined in

src/math/Matrix4.ts:104


rawData

rawData: Float32Array

matrix raw data format Float32Array

See

Float32Array

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:116

Accessors

determinant

get determinant(): number

Returns the matrix determinant

Returns

number

number determinant

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1887


position

get position(): Vector3

Return translation

Returns

Vector3

Vector3 Position of translation

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1918

set position(value): void

Set Position of translation

Parameters

NameTypeDescription
valueVector3Position of translation

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1928


scale

get scale(): Vector3

get Component of scale

Returns

Vector3

Vector3 scale

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1941

set scale(value): void

Set component of scale

Parameters

NameType
valueVector3

Returns

void

Defined in

src/math/Matrix4.ts:1949

Methods

allocMatrix

allocMatrix(allocCount): void

alloc web runtime cpu memory totalCount * 4(float) * 4 init matrix memory by totalCount * 4(float) * 4

Parameters

NameType
allocCountnumber

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:126


fromToRotation

fromToRotation(fromDirection, toDirection, target?): Matrix4

create matrix from two direction

Parameters

NameTypeDescription
fromDirectionVector3first direction
toDirectionVector3second direction
target?Matrix4ref matrix

Returns

Matrix4

return new one matrix

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:156


getAxisRotation

getAxisRotation(x, y, z, degrees): Matrix4

Generate a matrix (rotate degrees with x,y,z as the center axis)

Parameters

NameTypeDescription
xnumberx on the central axis
ynumbery on the central axis
znumberz on the central axis
degreesnumberrotation angle

Returns

Matrix4

Matrix4 result

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:171


sanitizeEuler

sanitizeEuler(euler): void

Arrange the Euler values

Parameters

NameTypeDescription
eulerVector3Euler values

Returns

void

Defined in

src/math/Matrix4.ts:205


makePositive

makePositive(euler): void

Parameters

NameType
eulerVector3

Returns

void

Defined in

src/math/Matrix4.ts:213


matrixToEuler

matrixToEuler(matrix, v): boolean

Convert the matrix to Euler angles

Parameters

NameTypeDescription
matrixMatrix4Matrix to be transformed
vVector3euler angle

Returns

boolean

Defined in

src/math/Matrix4.ts:245


matrixMultiply

matrixMultiply(aMat, bMat, target_Mat): void

Multiply the world matrix, specifying parameters and results according to the index

Parameters

NameTypeDescription
aMatMatrix4Matrix to be multiplied (please specify index)
bMatMatrix4Matrix to be multiplied (please specify index)
target_MatMatrix4Result matrix (get results based on index)

Returns

void

Defined in

src/math/Matrix4.ts:282


matrixAppend

matrixAppend(aMat, bMat, target_Mat): void

World matrix extension, according to the index to specify parameters and results

Parameters

NameTypeDescription
aMatMatrix4Matrix to be multiplied (please specify index)
bMatMatrix4Matrix to be multiplied (please specify index)
target_MatMatrix4Result matrix (get results based on index)

Returns

void

Defined in

src/math/Matrix4.ts:292


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

NameTypeDescription
radnumber-
target_MatMatrix4Result matrix (get results based on index)

Returns

void

Defined in

src/math/Matrix4.ts:302


matrixRotate

matrixRotate(rad, axis, target_Mat): void

Rotate the world matrix, specifying parameters and results according to the index

Parameters

NameTypeDescription
radnumber-
axisVector3-
target_MatMatrix4Result matrix (get results based on index)

Returns

void

Defined in

src/math/Matrix4.ts:312


lookAt

lookAt(eye, at, up?): void

current matrix move position and rotation to target

Parameters

NameTypeDefault valueDescription
eyeVector3undefinedeye position
atVector3undefinedtarget position
upVector3Vector3.Y_AXISnormalize axis way

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:352


multiply

multiply(mat4): void

matrix multiply

Parameters

NameTypeDescription
mat4Matrix4multiply target

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:403


multiplyMatrices

multiplyMatrices(a, b): Matrix4

Parameters

NameType
aMatrix4
bMatrix4

Returns

Matrix4

Defined in

src/math/Matrix4.ts:452


multiplyPoint3

multiplyPoint3(v, output?): Vector3

convert a vector3 to this matrix space if output not set , return a new one

Parameters

NameTypeDescription
vVector3target vector3
output?Vector3save target

Returns

Vector3

save target

Defined in

src/math/Matrix4.ts:499


multiplyVector4

multiplyVector4(a, out?): Vector3

Parameters

NameType
aVector3
out?Vector3

Returns

Vector3

Defined in

src/math/Matrix4.ts:508


transformVector4

transformVector4(v, target?): Vector3

convert a vector3 to this matrix space if output not set , return a new one

Parameters

NameTypeDescription
vVector3convert target
target?Vector3ref one vector3

Returns

Vector3

Vector3

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:531


perspectiveMultiplyPoint3

perspectiveMultiplyPoint3(v, output): boolean

Convert projection coordinates to 3D coordinates

Parameters

NameTypeDescription
vVector3vector3 target
outputVector3ref vector3d

Returns

boolean

Defined in

src/math/Matrix4.ts:555


perspective

perspective(fov, aspect, zn, zf): void

set matrix perspective

Parameters

NameTypeDescription
fovnumberperspective angle 0 ~ 90
aspectnumberaspect ratio
znnumbernear plane
zfnumberfar plane

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:585


perspective3

perspective3(fov, aspect, near, far): void

Parameters

NameType
fovnumber
aspectnumber
nearnumber
farnumber

Returns

void

Defined in

src/math/Matrix4.ts:612


frustum

frustum(l, r, b, t, n, f): void

Parameters

NameType
lnumber
rnumber
bnumber
tnumber
nnumber
fnumber

Returns

void

Defined in

src/math/Matrix4.ts:618


ortho

ortho(w, h, zn, zf): Matrix4

Parameters

NameTypeDescription
wnumberscreen width
hnumberscreen height
znnumbercamera near plane
zfnumbercamera far plane

Returns

Matrix4

this matrix

Version

Orillusion3D 0.5.1 set matrix orthogonal projection

Defined in

src/math/Matrix4.ts:651


orthoZO

orthoZO(left, right, bottom, top, near, far): Matrix4

set matrix orthogonal projection by view side

Parameters

NameTypeDescription
leftnumberorthogonal view left
rightnumberorthogonal view right
bottomnumberorthogonal view bottom
topnumberorthogonal view top
nearnumbercamera near plane
farnumbercamera far plane

Returns

Matrix4

this matrix

Defined in

src/math/Matrix4.ts:687


orthoOffCenter

orthoOffCenter(l, r, b, t, zn, zf): void

set matrix orthogonal projection by view center

Parameters

NameType
lnumber
rnumber
bnumber
tnumber
znnumber
zfnumber

Returns

void

Defined in

src/math/Matrix4.ts:714


transformDir

transformDir(fromDirection, toDirection): this

set matrix from two direction

Parameters

NameTypeDescription
fromDirectionVector3first direction
toDirectionVector3second direction

Returns

this

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:744


append

append(lhs): void

multiply matrix a b

Parameters

NameTypeDescription
lhsMatrix4target matrix

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:867


add

add(lhs): Matrix4

matrix a add matrix b

Parameters

NameTypeDescription
lhsMatrix4target matrix.

Returns

Matrix4

Matrix4 result.

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:913


sub

sub(lhs): Matrix4

matrix a sub matrix b

Parameters

NameTypeDescription
lhsMatrix4target matrix b.

Returns

Matrix4

Matrix4 .

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:976


mult

mult(v): Matrix4

Matrix times components.

Parameters

NameTypeDescription
vnumberThis matrix is going to be multiplied by this value

Returns

Matrix4

Matrix4 Returns a multiplicative result matrix.

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1040


appendRotation

appendRotation(degrees, axis): void

Add a direction Angle rotation to the current matrix (the matrix created by rotating degrees according to axis)

Parameters

NameTypeDescription
degreesnumberAngle of rotation.
axisVector3Angle of rotation around axis axis

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1087


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

NameTypeDescription
degreesnumberAngle of rotation.
axisVector3Rotation 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

src/math/Matrix4.ts:1098


appendScale

appendScale(xScale, yScale, zScale): void

Append the triaxial scaling value

Parameters

NameTypeDescription
xScalenumberx axis scaling
yScalenumbery axis scaling
zScalenumberz axis scaling

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1175


createByScale

createByScale(xScale, yScale, zScale): void

A scaling matrix is generated and other properties are reset

Parameters

NameTypeDescription
xScalenumberx axis scaling
yScalenumbery axis scaling
zScalenumberz axis scaling

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1187


appendTranslation

appendTranslation(x, y, z): void

Plus a translation matrix

Parameters

NameTypeDescription
xnumberx axis scaling
ynumbery axis scaling
znumberz axis scaling

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1214


clone

clone(): Matrix4

Returns a clone of the current matrix

Returns

Matrix4

Matrix4 The cloned matrix

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1226


copyRowFrom

copyRowFrom(row, Vector3): void

Assigns a value to one row of the current matrix

Parameters

NameTypeDescription
rownumberRow of copy
Vector3Vector3Value of copy

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1238


copyRowTo

copyRowTo(row, Vector3): void

One of the rows in the copy matrix stores the values in Vector3.

Parameters

NameTypeDescription
rownumberRow of copy
Vector3Vector3Copy the storage target

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1276


copyFrom

copyFrom(sourceMatrix3D): Matrix4

Assigns the value of a matrix to the current matrix.

Parameters

NameTypeDescription
sourceMatrix3DMatrix4source Matrix

Returns

Matrix4

Returns the current matrix

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1314


copyRawDataTo

copyRawDataTo(vector, index?, transpose?): void

CoMath.PIes the value of the current matrix to a float array.

Parameters

NameTypeDefault valueDescription
vectorFloat32ArrayundefinedThe target array.
indexnumber0copy from the index of the array.
transposebooleanfalseWhether to transpose the current matrix.

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1342


copyColFrom

copyColFrom(col, Vector3): void

Assigns a value to a column of the current matrix

Parameters

NameTypeDescription
colnumbercolumn
Vector3Vector3Source of value

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1368


copyColTo

copyColTo(col, Vector3): void

Copy a column of the current matrix

Parameters

NameTypeDescription
colnumbercolumn
Vector3Vector3Target of copy

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1406


copyToMatrix3D

copyToMatrix3D(dest): void

Copy the current matrix

Parameters

NameTypeDescription
destMatrix4Target of copy

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1443


makeRotationFromQuaternion

makeRotationFromQuaternion(quaternion): Matrix4

Calculate rotation matrix

Parameters

NameTypeDescription
quaternionQuaternionRotate the quaternion

Returns

Matrix4

Defined in

src/math/Matrix4.ts:1452


decompose

decompose(orientationStyle?, target?): Vector3[]

Decompose the current matrix

Parameters

NameTypeDefault valueDescription
orientationStylestring'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

src/math/Matrix4.ts:1467


getEuler

getEuler(target, quaternion, isDegree?, order?): Vector3

Get the Euler vector

Parameters

NameTypeDefault valueDescription
targetVector3undefinedVector of results
quaternionQuaternionundefinedRotate the quaternion
isDegreebooleantrueWhether to convert to Angle
order?stringundefinedconvert order

Returns

Vector3

Defined in

src/math/Matrix4.ts:1595


compose

compose(position, quaternion, scale): Matrix4

Calculate the combined matrix of displacement, rotation and scaling

Parameters

NameTypeDescription
positionVector3translation
quaternionQuaternionrotation
scaleVector3scale

Returns

Matrix4

Defined in

src/math/Matrix4.ts:1608


deltaTransformVector

deltaTransformVector(v, target?): Vector3

The current matrix transforms a vector

Parameters

NameTypeDescription
vVector3Vector to transform
target?Vector3The default is null and if the current argument is null then a new Vector3 will be returned

Returns

Vector3

Vector3 The transformed vector

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1662


identity

identity(): Matrix4

Unifies the current matrix

Returns

Matrix4

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1681


fill

fill(value): void

Fill the current matrix

Parameters

NameTypeDescription
valuenumberThe filled value

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1708


invers33

invers33(): void

Invert the current matrix

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1732


invert

invert(): boolean

Invert the current matrix

Returns

boolean

boolean Whether can invert it

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1769


transformPoint

transformPoint(v, target?): Vector3

Converts the current coordinates to the world coordinates

Parameters

NameTypeDescription
vVector3Current coordinates
target?Vector3world coordinate

Returns

Vector3

world coordinate

Defined in

src/math/Matrix4.ts:1819


transformVector

transformVector(v, target?): Vector3

Transforming a 3D vector with the current matrix does not deal with displacement

Parameters

NameTypeDescription
vVector3Vector of transformation
target?Vector3If the current argument is null then a new Vector3 will be returned

Returns

Vector3

Vector3 The transformed vector

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1841


transpose

transpose(): void

The current matrix transpose

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1861


getPosition

getPosition(out?): Vector3

Return matrix displacement

Parameters

NameTypeDescription
out?Vector3Position of translation

Returns

Vector3

Position of translation

Defined in

src/math/Matrix4.ts:1904


toString

toString(): string

Returns the value of the matrix as a string

Returns

string

string

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:1966


lerp

lerp(m0, m1, t): void

Interpolate between two matrices

Parameters

NameTypeDescription
m0Matrix4Matrix 0
m1Matrix4Matrix 1
tnumberFactor of interpolation 0.0 - 1.0

Returns

void

Version

Orillusion3D 0.5.1

Defined in

src/math/Matrix4.ts:2012


get

get(row, column): number

Read matrix element values

Parameters

NameTypeDescription
rownumberrow
columnnumbercolumn

Returns

number

Defined in

src/math/Matrix4.ts:2023


set

set(row, column, v): void

Sets the matrix element values

Parameters

NameTypeDescription
rownumberrow
columnnumbercolumn
vnumbervalue

Returns

void

Defined in

src/math/Matrix4.ts:2033


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

src/math/Matrix4.ts:2041


translate

translate(inTrans): Matrix4

Calculate the displacement from the vector

Parameters

NameTypeDescription
inTransVector3Vector

Returns

Matrix4

current matrix

Defined in

src/math/Matrix4.ts:2056


setTRInverse

setTRInverse(pos, q): void

from unity AMath.PI

Parameters

NameType
posVector3
qQuaternion

Returns

void

Defined in

src/math/Matrix4.ts:2073


setScale

setScale(inScale): Matrix4

Set scale value

Parameters

NameTypeDescription
inScaleVector3scale value

Returns

Matrix4

this matrix

Defined in

src/math/Matrix4.ts:2084


makeBasis

makeBasis(xAxis, yAxis, zAxis): Matrix4

Generate the matrix according to the three axes

Parameters

NameType
xAxisVector3
yAxisVector3
zAxisVector3

Returns

Matrix4

Defined in

src/math/Matrix4.ts:2110


makeRotationAxis

makeRotationAxis(axis, angle): Matrix4

Parameters

NameType
axisVector3
anglenumber

Returns

Matrix4

Defined in

src/math/Matrix4.ts:2120