androidx.xr.arcore.guava


Extension functions summary

ListenableFuture<AnchorCreateResult>
Earth.createAnchorOnSurfaceAsync(
    session: Session,
    latitude: Double,
    longitude: Double,
    altitudeAboveSurface: Double,
    eastUpSouthQuaternion: Quaternion,
    surface: Earth.Surface
)

Asynchronously creates a new Anchor at a specified horizontal position and altitude relative to the horizontal position's surface (Terrain or Rooftop).

ListenableFuture<UUID>

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

Extension functions

createAnchorOnSurfaceAsync

fun Earth.createAnchorOnSurfaceAsync(
    session: Session,
    latitude: Double,
    longitude: Double,
    altitudeAboveSurface: Double,
    eastUpSouthQuaternion: Quaternion,
    surface: Earth.Surface
): ListenableFuture<AnchorCreateResult>

Asynchronously creates a new Anchor at a specified horizontal position and altitude relative to the horizontal position's surface (Terrain or Rooftop).

The specified altitudeAboveSurface is interpreted to be relative to the given surface at the specified latitude/longitude geospatial coordinates, rather than relative to the WGS84 ellipsoid. Specifying an altitude of 0 will position the anchor directly on the surface whereas specifying a positive altitude will position the anchor above the surface, against the direction of gravity.

Surface.TERRAIN refers to the Earth's terrain (or floor) and Surface.ROOFTOP refers to the top of a building at the given horizontal location. If there is no building at the given location, then the rooftop surface is interpreted to be the terrain instead.

You may resolve multiple anchors at a time, but a session cannot be tracking more than 100 surface anchors at time. Attempting to resolve more than 100 surface anchors will return an AnchorCreateResourcesExhausted result.

Creating a Terrain anchor requires an active Earth which is State.RUNNING. If it is not, then this function returns an AnchorCreateIllegalState result. This call also requires a working internet connection to communicate with the ARCore API on Google Cloud. ARCore will continue to retry if it is unable to establish a connection to the ARCore service.

A Terrain anchor's tracking state will be TrackingState.PAUSED if the Earth is not actively tracking. Its tracking state will permanently become TrackingState.STOPPED if Config.GeospatialMode is disabled, or if another full-space app uses Geospatial.

Latitude and longitude are defined by the WGS84 specification, and the altitude value is defined by the elevation above the Earth's terrain (or floor) in meters.

The rotation quaternion provided is with respect to an east-up-south coordinate frame. An identity rotation will have the anchor oriented such that X+ points to the east, Y+ points up away from the center of the earth, and Z+ points to the south.

Parameters
session: Session

the current Session.

latitude: Double

the latitude of the anchor.

longitude: Double

the longitude of the anchor.

altitudeAboveSurface: Double

The altitude of the anchor above the given surface.

eastUpSouthQuaternion: Quaternion

the rotation Quaternion of the anchor.

surface: Earth.Surface

the Surface the anchor is attached to.

Throws
kotlin.IllegalArgumentException

if the latitude is outside the allowable range.

fun Anchor.persistAsync(session: Session): ListenableFuture<UUID>

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

Returns
ListenableFuture<UUID>

a ListenableFuture that returns a UUID that uniquely identifies this anchor.

Throws
kotlin.IllegalStateException

if Session.config is set to Config.AnchorPersistenceMode.DISABLED, or if there was an unexpected error persisting the anchor (e.g. ran out of memory).