Skip to main content

Class: Mesh

网格渲染对象

代码示例:

const points = new Mesh(renderer, { mode: renderer.gl.POINTS, geometry, program });
points.setParent(scene);
points.position.set(-1, 1, 0);

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Mesh(renderer, options?): Mesh

Parameters

NameTypeDescription
rendererany渲染器
optionsMeshOptionsMeshOptions

Returns

Mesh

Overrides

Object3D.constructor

Defined in

src/objects/Mesh.ts:121

Properties

gl

gl: WebGLRenderingContext | WebGL2RenderingContext

Defined in

src/objects/Mesh.ts:89


modelViewMatrix

modelViewMatrix: Matrix4

Defined in

src/objects/Mesh.ts:91


normalMatrix

normalMatrix: Matrix3

Defined in

src/objects/Mesh.ts:93


renderOrder

renderOrder: number

Defined in

src/objects/Mesh.ts:95


zDepth

zDepth: number

Defined in

src/objects/Mesh.ts:97


frustumCulled

frustumCulled: boolean

Defined in

src/objects/Mesh.ts:99


mode

mode: number

Defined in

src/objects/Mesh.ts:101


renderer

renderer: Renderer

Defined in

src/objects/Mesh.ts:103


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

id

get id(): string

获取当前 Meshid

Returns

string

Defined in

src/objects/Mesh.ts:151


geometry

get geometry(): Geometry

获取当前 Mesh 的几何体信息

Returns

Geometry

Defined in

src/objects/Mesh.ts:158


program

get program(): Program

获取当前 Meshprogram 对象

Returns

Program

Defined in

src/objects/Mesh.ts:165


wireframe

get wireframe(): boolean

获取是否是网格渲染

Returns

boolean

Defined in

src/objects/Mesh.ts:184

set wireframe(wireframe): void

设置是否是网格渲染

Parameters

NameType
wireframeboolean

Returns

void

Defined in

src/objects/Mesh.ts:173

Methods

draw

draw(options?): void

执行Mesh 的渲染,一般由Renderer 渲染器进行调度。

Parameters

NameType
optionsMeshDrawOptions

Returns

void

Defined in

src/objects/Mesh.ts:192


updateWireframeGeometry

updateWireframeGeometry(wireframe, force?): void

更新网格几何体数据,主要是顶点索引数据

Parameters

NameTypeDefault valueDescription
wireframeanyundefined是否更新索引数据为网格数据
forcebooleanfalse是否强制更新

Returns

void

Defined in

src/objects/Mesh.ts:233


updateGeometry

updateGeometry(geometry, destroy?): void

更新几何体信息,如果开启了 wireframe 还需要更新 WireframeGeometry

Parameters

NameTypeDefault valueDescription
geometryanyundefined几何体
destroybooleantrue是否销毁上一个几何体

Returns

void

Defined in

src/objects/Mesh.ts:270


updateProgram

updateProgram(program, destroy?): void

更新 Program 对象

Parameters

NameTypeDefault valueDescription
programanyundefined
destroybooleantrue是否销毁上一个 program

Returns

void

Defined in

src/objects/Mesh.ts:283


destroy

destroy(): void

销毁此 Mesh

Returns

void

Defined in

src/objects/Mesh.ts:293


clone

clone(): Mesh

克隆 Mesh 对象

Returns

Mesh

Overrides

Object3D.clone

Defined in

src/objects/Mesh.ts:301


copy

copy(mesh, recursive?): Mesh

将给定的 Mesh 对象复制到此对象

Parameters

NameTypeDefault valueDescription
meshanyundefined源对象
recursivebooleantrue设置是否复制子对象

Returns

Mesh

Overrides

Object3D.copy

Defined in

src/objects/Mesh.ts:316


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