class Anchor


An anchor describes a fixed location and orientation in the real world. To stay at a fixed location in physical space, the numerical description of this position may update as ARCore for XR updates its understanding of the physical world.

Summary

Nested types

The representation of the current state of an Anchor.

Public companion functions

AnchorCreateResult
create(session: Session, pose: Pose)

Creates and attaches an Anchor at the given pose.

List<UUID>

Retrieves all the UUID instances from Anchor objects that have been persisted by persist that are still present in the local storage.

AnchorCreateResult
load(session: Session, uuid: UUID)

Loads an Anchor from local storage, using the given uuid.

Anchor
loadFromNativePointer(session: Session, nativePointer: Long)

Loads an Anchor of the given native pointer.

Unit
unpersist(session: Session, uuid: UUID)

Deletes a persisted Anchor denoted by uuid from local storage.

Public constructors

Anchor(runtimeAnchor: Anchor)

Public functions

Unit

Detaches this anchor.

open operator Boolean
equals(other: Any?)
open Int
suspend UUID

Stores this anchor in the application's local storage so that it can be shared across sessions.

open suspend Unit

Updates the state of the Updatable.

Public properties

Anchor
StateFlow<Anchor.State>

The current State of this anchor.

Public companion functions

create

Added in 1.0.0-alpha04
fun create(session: Session, pose: Pose): AnchorCreateResult

Creates and attaches an Anchor at the given pose.

Parameters
session: Session

the Session that is used to create the anchor.

pose: Pose

the Pose that describes the location and orientation of the anchor.

Returns
AnchorCreateResult

the result of the operation. Can be AnchorCreateSuccess that contains the created Anchor, or AnchorCreateResourcesExhausted if the resources allocated for anchors have been exhausted.

getPersistedAnchorUuids

Added in 1.0.0-alpha04
fun getPersistedAnchorUuids(session: Session): List<UUID>

Retrieves all the UUID instances from Anchor objects that have been persisted by persist that are still present in the local storage.

Throws
kotlin.IllegalStateException

if AnchorPersistenceMode is set to Disabled.

load

Added in 1.0.0-alpha04
fun load(session: Session, uuid: UUID): AnchorCreateResult

Loads an Anchor from local storage, using the given uuid. The anchor will attempt to be attached in the same physical location as the anchor that was previously persisted. The uuid should be the return value of a previous call to persist.

Throws
kotlin.IllegalStateException

if AnchorPersistenceMode is set to Disabled.

loadFromNativePointer

Added in 1.0.0-alpha04
fun loadFromNativePointer(session: Session, nativePointer: Long): Anchor

Loads an Anchor of the given native pointer.

unpersist

Added in 1.0.0-alpha04
fun unpersist(session: Session, uuid: UUID): Unit

Deletes a persisted Anchor denoted by uuid from local storage.

Throws
kotlin.IllegalStateException

if AnchorPersistenceMode is set to Disabled.

Public constructors

Anchor

Added in 1.0.0-alpha04
Anchor(runtimeAnchor: Anchor)

Public functions

detach

Added in 1.0.0-alpha04
fun detach(): Unit

Detaches this anchor. This anchor will no longer be updated or tracked.

equals

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

hashCode

open fun hashCode(): Int

persist

suspend fun persist(): UUID

Stores this anchor in the application's local storage so that it can be shared across sessions.

Returns
UUID

the UUID that uniquely identifies this anchor.

Throws
kotlin.IllegalStateException

if AnchorPersistenceMode is set to Disabled.

update

Added in 1.0.0-alpha04
open suspend fun update(): Unit

Updates the state of the Updatable.

Public properties

runtimeAnchor

Added in 1.0.0-alpha04
val runtimeAnchorAnchor

state

Added in 1.0.0-alpha04
val stateStateFlow<Anchor.State>

The current State of this anchor.