API/core/ModelMesh/

ModelMesh

Mesh containing common vertex elements of the model.

Hierarchy: Mesh

constructor 

new ModelMesh(engine: Engine, name: string)

Create a model mesh.

Parameters

  • engine

    Engine to which the mesh belongs

  • optionalname

    Mesh name

bounds ReadOnly

bounds: BoundingBox = ...

The bounding volume of the mesh.

instanceId ReadOnly

instanceId: number = ++EngineObject._instanceIdCounter

Engine unique id.

isGCIgnored 

isGCIgnored: boolean = false

Whether to ignore the garbage collection check, if it is true, it will not be affected by ResourceManager.gc().

name 

name: string

Name.

accessible 

get accessible(): boolean

Whether to access data of the mesh.

destroyed 

get destroyed(): boolean

Whether it has been destroyed.

engine 

get engine(): Engine

Get the engine which the object belongs.

refCount 

get refCount(): number

Counted by valid references.

subMesh 

get subMesh(): SubMesh

First sub-mesh. Rendered using the first material.

subMeshes 

get subMeshes(): readonly <SubMesh[]>

A collection of sub-mesh, each sub-mesh can be rendered with an independent material.

vertexCount 

get vertexCount(): number

Vertex count of current mesh.

addSubMesh 

addSubMesh(subMesh: SubMesh): SubMesh

Add sub-mesh, each sub-mesh can correspond to an independent material.

Parameters

  • subMesh

    Start drawing offset, if the index buffer is set, it means the offset in the index buffer, if not set, it means the offset in the vertex buffer

Returns

Sub-mesh
addSubMesh(start: number, count: number, topology: MeshTopology): SubMesh

Add sub-mesh, each sub-mesh can correspond to an independent material.

Parameters

  • start

    Start drawing offset, if the index buffer is set, it means the offset in the index buffer, if not set, it means the offset in the vertex buffer

  • count

    Drawing count, if the index buffer is set, it means the count in the index buffer, if not set, it means the count in the vertex buffer

  • optionaltopology

    Drawing topology, default is MeshTopology.Triangles

Returns

Sub-mesh

clearSubMesh 

clearSubMesh(): void

Clear all sub-mesh.

destroy 

destroy(force: boolean): boolean

Destroy self.

Parameters

  • force

    Whether to force the destruction, if it is fasle, refCount = 0 can be released successfully.

Returns

Whether the release was successful.

getBoneIndices 

getBoneIndices(): []

Get joints for the mesh.

remarksPlease call the setJoints() method after modification to ensure that the modification takes effect.

getBoneWeights 

getBoneWeights(): []

Get weights for the mesh.

remarksPlease call the setWeights() method after modification to ensure that the modification takes effect.

getColors 

getColors(): []

Get colors for the mesh.

remarksPlease call the setColors() method after modification to ensure that the modification takes effect.

getIndices 

getIndices():

Get indices for the mesh.

getNormals 

getNormals(): []

Get normals for the mesh.

remarksPlease call the setNormals() method after modification to ensure that the modification takes effect.

getPositions 

getPositions(): []

Get positions for the mesh.

remarksPlease call the setPositions() method after modification to ensure that the modification takes effect.

getTangents 

getTangents(): []

Get tangents for the mesh.

remarksPlease call the setTangents() method after modification to ensure that the modification takes effect.

getUVs 

getUVs(): []

Get uv for the mesh.

remarksPlease call the setUV() method after modification to ensure that the modification takes effect.

getUVs(channelIndex: number): []

Get uv for the mesh by channelIndex.

remarksPlease call the setUV() method after modification to ensure that the modification takes effect.

Parameters

  • channelIndex

    The index of uv channels, in [0 ~ 7] range.

registerUpdateFlag 

registerUpdateFlag(): UpdateFlag

Register update flag, update flag will be true if the vertex element changes.

Returns

Update flag

removeSubMesh 

removeSubMesh(subMesh: SubMesh): void

Remove sub-mesh.

Parameters

  • subMesh

    Sub-mesh needs to be removed

setBoneIndices 

setBoneIndices(boneIndices: Vector4[]): void

Set per-vertex bone indices for the mesh.

Parameters

  • boneIndices

    The bone indices for the mesh.

setBoneWeights 

setBoneWeights(boneWeights: Vector4[]): void

Set per-vertex bone weights for the mesh.

Parameters

  • boneWeights

    The bone weights for the mesh.

setColors 

setColors(colors: Color[]): void

Set per-vertex colors for the mesh.

Parameters

  • colors

    The colors for the mesh.

setIndices 

setIndices(indices: ): void

Set indices for the mesh.

Parameters

  • indices

    The indices for the mesh.

setNormals 

setNormals(normals: Vector3[]): void

Set per-vertex normals for the mesh.

Parameters

  • normals

    The normals for the mesh.

setPositions 

setPositions(positions: Vector3[]): void

Set positions for the mesh.

Parameters

  • positions

    The positions for the mesh.

setTangents 

setTangents(tangents: Vector4[]): void

Set per-vertex tangents for the mesh.

Parameters

  • tangents

    The tangents for the mesh.

setUVs 

setUVs(uv: Vector2[]): void

Set per-vertex uv for the mesh.

Parameters

  • uv

    The uv for the mesh.

setUVs(uv: Vector2[], channelIndex: number): void

Set per-vertex uv for the mesh by channelIndex.

Parameters

  • uv

    The uv for the mesh.

  • channelIndex

    The index of uv channels, in [0 ~ 7] range.

uploadData 

uploadData(noLongerAccessible: boolean): void

Upload Mesh Data to the graphics API.

Parameters

  • noLongerAccessible

    Whether to access data later. If true, you'll never access data anymore (free memory cache)