Composable Function

PlanarEmbeddedSubspace

Creates a 3D space for spatial content that is embedded within and positioned by a 2D container.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free

PlanarEmbeddedSubspaceSample

public fun PlanarEmbeddedSubspaceSample() {
    @Composable
    @SubspaceComposable
    fun PanelWithPlanarEmbeddedSubspace() {
        // A PlanarEmbeddedSubspace is placed inside a SpatialPanel.
        // The 3D content inside the PlanarEmbeddedSubspace is positioned
        // relative to the 2D area of the SpatialPanel.
        // Here we place it in a Row to demonstrate that it participates in 2D layout.
        SpatialPanel {
            Row {
                Text("2D content")
                PlanarEmbeddedSubspace {
                    // The content of a PlanarEmbeddedSubspace must be a SubspaceComposable.
                    // Here we use another SpatialPanel to host 2D content. However,
                    // this could be any 3D content (i.e. glTFs).
                    SpatialPanel(SubspaceModifier.offset(z = (-50).dp)) {
                        Text("Embedded 3D content")
                    }
                }
            }
        }
    }
}