From e20c618b456ca330087c1c73e1b5de6e6ccfcd6f Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Fri, 19 Dec 2025 11:25:38 -0800 Subject: [PATCH] fix: camera distance + beacon position - Reduce camera distance for larger room view (0.5x iso, 0.6x overhead) - Fix beacon coords: use floor.width/height centering (matches page calcs) - Move beacon outside offset group (coords already centered) - Rooms now appear larger in default view --- .../components/facility3d/CameraPresets.tsx | 11 +++-- .../components/facility3d/FacilityScene.tsx | 49 ++++++------------- 2 files changed, 20 insertions(+), 40 deletions(-) diff --git a/frontend/src/components/facility3d/CameraPresets.tsx b/frontend/src/components/facility3d/CameraPresets.tsx index c4fae2a..d8cd2b2 100644 --- a/frontend/src/components/facility3d/CameraPresets.tsx +++ b/frontend/src/components/facility3d/CameraPresets.tsx @@ -26,15 +26,16 @@ const getPresetConfig = ( switch (preset) { case 'OVERHEAD': - // Top-down view - looking straight down + // Top-down view - camera height based on floor size, but closer + const overheadDist = focusTarget ? 8 : maxDim * 0.6; return { - position: [centerX, maxDim * 1.2, centerZ + 0.1] as [number, number, number], + position: [centerX, overheadDist, centerZ + 0.1] as [number, number, number], target: [centerX, 0, centerZ] as [number, number, number], }; case 'ISOMETRIC': - // 3/4 isometric view - classic strategy game angle - const isoDistance = focusTarget ? 15 : maxDim * 0.8; + // 3/4 isometric view - closer for better visibility + const isoDistance = focusTarget ? 12 : maxDim * 0.5; return { position: [centerX + isoDistance * 0.7, isoDistance * 0.6, centerZ + isoDistance * 0.7] as [number, number, number], target: [centerX, 0, centerZ] as [number, number, number], @@ -42,7 +43,7 @@ const getPresetConfig = ( default: return { - position: [0, 30, 40] as [number, number, number], + position: [0, 20, 25] as [number, number, number], target: [0, 0, 0] as [number, number, number], }; } diff --git a/frontend/src/components/facility3d/FacilityScene.tsx b/frontend/src/components/facility3d/FacilityScene.tsx index 563d585..56c64e3 100644 --- a/frontend/src/components/facility3d/FacilityScene.tsx +++ b/frontend/src/components/facility3d/FacilityScene.tsx @@ -33,35 +33,13 @@ export function FacilityScene({ dimMode = false, beaconPosition = null, }: FacilitySceneProps) { - // Calculate actual floor bounds from all sections - const floorBounds = useMemo(() => { - let minX = Infinity, minZ = Infinity, maxX = -Infinity, maxZ = -Infinity; + // Use floor dimensions for centering - must match the calculation in Facility3DViewerPage + const floorCenterX = (data.floor.width * SCALE) / 2; + const floorCenterZ = (data.floor.height * SCALE) / 2; - for (const room of data.rooms) { - for (const section of room.sections) { - minX = Math.min(minX, section.posX * SCALE); - minZ = Math.min(minZ, section.posY * SCALE); - maxX = Math.max(maxX, (section.posX + section.width) * SCALE); - maxZ = Math.max(maxZ, (section.posY + section.height) * SCALE); - } - } - - // Fallback to floor dimensions if no sections - if (minX === Infinity) { - minX = 0; - minZ = 0; - maxX = data.floor.width * SCALE; - maxZ = data.floor.height * SCALE; - } - - return { - minX, minZ, maxX, maxZ, - width: maxX - minX, - height: maxZ - minZ, - centerX: (minX + maxX) / 2, - centerZ: (minZ + maxZ) / 2, - }; - }, [data]); + // Calculate floor bounds for camera + const floorWidth = data.floor.width * SCALE; + const floorHeight = data.floor.height * SCALE; return ( <> @@ -74,8 +52,8 @@ export function FacilityScene({ shadow-mapSize={[2048, 2048]} /> - {/* Offset to center the content */} - + {/* Offset to center the content - uses floor dimensions to match page calculations */} + {data.rooms.map((room: Room3D) => ( ))} - {/* Beacon for selected/searched plant - MUST be inside offset group */} - {beaconPosition && } + {/* Beacon rendered OUTSIDE offset group - coords already include centering */} + {beaconPosition && } +