Loading model in AR

Hi everyone,

We are trying to show a model in AR and use the hitTest feature to place the model.
On the androïd phones we tested, this hitTest demo is working as expected:

But when loading a model, we can’t make it work anymore on the same phones. Here is our test playground:

Pinging the expert of WebXR @RaananW :wink:

Thanks a lot for your help, Pichou

In addition: The thing we observe in the playground is that the model is following the viewer but is not placed in front of it on the ground like in the hitTest demo.

Just a heads up that Raanan might take a while to respond as he’s in his much deserved vacation! :beach_umbrella: :musical_note:

I managed to make it worked thanks to another demo that I found.
I will relaunched the topic if needed but it is ok for now :wink:

FYI: https://playground.babylonjs.com/#XWBES1#279

4 Likes

Hello guys, I come back to you because of a recent new issue.

On this playground, you can see that the model is in front of you: https://playground.babylonjs.com/#XWBES1#285
But once in AR the model is shown with the backside in front of you.

Do you know why ?

From what @RaananW said here in the forum, we should see the model with the same angle as in the playground when entering XR. :face_with_monocle:

Oh, that behavior is a VR-only kind of thing. mainly because of the different in reference spaces between AR and VR. In AR your initial entry point is 0,height,0. height can change according to the reference space you have selected, but when you create a scene you reset the AR camera’s position to the entry point. I hope it makes sense :slight_smile:

Ok Thanks a lot for that clarification.
So how do I make sure the model stays in front of me like in the playground when entering XR?
Is it something to do with the hitTest feature for instance?

We tried with several models and they are all reversed once in AR. So I guess we must consistently add a 180-degree rotation to the model to have the correct expected view.

I don’t know if this is willing or by design that the model is reversed but that would be interesting to know why and if something can be changed in BabylonJS AR API to improve it :wink:

Cheers, Valentin

This is technically expected. This example might explain it:

prova | Babylon.js Playground (babylonjs.com)

If you look at a model from a negative z (i.e. " from the back") you will see its back :slight_smile: . Hit-testing updates the transformation of the mesh according to the provided matrix coming from the underlying system, and will keep the mesh oriented “correctly”, as if you are behind it. And yes, you will need to rotate the mesh 180 degrees if you want to see it looking at you. Either that, or add 180 rotation to the hit-test result. This will have the same result.

2 Likes