From 76b05dece66f56d9cff030d93b7da61ad14a8d6f Mon Sep 17 00:00:00 2001 From: Peter Hajas Date: Sun, 8 May 2022 09:14:00 -0600 Subject: [PATCH] Shift home in Z --- script.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index d6793bc..ba62b4e 100644 --- a/script.js +++ b/script.js @@ -16,7 +16,6 @@ let home = new THREE.Group() homeContainer.add(home) var areaData = { } - var areasWithEntitiesToUpdate = { } const renderer = new THREE.WebGLRenderer({ @@ -197,6 +196,8 @@ function configureScene(data) { var maxX = -1000 var minY = minX var maxY = maxX + var minZ = minX + var maxZ = maxX areaData = data @@ -225,19 +226,31 @@ function configureScene(data) { roomLabel.userData.name = "label" roomContainer.add(roomLabel) - setPosition(roomContainer, room.x, room.y, room.z || 0, room.w, room.h, room.d) + let roomZ = room.z || 0 + + setPosition(roomContainer, room.x, room.y, roomZ, room.w, room.h, room.d) home.add(roomContainer) minX = Math.min(minX, room.x) minY = Math.min(minY, room.y) + minZ = Math.min(minZ, roomZ) maxX = Math.max(maxX, room.x + room.w) maxY = Math.max(maxY, room.y + room.h) + maxZ = Math.max(maxZ, roomZ + room.d) } + let xExtent = maxX - minX let yExtent = maxY - minY + let zExtent = maxZ - minZ + home.position.x = -1 * (xExtent / 2) home.position.y = +1 * (yExtent / 2) + home.position.z = -1 * (zExtent / 2) + + let centerX = minX + (xExtent / 2) + let centerY = minY + (yExtent / 2) + let centerZ = minZ + (zExtent / 2) } async function loadHomeData() {