How to find all facets with thickness < 0.5 mm and paint red color

Hi All,

I am new with Babylon JS, I am starting a project that it will load a 3D model (.obj file) and paint red color to all facets with thickness < 0.5 mm.

I can find out all vertices and indices as follow:

and get all facets (triangles). So next step, I will need to measure thickness on each facet and paint red color to.

I am not sure how to measure them, it can be related to Ray ??? Can everyone help me to find out


Welcome aboard!

What do you call the thickness of a triangle? It is a flat polygon, so its thickness is 0(?)

Thanks for your reply @Evgeni_Popov
As my know that objects are from BJS built by facets (triangles). A basic box will be drawn by 12 triangles.
So this is case, I want to measure thickness of the box. And more general, objects will be loaded by *.obj file.

Still, I don’t understand, how do you define the thickness of this:

Some 3D printers can’t print some details which are less than 0.5mm, so I will check thickness of all details on model. In this case, maybe fingers in your example have less than 0.5mm and I will paint them in red color for warning.

Ok, I understand better.

So I think you need to find for each vertex of a triangle which is the nearest triangle that intersects the line going from this vertex in the direction of the inverse (opposite, meaning -normal) of the normal to this vertex (I don’t know if this algorithm will work in all cases)…

You can use the Ray class to compute the intersection of a line with the triangles of a mesh (don’t forget to exclude the source triangle from the computation!).

Thanks @Evgeni_Popov

I have created an example on Playground at

I tried to create multi rays with inverse of direction and intersect with box, how can I exclude source triangle and will get value on second intersection.

Currently, ray.distance always 0 because the ray intersect with source triangle.

The easiest way is to move a little bit pos in the negative normal direction:

A better way would be to get all intersections, sort them and take the first one with a non 0 distance, but there’s currently no way to retrieve all intersections of a ray with a mesh.

1 Like

Moving a little bit “pos” is ok for me, I see that it works on my side. Thanks for your help @Evgeni_Popov