GraphicsMesh

Description

Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts

A handle to in-memory mesh data in a GraphicsModel.

Create using the Graphics API, GraphicsModel.cloneModel, or GraphicsMesh.cloneMesh.

Properties

Name Type Summary
numParts number

The number of mesh parts. Read-only.

parts Array.<GraphicsMeshPart>

The mesh parts. Read-only.

numIndices number

The total number of vertex indices in the mesh. Read-only.

numVertices number

The total number of vertices in the mesh. Read-only.

numAttributes number

The number of vertex attributes. Read-only.

attributeNames Array.<Graphics.BufferTypeName>

The names of the vertex attributes. Read-only.

valid boolean

true if the mesh is valid, false if it isn't. Read-only.

strong boolean

true if the mesh is valid and able to be used, false if it isn't. Read-only.

extents Graphics.MeshExtents

The mesh extents, in model coordinates. Read-only.

bufferFormats Object.<Graphics.BufferTypeName, Graphics.BufferFormat>

Details of the buffers used for the mesh. Read-only.

Methods

Name Return Value Summary
addAttribute number

Adds an attribute for all vertices.

cloneMesh GraphicsMesh

Makes a copy of the mesh.

fillAttribute number

Sets the value of an attribute for all vertices.

findNearbyVertexIndices Array.<number>

Gets the indices of nearby vertices.

forEachVertex number

Calls a function for each vertex.

getIndices Array.<number>

Gets the vertex indices.

getMeshPointer undefined

Deprecated: This method is deprecated and will be removed.

getModelBasePointer undefined

Deprecated: This method is deprecated and will be removed.

getModelProviderPointer undefined

Deprecated: This method is deprecated and will be removed.

getParentModel GraphicsModel

Gets the model the mesh is part of.

Currently doesn't work.

getVertexAttributes Object.<Graphics.BufferTypeName, Graphics.BufferType>

Gets the attributes and attribute values of a vertex.

getVertexProperty Graphics.BufferType

Gets the value of a vertex's attribute.

isValidIndex boolean

Checks if an index is valid and, optionally, that vertex has a particular attribute.

queryVertexAttributes Array.<Graphics.BufferType>

Gets the value of an attribute for all vertices.

removeAttribute boolean

Removes an attribute from all vertices.

Note: The "position" attribute cannot be removed.

setVertexAttributes boolean

Updates attribute values of a vertex.

setVertexProperty boolean

Sets the value of a vertex's attribute.

updateVertexAttributes number

Updates vertex attributes by calling a function for each vertex. The function can return modified attributes to update the vertex with.

Type Definitions

forEachVertextCallback( attributes, index, properties )
Type: function

Called for each vertex when GraphicsMesh.updateVertexAttributes is called.

Parameters

Name Type Description
attributes Object.<Graphics.BufferTypeName, Graphics.BufferType>

The attributes of the vertex.

index number

The vertex index.

properties object

The properties of the mesh, per GraphicsMesh.

updateVertexAttributesCallback( attributes, index, properties ) → {Object.<Graphics.BufferTypeName, Graphics.BufferType>|boolean}
Returns: The attribute values to update the vertex with, or false to not update the vertex.
Type: function

Called for each vertex when GraphicsMesh.updateVertexAttributes is called. The value returned by the script function should be the modified attributes to update the vertex with, or false to not update the particular vertex.

Parameters

Name Type Description
attributes Object.<Graphics.BufferTypeName, Graphics.BufferType>

The attributes of the vertex.

index number

The vertex index.

properties object

The properties of the mesh, per GraphicsMesh.

Method Details

(static) addAttribute( name, defaultValueopt ) → {number}
Returns: The number of vertices the attribute was added to, 0 if the name was invalid or all vertices already had the attribute.

Adds an attribute for all vertices.

Parameters

Name Type Attributes Description
name Graphics.BufferTypeName

The name of the attribute.

defaultValue Graphics.BufferType <optional>

The value to give the attributes added to the vertices.

(static) cloneMesh( ) → {GraphicsMesh}
Returns: A copy of the mesh.

Makes a copy of the mesh.

(static) fillAttribute( name, value ) → {number}
Returns: 1 if the attribute name was valid and the attribute values were set, 0 otherwise.

Sets the value of an attribute for all vertices.

Parameters

Name Type Description
name Graphics.BufferTypeName

