public final 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

public final class Anchor.State

The representation of the current state of an Anchor.

Public constructors

Anchor(@NonNull Anchor runtimeAnchor)

Public methods

static final @NonNull AnchorCreateResult
create(@NonNull Session session, @NonNull Pose pose)

Creates an Anchor at the given pose.

final void

Detaches this anchor.

boolean
equals(Object other)
static final @NonNull List<@NonNull UUID>

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

final @NonNull Anchor
final @NonNull StateFlow<@NonNull Anchor.State>

The current State of this anchor.

int
static final @NonNull AnchorCreateResult
load(@NonNull Session session, @NonNull UUID uuid)

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

static final @NonNull Anchor
loadFromNativePointer(@NonNull Session session, long nativePointer)

Loads an Anchor of the given native pointer.

final @NonNull UUID

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

static final void
unpersist(@NonNull Session session, @NonNull UUID uuid)

Deletes a persisted Anchor denoted by uuid from local storage.

void

Updates the state of the Updatable.

Public constructors

Anchor

Added in 1.0.0-alpha01
public Anchor(@NonNull Anchor runtimeAnchor)

Public methods

create

Added in 1.0.0-alpha01
public static final @NonNull AnchorCreateResult create(@NonNull Session session, @NonNull Pose pose)

Creates an Anchor at the given pose.

Parameters
@NonNull Session session

the Session that is used to create the anchor.

@NonNull Pose pose

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

Returns
@NonNull 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.

detach

Added in 1.0.0-alpha01
public final void detach()

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

equals

public boolean equals(Object other)

getPersistedAnchorUuids

Added in 1.0.0-alpha01
public static final @NonNull List<@NonNull UUIDgetPersistedAnchorUuids(@NonNull Session session)

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

getRuntimeAnchor

Added in 1.0.0-alpha01
public final @NonNull Anchor getRuntimeAnchor()

getState

Added in 1.0.0-alpha01
public final @NonNull StateFlow<@NonNull Anchor.StategetState()

The current State of this anchor.

hashCode

public int hashCode()

load

Added in 1.0.0-alpha01
public static final @NonNull AnchorCreateResult load(@NonNull Session session, @NonNull UUID uuid)

Loads an Anchor from local storage, using the given uuid. The anchor will attempt to be 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.

loadFromNativePointer

Added in 1.0.0-alpha01
public static final @NonNull Anchor loadFromNativePointer(@NonNull Session session, long nativePointer)

Loads an Anchor of the given native pointer.

persist

public final @NonNull UUID persist()

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

Returns
@NonNull UUID

the UUID that uniquely identifies this anchor.

unpersist

Added in 1.0.0-alpha01
public static final void unpersist(@NonNull Session session, @NonNull UUID uuid)

Deletes a persisted Anchor denoted by uuid from local storage.

update

Added in 1.0.0-alpha01
public void update()

Updates the state of the Updatable.