Augmented reality mesh size not real size

It is my PG -
Box size is 0.2.
But when I put the box in my space in immersive ar mode, the size does not match the actual size.

The height is especially different.
The ruler is 0.2 meters.
How can I fix this?

Hey @buddy90210,

The main thing to remember is that we are getting those numbers from the underlying system. IE - your android system is providing us with the transformation, and we apply it.

This code you are using is a modified version the original webxr demo from our doc page. It is hard for me to follow up, as it seems like the rotation is not applied correctly, and I can’t really understand what’s happening on anchor-added.
Some notes about the code - it seems like you position the final mesh (box) incorrectly - it is partly “in the surface”. The box is 0.2x0.2x0.2, but its position is at 0.1,0.1,0.1. So setting its position will set its center not on top o f the floor, but 0.1 units inside of it. Once you do that - you get the 20 cm you asked for:

Still - it does take a little while for the system to provide exact hit test information. You can see the hit-test object changing its size from time to time - this is the android AR service “correcting” itself.

Thanks for your reply! It’s always very useful.

Yes, I try to deal with AR :grinning:

Because I myself do not fully understand how to do it correctly. I want to add mesh at hittest position. Not clone. Something like as google modelviewer. Can you suggest a better solution?

Thanks, this resolved the size issue.

1 Like

Of course - the best suggestion here (if you don’t want to clone) is to stop hit-testing when you add the model.

This demo is rather complex - it shows the connection between anchor points and hit-test results. So you actually add an anchor when clicking, and the anchor is being placed in the last hit-test position. Connect the mesh to the anchor itself, and stop the hit-test - this way the object will continue to be updated by the underlying system and you will not need to clone the object.

How can i do it?

You can set the feature’s paused flag to true:

WebXRHitTest | Babylon.js Documentation