The name of the attribute. The attribute is added to the vertices if not already present.

value Graphics.BufferType

The value to give the attributes.

(static) findNearbyVertexIndices( origin, epsilonopt ) → {Array.<number>}
Returns: The indices of nearby vertices.

Gets the indices of nearby vertices.

Parameters

Name Type Attributes Default Value Description
origin Vec3

The search position, in model coordinates.

epsilon number <optional>
1e-6

The search distance. If a vertex is within this distance from the origin it is considered to be "nearby".

(static) forEachVertex( callback ) → {number}
Returns: The number of vertices the callback was called for.

Calls a function for each vertex.

Parameters

Name Type Description
callback GraphicsMesh~forEachVertexCallback

The function to call for each vertex.

(static) getIndices( ) → {Array.<number>}
Returns: The vertex indices.

Gets the vertex indices.

(static) getMeshPointer( ) → {undefined}
Returns: undefined

Deprecated: This method is deprecated and will be removed.

(static) getModelBasePointer( ) → {undefined}
Returns: undefined

Deprecated: This method is deprecated and will be removed.

(static) getModelProviderPointer( ) → {undefined}
Returns: undefined

Deprecated: This method is deprecated and will be removed.

(static) getParentModel( ) → {GraphicsModel}
Returns: The model the mesh is part of, null if it isn't part of a model.

Gets the model the mesh is part of.

Currently doesn't work.

(static) getVertexAttributes( index ) → {Object.<Graphics.BufferTypeName, Graphics.BufferType>}
Returns: The attribute names and values for the vertex.

Gets the attributes and attribute values of a vertex.

Throws

Throws an error if the index is invalid.

Parameters

Name Type Description
index number

The vertex to get the attributes for.

(static) getVertexProperty( index, name ) → {Graphics.BufferType}
Returns: The value of the vertex attribute.

Gets the value of a vertex's attribute.

Throws

Throws an error if the index is invalid or name is invalid or isn't used in the mesh.

Parameters

Name Type Description
index number

The vertex index.

name Graphics.BufferTypeName

The name of the vertex attribute to get.

(static) isValidIndex( index, attributeopt ) → {boolean}
Returns: true if the index is valid and that vertex has the attribute if specified.

Checks if an index is valid and, optionally, that vertex has a particular attribute.

Throws

Throws an error if the index if invalid or name is invalid or isn't used in the mesh.

Parameters

Name Type Attributes Description
index number

The index to check.

attribute Graphics.BufferTypeName <optional>

The attribute to check.

(static) queryVertexAttributes( name ) → {Array.<Graphics.BufferType>}
Returns: The attribute values for all vertices.

Gets the value of an attribute for all vertices.

Throws

Throws an error if the name is invalid or isn't used in the mesh.

Parameters

Name Type Description
name Graphics.BufferTypeName

The name of the attribute to get the vertex values of.

(static) removeAttribute( name ) → {boolean}
Returns: true if the attribute existed and was removed, false otherwise.

Removes an attribute from all vertices.

Note: The "position" attribute cannot be removed.

Parameters

Name Type Description
name Graphics.BufferTypeName

The name of the attribute to remove.

(static) setVertexAttributes( index, values ) → {boolean}
Returns: true if the index and the attribute names and values were valid and the vertex was updated, false otherwise.

Updates attribute values of a vertex.

Throws

Throws an error if the index is invalid or one of the attribute names is invalid or isn't used in the mesh.

Parameters

Name Type Description
index number

The vertex to set the attributes for.

values Object.<Graphics.BufferTypeNAme, Graphics.BufferType>

The attribute names and values. Need not specify unchanged values.

(static) setVertexProperty( index, name, value ) → {boolean}
Returns: true if the vertex attribute value was set, false if it wasn't.

Sets the value of a vertex's attribute.

Throws

Throws an error if the index is invalid or name is invalid or isn't used in the mesh.

Parameters

Name Type Description
index number

The vertex index.

name Graphics.BufferTypeName

The name of the vertex attribute to set.

value Graphics.BufferType

The vertex attribute value to set.

(static) updateVertexAttributes( callback ) → {number}
Returns: The number of vertices the callback was called for.

Updates vertex attributes by calling a function for each vertex. The function can return modified attributes to update the vertex with.

Parameters

Name Type Description
callback GraphicsMesh~updateVertexAttributesCallback

The function to call for each vertex.