Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hit test support #33

Open
Rufus31415 opened this issue May 1, 2021 · 9 comments
Open

Add hit test support #33

Rufus31415 opened this issue May 1, 2021 · 9 comments

Comments

@Rufus31415
Copy link
Owner

https://immersive-web.github.io/hit-test/

@gisornator
Copy link

gisornator commented Jan 23, 2022

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"

@Rufus31415
Copy link
Owner Author

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

@gisornator
Copy link

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

@gisornator
Copy link

gisornator commented Jan 24, 2022

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)

@gisornator
Copy link

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.

@Rufus31415
Copy link
Owner Author

You are right, from now on, the hit-test feature shoul be declared, I'll add that here :

navigator.xr.requestSession(_isArSupported ? 'immersive-ar' : 'immersive-vr', { optionalFeatures: ['local-floor', 'hand-tracking'] }).then(function (session) {

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 events InputSourceSelect, InputSourceSelectStart, ...

@gisornator
Copy link

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?

@Rufus31415
Copy link
Owner Author

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

@DeveloperARKids
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants