Is there a relation between the facetData and the indices of the mesh?

I’m wondering if the facet number has a relation to the mesh indices.

is it like facetNumber*3 = facetIndex ?

Adding @jerome who knows it all about facets :slight_smile:

1 Like

I can’t remember what is facetNumber …

1 Like

This might help:

2 Likes

Thanks @adam :slight_smile:

1 Like

This could also be interesting:

const getFaceVertices = mesh => {
	var pdata = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind)
	var idata = mesh.getIndices()
	
    let vertices = []
	for (let i = 0; i < idata.length; i += 3) {
		let facet = [idata[i], idata[i+1], idata[i+2]]
		let pstring = []
		for (var j = 0; j < 3; j++) {
			pstring[j] = []
			for (var k = 0; k < 3; k++) {
				if (Math.abs(pdata[3*facet[j] + k]) < 0.0001) pdata[3*facet[j] + k] = 0
				pstring[j] = [...pstring[j], pdata[3*facet[j] + k]]
            }
            pstring[j] = new BABYLON.Vector3(pstring[j][0], pstring[j][1], pstring[j][2])
		}
        vertices = [...vertices, pstring]
	}

    return vertices
}
1 Like