Skip to main content
Version: 12 Dec 2024

MagicLeapSpatialAnchorsStorageFeature

NameSpace: SpatialAnchors

Inherits from:
MagicLeapOpenXRFeatureBase,
OpenXRFeature

Public Methods

bool CreateSpatialAnchorsFromStorage

public bool CreateSpatialAnchorsFromStorage(
List< string > anchorMapPositionIds
)

Parameters

TypeNameDescription
List< string >anchorMapPositionIds

bool DeleteStoredSpatialAnchor

public bool DeleteStoredSpatialAnchor(
List< string > anchorMapPositionIds
)

Parameters

TypeNameDescription
List< string >anchorMapPositionIds

bool DeleteStoredSpatialAnchors

Delete published anchors from Spatial Anchor Storage.

public bool DeleteStoredSpatialAnchors(
List< string > anchorMapPositionIds
)

Parameters

TypeNameDescription
List< string >anchorMapPositionIdsThe list of AnchorMapPositionIds to Delete. These were assigned in the OnPublishComplete event in MagicLeapSpatialAnchorsStorageFeature.

bool DeleteStoredSpatialAnchors

public bool DeleteStoredSpatialAnchors(
List< ARAnchor > anchors
)

Parameters

TypeNameDescription
List< ARAnchor >anchors

bool PublishSpatialAnchorsToStorage

Publish local anchors to Spatial Anchor Storage using the MagicLeap Anchor Id.

public bool PublishSpatialAnchorsToStorage(
List< ulong > anchorIds,
ulong expiration
)

Parameters

TypeNameDescription
List< ulong >anchorIdsThe list of AnchorIds to publish. These were assigned in the OnCreationComplete event in MagicLeapSpatialAnchorsFeature.
ulongexpirationThe time in seconds since epoch after which these anchors may: expire. Use 0 for permanent anchors. The system may retain them longer.

bool PublishSpatialAnchorsToStorage

Publish local anchors to Spatial Anchor Storage using ARAnchors. Will return false if XRAnchorSubsystem is not loaded.

public bool PublishSpatialAnchorsToStorage(
List< ARAnchor > anchors,
ulong expiration
)

Parameters

TypeNameDescription
List< ARAnchor >anchorsThe list of ARAnchors to publish. TrackingState must be Tracking to be valid for publish. Will be ignored if not.
ulongexpirationThe time in seconds since epoch after which these anchors may: expire. Use 0 for permanent anchors. The system may retain them longer.

bool QueryStoredSpatialAnchors

Determine the maximum number of anchors to accept their completion status each update.

public bool QueryStoredSpatialAnchors(
Vector3 position,
float radius
)

Parameters

TypeNameDescription
Vector3positionThe position of the center of the query
floatradiusThe radius of the search area in meters.

bool UpdateExpirationForStoredSpatialAnchor

Update the expiration time for published anchors in Spatial Anchor Storage.

public bool UpdateExpirationForStoredSpatialAnchor(
List< string > anchorMapPositionIds,
ulong expiration
)

Parameters

TypeNameDescription
List< string >anchorMapPositionIdsThe list of AnchorMapPositionIds to Delete. These were assigned in the OnPublishComplete event in MagicLeapSpatialAnchorsStorageFeature.
ulongexpirationThe time in seconds since epoch after which these anchors may: expire. The system may retain them longer.

bool UpdateExpirationForStoredSpatialAnchor

public bool UpdateExpirationForStoredSpatialAnchor(
List< ARAnchor > anchors,
ulong expiration
)

Parameters

TypeNameDescription
List< ARAnchor >anchors
ulongexpiration

bool UpdateExpirationonStoredSpatialAnchor

Update the expiration time for published anchors in Spatial Anchor Storage.

public bool UpdateExpirationonStoredSpatialAnchor(
List< string > anchorMapPositionIds,
ulong expiration
)

Parameters

TypeNameDescription
List< string >anchorMapPositionIdsThe list of AnchorMapPositionIds to Delete. These were assigned in the OnPublishComplete event in MagicLeapSpatialAnchorsStorageFeature.
ulongexpirationThe time in seconds since epoch after which these anchors may: expire. The system may retain them longer.

Protected Methods

OnInstanceCreate

protected override bool OnInstanceCreate(
ulong xrInstance
)

Parameters

TypeNameDescription
ulongxrInstance

OnSessionDestroy

protected override void OnSessionDestroy(
ulong xrSession
)

Parameters

TypeNameDescription
ulongxrSession

Public Attributes

FeatureId


public const string FeatureId = "com.magicleap.openxr.feature.ml2_spatialanchorstorage";


Protected Attributes

UsesExperimentalExtensions


protected override bool UsesExperimentalExtensions => true;


Public Events

OnCreationCompleteFromStorage

Receive the created anchor's Pose, the anchor's ulong AnchorId, the anchor's string anchorMapPositionId for the localized Map, and the XResult of the request to create the anchor.

public Action< Pose, ulong, string, XrResult > OnCreationCompleteFromStorage()

OnDeletedComplete

Receive a list of string anchorMapPositionIds of anchors that have been deleted from the Localized Map.

public Action< List< string > > OnDeletedComplete()

OnPublishComplete

Receive an ulong AnchorId and a string anchorMapPositionId for the published anchor.

public Action< ulong, string > OnPublishComplete()

OnQueryComplete

Receive a list of string anchorMapPositionIds of anchors returned from the Query of the Localized Map.

public Action< List< string > > OnQueryComplete()

OnUpdateExpirationCompleted

Receive a list of string anchorMapPositionIds of anchors that have had their expiration updated on the Localized Map.

public Action< List< string > > OnUpdateExpirationCompleted()