To enhance performance, I optimize by rendering the grid to a single THREE.Geometry() object using this loop:
build: function(){
square = new THREE.Geometry();
face = 0;
for(r = 0; r < this["rows"]; r++)
for(c = 0; c < this["cols"]; c++)
// create square
square.vertices.push(new THREE.Vector3(x, y, z));
square.vertices.push(new THREE.Vector3(x + w, y, z));
square.vertices.push(new THREE.Vector3(x + w, y - h, z));
square.vertices.push(new THREE.Vector3(x, y - h, z));
square.faces.push(new THREE.Face4(face + 0, face + 1, face + 2, face + 3));
face += 4;
// end of loops
// Add material to the entire grid.
// How can individual colors be applied to each square?
squareMaterial = new THREE.MeshBasicMaterial({
color:"white",
side:THREE.DoubleSide
});
grid = new THREE.Mesh(square, squareMaterial);
scene.add(grid);
Assuming there's a function that selects the vertices set (one square) from the grid (mesh), how do you then apply color specifically to this vertices set (square)?