I’m creating a custom mesh of a pole (somewhat rectangular in shape). The points are generated by another program and I am translating them into a babylon friendly format.
When I clean the array of indices (remove -1s, convert to triangles and remove unnecessary values etc), the shape rendered is not what it should be.
However, when I convert the indices from references to values instead of points (i.e.
//from indiceArr[i] => (x,y,z) //to indiceArr[i] => x indiceArr[i+1] => y indiceArr[i+2] => z
) the shape renders perfectly (minus some texture issues).
How is this so? By expanding the indices am I not creating 3 triangles for every 1 in the position array? Shouldn’t this expansion result in out of bounds reads within babylon?
Here is a playground demonstrating the issue: https://www.babylonjs-playground.com/#1PUDTS#13
The indices are expanded as follows:
var newIndices = []
for(var i in indices){
newIndices.push(indices[i]*3)
newIndices.push(indices[i]*3+1)
newIndices.push(indices[i]*3+2)
}