# 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)

*** ** * ** ***


```
public final class GltfModel implements 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/androidx/xr/scenecore/SpatialEnvironment` or to display 3D models with `https://developer.android.com/reference/androidx/xr/scenecore/GltfModelEntity`.

## Summary

| ### Public methods |
|---|---|
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModel#close()()` Closes the given `https://developer.android.com/reference/androidx/xr/scenecore/GltfModel`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/GltfModel` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModel#create(androidx.xr.runtime.Session,java.nio.file.Path)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/nio/file/Path.html path)` 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. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/GltfModel` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/xr/scenecore/GltfModel#create(androidx.xr.runtime.Session,android.net.Uri)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html uri)` Public factory for a GltfModel, where the glTF is asynchronously loaded from a `https://developer.android.com/reference/android/net/Uri.html`. |
| `boolean` | `https://developer.android.com/reference/androidx/xr/scenecore/GltfModel#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `int` | `https://developer.android.com/reference/androidx/xr/scenecore/GltfModel#hashCode()()` |

## Public methods

### close

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

```
@MainThread
public void close()
```

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

The `https://developer.android.com/reference/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/androidx/xr/scenecore/GltfModel` will be automatically closed when the `https://developer.android.com/reference/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. |

### create

```
@MainThread
public static final @NonNull GltfModel create(@NonNull Session session, @NonNull Path path)
```

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/GltfModel` | a `https://developer.android.com/reference/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
public static final @NonNull GltfModel create(@NonNull Session session, @NonNull Uri uri)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session` | The `https://developer.android.com/reference/androidx/xr/runtime/Session` to use for loading the model. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html uri` | The Uri for a binary glTF (.glb) model to be loaded. |

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

### equals

```
public boolean equals(Object other)
```

### hashCode

```
public int hashCode()
```