WebXR Hit Test Module (AR picking real world geometry)

I will try to look at this this week but have quite a lot on at moment.

Can you make a small reproducible project for this please? That would really help us. Or is this with the project that Moka posted in the first post?

1 Like

This project should help you. In fact, I just forked the project of Moka and added an error handler to see where the problem is coming from.

I did tried different variations of parameters with HitTest like the ones from the official documentation.

Still, I received different kind of error in the console while testing with Chrome Mobile on device.

The profile ā€œgeneric-touchscreenā€ is the one that interested me because I want to use AR with my mobile. It is like ā€œHit-testā€ is a feature not asked when we start the XR session from the API.

I think that it didnā€™t pass the step 2 of this documentation of the WebXR API:


Source: https://immersive-web.github.io/hit-test/#requesting-hit-test

1 Like

@yaustar Did you have time last week to check on this? I canā€™t find a workaround with the current state.

No, Iā€™m afraid not. Iā€™m hoping to get some time today

I had a look at this and for whatever reason, it works fine in the WebXR extension but not on device. I think I found the reason why but will require an engine change. Will keep you posted.

1 Like

Hereā€™s my fix: https://github.com/playcanvas/engine/pull/2381

While waiting for the next engine release, you can use my latest built engine files here with local engine param.

eg: https://launch.playcanvas.com/976117?debug=true&use_local_engine=https://yaustar.github.io/temp-engine-builds/playcanvas.1.34.0.xr.js

1 Like

So it was simply the absence of the optional parameter ā€œhit-testā€ for a WebXR session.

Also, I didnā€™t know about that url param ā€œuse_local_engineā€. This is interesting.

Thank you for your help!

1 Like

Yeah, you hit the nail on the head here. Very surprised this worked without the fix in the WebXR emulator which is frustrating.

1 Like

Hello,

I was trying to to make a simple AR hit test project, where I could place simple objects on the ground and when searching for help/solutions I stumbled upon this thread.

I am facing the same problem as:

Even when I try this link below, I still cannot place any grass when Iā€™m using my phone. I can only do so when using webXR emulator in chrome (on my personal computer).

Am I missing something or is this feature not yet available in PlayCanvas?

/edit:

Also, do I understand this correctly that:

  • WebXR technology is still in development and is not production ready yet. The specifications/docs are being drafted and the API is not stable yet?
  • Some of the WebXR features are being implemented in PlayCanvas by its contributors/users, however since the underlying technology is not stable yet, these features may not work in PlayCanvas

Does this sound right? Iā€™m just trying to look at the bigger picture here.

That fix is in the current version of PlayCanvas.

Thatā€™s correct. Itā€™s still a draft but the API is mostly stable.

It depends if WebXR implementations change before PlayCanvas is updated.

The demo I posted earlier works without the local engine Param. IE https://launch.playcanvas.com/976117

Project: https://playcanvas.com/editor/scene/976117

1 Like

Thank you. Turns out the previous link with the params worked as well but I just didnā€™t move the phone enough to detect a surface.

Iā€™ve updated the Hit Test example with better UX: https://playcanvas.com/project/672464/overview/ar-hit-test

There are couple of ways to start hit test session, previously Iā€™ve used input source that created when user touches the screen. This would lead to a delay until underlying system would pickup input source ray and start generating hit test results.
So Iā€™ve changed the demo, now it starts hit test session using VIEWER reference space, which basically a ray from middle of the screen (position of camera). So it is more apparent when hit test is happening, and it allows to see the target where it is pointing. Then with touch it places the object on that target.

There is real-world-geometry API in development, which would allow to get actual geometry and then do ray picking on PlayCanvas side. But for now we have to rely on Hit Test API which is dependant on underlying APIs.

5 Likes