From 822e93c457ee0aae102dfad24ce75aca0e69eb9e Mon Sep 17 00:00:00 2001 From: Peter Hajas Date: Sat, 7 May 2022 19:44:12 -0600 Subject: [PATCH] add a group for room stuff --- script.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index 52b3630..bc3100a 100644 --- a/script.js +++ b/script.js @@ -10,7 +10,7 @@ renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); const light = new THREE.AmbientLight(0xFFAAAA, 1) -light.position.z = 100 +// light.position.z = 100 scene.add(light) // back the camera up @@ -28,7 +28,7 @@ function animate() { homeContainer.rotation.z += 0.005; renderer.render( scene, camera ); -}; +} animate(); @@ -52,13 +52,17 @@ function configureScene(data) { // Add geometry for the rooms for (var room of data.rooms) { + let roomContainer = new THREE.Group() + let roomGeo = new THREE.BoxGeometry(room.w, room.h, room.d) let roomColor = new THREE.Color(room.color) let roomMaterial = new THREE.MeshPhysicalMaterial({ color: roomColor }) let roomMesh = new THREE.Mesh(roomGeo, roomMaterial) - setPosition(roomMesh, room.x, room.y, room.z || 0, room.w, room.h, room.d) - roomMesh.userData = room.name - home.add(roomMesh) + roomContainer.add(roomMesh) + + setPosition(roomContainer, room.x, room.y, room.z || 0, room.w, room.h, room.d) + roomContainer.userData = room.name + home.add(roomContainer) minX = Math.min(minX, room.x) minY = Math.min(minY, room.y)