Spatial Anchor
Spatial anchor point realizes the correspondence between virtual spatial position and real physical position by anchoring the position in the virtual environment to the position in the real world. Using the spatial anchor function in the application, it can be realized that the same user can see the same anchor position when he/she enters the same space several times, or when different users enter the same space.
Requirement
- Device Model: YVR2
- System Version: 1.2.9 and above
- SDK Version: 2.7.0 and above
Enable Spatial Anchor Feature
Follow the steps to enable spatial anchors in your projectr:
- In the upper left corner of the editor, select Edit > Project Settings > Plugins > YVR XR.
- Move to the MR tab and check Anchor Support Enabled.
Manage Spatial Anchor
YVR XR SDK's anchors are built on the UYvrXRAnchorComponent class, achors are required to be strongly associated with Unreal Engine's actor in your app. Each Actor can only bind one UYvrXRAnchorComponent class, i.e., one Actor corresponds to one anchor point. Similarly, for an anchor point to exist in an Unreal Engine scene, it needs an Actor to represent it. This Actor can be a blank Actor created temporarily, or an Actor that already exists in the scene; the anchor point will update its positional transformation in every frame, and feed these updates to the Actor associated with it.
The following APIs for managing spatial anchor lifecycle needs to be used in the event graph of UE editor and cannot be used in code. Refer to the following steps and related API references to use them.
Create Anchor Entity
Create an anchor entity in your app. Each anchor entity has a unique UUID, unique handle and actor within a single process.
Save Anchor Entity
Save anchors to the device's local disk. Saving to the cloud is not supported at this time. This API is asynchronous.
Delete Anchor Entity
Clear all anchors in the app. Emptying cloud anchors is not supported at this time. Emptied anchors will not be loaded. This API is asynchronous.
Get Spatial Anchor Information
Call the following API to get information about the anchor entity.
Get the UUID of the anchor entity
The API acquires real-time positional transformations of the anchor point to ensure that the anchor point position is always fixed.