Skip to main content

Class: OrthographicCamera

正交相机(在这种投影模式下,无论物体距离相机距离远或者近,在最终渲染的图片中物体的大小都保持不变)

代码示例:

const camera = new OrthographicCamera(width / - 2, width / 2, height / 2, height / - 2, 1, 1000);
scene.add(camera);

Hierarchy

  • Camera

    OrthographicCamera

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new OrthographicCamera(left, right, top, bottom, near, far, zoom?): OrthographicCamera

Parameters

NameTypeDefault value
leftanyundefined
rightanyundefined
topanyundefined
bottomanyundefined
nearanyundefined
faranyundefined
zoomnumber1

Returns

OrthographicCamera

Overrides

Camera.constructor

Defined in

src/cameras/OrthographicCamera.ts:14

Properties

cameraType

cameraType: CameraType

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

Inherited from

Camera.cameraType

Defined in

src/cameras/Camera.ts:76


projectionMatrix

projectionMatrix: ProjectionMatrix

投影矩阵

Inherited from

Camera.projectionMatrix

Defined in

src/cameras/Camera.ts:81


viewMatrix

viewMatrix: Matrix4

视图矩阵

Inherited from

Camera.viewMatrix

Defined in

src/cameras/Camera.ts:86


projectionViewMatrix

projectionViewMatrix: ProjectionMatrix

pv矩阵,它是 projectionMatrixviewMatrix 的乘积

Inherited from

Camera.projectionViewMatrix

Defined in

src/cameras/Camera.ts:91


worldPosition

worldPosition: Vector3

世界位置坐标

Inherited from

Camera.worldPosition

Defined in

src/cameras/Camera.ts:96


frustum

frustum: Matrix4

Inherited from

Camera.frustum

Defined in

src/cameras/Camera.ts:128


visible

visible: boolean

是否可见

Inherited from

Camera.visible

Defined in

src/objects/Object3D.ts:14


localMatrix

localMatrix: ProjectionMatrix

局部变换矩阵

Inherited from

Camera.localMatrix

Defined in

src/objects/Object3D.ts:19


worldMatrix

worldMatrix: ProjectionMatrix

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

Inherited from

Camera.worldMatrix

Defined in

src/objects/Object3D.ts:24


matrixAutoUpdate

matrixAutoUpdate: boolean

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

Inherited from

Camera.matrixAutoUpdate

Defined in

src/objects/Object3D.ts:29


position

position: Vector3

物体局部位置

Inherited from

Camera.position

Defined in

src/objects/Object3D.ts:34


scale

scale: Vector3

物体的局部缩放

Inherited from

Camera.scale

Defined in

src/objects/Object3D.ts:39


rotation

rotation: Euler

物体的局部旋转

Inherited from

Camera.rotation

Defined in

src/objects/Object3D.ts:44


quaternion

quaternion: Quaternion

物体的局部旋转

Inherited from

Camera.quaternion

Defined in

src/objects/Object3D.ts:49


up

up: Vector3

物体的朝向

Inherited from

Camera.up

Defined in

src/objects/Object3D.ts:54


children

children: Object3D[]

对象子级

Inherited from

Camera.children

Defined in

src/objects/Object3D.ts:59


parent

parent: WithNull<Object3D>

对象父级

Inherited from

Camera.parent

Defined in

src/objects/Object3D.ts:64


worldMatrixNeedsUpdate

worldMatrixNeedsUpdate: boolean

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

Inherited from

Camera.worldMatrixNeedsUpdate

Defined in

src/objects/Object3D.ts:69

Accessors

near

get near(): number

获取像机的近端面

Returns

number

Inherited from

Camera.near

Defined in

src/cameras/Camera.ts:172

set near(n): void

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

Parameters

NameTypeDescription
nnumbernear

Returns

void

Inherited from

Camera.near

Defined in

src/cameras/Camera.ts:180


far

get far(): number

获取像机的远端面

Returns

number

Inherited from

Camera.far

Defined in

src/cameras/Camera.ts:188

set far(f): void

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

Parameters

NameType
fnumber

Returns

void

Inherited from

Camera.far

Defined in

src/cameras/Camera.ts:196


fov

get fov(): number

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

Returns

number

Inherited from

Camera.fov

Defined in

src/cameras/Camera.ts:204

set fov(f): void

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

Parameters

NameTypeDescription
fnumber角度值

Returns

void

Inherited from

Camera.fov

Defined in

