Google. XR. ARCoreExtensions. ARAnchorManagerExtensions
Extensions to AR Foundation's ARAnchorManager class.
Summary
Public static functions |
|
---|---|
AddAnchor(this ARAnchorManager anchorManager, double latitude, double longitude, double altitude, Quaternion eunRotation)
|
Creates a new anchor at the specified geospatial location and orientation relative to the Earth.
|
AddCloudReferencePoint(this ARAnchorManager referencePointManager, ARAnchor referencePoint)
|
Deprecated.
Use ARAnchorManagerExtensions.HostCloudAnchor(this ARAnchorManager, ARAnchor) instead. Creates a new cloud reference point using an existing local Reference Point. |
EstimateFeatureMapQualityForHosting(this ARAnchorManager anchorManager, Pose pose)
|
Estimates the quality of the visual feature points seen by ARCore in the preceding few seconds and visible from the provided camera pose .
|
HostCloudAnchor(this ARAnchorManager anchorManager, ARAnchor anchor)
|
Creates a new Cloud Anchor using an existing local ARAnchor.
|
HostCloudAnchor(this ARAnchorManager anchorManager, ARAnchor anchor, int ttlDays)
|
Creates a new Cloud Anchor with a given lifetime using an existing local ARAnchor.
|
ResolveAnchorOnTerrain(this ARAnchorManager anchorManager, double latitude, double longitude, double altitudeAboveTerrain, Quaternion eunRotation)
|
Creates a
ARGeospatialAnchor at a specified horizontal position and altitude relative to the horizontal position's terrain. |
ResolveCloudAnchorId(this ARAnchorManager anchorManager, string cloudAnchorId)
|
Creates a new local Cloud Anchor from the provided Id.
|
ResolveCloudReferenceId(this ARAnchorManager referencePointManager, string cloudReferenceId)
|
Deprecated.
Please use ResolveCloudAnchorId(string) instead. Creates a new local cloud reference point from the provided Id. |
SetAuthToken(this ARAnchorManager anchorManager, string authToken)
|
void
Set the token to use when authenticating with the ARCore Cloud Anchor service on the iOS platform.
|
Public static functions
AddAnchor
ARGeospatialAnchor AddAnchor( this ARAnchorManager anchorManager, double latitude, double longitude, double altitude, Quaternion eunRotation )
Creates a new anchor at the specified geospatial location and orientation relative to the Earth.
Latitude and longitude are defined by the WGS84 specification, and altitude values are defined by the elevation above the WGS84 ellipsoid. To create an anchor using an altitude relative to the Earth's terrain instead of altitude above the WGS84 ellipsoid, use ARAnchorManagerExtensions.ResolveAnchorOnTerrain(this ARAnchorManager, double,
double, double, Quaternion)
. Creating anchors near the north pole or south pole is not supported. If the latitude is within 0.1 degrees of the north pole or south pole (90 degrees or -90 degrees), this function will return null
.
The rotation provided by eunRotation
is a rotation with respect to an east-up-north 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 north.
An anchor's tracking state will be TrackingState.None
while AREarthManager.EarthTrackingState
is TrackingState.None
. The tracking state will permanently become TrackingState.None
if the configuration is set to GeospatialMode.Disabled
.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Returns |
If successful, a
ARGeospatialAnchor , otherwise, null . |
AddCloudReferencePoint
ARCloudReferencePoint AddCloudReferencePoint( this ARAnchorManager referencePointManager, ARAnchor referencePoint )
Creates a new cloud reference point using an existing local Reference Point.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
If successful, a
ARCloudReferencePoint , otherwise null . |
Deprecated.
Use ARAnchorManagerExtensions.HostCloudAnchor(this ARAnchorManager, ARAnchor)
instead.
EstimateFeatureMapQualityForHosting
FeatureMapQuality EstimateFeatureMapQualityForHosting( this ARAnchorManager anchorManager, Pose pose )
Estimates the quality of the visual feature points seen by ARCore in the preceding few seconds and visible from the provided camera pose .
Cloud Anchors hosted using higher feature map quality will generally result in easier and more accurately resolved ARCloudAnchor
poses. If feature map quality cannot be estimated for the given pose , a warning message "Failed to estimate feature map quality" with the error status is logged and FeatureMapQuality.Insufficient
is returned.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
The estimated feature map quality.
|
HostCloudAnchor
ARCloudAnchor HostCloudAnchor( this ARAnchorManager anchorManager, ARAnchor anchor )
Creates a new Cloud Anchor using an existing local ARAnchor.
The sample code below illustrates how to host a Cloud Anchor.
private ARCloudAnchor _cloudAnchor; void HostCloudAnchor(Pose pose) { // Create a local anchor, you may also use another ARAnchor you already have. ARAnchor localAnchor = AnchorManager.AddAnchor(pose); // Request the Cloud Anchor. _cloudAnchor = AnchorManager.HostCloudAnchor(localAnchor); } void Update() { if (_cloudAnchor) { // Check the Cloud Anchor state. CloudAnchorState cloudAnchorState = _cloudAnchor.cloudAnchorState; if (cloudAnchorState == CloudAnchorState.Success) { myOtherGameObject.transform.SetParent(_cloudAnchor.transform, false); _cloudAnchor = null; } else if (cloudAnchorState == CloudAnchorState.TaskInProgress) { // Wait, not ready yet. } else { // An error has occurred. } } }
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
If successful, a
ARCloudAnchor , otherwise null . |
HostCloudAnchor
ARCloudAnchor HostCloudAnchor( this ARAnchorManager anchorManager, ARAnchor anchor, int ttlDays )
Creates a new Cloud Anchor with a given lifetime using an existing local ARAnchor.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
If successful, an
ARCloudAnchor , otherwise null . |
ResolveAnchorOnTerrain
ARGeospatialAnchor ResolveAnchorOnTerrain( this ARAnchorManager anchorManager, double latitude, double longitude, double altitudeAboveTerrain, Quaternion eunRotation )
Creates a ARGeospatialAnchor
at a specified horizontal position and altitude relative to the horizontal position's terrain.
Terrain means the ground or ground floor inside a building with VPS coverage. If the altitude relative to the WGS84 ellipsoid is known, use ARAnchorManagerExtensions.AddAnchor(this ARAnchorManager, double, double, double, Quaternion)
instead.
The specified altitudeAboveTerrain
is interpreted to be relative to the Earth's terrain (or floor) 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 terrain (or floor) whereas specifying a positive altitude will position the anchor above the terrain (or floor), against the direction of gravity.
This creates a new ARGeospatialAnchor
and schedules a task to resolve the anchor's pose using the given parameters. You may resolve multiple anchors at a time, but a session cannot be tracking more than 100 Terrain anchors at time.
The returned Terrain anchor will have its ARGeospatialAnchor.terrainAnchorState
set to TerrainAnchorState.TaskInProgress
, and its ARGeospatialAnchor.trackingState
set to TrackingState.None
. The anchor will remain in this state until its pose has been successfully resolved. If the resolving task results in an error, the anchor's ARGeospatialAnchor.terrainAnchorState
will detail error information.
Creating a Terrain anchor requires AREarthManager.EarthState
to be EarthState.Enabled
, and AREarthManager.EarthTrackingState
to be Tracking
. If it is not, then this function returns null
. 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.
Latitude and longitude are defined by the WGS84 specification. Creating anchors near the north pole or south pole is not supported. If the latitude is within 0.1 degrees of the north pole or south pole (90 degrees or -90 degrees), this function will return null
.
The rotation provided by eunRotation
is a rotation with respect to an east-up-north 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 north.
An anchor's tracking state will be TrackingState.None
while AREarthManager.EarthTrackingState
is TrackingState.None
. The tracking state will permanently become TrackingState.None
if the configuration is set to GeospatialMode.Disabled
.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Returns |
If successful, a
ARGeospatialAnchor , otherwise, null . |
ResolveCloudAnchorId
ARCloudAnchor ResolveCloudAnchorId( this ARAnchorManager anchorManager, string cloudAnchorId )
Creates a new local Cloud Anchor from the provided Id.
A session can be resolving up to 40 Cloud Anchors at a given time. If resolving fails, the anchor will be automatically removed from the session.
The sample code below illustrates how to resolve a Cloud Anchor.
private ARCloudAnchor _cloudAnchor; void ResolveCloudAnchor(string cloudAnchorId) { // Request the Cloud Anchor. _cloudAnchor = AnchorManager.ResolveCloudAnchorId(cloudAnchorId); } void Update() { if (_cloudAnchor) { // Check the Cloud Anchor state. CloudAnchorState cloudAnchorState = _cloudAnchor.cloudAnchorState; if (cloudAnchorState == CloudAnchorState.Success) { myOtherGameObject.transform.SetParent(_cloudAnchor.transform, false); _cloudAnchor = null; } else if (cloudAnchorState == CloudAnchorState.TaskInProgress) { // Wait, not ready yet. } else { // An error has occurred. } } }
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
If successful, a
ARCloudAnchor , otherwise null . |
ResolveCloudReferenceId
ARCloudReferencePoint ResolveCloudReferenceId( this ARAnchorManager referencePointManager, string cloudReferenceId )
Creates a new local cloud reference point from the provided Id.
Deprecated. Please use ResolveCloudAnchorId(string) instead.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Returns |
If successful, a
ARCloudReferencePoint , otherwise null . |
SetAuthToken
void SetAuthToken( this ARAnchorManager anchorManager, string authToken )
Set the token to use when authenticating with the ARCore Cloud Anchor service on the iOS platform.
This should be called each time the application's token is refreshed.
Details | |||||
---|---|---|---|---|---|
Parameters |
|