fix: camera distance + beacon position
Some checks are pending
Deploy to Production / deploy (push) Waiting to run
Test / backend-test (push) Waiting to run
Test / frontend-test (push) Waiting to run

- 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
This commit is contained in:
fullsizemalt 2025-12-19 11:25:38 -08:00
parent c282943ec3
commit e20c618b45
2 changed files with 20 additions and 40 deletions

View file

@ -26,15 +26,16 @@ const getPresetConfig = (
switch (preset) { switch (preset) {
case 'OVERHEAD': 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 { 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], target: [centerX, 0, centerZ] as [number, number, number],
}; };
case 'ISOMETRIC': case 'ISOMETRIC':
// 3/4 isometric view - classic strategy game angle // 3/4 isometric view - closer for better visibility
const isoDistance = focusTarget ? 15 : maxDim * 0.8; const isoDistance = focusTarget ? 12 : maxDim * 0.5;
return { return {
position: [centerX + isoDistance * 0.7, isoDistance * 0.6, centerZ + isoDistance * 0.7] as [number, number, number], position: [centerX + isoDistance * 0.7, isoDistance * 0.6, centerZ + isoDistance * 0.7] as [number, number, number],
target: [centerX, 0, centerZ] as [number, number, number], target: [centerX, 0, centerZ] as [number, number, number],
@ -42,7 +43,7 @@ const getPresetConfig = (
default: default:
return { 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], target: [0, 0, 0] as [number, number, number],
}; };
} }

View file

@ -33,35 +33,13 @@ export function FacilityScene({
dimMode = false, dimMode = false,
beaconPosition = null, beaconPosition = null,
}: FacilitySceneProps) { }: FacilitySceneProps) {
// Calculate actual floor bounds from all sections // Use floor dimensions for centering - must match the calculation in Facility3DViewerPage
const floorBounds = useMemo(() => { const floorCenterX = (data.floor.width * SCALE) / 2;
let minX = Infinity, minZ = Infinity, maxX = -Infinity, maxZ = -Infinity; const floorCenterZ = (data.floor.height * SCALE) / 2;
for (const room of data.rooms) { // Calculate floor bounds for camera
for (const section of room.sections) { const floorWidth = data.floor.width * SCALE;
minX = Math.min(minX, section.posX * SCALE); const floorHeight = data.floor.height * 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]);
return ( return (
<> <>
@ -74,8 +52,8 @@ export function FacilityScene({
shadow-mapSize={[2048, 2048]} shadow-mapSize={[2048, 2048]}
/> />
{/* Offset to center the content */} {/* Offset to center the content - uses floor dimensions to match page calculations */}
<group position={[-floorBounds.centerX, 0, -floorBounds.centerZ]}> <group position={[-floorCenterX, 0, -floorCenterZ]}>
{data.rooms.map((room: Room3D) => ( {data.rooms.map((room: Room3D) => (
<RoomObject <RoomObject
key={room.id} key={room.id}
@ -91,14 +69,15 @@ export function FacilityScene({
}} }}
/> />
))} ))}
{/* Beacon for selected/searched plant - MUST be inside offset group */}
{beaconPosition && <Beacon position={beaconPosition} />}
</group> </group>
{/* Beacon rendered OUTSIDE offset group - coords already include centering */}
{beaconPosition && <Beacon position={beaconPosition} />}
<ContactShadows <ContactShadows
position={[0, -0.02, 0]} position={[0, -0.02, 0]}
opacity={0.35} opacity={0.35}
scale={floorBounds.width * 1.5} scale={floorWidth * 1.5}
blur={2} blur={2}
far={12} far={12}
resolution={512} resolution={512}
@ -108,8 +87,8 @@ export function FacilityScene({
{/* Preset-based camera system */} {/* Preset-based camera system */}
<CameraPresets <CameraPresets
preset={cameraPreset} preset={cameraPreset}
floorWidth={floorBounds.width} floorWidth={floorWidth}
floorHeight={floorBounds.height} floorHeight={floorHeight}
focusTarget={focusTarget} focusTarget={focusTarget}
onReady={onControlsReady} onReady={onControlsReady}
/> />