Simple-WebXR-Unity
Simple-WebXR-Unity copied to clipboard
Add hit test support
https://immersive-web.github.io/hit-test/
Hey! I was testing Hit Test on iOS with great success but it seems to not work properly on Android. Any idea?
EDIT: Remote debugging gave me the following error
"PROD-BUILD.framework.js:92 Uncaught (in promise) DOMException: Failed to execute 'requestHitTestSource' on 'XRSession': Hit test feature is not supported by the session. at someurl-PROD-BUILD.framework.js:92:53710"
Hi! This means your browser doesn't support hit test. But I should test that XRSession contains requestHitTestSource to warn if this feature is not supported
Technically, the browser should support it. I tested it with Chrome 96.0.4664.92 (Android).
E.g. testing it through this works fine in the same browser: https://chromestatus.com/feature/4755348300759040
One thing I found:
According to several resources, it seems that it is required to ask for hit-testing when starting the AR Session: https://developer.mozilla.org/en-US/docs/Web/API/XRSession/requestHitTestSource
So maybe (that's just a guess because I can try it earliest in the evening) that line 575 (SimpleWebXR.jslib) needs to be changed to require the hit-test module:
navigator.xr.requestSession(_isArSupported ? 'immersive-ar' : 'immersive-vr', { requiredFeatures: ["local", "hit-test"], optionalFeatures: ['local-floor', 'hand-tracking'] }).then(function (session)
Okay, I was able to test it in the meantime and the solution from above worked now! I have a different issue now in regards of Unity's Input.Touch system. I'm not getting any errors in the console but I think this is related to the full screen.
You are right, from now on, the hit-test feature shoul be declared, I'll add that here : https://github.com/Rufus31415/Simple-WebXR-Unity/blob/a9060413037d6b5dd985abba29ed17fcd51ff79d/com.rufus31415.simplewebxr/Runtime/Plugins/WebGL/SimpleWebXR.jslib#L575 Thanks
On Android, I know that for safety, in full screen mode, a new context is created and I'm not sure if Input.Touch which reacts on javascript events on the
still works. The only way to access the touch during a session is through the WebXR API with eventsInputSourceSelect, InputSourceSelectStart, ...
Thanks for the quick response!
Yea, I will try that later tonight :) do you have something in the examples on how to interact with UI elements and InputSourceSelect, etc?
If you use it with MRTK, WebXR events are propagated to MRTK core. So you just have nothing special to do except choosing your input source in MRTK settings
I cant touch my ui button and 3d collider when in AR mode fullscreen, so i cant have any interaction after AR start. any example to fix this?