Tap gesture collisions not fully detecting for distant large entities

I am working on an app where we are attempting to place large entities quite far away from the user, when trying to recognise a tap gesture on them though the gesture isn't being picked up for part of the model.

It seems as though the larger and further a model is placed the more offset the collision shape seems to be. It responds to taps in a region that shrinks towards the bottom right. The actual size of the collision shape appears to be correct when viewed with the collision shape debug visualisation. I've been able to replicate this behaviour in the simulator and on a physical device.

It's hard to explain in words, there's a video in the README for the repo here

I've been able to replicate the issue in a simple sample app. Not sure if I might be using it wrong or if it is expected behaviour for tap gestures to be a bit off when places a large distance from the user. Appreciate any help, thanks.

struct ImmersiveView: View {
    @State private var tapCount = 0
    var body: some View {
        RealityView { content in
            let sphere = ModelEntity(mesh: .generateSphere(radius: 50), materials: [UnlitMaterial(color: .red)])
            sphere.setPosition([500, 0, 0], relativeTo: nil)
            sphere.components.set([
                InputTargetComponent(),
                CollisionComponent(shapes: [.generateBox(width: 250, height: 250, depth: 250)]),
            ])
            content.add(sphere)
        }
        .gesture(
            SpatialTapGesture()
                .targetedToAnyEntity()
                .onEnded { value in
                    tapCount += 1
                    print(tapCount)
                }
        )
    }
}
``

Answered by Vision Pro Engineer in 790035022

This is a known issue in (visionOS 1.0 - 1.2) that is fixed in visionOS 2.0 Beta.

I've done some more experimenting and found that the distance the object it from the user doesn't seem to be what causes the behaviour. Instead it is the size of the entity, the issue first appears at around a radius of 60 meters. At this size the object does have to be placed pretty far away from the user so distance might still be involved, not sure.

Additionally, where the entity is placed seems to affect where the area the taps are recognised shrinks towards. This is all with a distance of 200 meters from the origin.

Positive X Shrinks towards the bottom right

Negative X No response to any tap

Positive Z Shrinks towards the bottom left

Negative Z No response to any tap

Accepted Answer

This is a known issue in (visionOS 1.0 - 1.2) that is fixed in visionOS 2.0 Beta.

Tap gesture collisions not fully detecting for distant large entities
 
 
Q