How to set accurate floor's position in AR mode

Hi this is my first question topic.
Now, I create model viwer with image tracking with Web-XR feature. I could create basic feature about model viwer however the 3d model in viwer is too small so I checked various property and I found it put bottom of real floor.
So I would like to set floor’s height setting to put my model on real height, please tell me. Excuse me, if my engilish is not good. Thank you.

cc @RaananW

1 Like

As you get the floor position from WebXR (and it should be pretty accurate), I assume you are asking how you can make sure the mesh is always “on the floor”, even if the mode’s center is somewhere else. Is that the case, or are you really asking about the floor position in AR applications?

1 Like

Thank you for replying.
For some reason, my code generates the model lower than the position where the image is tracked (i.e., below the floor). Currently, I’m using a method that combines hit-test and image tracking functions, using hit-testing to determine the position of the floor and displaying the model when an image is tracked, in order to place the model at the floor level. I apologize for the late report.

this is probably because the object is centered. i.e. - it’s 0,0,0 position is somewhere in the center of the mesh, and not at the bottom of the mesh. Depending on the model you are loading and how they are constructed you will need to implement a compensation for this offset.

The simplest is to use the bounding information of the loaded mesh. Something roughly equivalent to this - glTF Loader Demo | Babylon.js Playground (babylonjs.com) (lines 18 and 19 will run a second after the model is loaded to show you the difference).

Note that this changes the position of the mesh! If this doesn’t fit your usecase you might need to bake this transformation to the mesh.

2 Likes

OK, I try to set model bottom you said !

1 Like

I checked model setting and I understand my problem caused by xr camera position.
I didn’t understand xr camera position is initialized when xr session initialize and xr camera’s position set to my smartphone camera position as origin. So I couldn’t get accurate and fixed floor position because I launch web app on ramdom position.
Anyway, I can get accurate floor position by setting fixed smartphone camera position because camera’s height - my height = floor position… Maybe I say fail things.
Thank you for many support @RaananW !

1 Like