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)
}
)
}
}
``