SpatialGltfModelSource

interface SpatialGltfModelSource


Defines the source for a 3D model to be rendered by the SpatialGltfModel composable.

Instances of SpatialGltfModelSource are created using fromPath or fromUri.

Summary

Public companion functions

SpatialGltfModelSource
fromPath(path: Path)

Creates a SpatialGltfModelSource that loads a glTF model from a Path relative to the application's assets/ folder.

SpatialGltfModelSource
fromUri(uri: Uri)

Creates a SpatialGltfModelSource that loads a glTF model from a content Uri.

Public functions

suspend GltfModel
createModel(session: Session)

Creates a GltfModel from the source.

Public companion functions

fromPath

Added in 1.0.0-alpha14
fun fromPath(path: Path): SpatialGltfModelSource

Creates a SpatialGltfModelSource that loads a glTF model from a Path relative to the application's assets/ folder.

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

Parameters
path: Path

The path of the binary glTF (.glb) model to be loaded, relative to the application's assets/ folder.

Returns
SpatialGltfModelSource

A SpatialGltfModelSource that can be used with the SpatialGltfModel composable.

Throws
IllegalArgumentException

if path is an absolute path.

fromUri

Added in 1.0.0-alpha14
fun fromUri(uri: Uri): SpatialGltfModelSource

Creates a SpatialGltfModelSource that loads a glTF model from a content Uri.

This is suitable for loading models from various sources, such as network locations or local storage, that can be represented by a Uri.

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

Parameters
uri: Uri

The Uri for the binary glTF (.glb) model to be loaded.

Returns
SpatialGltfModelSource

A SpatialGltfModelSource that can be used with the SpatialGltfModel composable.

Public functions

createModel

suspend fun createModel(session: Session): GltfModel

Creates a GltfModel from the source.

Parameters
session: Session

The XR session to create the model in.

Returns
GltfModel

The created GltfModel.