Spatial Anchor
Introduction​
Spatial Anchors are world-locked reference points in the AR environment that can be used to position and persist content across multiple sessions. By creating a spatial anchor at a specific 6DOF pose (position and orientation), virtual content can be placed relative to it. This allows for the resumption of AR sessions and the restoration of content to the exact real-world locations where users left them. This plays a crucial role in providing users with a consistent and reliable AR experience, as they can see the persistently present virtual content at the same location, no matter when they return or restart the application. The NRSDK provides Spatial Anchor functionality for XREAL glasses, enabling developers to easily create and manage spatial anchors in their Unity projects.
Main Features​
- Easily create and manage spatial anchors in Unity
- Save and load spatial anchors
- Support user interactions, such as clicking on spatial anchors
- Show mapping quality during spatial anchor creation.
Installation and Configuration​
Please follow these steps to import the SDK into your Unity project:
-
Download and import the SDK package.
-
Add the
AnchorItem
script to the game object you want to use as an anchor. -
Set the properties of
AnchorItem
in the Unity Inspector. -
Inspect Mapping Example scene and LocalMapExample.cs as reference for an implementation of spatial anchor.
Best Practice​
- After adding a spatial anchor, it is essential to observe the surrounding environment thoroughly, with the spatial anchor as the focal point. This procedure ensures that the added anchor can be reliably located in multiple sessions.
- Characteristics of a high-quality observation environment include:
- Adopting the anchor as the observational center and moving in various directions, such as forward, backward, left, and right, to ensure an ample observational perspective.
- Maintaining smooth and slow movement.
- Allotting an observation time between 5 and 15 seconds.
- Factors that can degrade the quality of the observation environment:
- Rapidly changing the viewpoint after adding the anchor, causing the anchor to leave the field of vision.
- Quick movements or turning of the head.
- Saving the anchor immediately after adding it, without adequately observing the environment.
- Elements of a high-quality visual environment are:
- Even lighting.
- Rich textural detail.
- Appropriate distance between 0.5 and 3 meters.
- Characteristics of a low-quality visual environment include:
- Poor lighting conditions.
- Transparent, semi-transparent, or reflective surfaces.
- Absence of texture, such as white walls.
- Characteristics of a high-quality observation environment include:
- Avoid attaching object to spatial anchors that are more than 3 meters away. Please create a new spatial anchor for the attachment of object. Any inaccuracies in the pose are magnified when an object is distanced from the spatial anchor.
- Utilize parent-child relationships to create a transformation hierarchy between the tightly arranged virtual object and their corresponding spatial anchors. This helps to maintain consistent relative positioning of the virtual object.
- To optimize system performance, destroy unused spatial anchors and only load the spatial anchors that are needed.