Post

Replies

Boosts

Views

Activity

VisionOS - Reposition a SwiftUI view using GeometryReader3D
I want to be position a SwiftUI view in VisionOS that is not at the feet of the user (ground zero) but in front of the user at eye level. In this WWDC video (https://developer.apple.com/videos/play/wwdc2023/10111/), they reposition a RealityKit model to that location but I want to do so with a SwiftUI view with an image. The following does not work: ImmersiveSpace(id: "Example") { GeometryReader3D { proxy in Image("Red Panda") .resizable() .frame(width: 1000, height: 1000) .position(centerPoint) .onAppear { if let translation = proxy.transform(in: .global)?.translation { self.centerPoint = Point3D(translation) } } } } .immersionStyle(selection: .constant(.full), in: .mixed, .full) } The above video at 13:57 talks about coordinate space conversion into the immersive space coordinate system by using the following: var body: some View { GeometryReader3D { proxy in .onTapGesture { model.solarEarth.position = proxy.transform(in: .immersiveSpace).center } } } But the Swift compiler does not like: proxy.transform(in: .immersiveSpace
1
0
516
Feb ’24