src/cameras/Camera.ts:212


aspect

get aspect(): number

获取相机视锥体的纵横比

Returns

number

Inherited from

Camera.aspect

Defined in

src/cameras/Camera.ts:220

set aspect(aspect): void

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

Parameters

NameType
aspectnumber

Returns

void

Inherited from

Camera.aspect

Defined in

src/cameras/Camera.ts:228


zoom

get zoom(): number

获取相机的缩放倍数

Returns

number

Inherited from

Camera.zoom

Defined in

src/cameras/Camera.ts:236

set zoom(zoom): void

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

Parameters

NameType
zoomnumber

Returns

void

Inherited from

Camera.zoom

Defined in

src/cameras/Camera.ts:244


bounds

get bounds(): WithUndef<Bounds>

获取像机视锥体的范围

Returns

WithUndef<Bounds>

Inherited from

Camera.bounds

Defined in

src/cameras/Camera.ts:252

set bounds(bounds): void

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

Parameters

NameType
boundsWithUndef<Bounds>

Returns

void

Inherited from

Camera.bounds

Defined in

src/cameras/Camera.ts:260

Methods

perspective

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

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

Parameters

NameType
fovnumber
aspectnumber
nearnumber
farnumber

Returns

void

Inherited from

Camera.perspective

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

Inherited from

Camera.orthographic

Defined in

src/cameras/Camera.ts:292


lookAt

lookAt(t): OrthographicCamera

设置相机的朝向

Parameters

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

Returns

OrthographicCamera

Inherited from

Camera.lookAt

Defined in

src/cameras/Camera.ts:317


updateMatrixWorld

updateMatrixWorld(): OrthographicCamera

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

Returns

OrthographicCamera

Inherited from

Camera.updateMatrixWorld

Defined in

src/cameras/Camera.ts:327


frustumIntersectsMesh

frustumIntersectsMesh(node, worldMatrix?): boolean

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

Parameters

NameTypeDefault value
nodeanyundefined
worldMatrixanynode.worldMatrix

Returns

boolean

Inherited from

Camera.frustumIntersectsMesh

Defined in

src/cameras/Camera.ts:340


project

project(v): OrthographicCamera

转换到世界坐标

Parameters

NameType
vany

Returns

OrthographicCamera

Inherited from

Camera.project

Defined in

src/cameras/Camera.ts:376


unproject

unproject(v): OrthographicCamera

Parameters

NameType
vany

Returns

OrthographicCamera

Inherited from

Camera.unproject

Defined in

src/cameras/Camera.ts:382


updateProjectionMatrix

updateProjectionMatrix(): void

更新投影矩阵

Returns

void

Overrides

Camera.updateProjectionMatrix

Defined in

src/cameras/OrthographicCamera.ts:31


add

add(object, notifyChild?): void

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

Parameters

NameTypeDefault value
objectObject3Dundefined
notifyChildbooleantrue

Returns

void

Inherited from

Camera.add

Defined in

src/objects/Object3D.ts:97


remove

remove(object, notifyChild?): void

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

Parameters

NameTypeDefault value
objectObject3Dundefined
notifyChildbooleantrue

Returns

void

Inherited from

Camera.remove

Defined in

src/objects/Object3D.ts:111


contains

contains(object): boolean

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

Parameters

NameType
objectObject3D

Returns

boolean

Inherited from

Camera.contains

Defined in

src/objects/Object3D.ts:124


setParent

setParent(object, notifyParent?): void

设置此渲染对象的父集

Parameters

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

Returns

void

Inherited from

Camera.setParent

Defined in

src/objects/Object3D.ts:133


traverse

traverse(callback): void

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

Parameters

NameTypeDescription
callbackany回调函数

Returns

void

Inherited from

Camera.traverse

Defined in

src/objects/Object3D.ts:147


updateMatrix

updateMatrix(): void

更新局部变换矩阵

Returns

void

Inherited from

Camera.updateMatrix

Defined in

src/objects/Object3D.ts:200


decompose

decompose(): void

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

Returns

void

Inherited from

Camera.decompose

Defined in

src/objects/Object3D.ts:208


clone

clone(): Object3D

克隆此渲染对象

Returns

Object3D

Inherited from

Camera.clone

Defined in

src/objects/Object3D.ts:218


copy

copy(object, recursive?): OrthographicCamera

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

Parameters

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

Returns

OrthographicCamera

Inherited from

Camera.copy

Defined in

src/objects/Object3D.ts:227