GeometryReader3D doesn't work

Hi,

I'm trying to place my 3D content relative to my SwiftUI window. And I find the GeometryReader3D doesn't work as expected. Or maybe I don't fully understand it?

When tapping the 3D models in the RealityKit scene, they should be expected to align with the center of the SwiftUI window, not the immersive space origin(0, 0, 0).

I further found out the transform of GeometryProxy3D.transform is always identity matrix, no matter in which space.

I also noticed in the example and doc, it should come with a ZStack, and I tried it as well, still failed.

Could some clarify it a little bit?

Below is a brief layout of my app:

        WindowGroup {
            ContentView()
        }

        ImmersiveSpace(id: "ImmersiveSpace") {
            ImmersiveView()
        }
    }
    var body: some View {
        GeometryReader3D { proxy in
            ZStack {
                RealityView { content in
                    if let scene = try? await Entity(named: "ImmersiveScene", in: realityKitContentBundle) {
                        content.add(scene)
                    }
                }
                .gesture(TapGesture().targetedToAnyEntity().onEnded({ value in
                    if let trans = proxy.transform(in: .immersiveSpace)?.translation {
                        value.entity.position = SIMD3<Float>(trans.vector)
                    }
                }))
            }

        }

    }
}

Setting .padding() to GeometryReader3D returned values other than origin(0, 0, 0). However, I am not sure if I am getting the correct value.

GeometryReader3D doesn't work
 
 
Q