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 handles touch gesture recognition automatically when you pass a SceneGestures configuration to the Scene composable. You never need to intercept raw MotionEvents or write gesture detectors manually — just choose a mode and, optionally, tune the sensitivity. Three modes are available in Core #1.

Gesture Modes

Gestures.none()

Disables all gesture input. The camera is static unless you move it programmatically.

Gestures.orbit()

One-finger drag to orbit the camera horizontally and vertically. This is the default mode passed to Scene.

Gestures.orbitAndZoom()

One-finger drag to orbit and two-finger pinch to zoom. Best for interactive exploration.

Signatures

object Gestures {
    fun none(): SceneGestures

    fun orbit(
        sensitivity: GestureSensitivity = GestureSensitivity.Adaptive,
    ): SceneGestures

    fun orbitAndZoom(
        sensitivity: GestureSensitivity = GestureSensitivity.Adaptive,
    ): SceneGestures
}

Passing Gestures to Scene

Scene(
    modifier = Modifier.fillMaxSize(),
    renderHostFactory = DefaultSceneRenderHostFactory,
    cameraState = cameraState,
    gestures = Gestures.orbitAndZoom(),
) {
    Element.Cube(...)
    Element.Sphere(...)
}
Swap Gestures.orbitAndZoom() for Gestures.none() or Gestures.orbit() at any time — Scene recomposes reactively when the gestures argument changes.

GestureSensitivity

GestureSensitivity controls how many degrees of camera rotation each pixel of drag input produces.

GestureSensitivity.Adaptive (default)

Scales drag sensitivity dynamically based on the current camera zoom, scene bounds, and viewport size. As the user zooms in, small drags still produce comfortable arcs rather than overshooting. This is the recommended policy for most apps.

GestureSensitivity.Fixed

A direct, constant mapping — each pixel of drag always produces exactly degreesPerPixel of rotation, regardless of zoom or viewport size. Use this when you want exact, predictable control over the angular response.
Gestures.orbit(
    sensitivity = GestureSensitivity.Fixed(degreesPerPixel = 0.3f),
)
sealed interface GestureSensitivity {
    data object Adaptive : GestureSensitivity
    data class Fixed(val degreesPerPixel: Float) : GestureSensitivity
}
Use GestureSensitivity.Adaptive (the default) for best results. It adjusts automatically as the user zooms in, preventing over-sensitive orbiting at high zoom levels.

SceneGestures Properties

The SceneGestures data class exposes the following read-only properties:
PropertyTypeDescription
orbitEnabledBooleantrue for Orbit and OrbitAndZoom modes.
zoomEnabledBooleantrue only for OrbitAndZoom mode.
orbitSensitivityGestureSensitivityThe sensitivity policy in effect for orbit drag input.

Disabling Gestures Conditionally

Because SceneGestures is an immutable value passed to Scene, you can switch modes reactively with standard Compose state:
var gestureMode by remember { mutableStateOf(true) }

Scene(
    gestures = if (gestureMode) Gestures.orbitAndZoom() else Gestures.none(),
    ...
) { ... }
Gesture input is wired through the Modifier.sceneGestureInput internal modifier applied by Scene to its AndroidView. You do not need to handle MotionEvents manually or attach your own gesture detectors.
  • Camera — control the orbit camera programmatically and animate it

Build docs developers (and LLMs) love