I want to generate an isometric room, and I want to color in this style:

But my current code gives me this result:

That's my current code (I don't know, if its the correct way to generate the blocks with this method. Maybee anyone can help me, how its work correctly?
for(let iX = 0; iX < 10; iX++) {
for(let iZ = 0; iZ < 10; iZ++) {
if(iX % 2 == 0) {
material = material1;
} else {
material = material2;
}
var box = generateBox(1, 0.1, 1, material);
box.name = `box-${iX}-${iZ}`;
box.position.set(iX, box.geometry.parameters.height / 2, iZ);
room.add(box);
}
}
You change material style based only on value of iX variable. Instead, you should change it based on values of both iX and iZ variables like this:
if ((iX + iZ) % 2 === 0) {
material = material1;
} else {
material = material2;
}