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();
|
2026-10-05 19:52:46 +13:00
|
|
|
const baseline = useRef(loaded);
|
2025-09-13 23:42:26 -05:00
|
|
|
const progress = useRef(0);
|
2026-10-05 19:52:46 +13:00
|
|
|
const pending = total - baseline.current;
|
2025-09-13 23:42:26 -05:00
|
|
|
|
|
|
|
|
progress.current = Math.max(
|
|
|
|
|
progress.current,
|
2026-10-05 19:52:46 +13:00
|
|
|
pending <= 0 ? 0 : ((loaded - baseline.current) / pending) * 100
|
2025-09-13 23:42:26 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return progress.current;
|
|
|
|
|
}
|