Class: PerspectiveCamera
透视相机
代码示例:
const camera = new PerspectiveCamera(45, width / height, 1, 1000)
scene.add(camera);
Hierarchy
-
↳
PerspectiveCamera
Table of contents
Constructors
Properties
- cameraType
- projectionMatrix
- viewMatrix
- projectionViewMatrix
- worldPosition
- frustum
- visible
- localMatrix
- worldMatrix
- matrixAutoUpdate
- position
- scale
- rotation
- quaternion
- up
- children
- parent
- worldMatrixNeedsUpdate
Accessors
Methods
- perspective
- orthographic
- lookAt
- updateMatrixWorld
- frustumIntersectsMesh
- project
- unproject
- updateProjectionMatrix
- add
- remove
- contains
- setParent
- traverse
- updateMatrix
- decompose
- clone
- copy
Constructors
constructor
• new PerspectiveCamera(fov
, aspect
, near
, far
): PerspectiveCamera
Parameters
Name | Type |
---|---|
fov | any |
aspect | any |
near | any |
far | any |
Returns
Overrides
Defined in
src/cameras/PerspectiveCamera.ts:13
Properties
cameraType
• cameraType: CameraType
相机类型(默认有两种相机:perspective和orthographic)
Inherited from
Defined in
projectionMatrix
• projectionMatrix: ProjectionMatrix
投影矩阵
Inherited from
Defined in
viewMatrix
• viewMatrix: Matrix4
视图矩阵
Inherited from
Defined in
projectionViewMatrix
• projectionViewMatrix: ProjectionMatrix
pv矩阵,它是 projectionMatrix
和viewMatrix
的乘积
Inherited from
Defined in
worldPosition
• worldPosition: Vector3
世界位置坐标
Inherited from
Defined in
frustum
• frustum: Matrix4
Inherited from
Defined in
visible
• visible: boolean
是否可见
Inherited from
Defined in
localMatrix
• localMatrix: ProjectionMatrix
局部变换矩阵
Inherited from
Defined in
worldMatrix
• worldMatrix: ProjectionMatrix
物体的世界变换 矩阵 (如果没有父级,那么他和局部变化矩阵相同)
Inherited from
Defined in
matrixAutoUpdate
• matrixAutoUpdate: boolean
当这个属性设置了之后,它将计算每一帧的位移、旋转(四元变换)和缩放矩阵,并重新计算 worldMatrix
属性
Inherited from
Defined in
position
• position: Vector3
物体局部位置
Inherited from
Defined in
scale
• scale: Vector3
物体的局部缩放
Inherited from
Defined in
rotation
• rotation: Euler
物体的局部旋转
Inherited from
Defined in
quaternion
• quaternion: Quaternion
物体的局部旋转
Inherited from
Defined in
up
• up: Vector3
物体的朝向
Inherited from
Defined in
children
• children: Object3D
[]
对象子级
Inherited from
Defined in
parent
• parent: WithNull
<Object3D
>
对象父级
Inherited from
Defined in
worldMatrixNeedsUpdate
• worldMatrixNeedsUpdate: boolean
当这个属性设置了之后,它将计算在那一帧中的 worldMatrix
,并将这个值重置为false。默认值为false
Inherited from
Defined in
Accessors
near
• get
near(): number
获取像机的近端面
Returns
number
Inherited from
Camera.near
Defined in
• set
near(n
): void
设置像机的近端面,并更新摄像机投影矩阵
Parameters
Name | Type | Description |
---|---|---|
n | number | near |
Returns
void
Inherited from
Camera.near
Defined in
far
• get
far(): number
获取像机的远端面
Returns
number
Inherited from
Camera.far
Defined in
• set
far(f
): void
设置像机的远端面,并更新摄像机投影矩阵
Parameters
Name | Type |
---|---|
f | number |
Returns
void
Inherited from
Camera.far
Defined in
fov
• get
fov(): number
获取摄像机视锥体垂直视野角度
Returns
number
Inherited from
Camera.fov
Defined in
• set
fov(f
): void
设置摄像机视锥体垂直视野角度,并更新摄像机投影矩阵
Parameters
Name | Type | Description |
---|---|---|
f | number | 角度值 |
Returns
void
Inherited from
Camera.fov
Defined in
aspect
• get
aspect(): number
获取相机视锥体的纵横比
Returns
number
Inherited from
Camera.aspect
Defined in
• set
aspect(aspect
): void
设置相机视锥体的纵横比,并更新摄像机投影矩阵
Parameters
Name | Type |
---|---|
aspect | number |
Returns
void
Inherited from
Camera.aspect
Defined in
zoom
• get
zoom(): number
获取相机的缩放倍数
Returns
number
Inherited from
Camera.zoom
Defined in
• set
zoom(zoom
): void
设置相机的缩放倍数,并更新摄像机投影矩阵
Parameters
Name | Type |
---|---|
zoom | number |
Returns
void
Inherited from
Camera.zoom
Defined in
bounds
• get
bounds(): WithUndef
<Bounds
>
获取像机视锥体的范围
Returns
WithUndef
<Bounds
>
Inherited from
Camera.bounds
Defined in
• set
bounds(bounds
): void
设置相机像机视锥体的范围,并更新摄像机投影矩阵
Parameters
Name | Type |
---|---|
bounds | WithUndef <Bounds > |
Returns
void
Inherited from
Camera.bounds
Defined in
Methods
perspective
▸ perspective(fov?
, aspect?
, near?
, far?
): void
创建或者更新 projectionMatrix
透视相机矩阵
Parameters
Name | Type |
---|---|
fov | number |
aspect | number |
near | number |
far | number |
Returns
void
Inherited from
Defined in
orthographic
▸ orthographic(left
, right
, top
, bottom
, near?
, far?
, zoom?
): void
创建或者更新 projectionMatrix
平面相机矩阵
Parameters
Name | Type | Default value |
---|---|---|
left | any | undefined |
right | any | undefined |
top | any | undefined |
bottom | any | undefined |
near | number | undefined |
far | number | undefined |
zoom | number | 1 |
Returns
void
Inherited from
Defined in
lookAt
▸ lookAt(t
): PerspectiveCamera
设置相机的朝向
Parameters
Name | Type | Description |
---|---|---|
t | any | 朝向位置,是一个三维向量 |
Returns
Inherited from
Defined in
updateMatrixWorld
▸ updateMatrixWorld(): PerspectiveCamera
用于更新一个对象的世界矩阵。
每个可视对象都有一个叫做 worldMatrix
的矩阵,表示这个对象在世界坐标系中的位置和方向。
当您修改对象的位置、旋转 或缩放时,对象的 worldMatrix
矩阵会发生变化。如果您希望将这些变化反映到场景中,就需要调用 updateMatrixWorld
函数。
Returns
Inherited from
Defined in
frustumIntersectsMesh
▸ frustumIntersectsMesh(node
, worldMatrix?
): boolean
判断 mesh 是否在相机视椎体内
Parameters
Name | Type | Default value |
---|---|---|
node | any | undefined |
worldMatrix | any | node.worldMatrix |
Returns
boolean
Inherited from
Defined in
project
▸ project(v
): PerspectiveCamera
转换到世界坐标
Parameters
Name | Type |
---|---|
v | any |
Returns
Inherited from
Defined in
unproject
▸ unproject(v
): PerspectiveCamera
Parameters
Name | Type |
---|---|
v | any |
Returns
Inherited from
Defined in
updateProjectionMatrix
▸ updateProjectionMatrix(): void
更新投影矩阵
Returns
void
Overrides
Defined in
src/cameras/PerspectiveCamera.ts:25
add
▸ add(object
, notifyChild?
): void
添加对象到这个对象的子级
Parameters
Name | Type | Default value |
---|---|---|
object | Object3D | undefined |
notifyChild | boolean | true |
Returns
void
Inherited from
Defined in
remove
▸ remove(object
, notifyChild?
): void
从此对象移除传入的对象(如果存在)
Parameters
Name | Type | Default value |
---|---|---|
object | Object3D | undefined |
notifyChild | boolean | true |
Returns
void
Inherited from
Defined in
contains
▸ contains(object
): boolean
判断此渲染对象的子集是否包含传入的渲染对象
Parameters
Name | Type |
---|---|
object | Object3D |
Returns
boolean
Inherited from
Defined in
setParent
▸ setParent(object
, notifyParent?
): void
设置此渲染对象的父集
Parameters
Name | Type | Default value | Description |
---|---|---|---|
object | any | undefined | 渲染对象 |
notifyParent | boolean | true | 设置是否将此渲染对象添加到传入的渲染对象中 |
Returns
void
Inherited from
Defined in
traverse
▸ traverse(callback
): void
遍历此对象(包含子对象)
Parameters
Name | Type | Description |
---|---|---|
callback | any | 回调函数 |
Returns
void
Inherited from
Defined in
updateMatrix
▸ updateMatrix(): void
更新局部变换矩阵
Returns
void
Inherited from
Defined in
decompose
▸ decompose(): void
从局部矩阵计算位置,旋转和缩放
Returns
void
Inherited from
Defined in
clone
▸ clone(): Object3D
克隆此渲染对象
Returns
Inherited from
Defined in
copy
▸ copy(object
, recursive?
): PerspectiveCamera
复制给定的对象到这个对象中
Parameters
Name | Type | Description |
---|---|---|
object | Object3D | 渲染对象 |
recursive? | boolean | 设置是否复制子对象 |