fix: missing url

update loading method
This commit is contained in:
xfy
2025-05-23 01:10:46 +08:00
parent e1347ef693
commit 9e5f25fd1e
6 changed files with 30 additions and 29 deletions

View File

@ -9,7 +9,8 @@ Title: Hacker Room - Stylized
*/
import { useGLTF, useTexture } from '@react-three/drei';
import { useLoader } from '@react-three/fiber';
import { JSX } from 'react';
import { JSX, useEffect } from 'react';
import useStore from 'store';
import * as THREE from 'three';
import { DRACOLoader, GLTF, GLTFLoader } from 'three-stdlib';
@ -47,10 +48,12 @@ type GLTFResult = GLTF & {
};
export function Model(props: JSX.IntrinsicElements['group']) {
const toggleLoading = useStore((state) => state.toggleLoading);
const { nodes, materials } = useLoader(
GLTFLoader,
'/models/hacker-room/hacker-room.glb',
(loader) => {
toggleLoading(true);
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('/libs/draco/');
loader.setDRACOLoader(dracoLoader);
@ -61,6 +64,10 @@ export function Model(props: JSX.IntrinsicElements['group']) {
const screenTexture = useTexture('/texture/desk/screen.png');
const tableTexture = useTexture('/texture/desk/table.png');
useEffect(() => {
toggleLoading(false);
}, [toggleLoading]);
return (
<group {...props} dispose={null}>
<mesh