Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

125
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda