SpatialGltfModel
Source set: Android
@Composable
@SubspaceComposable
public fun SpatialGltfModel(
state: SpatialGltfModelState,
modifier: SubspaceModifier = SubspaceModifier,
content: @Composable @SubspaceComposable () -> Unit = {},
)
This composable renders a glTF or .glb model that is loaded asynchronously from the provided source.
Layout and Sizing
The SpatialGltfModel's layout size is determined by the bounding box size of the glTFmodel that is being displayed coerced into the constraints of the layout.
- By default, the layout size will match the bounding box of the loaded 3D asset once it is loaded bounded by the current constraints.
- To force the SpatialGltfModel to a specific size, use a size modifier like SubspaceModifier.size().
- The rendered model will be scaled uniformly to fit within the constraints imposed by the layout and modifiers.
- The
contentwill be positioned at the center of the SpatialGltfModel by default. The developer may use GltfModelNode pose and size information to offset content relative to a desired position. Note: Because the model is loaded asynchronously, its intrinsic size will be zero during initial composition. The layout will be remeasured with the correct size once the model has finished loading. You can use the state parameter to observe the loading status via SpatialGltfModelState.status.
Parameters
| state | A SpatialGltfModelState object to observe and control the SpatialGltfModel. This can be created using rememberSpatialGltfModelState. The state should be created with a SpatialGltfModelSource that defines where to load the 3D model from. Use the helper functions fromPath, fromUri, or fromData to create a SpatialGltfModelSource. |
| modifier | The SubspaceModifier to be applied to this SpatialGltfModel. |
| content | The content within the space of the SpatialGltfModel |