How to get the three coordinates of a facet

Hi,

How to get the three coordinates (world) of a facet?

Thanks in advance.

https://doc.babylonjs.com/how_to/how_to_use_facetdata

Hi @jerome,

I have gone thru this. Unfortunately It is not straight forward for me. My requirement is simple. I am expecting a method something like

getFacetCoordinates(facetIndex);

I did something like this

var indices = mesh.getIndices();
var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
var nbFaces = indices.length / 3;

        var unionedPolygon = null;
        for (var i = 0; i < nbFaces; i++) {
            var normalBabylon = mesh.getFacetNormal(i);
                var i1 = indices[i * 3];
                var i2 = indices[i * 3 + 1];
                var i3 = indices[i * 3 + 2];

                var start = i1 * 3;
                var p1 = [positions[start], positions[start + 1], positions[start + 2]];

                var start = i2 * 3;
                var p2 = [positions[start], positions[start + 1], positions[start + 2]];

                var start = i3 * 3;
                var p3 = [positions[start], positions[start + 1], positions[start + 2]];

but somewhere I am wrong. Can you please help me in fixing this?

Hi @jerome, I think, I could do it. Please have a look.
https://playground.babylonjs.com/#XWEZ4S

1 Like

great :slight_smile:

1 Like