Graphics

Available in: Interface Scripts Client Entity Scripts

The experimental Graphics API (experimental) lets you query and manage certain graphics-related structures (like underlying meshes and textures) from scripting.
Methods

Type Definitions

Methods

canUpdateModel(id, meshIndexopt, partNumberopt) → {boolean}
Parameters:
Name Type Attributes Default Description
id Uuid
meshIndex number <optional>
-1
partNumber number <optional>
-1
Returns:
Type: boolean
exportModelToOBJ(model) → {string}
Parameters:
Name Type Description
model Graphics.Model
Returns:
Type: string
getModel(entityID) → {Graphics.Model}
Returns a model reference object associated with the specified UUID (EntityID, OverlayID, or AvatarID).
Parameters:
Name Type Description
entityID UUID The objectID of the model whose meshes are to be retrieved.
Returns:
the resulting Model object
Type: Graphics.Model
newMesh(ifsMeshData) → {Graphics.Mesh}
Create a new Mesh / Mesh Part with the specified data buffers.
Parameters:
Name Type Description
ifsMeshData Graphics.IFSData Index-Faced Set (IFS) arrays used to create the new mesh.
Returns:
the resulting Mesh / Mesh Part object
Type: Graphics.Mesh
newModel(meshes) → {Graphics.Model}
Parameters:
Name Type Description
meshes Array.<Graphics.Mesh>
Returns:
Type: Graphics.Model
updateModel(id, model) → {boolean}
Parameters:
Name Type Description
id Uuid
model Graphics.Model
Returns:
Type: boolean

Type Definitions

IFSData
Type: object
Properties:
Name Type Attributes Default Description
name string <optional>
"" mesh name (useful for debugging / debug prints).
topology string <optional>
""
indices Array.<number> vertex indices to use for the mesh faces.
vertices Array.<Vec3> vertex positions (model space)
normals Array.<Vec3> <optional>
[] vertex normals (normalized)
colors Array.<Vec3> <optional>
[] vertex colors (normalized)
texCoords0 Array.<Vec2> <optional>
[] vertex texture coordinates (normalized)
Material
Type: object
Properties:
Name Type Description
name string
model string
opacity number
roughness number
metallic number
scattering number
unlit boolean
emissiveMap string
albedoMap string
opacityMap string
metallicMap string
specularMap string
roughnessMap string
glossMap string
normalMap string
bumpMap string
occlusionMap string
lightmapMap string
scatteringMap string
MaterialLayer
Type: object
Properties:
Name Type Description
material Graphics.Material This layer's material.
priority number The priority of this layer. If multiple materials are applied to a mesh part, only the highest priority layer is used.
Mesh
Type: object
Properties:
Name Type Description
parts Array.<Graphics.MeshPart> Array of submesh part references.
attributeNames Array.<string> Vertex attribute names (color, normal, etc.)
numParts number The number of parts contained in the mesh.
numIndices number Total number of vertex indices in the mesh.
numVertices number Total number of vertices in the Mesh.
numAttributes number Number of currently defined vertex attributes.
valid boolean
strong boolean
extents object
bufferFormats object
MeshPart
Type: object
Properties:
Name Type Description
valid boolean
partIndex number The part index (within the containing Mesh).
firstVertexIndex number
baseVertexIndex number
lastVertexIndex number
topology Graphics.Topology element interpretation (currently only 'triangles' is supported).
attributeNames Array.<string> Vertex attribute names (color, normal, etc.)
numIndices number Number of vertex indices that this mesh part refers to.
numVerticesPerFace number Number of vertices per face (eg: 3 when topology is 'triangles').
numFaces number Number of faces represented by the mesh part (numIndices / numVerticesPerFace).
numVertices number Total number of vertices in the containing Mesh.
numAttributes number Number of currently defined vertex attributes.
extents object
bufferFormats object
Model
Type: object
Properties:
Name Type Description
objectID Uuid UUID of corresponding inworld object (if model is associated)
numMeshes number The number of submeshes contained in the model.
meshes Array.<Graphics.Mesh> Array of submesh references.
materialLayers Object.<string, Array.<Graphics.MaterialLayer>> Map of materials layer lists. You can look up a material layer list by mesh part number or by material name.
materialNames Array.<string> Array of all the material names used by the mesh parts of this model, in order (e.g. materialNames[0] is the name of the first mesh part's material).
Topology
Value Description
0 Points.
1 Lines.
2 Line strip.
3 Triangles.
4 Triangle strip.
5 Quads.
6 Quad strip.
Type: number