GltfModelNode


class GltfModelNode


GltfModelNode represents a node in a GltfModelEntity.

Nodes are the fundamental structural elements of a glTF scene. A GltfModelNode defines a spatial transformation and can be associated with other components such as a mesh. This class allows you to manipulate these spatial properties and, if a mesh is attached, override its rendering materials.

The lifecycle of a glTF node is tied to the glTF model itself. Trying to use the GltfModelNode after the GltfModelEntity is disposed will throw an IllegalStateException.

Summary

Public functions

Unit

Clears a previously set material override for a specific primitive of the mesh associated with this node.

Unit
@MainThread
setMaterialOverride(material: Material, primitiveIndex: Int)

Sets a material override for a primitive of the mesh associated with this node.

Public properties

Int

The index of this node in the flattened list of nodes of the glTF model.

Pose

The Pose of this node relative to its direct parent as defined in the source glTF asset.

Vector3

The scale of this node relative to its direct parent as defined in the source glTF asset.

Pose

The Pose of this node relative to the GltfModelEntity root.

Vector3

The scale of this node relative to the GltfModelEntity root.

String?

The name of the node as defined in the glTF file.

Public functions

clearMaterialOverride

Added in 1.0.0-alpha15
@MainThread
fun clearMaterialOverride(primitiveIndex: Int = 0): Unit

Clears a previously set material override for a specific primitive of the mesh associated with this node.

If no override was previously set for that primitive, this call has no effect.

Parameters
primitiveIndex: Int = 0

The zero-based index for the primitive of the associated mesh. The valid range is from 0 to (primitiveCount - 1), where primitiveCount is the total number of primitives defined for the mesh in the source glTF asset.

Throws
IllegalStateException

if this node is not associated with a mesh.

IndexOutOfBoundsException

if the primitiveIndex is out of bounds for the associated mesh.

setMaterialOverride

Added in 1.0.0-alpha15
@MainThread
fun setMaterialOverride(material: Material, primitiveIndex: Int = 0): Unit

Sets a material override for a primitive of the mesh associated with this node.

In a glTF model, a node may be associated with a mesh. A mesh consists of one or more geometric surfaces called primitives (such as a collection of triangles) that are rendered using a single material. This method applies a material override to a specific primitive within this node's associated mesh.

Parameters
material: Material

The new Material to apply to the primitive.

primitiveIndex: Int = 0

The zero-based index for the primitive of the associated mesh. The valid range is from 0 to (primitiveCount - 1), where primitiveCount is the total number of primitives defined for the mesh in the source glTF asset.

Throws
IllegalArgumentException

if the provided Material is invalid.

IllegalStateException

if this node is not associated with a mesh.

IndexOutOfBoundsException

if the primitiveIndex is out of bounds for the associated mesh.

Public properties

index

Added in 1.0.0-alpha15
val indexInt

The index of this node in the flattened list of nodes of the glTF model.

localPose

Added in 1.0.0-alpha15
var localPosePose

The Pose of this node relative to its direct parent as defined in the source glTF asset.

Even though the API exposes nodes as a flattened list, their local transforms still respect the structure of the original glTF asset. If this node has no parent in the source asset, this pose is relative to the GltfModelEntity root.

localScale

Added in 1.0.0-alpha15
var localScaleVector3

The scale of this node relative to its direct parent as defined in the source glTF asset.

modelPose

Added in 1.0.0-alpha15
var modelPosePose

The Pose of this node relative to the GltfModelEntity root.

Unlike localPose, which is strictly relative to the node's parent in the glTF file, the model pose represents the node's final, accumulated transformation within the model.

modelScale

Added in 1.0.0-alpha15
var modelScaleVector3

The scale of this node relative to the GltfModelEntity root.

name

Added in 1.0.0-alpha15
val nameString?

The name of the node as defined in the glTF file. Returns null if the node has no name.