mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-16 06:06:11 +01:00
23 lines
625 B
TypeScript
23 lines
625 B
TypeScript
import { alias } from "@blitzkit/core";
|
|
import { useLoader } from "@react-three/fiber";
|
|
import { Mesh, MeshStandardMaterial } from "three";
|
|
import { GLTFLoader } from "three-stdlib";
|
|
import { useDispose } from "./useDispose";
|
|
|
|
export function useModel(id: number) {
|
|
const path = alias("models_tanks", `/${id}/model.glb`);
|
|
const gltf = useLoader(GLTFLoader, path);
|
|
|
|
useDispose(gltf, path);
|
|
|
|
return {
|
|
gltf,
|
|
hasPbr: Object.values(gltf.nodes).some(
|
|
(node) =>
|
|
node instanceof Mesh &&
|
|
node.material instanceof MeshStandardMaterial &&
|
|
node.material.roughnessMap !== null,
|
|
),
|
|
};
|
|
}
|