Debugging Max Volume size - GeometryReader3D units?

Hello, I'm curious if anyone has some useful debug tools for out-of-bounds issues with Volumes.

I am opening a volume with a size of 1m, 1m, 10cm.

I am adding a RealityView with a ModelEntity that is 0.5m tall and I am seeing the model clip at the top and bottom. I find this odd, because I feel like it should be within the size of the Volume....

I was curious what size SwiftUI says the Volume's size is so I tried using a GeometryReader3D to tell me....

           GeometryReader3D { proxy in
                VStack {
                    Text("\(proxy.size.width)")
                    Text("\(proxy.size.height)")
                    Text("\(proxy.size.depth)")
                }
                .padding().glassBackgroundEffect()
            }

Unfortunately I get, 680, 1360, and 68. I'm guessing these units are in points, but that's not very helpful. The documentation says to use real-world units for Volumes, but none of the SwiftUI frame setters and getters appear to support different units.

Is there a way to convert between the two? I'm not clear if this is a bug or a feature suggestion.

Accepted Reply

Hi, you can convert these points to meters using PhysicalMetricsConverter.

    @Environment(\.physicalMetrics) private var metricsConverter: PhysicalMetricsConverter

    var body: some View {
        GeometryReader3D { proxy in
            let sizeInMeters = metricsConverter.convert(proxy.size, to: .meters)
            let _ = print(sizeInMeters)
  • Oh dang, thank you!

Add a Comment

Replies

Hi, you can convert these points to meters using PhysicalMetricsConverter.

    @Environment(\.physicalMetrics) private var metricsConverter: PhysicalMetricsConverter

    var body: some View {
        GeometryReader3D { proxy in
            let sizeInMeters = metricsConverter.convert(proxy.size, to: .meters)
            let _ = print(sizeInMeters)
  • Oh dang, thank you!

Add a Comment