I want the walls directly behind the floor without any space and not on the floor inside.
Currently, it displays correctly to me but I don't think the way I ave written it is correct.
This is my function to generate the room (floor and walls) and I want it shorter and better.
function generateRoom(w, d) {
var room = new THREE.Object3D();
// Floor
var material1 = new THREE.MeshPhongMaterial({
color: 'rgb(255, 255, 255)',
});
var material2 = new THREE.MeshPhongMaterial({
color: 'rgb(242, 242, 242)',
});
var material;
for(let iX = 0; iX < w; iX++) {
for(let iZ = 0; iZ < d; iZ++) {
if((iX + iZ) % 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);
}
}
// Walls
for(let iX = 0; iX < w; iX++) {
var wall = generateBox(1, 3, 0.1);
wall.name = `wall-${iX}`;
wall.position.set(iX, wall.geometry.parameters.height / 2, -0.45);
room.add(wall);
}
for(let iZ = 0; iZ < d; iZ++) {
var wall = generateBox(0.1, 3, 1);
wall.name = `wall-${iZ}`;
// Example here.. What I should use the instance of -0.45? I don't know why 0.45 shows me correct.
wall.position.set(-0.45, wall.geometry.parameters.height / 2, iZ);
room.add(wall);
}
return room;
}