Skip to main content

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.

Spatial is a declarative 3D rendering library for Android that brings the mental model of Jetpack Compose to 3D scene creation. Describe your scene with Scene, Element, and Modifier3D — Spatial takes care of OpenGL ES 3.0, the render loop, camera math, and gesture handling automatically.

Quickstart

Render your first 3D scene in under five minutes with a complete working example.

Installation

Add the Spatial modules to your Android project using Gradle.

Building Scenes

Learn how Scene, Element, Modifier3D, and CameraState work together.

API Reference

Full reference for every public composable, class, and function in the library.

Why Spatial?

Most Android 3D graphics require deep OpenGL knowledge — setting up EGL contexts, compiling shaders, managing buffers, and writing matrix math from scratch. Spatial eliminates all of that by providing a high-level declarative API that feels like writing a Compose UI.

Declarative

Describe what your scene looks like. Spatial re-renders when state changes, just like Compose.

GPU-Abstracted

OpenGL ES 3.0 complexity is fully hidden. No shaders, no buffer management, no EGL setup.

Cinematic Motion

Orbit, zoom, and animated camera transitions with smooth inertia and adaptive easing built in.

A minimal scene

CoreOneScene.kt
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.elitec.spatial_compose.Element
import com.elitec.spatial_compose.Gestures
import com.elitec.spatial_compose.Modifier3D
import com.elitec.spatial_compose.Scene
import com.elitec.spatial_compose.rememberCameraState
import com.elitec.spatial_compose_runtime_adapter.DefaultSceneRenderHostFactory
import com.elitec.spatial_units.deg
import com.elitec.spatial_units.meters

@Composable
fun CoreOneScene() {
    val cameraState = rememberCameraState(
        yaw = 20f.deg,
        pitch = (-12f).deg,
        zoom = 1.25f,
    )
    Scene(
        modifier = Modifier.fillMaxSize(),
        renderHostFactory = DefaultSceneRenderHostFactory,
        cameraState = cameraState,
        gestures = Gestures.orbitAndZoom(),
    ) {
        Element.Cube(
            modifier = Modifier3D.Default
                .size(2f.meters)
                .position(0f.meters, 0f.meters, (-5f).meters),
        )
        Element.Sphere(
            modifier = Modifier3D.Default
                .size(1f.meters)
                .position(3f.meters, 0f.meters, (-8f).meters),
        )
    }
}

Get started

1

Add Spatial to your project

Include the spatial-compose and spatial-compose-runtime-adapter modules in your build.gradle.kts. See Installation for the full dependency list.
2

Create a CameraState

Call rememberCameraState(yaw, pitch, zoom) inside a composable to get an observable camera you can read and animate programmatically.
3

Compose your Scene

Use the Scene composable with DefaultSceneRenderHostFactory and place Element.Cube, Element.Sphere, or Element.Plane inside its content block.
4

Apply Modifier3D transforms

Chain .position(), .rotateY(), .size(), and other Modifier3D operations on each element to position it in 3D space using readable units like 1.5f.meters and 45f.deg.

Build docs developers (and LLMs) love