forked from phenom/healer-man
15 lines
638 B
TypeScript
15 lines
638 B
TypeScript
import type { DungeonDefinition } from "../game/dungeonTypes";
|
|
|
|
export function dungeonRenderDistance(dungeon: DungeonDefinition): number {
|
|
const boundsDistance = Math.max(950, Math.min(10_000, Math.hypot(
|
|
dungeon.bounds.max[0] - dungeon.bounds.min[0],
|
|
dungeon.bounds.max[2] - dungeon.bounds.min[2],
|
|
) * 1.35));
|
|
const fogFar = dungeon.presentation.fog.far;
|
|
// Linear fog has completely obscured surfaces at this camera-space depth.
|
|
// The background must use the fog color so clipping cannot reveal a horizon.
|
|
return Number.isFinite(fogFar) && fogFar > 1
|
|
? Math.min(boundsDistance, fogFar)
|
|
: boundsDistance;
|
|
}
|