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

Hello @AtomicMan,

GeometryReader3D isn't necessary for positioning SwiftUI View's relative to the immersive space's origin, instead you can use the offset functions (and PhysicalMetric to convert between meters and points), for example:

struct ImmersiveView: View {
    
    @PhysicalMetric(from: .meters) private var oneMeter = 1
    
    var body: some View {
        Text("Hello World.")
            .offset(z: -oneMeter)
            .offset(x: 0, y: -oneMeter)
    }
}
VisionOS - Reposition a SwiftUI view using GeometryReader3D
 
 
Q