MovePolicy

sealed interface MovePolicy


Defines the behavior and configuration for movement applied by the movable modifier.

Summary

Public companion functions

MovePolicy
@ExperimentalMoveAnchorPolicy
anchor(
    anchorPlaneOrientations: Set<PlaneOrientation>,
    anchorPlaneSemantics: Set<PlaneSemantic>,
    onMove: ((SpatialMoveEvent) -> Unit)?
)

A policy that enables anchoring the movable element to detected real-world planes.

MovePolicy
custom(scaleWithDistance: Boolean, onMove: (SpatialMoveEvent) -> Unit)

A policy that accepts move events and reports the calculated pose updates via a callback, without automatically applying a resulting transformation.

MovePolicy
default(scaleWithDistance: Boolean, onMove: ((SpatialMoveEvent) -> Unit)?)

A policy that delegates the pose transformation entirely to the system.

Public companion functions

anchor

Added in 1.0.0-alpha16
@ExperimentalMoveAnchorPolicy
fun anchor(
    anchorPlaneOrientations: Set<PlaneOrientation> = emptySet(),
    anchorPlaneSemantics: Set<PlaneSemantic> = emptySet(),
    onMove: ((SpatialMoveEvent) -> Unit)? = null
): MovePolicy

A policy that enables anchoring the movable element to detected real-world planes.

Using this policy allows the user to snap the subspace element to physical surfaces (like tables or walls) that match the provided orientations and semantics. If no specific orientations or semantics are provided (i.e., the sets are empty), the element is permitted to anchor to any detected plane.

Parameters
anchorPlaneOrientations: Set<PlaneOrientation> = emptySet()

The set of PlaneOrientations (e.g., Horizontal, Vertical) that the element is permitted to anchor to. Defaults to an empty set, which allows all orientations.

anchorPlaneSemantics: Set<PlaneSemantic> = emptySet()

The set of PlaneSemantics (e.g., Wall, Floor, Table) that the element is permitted to anchor to. Defaults to an empty set, which allows all semantics.

onMove: ((SpatialMoveEvent) -> Unit)? = null

Optional observer callback invoked during the manipulation to monitor the movement and anchoring events.

custom

Added in 1.0.0-alpha16
fun custom(
    scaleWithDistance: Boolean = false,
    onMove: (SpatialMoveEvent) -> Unit
): MovePolicy

A policy that accepts move events and reports the calculated pose updates via a callback, without automatically applying a resulting transformation.

This policy enables custom behavior for movement of the content. The system calculates the target Pose based on input, but does not automatically apply it to the associated layout. The developer is responsible for consuming the onMove event and applying the result (e.g., by updating a state backed by SubspaceModifier.offset). Using this policy has higher latency than default.

Parameters
scaleWithDistance: Boolean = false

true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interactability and legibility of the panel. Scaling with distance respects other transformations applied to this layout.

onMove: (SpatialMoveEvent) -> Unit

callback invoked continuously during the interaction that receives a SpatialMoveEvent containing the calculated target pose, scale, and size. The pose contained in this event is the sum of all previous events in the move gesture. The receiver MUST use this data to update the element's external state to reflect movement.

default

Added in 1.0.0-alpha16
fun default(
    scaleWithDistance: Boolean = true,
    onMove: ((SpatialMoveEvent) -> Unit)? = null
): MovePolicy

A policy that delegates the pose transformation entirely to the system.

The system intercepts spatial input events, calculates the resulting Pose and scale, and automatically applies these transformations to the element's layout. This is the standard behavior where a 1:1 transformation is desired, and custom gesture handling or manual state management is not required. This policy will have a better overall performance than the custom policy.

Parameters
scaleWithDistance: Boolean = true

true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interactability and legibility of the panel. Scaling with distance respects other transformations applied to this layout.

onMove: ((SpatialMoveEvent) -> Unit)? = null

Optional observer callback invoked during the manipulation. Since the system automatically applies the move, this callback is strictly for monitoring changes and should not control the position. The onMove callback values can be used to position other sibling composables with the offset modifier. This callback reports a SpatialMoveEvent which will contain a Pose. The Pose contained in this event is the sum of all previous events in the move gesture.