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
This commit is contained in:
parent
c282943ec3
commit
e20c618b45
2 changed files with 20 additions and 40 deletions
|
|
@ -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],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */}
|
||||
<group position={[-floorBounds.centerX, 0, -floorBounds.centerZ]}>
|
||||
{/* Offset to center the content - uses floor dimensions to match page calculations */}
|
||||
<group position={[-floorCenterX, 0, -floorCenterZ]}>
|
||||
{data.rooms.map((room: Room3D) => (
|
||||
<RoomObject
|
||||
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>
|
||||
|
||||
{/* Beacon rendered OUTSIDE offset group - coords already include centering */}
|
||||
{beaconPosition && <Beacon position={beaconPosition} />}
|
||||
|
||||
<ContactShadows
|
||||
position={[0, -0.02, 0]}
|
||||
opacity={0.35}
|
||||
scale={floorBounds.width * 1.5}
|
||||
scale={floorWidth * 1.5}
|
||||
blur={2}
|
||||
far={12}
|
||||
resolution={512}
|
||||
|
|
@ -108,8 +87,8 @@ export function FacilityScene({
|
|||
{/* Preset-based camera system */}
|
||||
<CameraPresets
|
||||
preset={cameraPreset}
|
||||
floorWidth={floorBounds.width}
|
||||
floorHeight={floorBounds.height}
|
||||
floorWidth={floorWidth}
|
||||
floorHeight={floorHeight}
|
||||
focusTarget={focusTarget}
|
||||
onReady={onControlsReady}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue