Skip to main content

Class: Scene

场景对象,一般我们会将创建的网格渲染对象添加到场景中进行渲染

代码示例:

const scene = new Scene();

const points = new Mesh(renderer, { mode: renderer.gl.POINTS, geometry, program });

points.position.set(-1, 1, 0);

scene.add(points);

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Scene(): Scene

Returns

Scene

Inherited from

Object3D.constructor

Defined in

src/objects/Object3D.ts:71

Properties

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

Methods

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


lookAt

lookAt(eye, invert?): void

旋转物体使其在世界空间中面朝一个点

Parameters

NameTypeDescription
eyeVector3朝向位置
invert?boolean是否反转

Returns

void

Inherited from

Object3D.lookAt

Defined in

src/objects/Object3D.ts:160


updateMatrixWorld

updateMatrixWorld(force?): void

更新渲染对象的世界矩阵

Parameters

NameTypeDescription
force?boolean是否更新次渲染对象的子集

Returns

void

Inherited from

Object3D.updateMatrixWorld

Defined in

src/objects/Object3D.ts:174


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(): Scene

克隆场景对象

Returns

Scene

Overrides

Object3D.clone

Defined in

src/objects/Scene.ts:21


copy

copy(source, recursive): Scene

将传入的场景对象的各属性复制到此场景实例中

Parameters

NameTypeDescription
sourceany源场景
recursiveany设置是否复制子对象

Returns

Scene

Overrides

Object3D.copy

Defined in

src/objects/Scene.ts:30