For a while now I have been storing my 3d vertices as a one dimensional array. If I needed to run a loop on my vertices array I would do something like
for(i<vertices.length; i++)
x = vertices[0 + (i*3)]
y = vertices[1 + (i*3)]
z = vertices[2 + (i*3)]
It just hit me how it could be really inefficient to have to perform an addition and multiplication, possibly 2 or more clock cycles, each time I want to access an element in my array.
I wonder if it would be more efficient to have a class Vertex with x, y and z member variables. I'm working in javascript so I can't make a struct, I can only make an object.
If anyone has some solid knowledge on the different costs involved I would appreciate it.