Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
Three.js Isometric Room - Walls and Floor

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;
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda