EDIT:
In the case that our dev environments are different, I will suggest this code fix:
EDIT-2:
The 'j's in the index selecting portion should be 'i's, I just changed that right now.
Try this:
// Geometry
var cbgeometry = new THREE.PlaneGeometry( 500, 500, 8, 8 );
// Materials
var cbmaterials = [];
cbmaterials.push( new THREE.MeshBasicMaterial( { color: 0xffffff, side: THREE.DoubleSide }) );
cbmaterials.push( new THREE.MeshBasicMaterial( { color: 0x000000, side: THREE.DoubleSide }) );
var l = cbgeometry.faces.length / 2; // <-- Right here. This should still be 8x8 (64)
console.log("This should be 64: " + l);// Just for debugging puporses, make sure this is 64
for( var i = 0; i < l; i ++ ) {
j = i * 2; // <-- Added this back so we can do every other 'face'
cbgeometry.faces[ j ].materialIndex = ((i + Math.floor(i/8)) % 2); // The code here is changed, replacing all 'i's with 'j's. KEEP THE 8
cbgeometry.faces[ j + 1 ].materialIndex = ((i + Math.floor(i/8)) % 2); // Add this line in, the material index should stay the same, we're just doing the other half of the same face
}
// Mesh
cb = new THREE.Mesh( cbgeometry, new THREE.MeshFaceMaterial( cbmaterials ) );
scene.add( cb );
I commented where I did the line changes.
I put the Math.floor(i/8) in the material index to offset every other layer. Otherwise, it would just be vertical lines.
Also, the 3rd material was removed, leaving behind just white and black to work with.
Thanks for this question, it was fun working it out!