Finding the position of sides of mesh

Hi All,
I am doing snapping things but I am facing difficulty while doing snapping is that I am not able to find sides of mesh.
So can anyone help me to find out sides of mesh like top,bottom,right and left sides of mesh.

Hi there. Best advice I can give is showing a playground of what you are trying to do?

Other thing I found is a forum post about snapping. Not sure if this is what you are referring to. Snap mesh on local X,Z axis of another object while moving?

1 Like

Hi. How about trying to use the boundingInfo of the mesh?
For example, `const boundingBox = someMesh.getBoundingInfo().boundingBox`

Hi @ynnek,
Yes I have done that I have find out topVertices of bounding box but after finding topVertices how should I be able to find out about top,bottom sides of mesh

If you mean a facet with the word ‘side’, then you can get the position of the facet by using `someMesh.getFacetPosition(facetIndex);`

Here’s another method that could work:

https://playground.babylonjs.com/#DI3GL1#2

What’s happening here is:

1. You select a facet (in the case of this playground it’s manually setting the facet through code).
2. You get the normal direction of that facet
3. You compare it to the Babylon constants of Up, Down, Forward, Backward, Left, and Right.
1 Like

look to the console output if you click on the sides of the cube.

but it is difficult to know which side is “top” or “left” etc. if the mesh has a complex form. you need to calculate the rotation of the clicked vertex in relation to the camera position to say it’s positioned more to “top” or to “left” etc. You may work with degree of rotation instead of abstraction like “top” or “front” etc.

By the way: “back” is obsolete. You can not click on a face which you can not see thru the eye of the camera. ^^

2 Likes