API reference
API reference
Select your platform
No SDKs available
No versions available

SceneMesh Class

Modifiers: final
SceneMesh combines SceneMaterials with geometry to create a textured 3D Object. Geometries can come from:
  1. glb/gltf files
  2. Generated geometries from SceneMesh Companion Object.
A SceneMesh is the asset form of a mesh. A SceneObject is an instance of a SceneMesh that is usually attached to an entity.
SceneMesh provides functionality for creating, manipulating, and rendering 3D geometry with materials. It supports various primitive shapes (box, sphere, quad, etc.) as well as loading 3D models from files.

Signature

class SceneMesh

Constructors

SceneMesh ( handle )
Signature
constructor(handle: Long)
Parameters
handle: Long
Returns
SceneMesh
SceneMesh ( filename , defaultShaderOverride , defaultSceneOverride )
Signature
constructor(filename: String, defaultShaderOverride: String, defaultSceneOverride: Int = -1)
Parameters
filename: String
defaultShaderOverride: String
defaultSceneOverride: Int
Returns
SceneMesh

Properties

animationNameToTrack : Map
[Get]
Signature
val animationNameToTrack: Map<String, Int>
associatedFiles : Array?
[Get]
Signature
var associatedFiles: Array
handle : Long
[Get]
Signature
var handle: Long
materials : Array?
[Get]
Signature
var materials: Array<SceneMaterial>?
nodeNameToId : Map
[Get]
Signature
val nodeNameToId: Map<String, Int>

Methods

