# AnchorPlacement

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/AnchorPlacement.kt+class:androidx.xr.scenecore.AnchorPlacement) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public final class AnchorPlacement
```

<br />

*** ** * ** ***

AnchorPlacement for setting how an `https://developer.android.com/reference/androidx/xr/scenecore/Entity` should be anchored in a `https://developer.android.com/reference/androidx/xr/scenecore/MovableComponent`.

When an AnchorPlacement is added to a MovableComponent, the attached Entity may be automatically anchored and reparented to a new Entity at the end of the movement.

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/AnchorPlacement` | `https://developer.android.com/reference/androidx/xr/scenecore/AnchorPlacement#createForPlanes(kotlin.collections.Set,kotlin.collections.Set)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PlaneOrientation> anchorablePlaneOrientations, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PlaneSemanticType> anchorablePlaneSemanticTypes )` Creates an anchor placement for anchoring to planes. |
| `boolean` | `https://developer.android.com/reference/androidx/xr/scenecore/AnchorPlacement#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PlaneOrientation>` | `https://developer.android.com/reference/androidx/xr/scenecore/AnchorPlacement#getAnchorablePlaneOrientations()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PlaneSemanticType>` | `https://developer.android.com/reference/androidx/xr/scenecore/AnchorPlacement#getAnchorablePlaneSemanticTypes()()` |
| `int` | `https://developer.android.com/reference/androidx/xr/scenecore/AnchorPlacement#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/xr/scenecore/AnchorPlacement#toString()()` |

## Public methods

### createForPlanes

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public static final @NonNull AnchorPlacement createForPlanes(
    @NonNull Set<@NonNull PlaneOrientation> anchorablePlaneOrientations,
    @NonNull Set<@NonNull PlaneSemanticType> anchorablePlaneSemanticTypes
)
```

Creates an anchor placement for anchoring to planes.

Setting a `https://developer.android.com/reference/androidx/xr/scenecore/PlaneOrientation` or `https://developer.android.com/reference/androidx/xr/scenecore/PlaneSemanticType` filter means that the `https://developer.android.com/reference/androidx/xr/scenecore/Entity` with a `https://developer.android.com/reference/androidx/xr/scenecore/MovableComponent` will be anchored to a plane of that matches at least one of the specified PlaneOrientation filters and at least one specified PlaneSemanticType filters if it is released nearby. By default this the Entity will be anchored to any plane. If no PlaneOrientation or no PlaneSemanticType is set the Entity will not be anchored. This setting requires `https://developer.android.com/reference/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` to be called with `https://developer.android.com/reference/androidx/xr/runtime/PlaneTrackingMode#HORIZONTAL_AND_VERTICAL()` in order to be able to discover planes.

When an Entity is anchored to the plane the pose will be rotated so that it's Z-vector will be pointing out of the plane (i.e. if it is a panel it will be flat along the plane). The `https://developer.android.com/reference/androidx/xr/scenecore/EntityMoveListener#onMoveEnd(androidx.xr.scenecore.Entity,androidx.xr.runtime.math.Ray,androidx.xr.runtime.math.Pose,kotlin.Float,androidx.xr.scenecore.Entity)` callback can be used to listen for the Entity being anchored, reanchored, or unanchored. When anchored the parent will be updated to a new anchor Entity. When unanchored the parent will be set to the `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PlaneOrientation> anchorablePlaneOrientations` | The set of plane types to filter by. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PlaneSemanticType> anchorablePlaneSemanticTypes` | The set of plane semantics to filter by. |

### equals

```
public boolean equals(Object other)
```

### getAnchorablePlaneOrientations

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull Set<@NonNull PlaneOrientation> getAnchorablePlaneOrientations()
```

### getAnchorablePlaneSemanticTypes

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull Set<@NonNull PlaneSemanticType> getAnchorablePlaneSemanticTypes()
```

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```