GraphicsMeshPart

Description

Supported Script Types:

  • Interface Scripts
  • Client Entity Scripts
  • Avatar Scripts
A handle to in-memory mesh part data in a GraphicsModel.

Created using the Graphics API, GraphicsModel.cloneModel, GraphicsMesh.cloneMesh, or GraphicsMeshPart.cloneMeshPart.

Properties

Name Type Summary
valid boolean

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

partIndex number

The index of the part within the whole mesh (i.e., parent and mesh parts). Read-only.

firstVertexIndex number

The index of the first vertex.

baseVertexIndex number

The index of the base vertex.

lastVertexIndex number

The index of the last vertex.

topology Graphics.MeshTopology

The element interpretation. Currently only triangles is supported.

numIndices number

The number of vertex indices in the mesh part.

numVertices number

The number of vertices in the whole mesh (i.e., parent and mesh parts). Read-only.

numVerticesPerFace number

The number of vertices per face, per the topology (e.g., 3 for triangles). Read-only.

numFaces number

The number of faces represented by the mesh part. Read-only.

numAttributes number

The number of vertex attributes in the whole mesh (i.e., parent and mesh parts). Read-only.

attributeNames Array.<Graphics.BufferTypeName>

The names of the vertex attributes in the whole mesh (i.e., parent and mesh parts). Read-only.

extents Graphics.MeshExtents

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

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

Details of the buffers used for the whole mesh (i.e., parent and mesh parts). Read-only.

Methods

Name Return Value Summary
addAttribute number

Adds an attribute to the (whole) mesh's vertices.

cloneMeshPart GraphicsMeshPart

Makes a copy of the mesh part.

dedupeVertices boolean

Deduplicates vertices.

fillAttribute number

Sets the value of an attribute for all vertices in the whole mesh (i.e., parent and mesh parts).

findNearbyPartVertexIndices Array.<number>

Gets the indices of nearby vertices in the mesh part.

getFace Array.<number>

Gets the vertex indices that make up a face.

getIndices Array.<number>

Gets the vertex indices.

getParentMesh GraphicsMesh

Gets the parent mesh.

getVertexProperty Graphics.BufferType

Gets the value of a vertex's attribute.

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

Gets the attributes and attribute values of a vertex.

isValidIndex boolean

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

replaceMeshPartData boolean

Replaces a mesh part with a copy of another mesh part.

rotate Graphics.MeshExtents

Rotates the mesh part, using a quaternion.

rotateDegrees Graphics.MeshExtents

Rotates the mesh part, using Euler angles.

scale Graphics.MeshExtents

Scales the mesh part.

scaleToFit Graphics.MeshExtents

Scales the mesh to so that it's maximum model coordinate dimension is a specified length.

setIndices boolean

Sets the vertex indices.

setVertexProperty boolean

Sets the value of a vertex's attribute.

setVertextAttributes boolean

Updates attribute values of a vertex.

toOBJ string

Exports the mesh part to OBJ format.

transform Graphics.MeshExtents

Scales, rotates, and translates the mesh.

translate Graphics.MeshExtents

Translates the mesh part.

updateVertexAttributes number

Updates vertex attributes by calling a function for each vertex in the whole mesh (i.e., the parent and mesh parts). The function can return modified attributes to update the vertex with.

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 to the (whole) mesh's 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) cloneMeshPart( ) → {GraphicsMeshPart}
Returns: A copy of the mesh part.

Makes a copy of the mesh part.

(static) dedupeVertices( epsilonopt ) → {boolean}
Returns: true if the deduplication succeeded, false if it didn't.

Deduplicates vertices.

Parameters

Name Type Attributes Default Value Description
epsilon number <optional>
1e-6

The deduplicadtion distance. If a pair of vertices is within this distance of each other they are combined into a single vertex.

(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 in the whole mesh (i.e., parent and mesh parts).

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) findNearbyPartVertexIndices( origin, epsilonopt ) → {Array.<number>}
Returns: The indices of nearby vertices.

Gets the indices of nearby vertices in the mesh part.

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) getFace( index ) → {Array.<number>}
Returns: The vertex indices that make up the face, of number per the mesh topology.

Gets the vertex indices that make up a face.

Parameters

Name Type Description
index number

The index of the face.

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

Gets the vertex indices.

(static) getParentMesh( ) → {GraphicsMesh}
Returns: The parent mesh.

Gets the parent mesh.

(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) getVertextAttributes( 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) 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) replaceMeshPartData( source, attributesopt ) → {boolean}
Returns: true if the mesh part was successfully replaced, false if it wasn't.

Replaces a mesh part with a copy of another mesh part.

Throws

Throws an error if the mesh part of source mesh part aren't valid.

Parameters

Name Type Attributes Description
source GrphicsMeshPart

The mesh part to copy.

attributes Array.<Graphics.BufferTypeName> <optional>

The attributes to copy. If not specified, all attributes are copied from the source.

(static) rotate( rotation, originopt ) → {Graphics.MeshExtents}
Returns: The resulting mesh extents, in model coordinates.

Rotates the mesh part, using a quaternion.

Parameters

Name Type Attributes Description
rotation Quat

The rotation to perform, in model coordinates.

origin Vec3 <optional>

The point about which to rotate, in model coordinates.

Warning: Currently doesn't work as expected.

(static) rotateDegrees( eulerAngles, originopt ) → {Graphics.MeshExtents}
Returns: The resulting mesh extents, in model coordinates.

Rotates the mesh part, using Euler angles.

Parameters

Name Type Attributes Description
eulerAngles Vec3

The rotation to perform, in mesh coordinates, as Euler angles in degrees.

origin Vec3 <optional>

The point about which to rotate, in model coordinates.

Warning: Currently doesn't work as expected.

(static) scale( scale, originopt ) → {Graphics.MeshExtents}
Returns: The resulting mesh extents, in model coordinates.

Scales the mesh part.

Parameters

Name Type Attributes Description
scale Vec3

The scale to apply in each model coordinate direction.

origin Vec3 <optional>

The origin to scale about. If not specified, the center of the mesh part is used.

(static) scaleToFit( scale ) → {Graphics.MeshExtents}
Returns: The resulting mesh extents, in model coordinates.

Scales the mesh to so that it's maximum model coordinate dimension is a specified length.

Parameters

Name Type Description
scale number

The target dimension.

(static) setIndices( indices ) → {boolean}
Returns: true if successful, false if not.

Sets the vertex indices.

Throws

Throws an error if the number of indices isn't the same, or an index is invalid.

Parameters

Name Type Description
indices Array.<number>

The vertex indices.

(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) setVertextAttributes( 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) toOBJ( ) → {string}
Returns: The OBJ format representation of the mesh part.

Exports the mesh part to OBJ format.

(static) transform( transform ) → {Graphics.MeshExtents}
Returns: The resulting mesh extents, in model coordinates.

Scales, rotates, and translates the mesh.

Parameters

Name Type Description
transform Mat4

The scale, rotate, and translate transform to apply.

(static) translate( translation ) → {Graphics.MeshExtents}
Returns: The rseulting mesh extents, in model coordinates.

Translates the mesh part.

Parameters

Name Type Description
translation Vec3

The translation to apply, in model coordinates.

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

Updates vertex attributes by calling a function for each vertex in the whole mesh (i.e., the parent and mesh parts). 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.