Class MLSpatialAnchors
Spatial anchors are XrSpace entities tied to a physical location. This allows the developer to place virtual content in real world locations.
The runtime should then adjust the XrSpace over time as needed, independently of all other spaces and anchors, to ensure that it maintains its original mapping to the real world.
Caution
If head pose is lost and regained, spatial anchors may also be lost. It is therefore strongly recommended that once an anchor is created, it is also persisted using the XR_ML_spatial_anchors_storage extension.
Permissions
Android applications must have the com.magicleap.permission.SPATIAL_ANCHOR permission listed in their manifest to use this extension. (protection level: normal)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intExtendsXrResult.static final intExtendsXrResult.static final intExtendsXrResult.static final intExtendsXrResult.static final StringThe extension name.static final intThe extension specification version.static final intXrSpatialAnchorConfidenceML - Spatial anchor confidencestatic final intXrSpatialAnchorConfidenceML - Spatial anchor confidencestatic final intXrSpatialAnchorConfidenceML - Spatial anchor confidencestatic final intExtendsXrStructureType.static final intExtendsXrStructureType.static final intExtendsXrStructureType. -
Method Summary
Modifier and TypeMethodDescriptionstatic intnxrCreateSpatialAnchorsAsyncML(XrSession session, long createInfo, long future) Unsafe version of:CreateSpatialAnchorsAsyncMLstatic intnxrCreateSpatialAnchorsCompleteML(XrSession session, long future, long completion) Unsafe version of:CreateSpatialAnchorsCompleteMLstatic intnxrGetSpatialAnchorStateML(XrSpace anchor, long state) Unsafe version of:GetSpatialAnchorStateMLstatic intxrCreateSpatialAnchorsAsyncML(XrSession session, XrSpatialAnchorsCreateInfoBaseHeaderML createInfo, LongBuffer future) Create spatial anchors.static intxrCreateSpatialAnchorsCompleteML(XrSession session, long future, XrCreateSpatialAnchorsCompletionML completion) Completion function for spatial anchor creation.static intxrGetSpatialAnchorStateML(XrSpace anchor, XrSpatialAnchorStateML state) Retrieve spatial anchor state.
-
Field Details
-
XR_ML_spatial_anchors_SPEC_VERSION
public static final int XR_ML_spatial_anchors_SPEC_VERSIONThe extension specification version.- See Also:
-
XR_ML_SPATIAL_ANCHORS_EXTENSION_NAME
The extension name.- See Also:
-
XR_TYPE_SPATIAL_ANCHORS_CREATE_INFO_FROM_POSE_ML
public static final int XR_TYPE_SPATIAL_ANCHORS_CREATE_INFO_FROM_POSE_MLExtendsXrStructureType.Enum values:
- See Also:
-
XR_TYPE_CREATE_SPATIAL_ANCHORS_COMPLETION_ML
public static final int XR_TYPE_CREATE_SPATIAL_ANCHORS_COMPLETION_MLExtendsXrStructureType.Enum values:
- See Also:
-
XR_TYPE_SPATIAL_ANCHOR_STATE_ML
public static final int XR_TYPE_SPATIAL_ANCHOR_STATE_MLExtendsXrStructureType.Enum values:
- See Also:
-
XR_ERROR_SPATIAL_ANCHORS_PERMISSION_DENIED_ML
public static final int XR_ERROR_SPATIAL_ANCHORS_PERMISSION_DENIED_MLExtendsXrResult.Enum values:
- See Also:
-
XR_ERROR_SPATIAL_ANCHORS_NOT_LOCALIZED_ML
public static final int XR_ERROR_SPATIAL_ANCHORS_NOT_LOCALIZED_MLExtendsXrResult.Enum values:
- See Also:
-
XR_ERROR_SPATIAL_ANCHORS_OUT_OF_MAP_BOUNDS_ML
public static final int XR_ERROR_SPATIAL_ANCHORS_OUT_OF_MAP_BOUNDS_MLExtendsXrResult.Enum values:
- See Also:
-
XR_ERROR_SPATIAL_ANCHORS_SPACE_NOT_LOCATABLE_ML
public static final int XR_ERROR_SPATIAL_ANCHORS_SPACE_NOT_LOCATABLE_MLExtendsXrResult.Enum values:
- See Also:
-
XR_SPATIAL_ANCHOR_CONFIDENCE_LOW_ML
public static final int XR_SPATIAL_ANCHOR_CONFIDENCE_LOW_MLXrSpatialAnchorConfidenceML - Spatial anchor confidenceDescription
Enum Description SPATIAL_ANCHOR_CONFIDENCE_LOW_MLLow quality, this anchor can be expected to move significantly. SPATIAL_ANCHOR_CONFIDENCE_MEDIUM_MLMedium quality, this anchor may move slightly. SPATIAL_ANCHOR_CONFIDENCE_HIGH_MLHigh quality, this anchor is stable and suitable for digital content attachment. See Also
- See Also:
-
XR_SPATIAL_ANCHOR_CONFIDENCE_MEDIUM_ML
public static final int XR_SPATIAL_ANCHOR_CONFIDENCE_MEDIUM_MLXrSpatialAnchorConfidenceML - Spatial anchor confidenceDescription
Enum Description SPATIAL_ANCHOR_CONFIDENCE_LOW_MLLow quality, this anchor can be expected to move significantly. SPATIAL_ANCHOR_CONFIDENCE_MEDIUM_MLMedium quality, this anchor may move slightly. SPATIAL_ANCHOR_CONFIDENCE_HIGH_MLHigh quality, this anchor is stable and suitable for digital content attachment. See Also
- See Also:
-
XR_SPATIAL_ANCHOR_CONFIDENCE_HIGH_ML
public static final int XR_SPATIAL_ANCHOR_CONFIDENCE_HIGH_MLXrSpatialAnchorConfidenceML - Spatial anchor confidenceDescription
Enum Description SPATIAL_ANCHOR_CONFIDENCE_LOW_MLLow quality, this anchor can be expected to move significantly. SPATIAL_ANCHOR_CONFIDENCE_MEDIUM_MLMedium quality, this anchor may move slightly. SPATIAL_ANCHOR_CONFIDENCE_HIGH_MLHigh quality, this anchor is stable and suitable for digital content attachment. See Also
- See Also:
-
-
Method Details
-
nxrCreateSpatialAnchorsAsyncML
Unsafe version of:CreateSpatialAnchorsAsyncML -
xrCreateSpatialAnchorsAsyncML
public static int xrCreateSpatialAnchorsAsyncML(XrSession session, XrSpatialAnchorsCreateInfoBaseHeaderML createInfo, LongBuffer future) Create spatial anchors.C Specification
The
CreateSpatialAnchorsAsyncMLfunction is defined as:XrResult xrCreateSpatialAnchorsAsyncML( XrSession session, const XrSpatialAnchorsCreateInfoBaseHeaderML* createInfo, XrFutureEXT* future);Description
This function starts an asynchronous spatial anchor creation. Call one of the
PollFutureEXTfunctions to check the ready state on the future. Once the future is in ready state, callCreateSpatialAnchorsCompleteMLto retrieve the results.Valid Usage (Implicit)
- The
XR_ML_spatial_anchorsextension must be enabled prior to callingCreateSpatialAnchorsAsyncML sessionmust be a validXrSessionhandlecreateInfomust be a pointer to a validXrSpatialAnchorsCreateInfoBaseHeaderML-based structure. See also:XrSpatialAnchorsCreateInfoFromPoseML,XrSpatialAnchorsCreateInfoFromUuidsMLfuturemust be a pointer to anXrFutureEXTvalue
Return Codes
- On success, this command returns
- On failure, this command returns
See Also
XrSpatialAnchorsCreateInfoBaseHeaderML,XrSpatialAnchorsCreateInfoFromPoseML,CreateSpatialAnchorsCompleteML- Parameters:
session- a handle to anXrSessionpreviously created withCreateSession.createInfo- a pointer to anXrSpatialAnchorsCreateInfoBaseHeaderMLderived structure.future- a pointer to anXrFutureEXT.
- The
-
nxrCreateSpatialAnchorsCompleteML
public static int nxrCreateSpatialAnchorsCompleteML(XrSession session, long future, long completion) Unsafe version of:CreateSpatialAnchorsCompleteML -
xrCreateSpatialAnchorsCompleteML
public static int xrCreateSpatialAnchorsCompleteML(XrSession session, long future, XrCreateSpatialAnchorsCompletionML completion) Completion function for spatial anchor creation.C Specification
The
CreateSpatialAnchorsCompleteMLfunction is defined as:XrResult xrCreateSpatialAnchorsCompleteML( XrSession session, XrFutureEXT future, XrCreateSpatialAnchorsCompletionML* completion);Valid Usage (Implicit)
- The
XR_ML_spatial_anchorsextension must be enabled prior to callingCreateSpatialAnchorsCompleteML sessionmust be a validXrSessionhandlecompletionmust be a pointer to anXrCreateSpatialAnchorsCompletionMLstructure
Return Codes
- On success, this command returns
- On failure, this command returns
See Also
XrCreateSpatialAnchorsCompletionML,CreateSpatialAnchorsAsyncML- Parameters:
session- a handle to anXrSessionpreviously created withCreateSession.future- theXrFutureEXTto complete.completion- a pointer to anXrCreateSpatialAnchorsCompletionMLfilled in by the runtime.
- The
-
nxrGetSpatialAnchorStateML
Unsafe version of:GetSpatialAnchorStateML -
xrGetSpatialAnchorStateML
Retrieve spatial anchor state.C Specification
The
GetSpatialAnchorStateMLfunction is defined as:XrResult xrGetSpatialAnchorStateML( XrSpace anchor, XrSpatialAnchorStateML* state);Description
The runtime must return
ERROR_VALIDATION_FAILUREif theXrSpaceis not an spatial anchor.Valid Usage (Implicit)
- The
XR_ML_spatial_anchorsextension must be enabled prior to callingGetSpatialAnchorStateML anchormust be a validXrSpacehandlestatemust be a pointer to anXrSpatialAnchorStateMLstructure
Return Codes
- On success, this command returns
- On failure, this command returns
See Also
XrCreateSpatialAnchorsCompletionML,XrSpatialAnchorStateML,CreateSpatialAnchorsAsyncML- Parameters:
anchor- a handle to anXrSpacecorresponding to a spatial anchor.state- a pointer to anXrSpatialAnchorStateMLstructure to populate with the spatial anchor state.
- The
-