# 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)

*** ** * ** ***


```
class AnchorPlacement
```

<br />

*** ** * ** ***

AnchorPlacement for setting how an `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity` should be anchored in a `https://developer.android.com/reference/kotlin/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 companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorPlacement` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorPlacement#createForPlanes(kotlin.collections.Set,kotlin.collections.Set)( anchorablePlaneOrientations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneOrientation>, anchorablePlaneSemanticTypes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneSemanticType> )` Creates an anchor placement for anchoring to planes. |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorPlacement#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorPlacement#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorPlacement#toString()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneOrientation>` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorPlacement#anchorablePlaneOrientations()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneSemanticType>` | `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/AnchorPlacement#anchorablePlaneSemanticTypes()` |

## Public companion functions

### createForPlanes

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

```
fun createForPlanes(
    anchorablePlaneOrientations: Set<PlaneOrientation> = PlaneOrientation.ALL,
    anchorablePlaneSemanticTypes: Set<PlaneSemanticType> = PlaneSemanticType.ALL
): AnchorPlacement
```

Creates an anchor placement for anchoring to planes.

Setting a `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneOrientation` or `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneSemanticType` filter means that the `https://developer.android.com/reference/kotlin/androidx/xr/scenecore/Entity` with a `https://developer.android.com/reference/kotlin/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/kotlin/androidx/xr/runtime/Session#configure(androidx.xr.runtime.Config)` to be called with `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/xr/scenecore/ActivitySpace`.

| Parameters |
|---|---|
| `anchorablePlaneOrientations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneOrientation> = PlaneOrientation.ALL` | The set of plane types to filter by. |
| `anchorablePlaneSemanticTypes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/xr/scenecore/PlaneSemanticType> = PlaneSemanticType.ALL` | The set of plane semantics to filter by. |

## Public functions

### equals

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

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### anchorablePlaneOrientations

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

```
val anchorablePlaneOrientations: Set<PlaneOrientation>
```

### anchorablePlaneSemanticTypes

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

```
val anchorablePlaneSemanticTypes: Set<PlaneSemanticType>
```