Class: ProjectionMatrix
一个表示 4*4 的矩阵 1--0--0--0 | | | | 0--1--0--0 | | | | 0--0--1--0 | | | | 0--0--0--1
const m = new Matrix4();
Hierarchy
-
↳
ProjectionMatrix
Table of contents
Constructors
Properties
Accessors
Methods
- fromArray
- toArray
- set
- transpose
- invert
- adjoint
- determinant
- add
- subtract
- multiply
- multiplyScalar
- premultiply
- translate
- rotate
- scale
- scaleScalar
- fromTranslation
- fromRotation
- fromRotationX
- fromRotationY
- fromRotationZ
- fromScale
- fromRotationTranslation
- fromPerspective
- fromOrthogonal
- fromQuat
- equals
- getRotation
- getScale
- getTranslation
- rotateX
- rotateY
- rotateZ
- compose
- decompose
- copy
- clone
- frustum
- orthographic
- perspective
- lookAt
- toString
Constructors
constructor
• new ProjectionMatrix(m00?
, m01?
, m02?
, m03?
, m10?
, m11?
, m12?
, m13?
, m20?
, m21?
, m22?
, m23?
, m30?
, m31?
, m32?
, m33?
): ProjectionMatrix
Parameters
Name | Type | Default value | Description |
---|---|---|---|
m00 | number | 1 | 第一行第一列,默认是 1 |
m01 | number | 0 | 第一行第二列,默认是 0 |
m02 | number | 0 | 第一行第三列,默认是 0 |
m03 | number | 0 | 第一行第四列,默认是 0 |
m10 | number | 0 | 第二行第一列,默认是 0 |
m11 | number | 1 | 第二行第二列,默认是 1 |
m12 | number | 0 | 第二行第三列,默认是 0 |
m13 | number | 0 | 第二行第四列,默认是 0 |
m20 | number | 0 | 第三行第一列,默认是 0 |
m21 | number | 0 | 第三行第二列,默认是 0 |
m22 | number | 1 | 第三行第三列,默认是 1 |
m23 | number | 0 | 第三行第四列,默认是 0 |
m30 | number | 0 | 第四行第一列,默认是 0 |
m31 | number | 0 | 第四行第二列,默认是 0 |
m32 | number | 0 | 第四行第三列,默认是 0 |
m33 | number | 1 | 第四行第四列,默认是 1 |
Returns
Inherited from
Defined in
Properties
elements
• elements: Float32Array
| Float64Array
Inherited from
Defined in
Accessors
x
• get
x(): number
获取向量 x 值
Returns
number
number;
Inherited from
Matrix4.x
Defined in
y
• get
y(): number
获取向量 y 值
Returns
number
number;
Inherited from
Matrix4.y
Defined in
z
• get
z(): number
获取向量 z 值
Returns
number
number;
Inherited from
Matrix4.z
Defined in
w
• get
w(): number
获取向量 w 值
Returns
number
number;
Inherited from
Matrix4.w
Defined in
identity
• get
identity(): Matrix4
获取单位矩阵
Returns
Inherited from
Matrix4.identity
Defined in
Methods
fromArray
▸ fromArray(array
, offset?
): ProjectionMatrix
从数组构建矩阵
Parameters
Name | Type | Default value | Description |
---|---|---|---|
array | any | undefined | 原始数组 |
offset | number | 0 | 数组偏移量 |
Returns
Inherited from
Defined in
toArray
▸ toArray(out?
, offset?
): Float32Array
| Float64Array
| number
[]
从矩阵转换到数组
Parameters
Name | Type | Default value | Description |
---|---|---|---|
out | Float32Array | Float64Array | number [] | [] | 输出数据 |
offset | number | 0 | 偏移量 |
Returns
Float32Array
| Float64Array
| number
[]
Inherited from
Defined in
set
▸ set(m00
, m01
, m02
, m03
, m10
, m11
, m12
, m13
, m20
, m21
, m22
, m23
, m30
, m31
, m32
, m33
): ProjectionMatrix
将此矩阵的每一项设置为给定的值
Parameters
Name | Type |
---|---|
m00 | any |
m01 | any |
m02 | any |
m03 | any |
m10 | any |
m11 | any |
m12 | any |
m13 | any |
m20 | any |
m21 | any |
m22 | any |
m23 | any |
m30 | any |
m31 | any |
m32 | any |
m33 | any |
Returns
Inherited from
Defined in
transpose
▸ transpose(): ProjectionMatrix
将此矩阵转换为转置矩阵
Returns
this
Inherited from
Defined in
invert
▸ invert(m?
): ProjectionMatrix
将此矩阵转换为逆矩阵
Parameters
Name | Type | Description |
---|---|---|
m | ProjectionMatrix | 默认为当前实例 |
Returns
Matrix4
Inherited from
Defined in
adjoint
▸ adjoint(m?
): ProjectionMatrix
计算此矩阵的伴随矩阵
Parameters
Name | Type | Description |
---|---|---|
m | ProjectionMatrix | 默认为当前实例 |
Returns
Inherited from
Defined in
determinant
▸ determinant(): any
计算行列式
Returns
any
Inherited from
Defined in
add
▸ add(a
, b?
): ProjectionMatrix
将两个 Matrix4 矩阵相加
Parameters
Name | Type | Description |
---|---|---|
a | Matrix4 | |
b? | Matrix4 | 如果不传,计算 this 和 a 的和 |
Returns
this
Inherited from
Defined in
subtract
▸ subtract(a
, b?
): ProjectionMatrix
将两个 Matrix4 矩阵相减
Parameters
Name | Type | Description |
---|---|---|
a | Matrix4 | |
b? | Matrix4 | 如果不传,计算 this 和 a 的差 |
Returns
this
Inherited from
Defined in
multiply
▸ multiply(a
, b?
): ProjectionMatrix
计算两个 Matrix4 矩阵的乘积
Parameters
Name | Type | Description |
---|---|---|
a | Matrix4 | |
b? | Matrix4 | 如果不传,计算 this 和 a 的乘积 |
Returns
this
Inherited from
Defined in
multiplyScalar
▸ multiplyScalar(a?
, b?
): ProjectionMatrix
计算 Matrix4 与标量的乘积
Parameters
Name | Type | Description |
---|---|---|
a | Matrix4 | 如果不传,计算 this 和 b 的乘积 |
b? | number |
Returns
Inherited from
Defined in
premultiply
▸ premultiply(a
, b?
): ProjectionMatrix
左乘
Parameters
Name | Type | Description |
---|---|---|
a | Matrix4 | |
b? | Matrix4 | 如果不传,计算 this 和 a 的左乘 |
Returns
this
Inherited from
Defined in
translate
▸ translate(v
): ProjectionMatrix
通过给定的向量 Vector3 平移此矩阵
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | 向量 |
Returns
this
Inherited from
Defined in
rotate
▸ rotate(rad
): ProjectionMatrix
旋转此矩阵
Parameters
Name | Type | Description |
---|---|---|
rad | number | 弧度 |
Returns
this
Inherited from
Defined in
scale
▸ scale(vec3
): ProjectionMatrix
通过给定的 Vector3 向量缩放此矩阵
Parameters
Name | Type |
---|---|
vec3 | Vector3 |
Returns
Inherited from
Defined in
scaleScalar
▸ scaleScalar(s
): ProjectionMatrix
通过标量 s 缩放此矩阵,默认在内部构建一个三维向量 [s, s, s]
Parameters
Name | Type |
---|---|
s | number |
Returns
Inherited from
Defined in
fromTranslation
▸ fromTranslation(vec
): ProjectionMatrix
从平移向量创建矩阵
Parameters
Name | Type |
---|---|
vec | Vector3 |
Returns
Inherited from
Defined in
fromRotation
▸ fromRotation(rad
, axis
): ProjectionMatrix
从给定轴和旋转角度创建矩阵
Parameters
Name | Type | Description |
---|---|---|
rad | number | 弧度 |
axis | any | 轴 |
Returns
Inherited from
Defined in
fromRotationX
▸ fromRotationX(rad
): ProjectionMatrix
从绕 X 轴的给定角度创建矩阵
Parameters
Name | Type |
---|---|
rad | number |
Returns
Inherited from
Defined in
fromRotationY
▸ fromRotationY(rad
): ProjectionMatrix
从绕 Y 轴的给定角度创建矩阵
Parameters
Name | Type |
---|---|
rad | number |
Returns
Inherited from
Defined in
fromRotationZ
▸ fromRotationZ(rad
): ProjectionMatrix
从绕 Z 轴的给定角度创建矩阵
Parameters
Name | Type |
---|---|
rad | any |
Returns
Inherited from
Defined in
fromScale
▸ fromScale(vec
): ProjectionMatrix
从缩放向量计算矩阵
Parameters
Name | Type |
---|---|
vec | Vector3 |
Returns
Inherited from
Defined in
fromRotationTranslation
▸ fromRotationTranslation(quat
, v
): ProjectionMatrix
从平移向量和四元数计算矩阵
Parameters
Name | Type |
---|---|
quat | Quaternion |
v | Vector3 |
Returns
Inherited from
Matrix4.fromRotationTranslation
Defined in
fromPerspective
▸ fromPerspective(fov
, aspect
, near
, far
): ProjectionMatrix
创建一个透视投影矩阵
Parameters
Name | Type |
---|---|
fov | any |
aspect | any |
near | any |
far | any |
Returns
Inherited from
Defined in
fromOrthogonal
▸ fromOrthogonal(left
, right
, bottom
, top
, near
, far
): ProjectionMatrix
创建一个正交投影矩阵
Parameters
Name | Type |
---|---|
left | any |
right | any |
bottom | any |
top | any |
near | any |
far | any |
Returns
Inherited from
Defined in
fromQuat
▸ fromQuat(q
): ProjectionMatrix
从给定的四元数计算矩阵
Parameters
Name | Type |
---|---|
q | Quaternion |
Returns
Inherited from
Defined in
equals
▸ equals(mat4
): any
判断两个矩阵是否近似相等
Parameters
Name | Type |
---|---|
mat4 | any |
Returns
any
Inherited from
Defined in
getRotation
▸ getRotation(q?
): Quaternion
获取旋转向量
Parameters
Name | Type |
---|---|
q | Quaternion |
Returns
Inherited from
Defined in
getScale
▸ getScale(v?
): Vector3
获取缩放向量
Parameters
Name | Type |
---|---|
v | Vector3 |
Returns
Inherited from
Defined in
getTranslation
▸ getTranslation(v?
): Vector3
获取平移向量
Parameters
Name | Type |
---|---|
v | Vector3 |
Returns
Inherited from
Defined in
rotateX
▸ rotateX(rad
): ProjectionMatrix
围绕 X 轴按给定弧度旋转矩阵
Parameters
Name | Type |
---|---|
rad | any |
Returns
Inherited from
Defined in
rotateY
▸ rotateY(rad
): ProjectionMatrix
围绕 Y 轴按给定弧度旋转矩阵
Parameters
Name | Type |
---|---|
rad | any |
Returns
Inherited from
Defined in
rotateZ
▸ rotateZ(rad
): ProjectionMatrix
围绕 Z 轴按给定弧度旋转矩阵
Parameters
Name | Type |
---|---|
rad | any |
Returns
Inherited from
Defined in
compose
▸ compose(v
, q
, s
): ProjectionMatrix
从四元数旋转、平移和缩放创建矩阵
Parameters
Name | Type |
---|---|
v | Vector3 |
q | Quaternion |
s | Vector3 |
Returns
Inherited from
Defined in
decompose
▸ decompose(): Object
从矩阵转换到四元数、平移和缩放向量
Returns
Object
Name | Type |
---|---|
rotation | Quaternion |
scale | Vector3 |
translation | Vector3 |
Inherited from
Defined in
copy
▸ copy(m
): ProjectionMatrix
将传入的 Matrix4 复制到此矩阵
Parameters
Name | Type | Description |
---|---|---|
m | Matrix4 | 源矩阵 |
Returns
this
Inherited from
Defined in
clone
▸ clone(): Matrix4
从此矩阵创建一个新的 4*4 矩阵
Returns
a new Matrix4
Inherited from
Defined in
frustum
▸ frustum(mat4
, left
, right
, top
, bottom
, near
, far
): ProjectionMatrix
一般用于生成相机的视椎体,用来做视椎剔除加速渲染
Parameters
Name | Type |
---|---|
mat4 | any |
left | any |
right | any |
top | any |
bottom | any |
near | any |
far | any |
Returns
Defined in
src/math/ProjectionMatrix.ts:17
orthographic
▸ orthographic(left
, right
, top
, bottom
, near
, far
): ProjectionMatrix
生成平面相机投影矩阵
Parameters
Name | Type |
---|---|
left | any |
right | any |
top | any |
bottom | any |
near | any |
far | any |
Returns
Defined in
src/math/ProjectionMatrix.ts:31
perspective
▸ perspective(fovy
, aspect
, near
, far
): ProjectionMatrix
生成透视相机投影矩阵
Parameters
Name | Type |
---|---|
fovy | any |
aspect | any |
near | any |
far | any |
Returns
Defined in
src/math/ProjectionMatrix.ts:43
lookAt
▸ lookAt(eye
, target?
, up?
): ProjectionMatrix
设置物体的朝向
Parameters
Name | Type |
---|---|
eye | any |
target | Vector3 |
up | Vector3 |
Returns
Defined in
src/math/ProjectionMatrix.ts:54
toString
▸ toString(): string
转换为字符串
Returns
string