Start native apps faster with the Composables CLI ->
Interface

SpatialGltfModelSource

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

Source set: Android
public 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.

Functions

createModel

Source set: Android
public suspend fun createModel(session: Session): GltfModel

Creates a GltfModel from the source.

Parameters

session The XR session to create the model in.

Return

The created GltfModel.

Members

Companion

Source set: Android
public companion object

Functions

fromPath

Source set: Android
public 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 The path of the binary glTF (.glb) model to be loaded, relative to the application's assets/ folder.

Return

A SpatialGltfModelSource that can be used with the SpatialGltfModel composable.

Throws: IllegalArgumentException

if path is an absolute path.

fromUri

Source set: Android
public 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 The Uri for the binary glTF (.glb) model to be loaded.

Return

A SpatialGltfModelSource that can be used with the SpatialGltfModel composable.

fromResource

Source set: Android
public fun fromResource(context: Context, @RawRes resId: Int): SpatialGltfModelSource

Creates a SpatialGltfModelSource that loads a glTF model from a resource ID.

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

Parameters

context The context to use for loading the resource.
resId The resource ID of the binary glTF (.glb) model to be loaded.

Return

A SpatialGltfModelSource that can be used with the SpatialGltfModel composable.