Mesh
Mesh
Wrapper around a native mesh data
Kind: global class
new Mesh (params)
Constructor
Param | Type | Description |
---|---|---|
params | object | Either a mesh index to wrap or set of parameters to create a new mesh |
params.vertexCount | number | Number of vertices to allocate |
params.skinned | boolean | true if the mesh should be skinned. Defaults to false. |
params.vertexData | Array.<number> | (deprecated, use vertexCount instead and set data with attribute instead.) Interleaved vertex data values. A vertex is a set of 8 float values: - 0-2 Position - 3-5 Normal - 6-8 Texture Coordinate |
params.indexData | Array.<number> | Index data values |
params.indexType | MeshIndexType | Index type, null if not indexed |
.vertexData ⇒ Float32Array
Deprecated
Kind: instance property of Mesh
Returns: Float32Array - Vertex data (read-only)
.vertexCount ⇒ number
Kind: instance property of Mesh
Returns: number - Number of vertices in this mesh
.indexData ⇒ Uint8Array | Uint16Array | Uint32Array
Kind: instance property of Mesh
Returns: Uint8Array | Uint16Array | Uint32Array - Index data (read-only) or
null if the mesh is not indexed
.update ()
Updates the bounding sphere to match new vertex positions.
Kind: instance method of Mesh
.getBoundingSphere (out) ⇒ Float32Array
Mesh bounding sphere.
Kind: instance method of Mesh
Returns: Float32Array - Bounding sphere, 0-2 sphere origin, 3 radius.
If the position data is changed, call update to update the
bounding sphere.
Param | Type | Description |
---|---|---|
out | Float32Array | Preallocated array to write into, to avoid garbage, otherwise will allocate a new Float32Array. |
Example
.attribute (attr) ⇒ MeshAttributeAccessor
Get an attribute accessor to retrieve or modify data of give attribute
Kind: instance method of Mesh
Returns: MeshAttributeAccessor - attr Attribute to get access to or null
,
if mesh does not have this attribute.
If there are no shaders in the scene that use TextureCoordinate
for example,
no meshes will have the TextureCoordinate
attribute.
For flexible reusable components, take this into account that only Position
is guaranteed to be present at all time.
Param | Type | Description |
---|---|---|
attr | MeshAttribute | Attribute to get access to |
.destroy ()
Destroy and free the meshes memory.
It is best practice to set the mesh variable to null
after calling
destroy to prevent accidental use:
Kind: instance method of Mesh
0.9.0+
Example
.VERTEX_FLOAT_SIZE
Deprecated
Size of a vertex in float elements
Kind: static property of Mesh
.VERTEX_SIZE
Deprecated
Size of a vertex in bytes
Kind: static property of Mesh
.POS
Deprecated
Position attribute offsets in float elements
Kind: static property of Mesh
.TEXCOORD
Deprecated
Texture coordinate attribute offsets in float elements
Kind: static property of Mesh
.NORMAL
Deprecated
Normal attribute offsets in float elements
Kind: static property of Mesh