Files
blitzkit/packages/website/src/hooks/useStableProgress.ts
T

16 lines
430 B
TypeScript
Raw Normal View History

2025-09-13 23:42:26 -05:00
import { useProgress } from "@react-three/drei";
import { useRef } from "react";
export function useStableProgress() {
const { loaded, total } = useProgress();
const baseline = useRef(loaded);
2025-09-13 23:42:26 -05:00
const progress = useRef(0);
const pending = total - baseline.current;
2025-09-13 23:42:26 -05:00
progress.current = Math.max(
progress.current,
pending <= 0 ? 0 : ((loaded - baseline.current) / pending) * 100
2025-09-13 23:42:26 -05:00
);
return progress.current;
}