remove cache from useModel

This commit is contained in:
TrèsAbhi authored and GitHub committed 2026-05-11 16:18:54 -05:00
1 parent 3edf4a25be
commit 042a1afa74
1 file changed
+1 -13
+1 -13
View File
@@ -3,19 +3,10 @@ import { type ObjectMap, useLoader } from "@react-three/fiber";
import { Mesh, MeshStandardMaterial } from "three"; import { Mesh, MeshStandardMaterial } from "three";
import { type GLTF, GLTFLoader } from "three-stdlib"; import { type GLTF, GLTFLoader } from "three-stdlib";
const cache: Record<
number,
{
gltf: GLTF & ObjectMap;
hasPbr: boolean;
}
> = {};
export function useModel(id: number) { export function useModel(id: number) {
const gltf = useLoader(GLTFLoader, asset(`3d/tanks/models/${id}.glb`)); const gltf = useLoader(GLTFLoader, asset(`3d/tanks/models/${id}.glb`));
if (!cache[id]) { return {
cache[id] = {
gltf, gltf,
hasPbr: Object.values(gltf.nodes).some( hasPbr: Object.values(gltf.nodes).some(
(node) => (node) =>
@@ -25,6 +16,3 @@ export function useModel(id: number) {
), ),
}; };
} }
return cache[id];
}