# GltfModelEntity

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/GltfModelEntity.kt+class:androidx.xr.scenecore.GltfModelEntity) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
class GltfModelEntity : Entity
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) |||
|   | ↳ | [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) ||
|   |   | ↳ | [androidx.xr.scenecore.GltfModelEntity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity) |

*** ** * ** ***

GltfModelEntity is a concrete implementation of Entity that hosts a glTF model.

Note: The size property of this Entity is always reported as {0, 0, 0}, regardless of the actual size of the model.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity#create(androidx.xr.runtime.Session,androidx.xr.scenecore.GltfModel,androidx.xr.runtime.math.Pose,androidx.xr.scenecore.Entity)(session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session, model: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel, pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose, parent: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity?)` Public factory function for a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfAnimation>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity#getAnimations()()` A list of all `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfAnimation`s defined in the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity#stopAllAnimations()()` Stops all playing animations in this `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelNode>` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity#nodes()` A list of all `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelNode`s defined in the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`. |

### Inherited functions

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) `open suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/HitTestResult?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)(origin: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3)`

Perform a hit test from the specified origin in the specified direction into the Scene.
`open suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/HitTestResult?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3,kotlin.Int)(origin: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, hitTestFilter: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Creates a hit test from the specified origin in the specified direction into the scene.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformDirectionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(direction: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a direction from this ScenePose's local space to the destination ScenePose's local space.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformPoseTo(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.ScenePose)(pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Returns a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` relative to this ScenePose, transformed into a Pose relative to the destination.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformPositionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(position: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a position from this ScenePose's local space to the destination ScenePose's local space.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#transformVectorTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(vector: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, destination: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ScenePose)`

Transforms a vector from this ScenePose's local space to the destination ScenePose's local space.
From [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#addChild(androidx.xr.scenecore.Entity)(child: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity)`

Sets an Entity to be a child of this Entity in the scene graph.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)(component: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component)`

Adds a Component to this Entity.
`@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getAlpha(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Returns the alpha transparency set for this Entity, relative to given Space.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component>` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponents()()`

Retrieves all components attached to this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<T>` `<T : https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component> https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)(type: https://developer.android.com/reference/java/lang/Class.html<T>)`

Retrieves all Components of the given type `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)` and its subtypes attached to this Entity.
`open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getPose(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Returns the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` for this Entity, relative to the provided `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space`.
`open @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#getScale(androidx.xr.scenecore.Space)(relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Returns the scale of this entity, relative to given space.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#isEnabled(kotlin.Boolean)(includeParents: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Returns the enabled status of this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#removeAllComponents()()`

Remove all components from this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#removeComponent(androidx.xr.scenecore.Component)(component: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Component)`

Removes the given Component from this Entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setAlpha(kotlin.Float)(alpha: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Sets the alpha transparency of the Entity relative to the parent Space.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setEnabled(kotlin.Boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets the local enabled state of this Entity.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setPose(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.Space)(pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose, relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Sets the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` for this Entity.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#setScale(kotlin.Float,androidx.xr.scenecore.Space)(scale: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, relativeTo: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Space)`

Sets the scale of this Entity relative to the given Space.

### Inherited properties

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose) `open https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/BaseScenePose#poseInActivitySpace()`

The current `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` relative to the activity space root.
From [androidx.xr.scenecore.Entity](https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity>` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#children()`

Provides the list of all children of this entity.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#contentDescription()`

Alternate text for this Entity to be consumed by Accessibility systems.
`open https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity?` `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity#parent()`

The parent of this Entity, from which this Entity will inherit most of its properties.

## Public companion functions

### create

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

```
@MainThread
fun create(
    session: Session,
    model: GltfModel,
    pose: Pose = Pose.Identity,
    parent: Entity? = null
): GltfModelEntity
```

Public factory function for a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`.

This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads

| Parameters |
|---|---|
| `session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` to create the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` in. |
| `model: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` | The `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` this `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity` is referencing. |
| `pose: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose = Pose.Identity` | The initial `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose` of the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity`. The default value is `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Pose#Identity()`. |
| `parent: https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity? = null` | Parent entity. Defaults to `null`. If `null`, the entity is created but not attached to the scene graph, meaning it will be invisible. If a parent entity (e.g., `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/ActivitySpace` or any other `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity` already present in the scene) is assigned later, the entity will become visible (provided it is enabled). This allows for `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity` pre-configuration before making it visible. |

## Public functions

### getAnimations

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

```
@MainThread
fun getAnimations(): List<GltfAnimation>
```

A list of all `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfAnimation`s defined in the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`. The list is lazily initialized on the first access.

The returned list corresponds to the array of animations defined in the source glTF file. The order of elements in this list is guaranteed to match the order of animations in the glTF file's `animations` array.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the entity has been disposed. |

### stopAllAnimations

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

```
@MainThread
fun stopAllAnimations(): Unit
```

Stops all playing animations in this `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`.

Calling this method stops all animations that are currently in the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfAnimation.AnimationState#PLAYING()` or `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfAnimation.AnimationState#PAUSED()` state. If no animations are playing or paused, this method has no effect.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the entity has been disposed. |

## Public properties

### nodes

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

```
val nodes: List<GltfModelNode>
```

A list of all `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelNode`s defined in the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`. The list is lazily initialized on the first access.

The returned list corresponds to the flattened array of nodes defined in the source glTF file. The order of elements in this list is guaranteed to match the order of nodes in the glTF file's `nodes` array.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the entity has been disposed. |