# GltfModelNode

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/GltfModelNode.kt+class:androidx.xr.scenecore.GltfModelNode) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public final class GltfModelNode
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode` represents a node in a `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity`.

Nodes are the fundamental structural elements of a glTF scene. A `https://developer.android.com/reference/androidx/xr/scenecore/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 `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode` after the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` is disposed will throw an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html`.

## Summary

| ### Public methods |
|---|---|
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#clearMaterialOverride(kotlin.Int)(int primitiveIndex)` Clears a previously set material override for a specific primitive of the mesh associated with this node. |
| `final int` | `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#getIndex()()` The index of this node in the flattened list of nodes of the glTF model. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#getLocalPose()()` The `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of this node relative to its direct parent as defined in the source glTF asset. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#getLocalScale()()` The scale of this node relative to its direct parent as defined in the source glTF asset. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#getModelPose()()` The `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#getModelScale()()` The scale of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root. |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#getName()()` The name of the node as defined in the glTF file. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#setLocalPose(androidx.xr.runtime.math.Pose)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose value)` The `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of this node relative to its direct parent as defined in the source glTF asset. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#setLocalScale(androidx.xr.runtime.math.Vector3)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 value)` The scale of this node relative to its direct parent as defined in the source glTF asset. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#setMaterialOverride(androidx.xr.scenecore.Material,kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Material material, int primitiveIndex)` Sets a material override for a primitive of the mesh associated with this node. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#setModelPose(androidx.xr.runtime.math.Pose)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose value)` The `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root. |
| `final void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#setModelScale(androidx.xr.runtime.math.Vector3)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 value)` The scale of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root. |

## Public methods

### clearMaterialOverride

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if this node is not associated with a mesh. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#clearMaterialOverride(kotlin.Int)` is out of bounds for the associated mesh. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#setMaterialOverride(androidx.xr.scenecore.Material,kotlin.Int)` |   |

### getIndex

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
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](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@MainThread
public final @NonNull Pose getLocalPose()
```

The `https://developer.android.com/reference/androidx/xr/runtime/math/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 `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root.

### getLocalScale

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@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](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@MainThread
public final @NonNull Pose getModelPose()
```

The `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root.

Unlike `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#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](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@MainThread
public final @NonNull Vector3 getModelScale()
```

The scale of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root.

### getName

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
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](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@MainThread
public final void setLocalPose(@NonNull Pose value)
```

The `https://developer.android.com/reference/androidx/xr/runtime/math/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 `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root.

### setLocalScale

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@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](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Material material` | The new `https://developer.android.com/reference/androidx/xr/scenecore/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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the provided `https://developer.android.com/reference/androidx/xr/scenecore/Material` is invalid. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if this node is not associated with a mesh. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-index-out-of-bounds-exception/index.html` | if the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#setMaterialOverride(androidx.xr.scenecore.Material,kotlin.Int)` is out of bounds for the associated mesh. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#clearMaterialOverride(kotlin.Int)` |   |

### setModelPose

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@MainThread
public final void setModelPose(@NonNull Pose value)
```

The `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root.

Unlike `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelNode#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](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
@MainThread
public final void setModelScale(@NonNull Vector3 value)
```

The scale of this node relative to the `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity` root.