Get height and width of imported mesh

Hi all

i’ve room model and i want to detect height and width each wall, its possible to do that?

like this

this is my playground:

thank you all :slight_smile:

I think you can get the needed info using BoundingInfo - Babylon.js Documentation (use like mesh.getBoundingInfo().boundingBox) and then get the extends.

As @tapio40k said you can use the bounding info if the mesh the wall is part of does not have other geometry that would make the bounding box taller than the wall. In that case, I think you will need to compute the height by retrieving the vertex coordinates of the wall. Or if it is an option, use Blender or any similiar tool to perform this computation.

thanks @tapio40k and @Evgeni_Popov… i got the height but i have problem when i try to get width,

I just want to get the mesh width that I marked like this… but there is one mesh… can i do that?

It would be much easier if the walls were separate meshes. If all the walls are included in a single mesh and you can’t load the model into Blender and ‘measure’ it there, one option would be to do manual picking using your mouse (Picking Collisions - Babylon.js Documentation) so that you first click one edge of the wall, detect its coordinates and then click another edge to get its position. Then you can calculate things at least approximately.

1 Like

ok @tapio40k i will try, thank you :slight_smile:

is there no other way? i wanted to be able to detect it automatically

Well as @tapio40k mentioned, you should either separate wall into segments you want to measure and then with bounding box you can easily detect the width and height. If you cannot separate mesh into segments then you can add some helper planes/boxes in the 3d software, if possible of course. For example you add box that matches the width and height of the segments you want to measure. You hide those helper meshes in Babylon scene, but you have access to their bounding boxes, which means that you can get their height and width, and because they are matching the wall segments, that means you have the wall dimensions.

I am not sure how are you using boundingBox, but just in case, I want to mention, as sometimes people oversee this.

If you are using something like this

mesh.getBoundingInfo().boundingBox.extendSize -> extend size values are calculated from the center of the bounding box to the edge of the bounding box. So basically that’s 1/2height, 1/2width, 1/2*depth. So remember to double the values of extendSize to get full dimensions.


thanks @nogalo, i will try