So this is a simple question, I need to get the vertices and faces of a created mesh for internal process in my software.
I think you can get the vertices of the figure by doing
mesh.getPositionData() (correct me if I’m wrong) but I also need the faces index of the mesh.
Is there any way to get the face index of the mesh? I look through the documentation of the property mesh and I don’t seem to find something like that.
I guess you mean the facets/triangles? You can get the indices for those using mesh.getIndices(). The first 3 indices are for the first facet’s 3 positions, the next 3 indices are for the second facet’s 3 positions, and so on…
And then in the positions array, index * 3 is the x value, index * 3 + 1 is y, and index * 3 + 2 is z. For example you can use FromArray with an offset to get the position like below.
const position = BABYLON.Vector3.FromArray(positions, 3 * index);
Also, I believe getPositionData(…) has required parameters for applying skeleton/morph. If it’s just geometry you can get position vertices directly and they are wound as Blake describes: