javascript - What do the .forEach statements below do? -
what 2 foreach statements below do? 'col' built-in property arrays?
var width = data.length, height = data[0].length; data.foreach(function(col){ col.foreach(function(val){ geometry.vertices.push(new three.vector3(val.x,val.y,val.z)) colors.push(getcolor(2.5,0,val.z)); }); }); in case of before code required:
var info = new array(); for(var x=bigin;x<end;x++){ var row = []; for(var y=bigin;y<end;y++){ z = 2.5*(math.cos(math.sqrt(x*x+y*y))+1); row.push({x: x, y: y, z: z}); } data.push(row); }
array.foreach iterates on array, for loop.
array.foreach(function( indice ) {}); data array of arrays, col passed argument first foreach, sec foreach iterates arrays within data.
it's obvious in code creates data well
var info = []; // info array ... var row = []; // row array for(var ...){ // stuff } data.push(row); // set 1 array within other and it's iterated
data.foreach(function(col){ // <- col passed argument col.foreach(function(val){ // stuff }); }); javascript three.js
No comments:
Post a Comment