Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!