Skip to main content

Class: Camera

相机基类

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Camera(«destructured»?): Camera

Parameters

NameType
«destructured»CameraOptions

Returns

Camera

Overrides

Object3D.constructor

Defined in

src/cameras/Camera.ts:130

Properties

cameraType

cameraType: CameraType

相机类型(默认有两种相机:perspective和orthographic)

Defined in

src/cameras/Camera.ts:76


projectionMatrix

projectionMatrix: ProjectionMatrix

投影矩阵

Defined in

src/cameras/Camera.ts:81


viewMatrix

viewMatrix: Matrix4

视图矩阵

Defined in

src/cameras/Camera.ts:86


projectionViewMatrix

projectionViewMatrix: ProjectionMatrix

pv矩阵,它是 projectionMatrixviewMatrix 的乘积

Defined in

src/cameras/Camera.ts:91


worldPosition

worldPosition: Vector3

世界位置坐标

Defined in

src/cameras/Camera.ts:96


frustum

frustum: Matrix4

Defined in

src/cameras/Camera.ts:128


visible

visible: boolean

是否可见

Inherited from

Object3D.visible

Defined in

src/objects/Object3D.ts:14


localMatrix

localMatrix: ProjectionMatrix

局部变换矩阵

Inherited from

Object3D.localMatrix

Defined in

src/objects/Object3D.ts:19


worldMatrix

worldMatrix: ProjectionMatrix

物体的世界变换矩阵 (如果没有父级,那么他和局部变化矩阵相同)

Inherited from

Object3D.worldMatrix

Defined in

src/objects/Object3D.ts:24


matrixAutoUpdate

matrixAutoUpdate: boolean

当这个属性设置了之后,它将计算每一帧的位移、旋转(四元变换)和缩放矩阵,并重新计算 worldMatrix 属性

Inherited from

Object3D.matrixAutoUpdate

Defined in

src/objects/Object3D.ts:29


position

position: Vector3

物体局部位置

Inherited from

Object3D.position

Defined in

src/objects/Object3D.ts:34


scale

scale: Vector3

物体的局部缩放

Inherited from

Object3D.scale

Defined in

src/objects/Object3D.ts:39


rotation

rotation: Euler

物体的局部旋转

Inherited from

Object3D.rotation

Defined in

src/objects/Object3D.ts:44


quaternion

quaternion: Quaternion

物体的局部旋转

Inherited from

Object3D.quaternion

Defined in

src/objects/Object3D.ts:49


up

up: Vector3

物体的朝向

Inherited from

Object3D.up

Defined in

src/objects/Object3D.ts:54


children

children: Object3D[]

对象子级

Inherited from

Object3D.children

Defined in

src/objects/Object3D.ts:59


parent

parent: WithNull<Object3D>

对象父级

Inherited from

Object3D.parent

Defined in

src/objects/Object3D.ts:64


worldMatrixNeedsUpdate

worldMatrixNeedsUpdate: boolean

当这个属性设置了之后,它将计算在那一帧中的 worldMatrix,并将这个值重置为false。默认值为false

Inherited from

Object3D.worldMatrixNeedsUpdate

Defined in

src/objects/Object3D.ts:69

Accessors

near

get near(): number

获取像机的近端面

Returns

number

Defined in

src/cameras/Camera.ts:172

set near(n): void

设置像机的近端面,并更新摄像机投影矩阵

Parameters

NameTypeDescription
nnumbernear

Returns

void

Defined in

src/cameras/Camera.ts:180


far

get far(): number

获取像机的远端面

Returns

number

Defined in

src/cameras/Camera.ts:188

set far(f): void

设置像机的远端面,并更新摄像机投影矩阵

Parameters

NameType
fnumber

Returns

void

Defined in

src/cameras/Camera.ts:196


fov

get fov(): number

获取摄像机视锥体垂直视野角度

Returns

number

Defined in

src/cameras/Camera.ts:204

set fov(f): void

设置摄像机视锥体垂直视野角度,并更新摄像机投影矩阵

Parameters

NameTypeDescription
fnumber角度值

Returns

void

Defined in

src/cameras/Camera.ts:212


aspect

get aspect(): number

获取相机视锥体的纵横比

Returns

number

Defined in

src/cameras/Camera.ts:220

set aspect(aspect): void

设置相机视锥体的纵横比,并更新摄像机投影矩阵

Parameters

NameType
aspectnumber

Returns

void

Defined in

src/cameras/Camera.ts:228


zoom

get zoom(): number

获取相机的缩放倍数

Returns

number

Defined in

src/cameras/Camera.ts:236

set zoom(zoom): void

设置相机的缩放倍数,并更新摄像机投影矩阵

Parameters

NameType
zoomnumber

Returns

void

Defined in

src/cameras/Camera.ts:244


bounds

