Saving and Loading World Data with Realitykit

I am trying to use ARWorldmap to save and load the data to relocalize the scene. The example I used was from apple's documentation: https://developer.apple.com/documentation/arkit/world_tracking/saving_and_loading_world_data

However, this example uses scenekit to render, and I want to use realitykit.

In the example, they use: Scenekit renderer didAdd to render everytime a new anchor has been added.

What I did was to swap out the scenekit in the example and replace the method above with ARsession's didAdd Anchors and create a new anchorentity from the anchor added.

The app runs with no problem until I tried to load the saved world data. The anchor restored with no problem at all with the correct coordinate. ARsession's didAdd Anchors function was called and it recreates my AnchorEntity at the anchor location.

However, my anchorentity created in the didAdd anchors method is at the wrong location as they randomly drifted from where they were supposed to be.

Anyone has any clue on how to solve this?
I ported the Apple sample from SceneKit into RealityKit and SwiftUI. It works the same as the old one. Here is the code on GitHub.
Hi,

I am also trying to get this work. Now with the newest technology, the LIDAR scanner.
I realy don't know how to save and load the anchors generated during tapping and
using the LIDAR scanner. My question, you mentionend "The anchor restored with no
problem at all with the correct coordinate". How did you checked this?

Thanks,

Marc


Saving and Loading World Data with Realitykit
 
 
Q