Skip to main content
Version: 21 Aug 2024

NativeBindings

See ml_spatial_anchor.h for additional comments.

Inherits from:
MagicLeapNativeBindings

Public Methods

MLResult.Code MLSpatialAnchorCreate

Create a new local Spatial Anchor at the desired location. On success, out_anchor will be returned with the desired transform and a newly generated ID. Any unpublished anchor will be lost if the Headpose session is lost. See #MLHeadTrackingGetMapEvents for more details.

public MLResult.Code MLSpatialAnchorCreate(
ulong handle,
in MLSpatialAnchorCreateInfo createInfo,
out MLSpatialAnchor anchor
)

Parameters

TypeNameDescription
ulonghandle
in MLSpatialAnchorCreateInfocreateInfoA structure used to populate anchor creation info when creating a new Spatial Anchor.
out MLSpatialAnchoranchorA structure representing a user-defined Spatial Anchor.

MLResult.Code MLSpatialAnchorDelete

Delete an existing Spatial Anchor. If successful, this will delete the anchor from persistent storage based on the currently selected mapping mode.

public MLResult.Code MLSpatialAnchorDelete(
ulong handle,
MLUUIDBytes anchorId
)

Parameters

TypeNameDescription
ulonghandle
MLUUIDBytesanchorIdUniversally unique identifier, byte array.

MLResult.Code MLSpatialAnchorGetLocalizationInfo

Get the current localization status of the device.

public MLResult.Code MLSpatialAnchorGetLocalizationInfo(
ulong handle,
ref MLSpatialAnchorLocalizationInfo localizationInfo
)

Parameters

TypeNameDescription
ulonghandle
ref MLSpatialAnchorLocalizationInfolocalizationInfoA structure containing information about the device's localization state.

MLResult.Code MLSpatialAnchorPublish

Publish an existing local Spatial Anchor to the persistent backend. Depending on the currently selected mapping mode, this can store the anchor locally or in the cloud. This call will fail if the device is not localized to a space. This call will fail if the device is not localized to a space. Any unpublished anchor will be lost if the Headpose session is lost.See #MLHeadTrackingGetMapEvents for more details

public MLResult.Code MLSpatialAnchorPublish(
ulong handle,
MLUUIDBytes anchorId
)

Parameters

TypeNameDescription
ulonghandle
MLUUIDBytesanchorIdUniversally unique identifier, byte array.

MLResult.Code MLSpatialAnchorQueryCreate

Create a new query for Spatial Anchors in the current space. It is the responsibility of the caller to call MLSpatialAnchorQueryDestroy with the query handle returned from this function after the results are no longer needed.

public MLResult.Code MLSpatialAnchorQueryCreate(
ulong handle,
in MLSpatialAnchorQueryFilter queryFilter,
out ulong queryHandle,
out uint resultsCount
)

Parameters

TypeNameDescription
ulonghandle
in MLSpatialAnchorQueryFilterqueryFilterA collection of filters for Spatial Anchor queries. Filters that have been set will be combined via logical conjunction. E. g. results must match the ids filter AND fall within the radius constraint when both have been set. This struct must be initialized by calling #MLSpatialAnchorQueryFilterInit before use.
out ulongqueryHandle
out uintresultsCount

MLResult.Code MLSpatialAnchorQueryDestroy

Destroy a previously created query handle and release its associated resources.

public MLResult.Code MLSpatialAnchorQueryDestroy(
ulong handle,
ulong queryHandle
)

Parameters

TypeNameDescription
ulonghandle
ulongqueryHandle

MLResult.Code MLSpatialAnchorQueryGetResult

Get the result of a previous Spatial Anchor query. Putting index bounds on the results allows the caller to only receive a subset of the total number of results generated by the query. This is useful as a form of pagination in the case of a large number of anchors in the current space. Indexing is zero-based so if there are N results in the query, then it is required that 0 <= first_index <= last_index < N.

public MLResult.Code MLSpatialAnchorQueryGetResult(
ulong handle,
ulong queryHandle,
uint firstIndex,
uint lastIndex,
MLSpatialAnchor [] results
)

Parameters

TypeNameDescription
ulonghandle
ulongqueryHandle
uintfirstIndex
uintlastIndex
MLSpatialAnchor []resultsA structure representing a user-defined Spatial Anchor.

MLResult.Code MLSpatialAnchorTrackerCreate

Create a Spatial Anchor tracker.

public MLResult.Code MLSpatialAnchorTrackerCreate(
out ulong handle
)

Parameters

TypeNameDescription
out ulonghandle

MLResult.Code MLSpatialAnchorTrackerDestroy

Destroy a previously created Spatial Anchor tracker.

public MLResult.Code MLSpatialAnchorTrackerDestroy(
ulong handle
)

Parameters

TypeNameDescription
ulonghandle

MLResult.Code MLSpatialAnchorUpdate

Update a Spatial Anchor's properties. The only property that can currently be updated is the expirationTimeStamp.

public MLResult.Code MLSpatialAnchorUpdate(
ulong handle,
in MLSpatialAnchor anchor
)

Parameters

TypeNameDescription
ulonghandle
in MLSpatialAnchoranchorA structure representing a user-defined Spatial Anchor.