Reputation: 556
The main challenge in solving this problem is how to determine where north is within the coordinate system of RealityView.
I've found that RealityView's coordinate system guarantees that the Y-axis is always perpendicular to the ground (with the Y-axis pointing towards the sky),
but it does not guarantee that the X-axis is parallel to the longitude and the Z-axis is parallel to the latitude.
Even though I've enabled the WorldTrackingProvider, the X-axis and Z-axis orientations of the RealityView coordinate system are still uncertain.
Background information: working on visionOS.
Upvotes: 2
Views: 213
Reputation: 58153
RealityKit and ARKit for visionOS create a scene's coordinate space, relative to the Vision Pro's camera's position and orientation (i.e. in the camera's local space). On the visionOS 1.3, the CLHeading object, which can help you calculate the device's orientation, relative to true or magnetic north, isn't yet supported. Nevertheless, there's .gravityAndHeading enum's case in ARKit for iOS.
P. S.
You might be interested to know that visionOS 2.0 introduces a new heading option for volumes called .gravityAligned
. Now, you can create a volume that always remains parallel to the floor, even if it's raised high enough above the floor level.
@main struct YourApp : App {
var body: some Scene {
WindowGroup {
ContentView()
}
.windowStyle(.volumetric)
.volumeWorldAlignment(.gravityAligned)
}
}
Upvotes: 2