calculateNodeGlobalMatrix ( index )
Calculates the global transformation matrix of a node.
Signature
fun calculateNodeGlobalMatrix(index: Int): Matrix44
Parameters
index: Int  The index of the node
Returns
Matrix44  The global transformation matrix of the node
computeCombinedBounds ()
Computes the combined bounding box of all geometry in this mesh.
Signature
fun computeCombinedBounds(): Bound3D
Returns
Bound3D  The combined bounding box
destroy ()
Signature
fun destroy()
getAnimationTracks ()
Gets all animation tracks defined in this mesh.
Signature
fun getAnimationTracks(): Array<AnimationTrack>
Returns
Array  An array of animation tracks
getMaterial ( index )
Gets a material from this mesh by index. This material is the "parent" of any SceneObjects instanced from this mesh. Any changes to attributes will apply to the non-overridden properties of the child materials.
If you know the name of the material, you can get the index from SceneMesh.getMaterialIndex()
Signature
fun getMaterial(index: Int): SceneMaterial?
Parameters
index: Int  The index of the material to get
Returns
SceneMaterial?  The material at the specified index, or null if no materials are available
getMaterial ( material )
Gets a material by name. This material is the "parent" of any SceneObjects instanced from this mesh. Any changes to attributes will apply to the non-overridden properties of the child materials.
Signature
fun getMaterial(material: String): SceneMaterial?
Parameters
material: String  The name of the material to find
Returns
SceneMaterial?  The material with the specified name, or null if not found
getMaterialIndex ( material )
Gets the index of a material by name.
Signature
fun getMaterialIndex(material: String): Int
Parameters
material: String  The name of the material to find
Returns
Int  The index of the material, or -1 if not found
getMaterialIndexForNodeMeshElement ( nodeId , meshElementId )
Gets the material index for a specific node and mesh element.
Signature
fun getMaterialIndexForNodeMeshElement(nodeId: Int, meshElementId: Int): Int
Parameters
nodeId: Int  The ID of the node
meshElementId: Int  The ID of the mesh element
Returns
Int  The index of the material used by the specified node and mesh element
getMaterialName ( materialIndex )
Gets the name of a material by index.
Signature
fun getMaterialName(materialIndex: Int): String
Parameters
materialIndex: Int  The index of the material
Returns
String  The name of the material
getNodeCount ()
Gets the number of nodes in this mesh.
Signature
fun getNodeCount(): Int
Returns
Int  The number of nodes
getNodeIndex ( name )
Gets the index of a node by name.
Signature
fun getNodeIndex(name: String): Int
Parameters
name: String  The name of the node to find
Returns
Int  The index of the node, or -1 if not found
getNodeLocalMatrix ( index )
Gets the local transformation matrix of a node.
Signature
fun getNodeLocalMatrix(index: Int): Matrix44
Parameters
index: Int  The index of the node
Returns
Matrix44  The local transformation matrix of the node
getNodeName ( index )
Gets the name of a node by index.
Signature
fun getNodeName(index: Int): String
Parameters
index: Int  The index of the node
Returns
String  The name of the node
updateCylinderSurface ( radius , height , fractionOfCircle )
Updates the geometry of a cylinder surface mesh.
Signature
fun updateCylinderSurface(radius: Float, height: Float, fractionOfCircle: Float)
Parameters
radius: Float  The new radius of the cylinder
height: Float  The new height of the cylinder
fractionOfCircle: Float  The new fraction of the circle to include
updateGeometryDirect ( positionsPtr , normalsPtr , uvsPtr , colorsPtr , indicesPtr , vertexCount , indexCount , updateBVH )
Updates geometry directly from raw C++ array pointers. The pointers are passed as Long values and written straight into the GPU buffer via map/memcpy/unmap — zero JNI array copies.
Signature
fun updateGeometryDirect(positionsPtr: Long, normalsPtr: Long, uvsPtr: Long, colorsPtr: Long, indicesPtr: Long, vertexCount: Int, indexCount: Int, updateBVH: Boolean = false)
Parameters
positionsPtr: Long  C++ float* to xyz position triplets
normalsPtr: Long  C++ float* to xyz normal triplets
uvsPtr: Long  C++ float* to uv pairs
colorsPtr: Long  C++ int32_t* to ARGB packed ints
indicesPtr: Long  C++ int32_t* to triangle indices
vertexCount: Int  Number of vertices
indexCount: Int  Number of indices
updateBVH: Boolean  Whether to update the bounding volume hierarchy
updateGeometryDirect ( positionsPtr , normalsPtr , uvsPtr , colorsPtr , indicesPtr , vertexCount , indexCount , materialRanges , updateBVH )
Update mesh geometry directly from C++ pointers (zero-copy) with updated material ranges. Use this overload when per-material index sections change each frame (e.g., particle systems with multiple emitters).
Signature
fun updateGeometryDirect(positionsPtr: Long, normalsPtr: Long, uvsPtr: Long, colorsPtr: Long, indicesPtr: Long, vertexCount: Int, indexCount: Int, materialRanges: IntArray, updateBVH: Boolean = false)
Parameters
positionsPtr: Long  C++ float* to xyz position triplets
normalsPtr: Long  C++ float* to xyz normal triplets
uvsPtr: Long  C++ float* to uv pairs
colorsPtr: Long  C++ int32_t* to ARGB packed ints
indicesPtr: Long  C++ int32_t* to triangle indices
vertexCount: Int  Number of vertices
indexCount: Int  Number of indices
materialRanges: IntArray  Flattened pairs of (startIndex, indexCount) per material section. For example, intArrayOf(0, 6, 6, 3) defines two sections: the first uses 6 indices starting at 0, the second uses 3 indices starting at 6.
updateBVH: Boolean  Whether to update the bounding volume hierarchy
updateWithTriangleMesh ( triMesh , updateBVH )
Updates this mesh with geometry from a triangle mesh.
Signature
fun updateWithTriangleMesh(triMesh: TriangleMesh, updateBVH: Boolean = false)
Parameters
triMesh: TriangleMesh  The triangle mesh to use for the update
updateBVH: Boolean  Whether to update the bounding volume hierarchy

Companion Object

Methods

