Documentation Index
Fetch the complete documentation index at: https://mintlify.com/danielitoCode/Spatial/llms.txt
Use this file to discover all available pages before exploring further.
DefaultSceneRenderHostFactory is the production SceneRenderHostFactory implementation from the spatial-compose-runtime-adapter module. Passing it to Scene(renderHostFactory = ...) connects the declarative Compose layer to the full OpenGL ES 3.0 renderer, hooking up the GL surface, camera runtime, and Choreographer-driven frame loop — all without any boilerplate in your composable.
Import
spatial-compose-runtime-adapter
Declaration
DefaultSceneRenderHostFactory is a Kotlin object — a singleton. You never instantiate it; simply reference it by name wherever a SceneRenderHostFactory is expected.
What it does
WhenScene calls DefaultSceneRenderHostFactory.create(context), it constructs a SpatialRuntimeSceneRenderHost that wires together the full rendering stack:
SpatialGlRenderTarget— aGLSurfaceViewwrapper that owns the EGL surface and OpenGL ES 3.0 context.SpatialCamera— the runtime camera that convertsCameraSnapshotvalues (yaw, pitch, zoom) into view/projection matrices each frame.SpatialRuntime— the render loop that accepts a node list and a camera snapshot on every frame, built with aChoreographerFrameSchedulerso frame pacing is synchronized with the Android display vsync signal.
SceneRenderHost then exposes updateScene(), updateCamera(), requestFrame(), and dispose() to the Scene composable.
Internal class: SpatialRuntimeSceneRenderHost
SceneRenderHostFactory interface
DefaultSceneRenderHostFactory satisfies the SceneRenderHostFactory functional interface defined in spatial-compose:
Scene calls create(context) exactly once during composition, holds the resulting SceneRenderHost for the lifetime of the composable, and calls dispose() when the composable leaves the composition.
SceneRenderHost interface
The object returned bycreate() implements SceneRenderHost:
The Android
View used as the rendering surface. Scene embeds this view into the Compose layout via AndroidView. For DefaultSceneRenderHostFactory this is the GLSurfaceView owned by SpatialGlRenderTarget.Stages a new list of
RenderableNode values for the next render pass. The list is held in pendingNodes and forwarded to SpatialRuntime on the next requestFrame() call.Stages a new
CameraSnapshot for the next render pass. CameraSnapshot carries yaw, pitch, zoom, version, and source fields from spatial-core.Triggers a render pass by forwarding the pending nodes and camera snapshot to
SpatialRuntime.requestFrame(). The Choreographer scheduler ensures the pass runs on the next vsync boundary.Shuts down the runtime (
SpatialRuntime.onShutdown()) and releases all OpenGL resources held by the SpatialGlRenderTarget. Always called automatically by Scene when the composable is removed from the tree.Usage
PassDefaultSceneRenderHostFactory as the renderHostFactory argument of Scene for any production Android target:
Custom render host
For testing, Compose Previews, or alternative rendering backends, you can supply your ownSceneRenderHostFactory implementation instead of DefaultSceneRenderHostFactory. Because SceneRenderHostFactory is a fun interface, a lambda is all you need:
In tests or Compose Previews you may supply a no-op
SceneRenderHostFactory implementation to avoid needing a real GL context. The Scene composable will still compose correctly — it simply won’t produce any rendered output.