get bounds(): WithUndef<Bounds>

获取像机视锥体的范围

Returns

WithUndef<Bounds>

Defined in

src/cameras/Camera.ts:252

set bounds(bounds): void

设置相机像机视锥体的范围,并更新摄像机投影矩阵

Parameters

NameType
boundsWithUndef<Bounds>

Returns

void

Defined in

src/cameras/Camera.ts:260

Methods

perspective

perspective(fov?, aspect?, near?, far?): void

创建或者更新 projectionMatrix 透视相机矩阵

Parameters

NameType
fovnumber
aspectnumber
nearnumber
farnumber

Returns

void

Defined in

src/cameras/Camera.ts:272


orthographic

orthographic(left, right, top, bottom, near?, far?, zoom?): void

创建或者更新 projectionMatrix 平面相机矩阵

Parameters

NameTypeDefault value
leftanyundefined
rightanyundefined
topanyundefined
bottomanyundefined
nearnumberundefined
farnumberundefined
zoomnumber1

Returns

void

Defined in

src/cameras/Camera.ts:292


lookAt

lookAt(t): Camera

设置相机的朝向

Parameters

NameTypeDescription
tany朝向位置,是一个三维向量

Returns

Camera

Overrides

Object3D.lookAt

Defined in

src/cameras/Camera.ts:317


updateMatrixWorld

updateMatrixWorld(): Camera

用于更新一个对象的世界矩阵。 每个可视对象都有一个叫做 worldMatrix 的矩阵,表示这个对象在世界坐标系中的位置和方向。 当您修改对象的位置、旋转或缩放时,对象的 worldMatrix 矩阵会发生变化。如果您希望将这些变化反映到场景中,就需要调用 updateMatrixWorld 函数。

Returns

Camera

Overrides

Object3D.updateMatrixWorld

Defined in

src/cameras/Camera.ts:327


frustumIntersectsMesh

frustumIntersectsMesh(node, worldMatrix?): boolean

判断 mesh 是否在相机视椎体内

Parameters

NameTypeDefault value
nodeanyundefined
worldMatrixanynode.worldMatrix

Returns

boolean

Defined in

src/cameras/Camera.ts:340


project

project(v): Camera

转换到世界坐标

Parameters

NameType
vany

Returns

Camera

Defined in

src/cameras/Camera.ts:376


unproject

unproject(v): Camera

Parameters

NameType
vany

Returns

Camera

Defined in

src/cameras/Camera.ts:382


updateProjectionMatrix

updateProjectionMatrix(): void

更新摄像机投影矩阵,必须由子类实现

Returns

void

Defined in

src/cameras/Camera.ts:391


add

add(object, notifyChild?): void

添加对象到这个对象的子级

Parameters

NameTypeDefault value
objectObject3Dundefined
notifyChildbooleantrue

Returns

void

Inherited from

Object3D.add

Defined in

src/objects/Object3D.ts:97


remove

remove(object, notifyChild?): void

从此对象移除传入的对象(如果存在)

Parameters

NameTypeDefault value
objectObject3Dundefined
notifyChildbooleantrue

Returns

void

Inherited from

Object3D.remove

Defined in

src/objects/Object3D.ts:111


contains

contains(object): boolean

判断此渲染对象的子集是否包含传入的渲染对象

Parameters

NameType
objectObject3D

Returns

boolean

Inherited from

Object3D.contains

Defined in

src/objects/Object3D.ts:124


setParent

setParent(object, notifyParent?): void

设置此渲染对象的父集

Parameters

NameTypeDefault valueDescription
objectanyundefined渲染对象
notifyParentbooleantrue设置是否将此渲染对象添加到传入的渲染对象中

Returns

void

Inherited from

Object3D.setParent

Defined in

src/objects/Object3D.ts:133


traverse

traverse(callback): void

遍历此对象(包含子对象)

Parameters

NameTypeDescription
callbackany回调函数

Returns

void

Inherited from

Object3D.traverse

Defined in

src/objects/Object3D.ts:147


updateMatrix

updateMatrix(): void

更新局部变换矩阵

Returns

void

Inherited from

Object3D.updateMatrix

Defined in

src/objects/Object3D.ts:200


decompose

decompose(): void

从局部矩阵计算位置,旋转和缩放

Returns

void

Inherited from

Object3D.decompose

Defined in

src/objects/Object3D.ts:208


clone

clone(): Object3D

克隆此渲染对象

Returns

Object3D

Inherited from

Object3D.clone

Defined in

src/objects/Object3D.ts:218


copy

copy(object, recursive?): Camera

复制给定的对象到这个对象中

Parameters

NameTypeDescription
objectObject3D渲染对象
recursive?boolean设置是否复制子对象

Returns

Camera

Inherited from

Object3D.copy

Defined in

src/objects/Object3D.ts:227