# GltfModel

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

*** ** * ** ***


```
class GltfModel : AutoCloseable
```

<br />

*** ** * ** ***

GltfModel represents a [glTF](https://www.khronos.org/Gltf) resource in SceneCore. These can be used as part of the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/SpatialEnvironment` or to display 3D models with `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModelEntity`.

## Summary

| ### Public companion functions |
|---|---|
| `suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel#create(androidx.xr.runtime.Session,java.nio.file.Path)(session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session, path: https://developer.android.com/reference/java/nio/file/Path.html)` Public factory for a GltfModel, where the glTF is asynchronously loaded from a `https://developer.android.com/reference/java/nio/file/Path.html` relative to the application's `assets/` folder. |
| `suspend https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel#create(androidx.xr.runtime.Session,android.net.Uri)(session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session, uri: https://developer.android.com/reference/android/net/Uri.html)` Public factory for a GltfModel, where the glTF is asynchronously loaded from a `https://developer.android.com/reference/android/net/Uri.html`. |

| ### Public functions |
|---|---|
| `open 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/GltfModel#close()()` Closes the given `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel`. |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel#hashCode()()` |

## Public companion functions

### create

```
@MainThread
suspend fun create(session: Session, path: Path): GltfModel
```

Public factory for a GltfModel, where the glTF is asynchronously loaded from a `https://developer.android.com/reference/java/nio/file/Path.html` relative to the application's `assets/` folder.

Currently, only binary glTF (.glb) files are supported.

| Parameters |
|---|---|
| `session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` | The `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` to use for loading the model. |
| `path: https://developer.android.com/reference/java/nio/file/Path.html` | The Path of the binary glTF (.glb) model to be loaded, relative to the application's `assets/` folder. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` | a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` upon completion. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/java/nio/file/Path.html#isAbsolute()` is true, as this method requires a relative path. |

### create

```
@MainThread
suspend fun create(session: Session, uri: Uri): GltfModel
```

Public factory for a GltfModel, where the glTF is asynchronously loaded from a `https://developer.android.com/reference/android/net/Uri.html`.

Currently, only binary glTF (.glb) files are supported.

| Parameters |
|---|---|
| `session: https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` | The `https://developer.android.com/reference/kotlin/androidx/xr/runtime/Session` to use for loading the model. |
| `uri: https://developer.android.com/reference/android/net/Uri.html` | The Uri for a binary glTF (.glb) model to be loaded. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` | a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` upon completion. |

## Public functions

### close

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

```
@MainThread
open fun close(): Unit
```

Closes the given `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel`.

The `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` can be explicitly closed at any time or garbage collected. When either happens, its resources are freed. If close() is not explicitly invoked by the client, the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` will be automatically closed when the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/GltfModel` is garbage collected.

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

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```