mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
Lets people on limited data stop the Tankopedia from downloading 3D models automatically. - Added an Automatically load 3D models switch to the settings page, on by default - When off, the tank page hero shows a Load 3D model button where the loading bar sits - Held back every model download on the tank page until requested, including the dynamic armor switcher and the gun flexibility visualizer - Wrapped the tank sandbox in its own suspense boundary so the loading bar shows real progress instead of the whole page waiting on the model - Measured loading progress from when each loading bar appears so it always starts empty - Added the English strings; other languages fall back until translated Fixes #311
17 lines
430 B
TypeScript
17 lines
430 B
TypeScript
import { useProgress } from "@react-three/drei";
|
|
import { useRef } from "react";
|
|
|
|
export function useStableProgress() {
|
|
const { loaded, total } = useProgress();
|
|
const baseline = useRef(loaded);
|
|
const progress = useRef(0);
|
|
const pending = total - baseline.current;
|
|
|
|
progress.current = Math.max(
|
|
progress.current,
|
|
pending <= 0 ? 0 : ((loaded - baseline.current) / pending) * 100
|
|
);
|
|
|
|
return progress.current;
|
|
}
|