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 |
|---|
This function is deprecated. Use SubspaceModifier.movable(movePolicy = MovePolicy.anchor()) on the Composable's modifier instead. |
Public functions |
|
|---|---|
open operator Boolean |
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
AnchorPolicy(
isEnabled: Boolean = true,
anchorPlaneOrientations: Set<PlaneOrientation> = emptySet(),
anchorPlaneSemantics: Set<PlaneSemantic> = emptySet()
)
Public functions
Public properties
anchorPlaneOrientations
val anchorPlaneOrientations: Set<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
val anchorPlaneSemantics: Set<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
val isEnabled: Boolean
Whether anchoring is enabled for this object. If false, the object will not be able to anchor to surfaces. Defaults to true.