GltfModelNode


public final 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 methods

final void
@MainThread
clearMaterialOverride(int primitiveIndex)

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

final int

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

final @NonNull Pose

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

final @NonNull Vector3

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

final @NonNull Pose

The Pose of this node relative to the GltfModelEntity root.

final @NonNull Vector3

The scale of this node relative to the GltfModelEntity root.

final String

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

final void

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

final void

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

final void
@MainThread
setMaterialOverride(@NonNull Material material, int primitiveIndex)

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

final void

The Pose of this node relative to the GltfModelEntity root.

final void

The scale of this node relative to the GltfModelEntity root.

Public methods

clearMaterialOverride

Added in 1.0.0-alpha15
@MainThread
public final void clearMaterialOverride(int primitiveIndex)

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
int primitiveIndex

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.

getIndex

Added in 1.0.0-alpha15
public final int getIndex()

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

getLocalPose

Added in 1.0.0-alpha15
@MainThread
public final @NonNull Pose getLocalPose()

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.

getLocalScale

Added in 1.0.0-alpha15
@MainThread
public final @NonNull Vector3 getLocalScale()

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

getModelPose

Added in 1.0.0-alpha15
@MainThread
public final @NonNull Pose getModelPose()

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.

getModelScale

Added in 1.0.0-alpha15
@MainThread
public final @NonNull Vector3 getModelScale()

The scale of this node relative to the GltfModelEntity root.

getName

Added in 1.0.0-alpha15
public final String getName()

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

setLocalPose

Added in 1.0.0-alpha15
@MainThread
public final void setLocalPose(@NonNull Pose value)

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.

setLocalScale

Added in 1.0.0-alpha15
@MainThread
public final void setLocalScale(@NonNull Vector3 value)

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

setMaterialOverride

Added in 1.0.0-alpha15
@MainThread
public final void setMaterialOverride(@NonNull Material material, int primitiveIndex)

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
@NonNull Material material

The new Material to apply to the primitive.

int primitiveIndex

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.

setModelPose

Added in 1.0.0-alpha15
@MainThread
public final void setModelPose(@NonNull Pose value)

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.

setModelScale

Added in 1.0.0-alpha15
@MainThread
public final void setModelScale(@NonNull Vector3 value)

The scale of this node relative to the GltfModelEntity root.