WebXR Hit Test Module (AR picking real world geometry)

Does this test works? https://immersive-web.github.io/webxr-samples/hit-test.html
And this doesnt? https://playcanv.as/p/Kjol3uRS/

There has been a regression in WebXR AR Module in recent Chrome, they aware of it.
Bear in mind - it is very experimental feature in browsers, and is not production ready, only for early experiments. Also it is a subject to change.

Yes,
The first link works for us but not the second one.

I have same problem

Could it be because that build is running in a iframe? How about:

https://playcanv.as/e/p/Kjol3uRS/

Does that work?

Could it be because that build is running in a iframe? How about: https://playcanv.as/e/p/Kjol3uRS/

There is no difference.

My camera is activated but it looks like there’s no floor detection. I tried different rooms with different lights but no luck. Strangely, with the same device, it’s working well with the Hit-test example on Google Chrome and even the “AR scene viewer”.

I just can’t put grass on any floor.

I will investigate it.

1 Like

Also, it is/was working when using the WebXR API Emulator with Chrome in the developer console.

@moka Currently, it is not working for me because there is an error on the callback of hitTestStart().

image

The error is:

Failed to execute 'requestHitTestSourceForTransientInput' on 'XRSession': Hit test feature is not supported by the session.

Also, this return true, saying to me that Hit Test is available:

//It's true
this.availableHitTest.enabled = ! this.app.xr.supported || ! this.app.xr.hitTest || ! this.app.xr.hitTest.supported;

With the same device, I have no problem with this example: WebXR Hit Test Sample

This error come from the WebXR API itself.

Another test that can help you. If I set the profile to “generic-touchscreen”, I can reproduce the problem with my WebXR Emulator

image

The error:

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.