coordinate system in shareplay + spatial persona experience

I cannot figure out how shareplay + spatial persona place the origin of RealityKit's coordinate system

I have an App on visionOS with immersiveSpace(.mix) scene. In the scene I am using ARKit to track my hand, creating a virtual object following the movement of my hand palm. Every frame I query positions from the HandAnchor to update the position of my object, using originFromAnchorTransform to correctly place my object in the scene.

However when I try to adopt that into a shareplay experience with spatial persona, the virtual object's position update becomes a mess. With different template (.sidebyside or .conversational), the origin in my space appears with no pattern. I can always see that the virtual object don't follow my hand but in a random place. it seems that there was a differnce/transform between handAnchor's origin and immersiveSpace origin under stpatial persona + shareplay mode. isn't it?

Or is there something I can try to use convert(displacement.inverse.rotation, from: .immersiveSpace, to: .scene) that mentioned here: https://developer.apple.com/documentation/realitykit/realitycoordinatespaceconverting and https://developer.apple.com/documentation/swiftui/environmentvalues/immersivespacedisplacement to do the translation and apply it on my virtual object. But not working yet. Can someone tells me how to do this correctly?

Answered by Vision Pro Engineer in 788912022

If your goal is to anchor an entity to the user's hand consider using an AnchorEntity with the appropriate HandLocation.

let anchorEntity = AnchorEntity(.hand(.right, location: .palm))
anchorEntity.addChild(yourEntity)

If your goal is to anchor an entity to the user's hand consider using an AnchorEntity with the appropriate HandLocation.

let anchorEntity = AnchorEntity(.hand(.right, location: .palm))
anchorEntity.addChild(yourEntity)
coordinate system in shareplay + spatial persona experience
 
 
Q