forked from phenom/healer-man
27 lines
734 B
TypeScript
27 lines
734 B
TypeScript
import { PerformanceMonitor } from "@react-three/drei";
|
|
import type { GameplayFrameRateLimit } from "../game/frameRateSettings";
|
|
import {
|
|
dprForPerformanceFactor,
|
|
performanceBoundsForFrameRate,
|
|
} from "./adaptiveGraphicsQualityMath";
|
|
|
|
export function AdaptiveGraphicsQuality({
|
|
frameRateLimit,
|
|
onDprChange,
|
|
}: {
|
|
readonly frameRateLimit: GameplayFrameRateLimit;
|
|
readonly onDprChange: (dpr: number) => void;
|
|
}) {
|
|
return (
|
|
<PerformanceMonitor
|
|
factor={1}
|
|
iterations={6}
|
|
ms={250}
|
|
step={0.25}
|
|
threshold={0.75}
|
|
bounds={(refreshRate) => performanceBoundsForFrameRate(frameRateLimit, refreshRate)}
|
|
onChange={({ factor }) => onDprChange(dprForPerformanceFactor(factor))}
|
|
/>
|
|
);
|
|
}
|