o think is not that

This commit is contained in:
math-pixel
2026-06-01 22:26:58 +02:00
parent cd0afcda8c
commit d975aac018
6 changed files with 117 additions and 19 deletions
@@ -0,0 +1,37 @@
import { useEffect } from "react";
import { useGLTF } from "@react-three/drei";
import { REPAIR_CASE_MODEL_PATH } from "@/data/gameplay/repairCaseConfig";
import { REPAIR_MISSIONS } from "@/data/gameplay/repairMissions";
import type { RepairMissionId } from "@/types/gameplay/repairMission";
function getPreloadPaths(mission: RepairMissionId): string[] {
const config = REPAIR_MISSIONS[mission];
return [
...new Set([
REPAIR_CASE_MODEL_PATH,
config.modelPath,
...config.brokenParts.flatMap((p) => p.modelPath ?? []),
...config.replacementParts.flatMap((p) => p.modelPath ?? []),
]),
];
}
interface RepairGamePreloaderProps {
mission: RepairMissionId;
}
/**
* Fires useGLTF.preload() for every asset used by a repair mission.
* Renders nothing — pure background loading.
*/
export function RepairGamePreloader({
mission,
}: RepairGamePreloaderProps): null {
useEffect(() => {
for (const path of getPreloadPaths(mission)) {
useGLTF.preload(path);
}
}, [mission]);
return null;
}