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)