mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
12 lines
382 B
TypeScript
12 lines
382 B
TypeScript
import { ObjectMap, useLoader } from '@react-three/fiber';
|
|
import { GLTF, GLTFLoader } from 'three-stdlib';
|
|
import { asset } from '../core/blitzkrieg/asset';
|
|
|
|
const cache: Record<number, GLTF & ObjectMap> = {};
|
|
|
|
export function useArmor(id: number) {
|
|
const gltf = useLoader(GLTFLoader, asset(`3d/tanks/armor/${id}.glb`));
|
|
if (!cache[id]) cache[id] = gltf;
|
|
return cache[id];
|
|
}
|