visionOS Attachments vs. RealityView Entity Gestures

145 views Asked by At

I am building a visionOS app that uses an immersive space with a 3D object (.usda file). I have added hotspots to the object using Transforms in Reality Composer Pro and enabled those hotspots using the onTap gesture. It works great, but now I want to allow the user to move the 3D object using a drag gesture. When I add that capability, my attachments onTap gestures seem to be suppressed. I've tried using .simultaneousGesture, prioritizing the onTap gesture, etc. but the tapping on the attachments text is not working as I expect it to.

Does anyone know how to make gestures associated with attachments work in conjunction with gestures on the 3D object itself?

Here is my onTap gesture code:

.onTapGesture {
            withAnimation(.spring) {
                if !showingMoreInfo {
                    AudioManager.shared.playAudio(named: audioFile, withExtension: "mp3")
                } else {
                    AudioManager.shared.stopAudio()
                }
                showingMoreInfo.toggle()
            }
        }

and here is my drag gesture code for the RealityView object:

// Enable people to move the model anywhere in their space.
       .simultaneousGesture(DragGesture(minimumDistance: 0.0, coordinateSpace: .global)
            .handActivationBehavior(.pinch)
            .onChanged { value in
               if let startPosition {                        
                 let delta = value.location3D - value.startLocation3D
                    position = startPosition + delta
               } else {
                    startPosition = position
                }
            }
            .onEnded { _ in
                startPosition = nil
            }
        )
0

There are 0 answers