three.js - JavaScript formula to create grid -
im wanting tile grid of objects using javascript.i have forgotten formula, cant seem find online anywhere:
var width = 113; var height = 113; var col = 10; var row = 10; ( j = 0; j < col; j ++ ) { var object = new object(); object.position.x = 0 + width * j // nee loop here? //add object to.... }
this return row of 10 objects spaced width want columns 10x10 grid, after formula in javascript..
you nest 2 for
loops, this:
var width = 113; var height = 113; var col = 10; var row = 10; var space = ...; // rows loop ( j = 0; j < row; j ++ ) { // each column in row ( = 0; < col; ++ ) { // j row index , column index.. var object = new object(); object.position.x = (width + space) * i; object.position.y = (height + space) * j; // add object to... } }
Comments
Post a Comment