Post

Replies

Boosts

Views

Activity

Reply to Tapping once with both hands only works sometimes in visionOS
Hello Sydney, Thank you for the response. I forgot to add that there is a metal view involved in this app and that could be another reason why this problem occurs. I have some simple code here that shows the problem. Can you give this a test? You will notice that the gesture only gets recognized about half the time. struct ContentView: View { var body: some View { MetalView() } } struct MetalView: UIViewRepresentable { var device: MTLDevice? init() { self.device = MTLCreateSystemDefaultDevice() } func makeUIView(context: Context) -> MTKView { let mtkView = MTKView() mtkView.device = device mtkView.clearColor = MTLClearColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) mtkView.delegate = context.coordinator // Add tap gesture recognizer let tapGesture = UITapGestureRecognizer(target: context.coordinator, action: #selector(context.coordinator.handleTap(_:))) tapGesture.numberOfTapsRequired = 1 // Should require both hands to tap. tapGesture.numberOfTouchesRequired = 2 mtkView.addGestureRecognizer(tapGesture) return mtkView } func updateUIView(_ uiView: MTKView, context: Context) { } func makeCoordinator() -> Coordinator { Coordinator(self) } class Coordinator: NSObject, MTKViewDelegate { var parent: MetalView init(_ parent: MetalView) { self.parent = parent } func mtkView(_ view: MTKView, drawableSizeWillChange size: CGSize) { } func draw(in view: MTKView) { guard let drawable = view.currentDrawable else { return } guard let descriptor = view.currentRenderPassDescriptor else { return } let commandQueue = parent.device?.makeCommandQueue() let commandBuffer = commandQueue?.makeCommandBuffer() let renderEncoder = commandBuffer?.makeRenderCommandEncoder(descriptor: descriptor) renderEncoder?.endEncoding() commandBuffer?.present(drawable) commandBuffer?.commit() } @objc func handleTap(_ sender: UITapGestureRecognizer) { print("MTKView tapped") } } } I'm happy to submit a feedback report but I'm curious what your feedback is when you see the issue. Thank you!
Topic: Spatial Computing SubTopic: General Tags:
Jul ’24
Reply to Render metal with passthrough not working with correct Info.plist
Does your application start with the CompositorServices ImmersiveSpace? Yep, I have an ImmersiveSpace whos content is created using Compositor Services. Regarding the plist, I had exactly that and I am getting a black background with no passthrough. Also in the ImmersiveSpace you will need to set the style to mixed. This is how you would set it to be always mixed: Yep I have that set too.
Topic: Spatial Computing SubTopic: General Tags:
Jun ’24