axis ( size , thickness , material )
Creates a coordinate axis visualization mesh.
Signature
fun axis(size: Float, thickness: Float, material: SceneMaterial): SceneMesh
Parameters
size: Float  Length of each axis
thickness: Float  Thickness of the axis lines
material: SceneMaterial  Material to apply to the axes
Returns
SceneMesh  A new axis mesh
box ( minx , miny , minz , maxx , maxy , maxz , material )
Creates a box mesh with the specified dimensions and material.
Signature
fun box(minx: Float, miny: Float, minz: Float, maxx: Float, maxy: Float, maxz: Float, material: SceneMaterial): SceneMesh
Parameters
minx: Float  Minimum X coordinate
miny: Float  Minimum Y coordinate
minz: Float  Minimum Z coordinate
maxx: Float  Maximum X coordinate
maxy: Float  Maximum Y coordinate
maxz: Float  Maximum Z coordinate
material: SceneMaterial  Material to apply to the box
Returns
SceneMesh  A new box mesh
box ( min , max , material )
Creates a box mesh with the specified bounds and material.
Signature
fun box(min: Vector3, max: Vector3, material: SceneMaterial): SceneMesh
Parameters
min: Vector3  Minimum corner coordinates
max: Vector3  Maximum corner coordinates
material: SceneMaterial  Material to apply to the box
Returns
SceneMesh  A new box mesh
cylinderSurface ( radius , height , fractionOfCircle , material , materialBack )
Creates a portion of a cylinder centered at (0, 0, 0) that is a single sided surface facing inwards. This cylinder is symmetric about the XZ plane.
Signature
fun cylinderSurface(radius: Float, height: Float, fractionOfCircle: Float, material: SceneMaterial, materialBack: SceneMaterial? = null): SceneMesh
Parameters
radius: Float  The radius of the cylinder.
height: Float  The height of the cylinder (extends from Y=-height/2 to Y=height/2).
fractionOfCircle: Float  The fraction (0 to 1) of the cylinder's circumference to include.
material: SceneMaterial  Material for the inside of the cylinder.
materialBack: SceneMaterial?  Material for the outside/backside of the cylinder.
Returns
SceneMesh  A new cylinder surface mesh
dome ( radius , material )
Creates a dome mesh (half-sphere) with the specified radius and material.
Signature
fun dome(radius: Float, material: SceneMaterial): SceneMesh
Parameters
radius: Float  Radius of the dome
material: SceneMaterial  Material to apply to the dome
Returns
SceneMesh  A new dome mesh
equirectSurface ( radius , centralHorizontalAngle , upperVerticalAngle , lowerVerticalAngle , material )
Creates an inward portion of a sphere centered at (0, 0, 0). Uses a parameterization similar to OpenXR's equirect2 layers.
Signature
fun equirectSurface(radius: Float, centralHorizontalAngle: Float, upperVerticalAngle: Float, lowerVerticalAngle: Float, material: SceneMaterial): SceneMesh
Parameters
radius: Float  The radius of the sphere.
centralHorizontalAngle: Float  How far the surface wraps around the sphere horizontally 0, 2pi
upperVerticalAngle: Float  The angle from the center of the sphere to the top of the surface -pi/2, pi/2
lowerVerticalAngle: Float  The angle from the center of the sphere to the bottom of the surface -pi/2, pi/2
material: SceneMaterial
Returns
SceneMesh
fromTriangleMesh ( mesh , createBVH )
Creates a mesh from a triangle mesh.
Signature
fun fromTriangleMesh(mesh: TriangleMesh, createBVH: Boolean): SceneMesh
Parameters
createBVH: Boolean  Whether to create a bounding volume hierarchy for the mesh
Returns
SceneMesh  A new mesh based on the triangle mesh
loadLocalFile ( filename , defaultShaderOverride , defaultSceneOverride )
Loads a 3D model from a glTF file.
Signature
fun loadLocalFile(filename: String, defaultShaderOverride: String = "", defaultSceneOverride: Int = -1): SceneMesh
Parameters
filename: String  Path to the model file (either .glb or .gltf)
defaultShaderOverride: String  Optional shader to override the default shader
defaultSceneOverride: Int  Optional scene index to override the default scene
Returns
SceneMesh  A new SceneMesh containing the loaded model
loadLocalFile ( filename , materials , defaultSceneOverride )
Loads a 3D model from a glTF file.
Signature
fun loadLocalFile(filename: String, materials: List<SceneMaterial>, defaultSceneOverride: Int = -1): SceneMesh
Parameters
filename: String  Path to the model file (either .glb or .gltf)
materials: List
defaultSceneOverride: Int  Optional scene index to override the default scene
Returns
SceneMesh  A new SceneMesh containing the loaded model
meshWithMaterials ( positions , normals , uvs , colors , indices , materialRanges , materials , createBVH )
Creates a custom mesh with the specified geometry data and materials.
Signature
fun meshWithMaterials(positions: FloatArray, normals: FloatArray, uvs: FloatArray, colors: IntArray, indices: IntArray, materialRanges: IntArray, materials: Array<SceneMaterial>, createBVH: Boolean): SceneMesh
Parameters
positions: FloatArray  Vertex positions as a flat array of floats (x, y, z triplets)
normals: FloatArray  Vertex normals as a flat array of floats (x, y, z triplets)
uvs: FloatArray  Primary texture coordinates as a flat array of floats (u, v pairs)
colors: IntArray  Vertex colors as an array of ARGB integers
indices: IntArray  Vertex indices as an array of integers
materialRanges: IntArray  Flattened pairs of (startIndex, indexCount) per material section. For example, intArrayOf(0, 6, 6, 3) defines two sections: the first uses 6 indices starting at 0, the second uses 3 indices starting at 6.
materials: Array  Array of materials to apply to the mesh
createBVH: Boolean  Whether to create a bounding volume hierarchy for the mesh
Returns
SceneMesh  A new custom mesh
meshWithMaterials ( positions , normals , uvs , uv1s , colors , indices , materialRanges , materials , createBVH )
Creates a custom mesh with the specified geometry data, dual UV channels, and materials.
Signature
fun meshWithMaterials(positions: FloatArray, normals: FloatArray, uvs: FloatArray, uv1s: FloatArray, colors: IntArray, indices: IntArray, materialRanges: IntArray, materials: Array<SceneMaterial>, createBVH: Boolean): SceneMesh
Parameters
positions: FloatArray  Vertex positions as a flat array of floats (x, y, z triplets)
normals: FloatArray  Vertex normals as a flat array of floats (x, y, z triplets)
uvs: FloatArray  Primary texture coordinates as a flat array of floats (u, v pairs)
uv1s: FloatArray  Secondary texture coordinates as a flat array of floats (u, v pairs)
colors: IntArray  Vertex colors as an array of ARGB integers
indices: IntArray  Vertex indices as an array of integers
materialRanges: IntArray  Flattened pairs of (startIndex, indexCount) per material section. For example, intArrayOf(0, 6, 6, 3) defines two sections: the first uses 6 indices starting at 0, the second uses 3 indices starting at 6.
materials: Array  Array of materials to apply to the mesh
createBVH: Boolean  Whether to create a bounding volume hierarchy for the mesh
Returns
SceneMesh  A new custom mesh
panel ( min , max , edgeRadius , materialPanel , materialGlass )
Creates a panel mesh with a glass frame.
Signature
fun panel(min: Vector3, max: Vector3, edgeRadius: Vector3, materialPanel: SceneMaterial, materialGlass: SceneMaterial): SceneMesh
Parameters
min: Vector3  Minimum corner coordinates
max: Vector3  Maximum corner coordinates
edgeRadius: Vector3
materialPanel: SceneMaterial  Material for the panel surface
materialGlass: SceneMaterial  Material for the glass/border
Returns
SceneMesh  A new panel mesh
quad ( min , max , material )
Creates a single-sided quad (flat rectangle) mesh with the specified bounds and material.
Signature
fun quad(min: Vector3, max: Vector3, material: SceneMaterial): SceneMesh
Parameters
min: Vector3  Minimum corner coordinates
max: Vector3  Maximum corner coordinates
material: SceneMaterial  Material to apply to the quad
Returns
SceneMesh  A new quad mesh
roundedBox ( min , max , edgeRadius , material )
Creates a box with rounded corners.
Signature
fun roundedBox(min: Vector3, max: Vector3, edgeRadius: Vector3, material: SceneMaterial): SceneMesh
Parameters
min: Vector3  Minimum corner coordinates
max: Vector3  Maximum corner coordinates
edgeRadius: Vector3
material: SceneMaterial  Material to apply to the box
Returns
SceneMesh  A new rounded box mesh
singleSidedQuad ( halfWidth , halfHeight , material )
Creates a single-sided quad mesh with the specified dimensions and material.
Signature
fun singleSidedQuad(halfWidth: Float, halfHeight: Float, material: SceneMaterial): SceneMesh
Parameters
halfWidth: Float
halfHeight: Float
material: SceneMaterial  Material to apply to the quad
Returns
SceneMesh  A new single-sided quad mesh
skybox ( radius , material )
Creates a skybox mesh with the specified radius and material.
A skybox is a large sphere or cube that surrounds the scene and displays a background environment.
Signature
fun skybox(radius: Float, material: SceneMaterial): SceneMesh
Parameters
radius: Float  Radius of the skybox
material: SceneMaterial  Material to apply to the skybox (typically with an environment texture)
Returns
SceneMesh  A new skybox mesh
sphere ( radius , material )
Creates a sphere mesh with the specified radius and material.
Signature
fun sphere(radius: Float, material: SceneMaterial): SceneMesh
Parameters
radius: Float  Radius of the sphere
material: SceneMaterial  Material to apply to the sphere
Returns
SceneMesh  A new sphere mesh