Graphics

Description

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

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

Methods

Name Return Value Summary
canUpdateModel boolean
exportModelToOBJ string
getModel Graphics.Model Returns a model reference object associated with the specified UUID (EntityID or AvatarID).
newMesh Graphics.Mesh Create a new Mesh / Mesh Part with the specified data buffers.
newModel Graphics.Model
updateModel boolean

Type Definitions

IFSData
Type: object

 

Properties

Name Type Attributes Summary
name string <optional>
mesh name (useful for debugging / debug prints).

Default Value: ""

topology string <optional>

Default Value: ""

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)

Default Value: []

colors Array.<Vec3> <optional>
vertex colors (normalized)

Default Value: []

texCoords0 Array.<Vec2> <optional>
vertex texture coordinates (normalized)

Default Value: []

Material
Type: object

 

Properties

Name Type Summary
name string
model string
opacity number | string
roughness number | string
metallic number | string
scattering number | string
unlit boolean | string
emissiveMap string
albedoMap string
opacityMap string
metallicMap string
specularMap string
roughnessMap string
glossMap string
normalMap string
bumpMap string
occlusionMap string
lightmapMap string
scatteringMap string
texCoordTransform0 Mat4 | string
texCoordTransform1 Mat4 | string
lightmapParams string
materialParams string
defaultFallthrough boolean
MaterialLayer
Type: object

 

Properties

Name Type Summary
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 Summary
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 Summary
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 Summary
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
Type: number

ValueDescription
0Points.
1Lines.
2Line strip.
3Triangles.
4Triangle strip.
5Quads.
6Quad strip.

Method Details

(static) canUpdateModel( id, meshIndexopt, partNumberopt ) → {boolean}
Returns: boolean

Parameters

Name Type Attributes Default Value Description
id Uuid
meshIndex number <optional>
-1
partNumber number <optional>
-1
(static) exportModelToOBJ( model ) → {string}
Returns: string

Parameters

Name Type Description
model Graphics.Model
(static) getModel( entityID ) → {Graphics.Model}
Returns: the resulting Model object

Returns a model reference object associated with the specified UUID (EntityID or AvatarID).

Parameters

Name Type Description
entityID UUID The objectID of the model whose meshes are to be retrieved.
(static) newMesh( ifsMeshData ) → {Graphics.Mesh}
Returns: the resulting Mesh / Mesh Part object

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.
(static) newModel( meshes ) → {Graphics.Model}
Returns: Graphics.Model

Parameters

Name Type Description
meshes Array.<Graphics.Mesh>
(static) updateModel( id, model ) → {boolean}
Returns: boolean

Parameters

Name Type Description
id Uuid
model Graphics.Model