I'm looking at the following piece of code in which the for loops don't have bracket. I have a hard time figuring how that's supposed to work. I come from a background in C#, Java and some C++. All those language tend to be stricter than javascript regarding brackets usage.
function StupidMesh(volume, dims) {
var vertices = [], faces = [], x = [0,0,0], n = 0;
for(x[2]=0; x[2]<dims[2]; ++x[2])
for(x[1]=0; x[1]<dims[1]; ++x[1])
for(x[0]=0; x[0]<dims[0]; ++x[0], ++n)
if(!!volume[n]) {
for(var d=0; d<3; ++d) {
var t = [x[0], x[1], x[2]]
, u = [0,0,0]
, v = [0,0,0];
u[(d+1)%3] = 1;
v[(d+2)%3] = 1;
for(var s=0; s<2; ++s) {
t[d] = x[d] + s;
var tmp = u;
u = v;
v = tmp;
var vertex_count = vertices.length;
vertices.push([t[0], t[1], t[2] ]);
vertices.push([t[0]+u[0], t[1]+u[1], t[2]+u[2] ]);
vertices.push([t[0]+u[0]+v[0], t[1]+u[1]+v[1], t[2]+u[2]+v[2]]);
vertices.push([t[0] +v[0], t[1] +v[1], t[2] +v[2]]);
faces.push([vertex_count, vertex_count+1, vertex_count+2, vertex_count+3, volume[n]]);
}
}
}
return { vertices:vertices, faces:faces };
}