AnchorPolicy

class AnchorPolicy : DragPolicy


Represents the anchoring behavior of a spatial object.

An AnchorPolicy object can be placed and re-anchored on detected surfaces in the environment. This class defines properties that control how anchoring behaves, such as whether it's enabled and what types of planes it can anchor to.

This functionality requires androidx.xr.runtime.Session.configure to be called with androidx.xr.runtime.PlaneTrackingMode.HORIZONTAL_AND_VERTICAL. This configuration requires that the SCENE_UNDERSTANDING_COARSE Android permission is granted. If not granted, the anchorable functionality will be disabled, and the element will behave as if the anchorable modifier was not applied.

Summary

Public constructors

AnchorPolicy(
    isEnabled: Boolean,
    anchorPlaneOrientations: Set<PlaneOrientation>,
    anchorPlaneSemantics: Set<PlaneSemantic>
)

This function is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead.

Public functions

open operator Boolean
equals(other: Any?)

This function is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead.

open Int

This function is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead.

open String

This function is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead.

Public properties

Set<PlaneOrientation>

This property is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead.

Set<PlaneSemantic>

This property is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead.

Boolean

This property is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead.

Public constructors

AnchorPolicy

Added in 1.0.0-alpha17
Deprecated in 1.0.0-alpha17
AnchorPolicy(
    isEnabled: Boolean = true,
    anchorPlaneOrientations: Set<PlaneOrientation> = emptySet(),
    anchorPlaneSemantics: Set<PlaneSemantic> = emptySet()
)

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

anchorPlaneOrientations

Added in 1.0.0-alpha17
Deprecated in 1.0.0-alpha17
val anchorPlaneOrientationsSet<PlaneOrientation>

A set of PlaneOrientation values that define the orientations of planes this object can anchor to. An empty set means anchoring is not restricted by orientation. For example, PlaneOrientation.Horizontal for floors/ceilings or PlaneOrientation.Vertical for walls. Defaults to an empty set.

anchorPlaneSemantics

Added in 1.0.0-alpha17
Deprecated in 1.0.0-alpha17
val anchorPlaneSemanticsSet<PlaneSemantic>

A set of PlaneSemantic values that define the semantic types of planes this object can anchor to. An empty set means anchoring is not restricted by semantic type. For example, PlaneSemantic.Floor or PlaneSemantic.Wall. Defaults to an empty set.

isEnabled

Added in 1.0.0-alpha17
Deprecated in 1.0.0-alpha17
val isEnabledBoolean

Whether anchoring is enabled for this object. If false, the object will not be able to anchor to surfaces. Defaults to true.