I have downloaded the model(gltf) from here: Oak Cut String Minimalist Staircase - Download Free 3D model by TKstairs.com (@tkstairs) [608fc2a] - Sketchfab
This is the code I run(/Users/name/Desktop/three-project/examples/worlds/Staircase.tsx)
import * as THREE from "three";
import React, { useRef } from "react";
import { useGLTF } from "@react-three/drei";
import { GLTF } from "three-stdlib";
import { Group } from "three";
type GLTFResult = GLTF & {
nodes: {
['_x0023_RISERbig-oaktexjpg1111']: THREE.Mesh;
['_x0023_STRINGbig-oaktexjpg1111']: THREE.Mesh;
['_x0023_TREADbig-oaktexjpg1111']: THREE.Mesh;
};
materials: {
['x0023_RISERbig-oaktex.jpg1111']: THREE.MeshStandardMaterial;
['x0023_STRINGbig-oaktex.jpg1111']: THREE.MeshStandardMaterial;
['x0023_TREADbig-oaktex.jpg1111']: THREE.MeshStandardMaterial;
};
};
const FILE_URL = './assets/staircase/scene.gltf';
export default function Model(props: JSX.IntrinsicElements["group"]) {
const group = useRef<Group>(null);
const { nodes, materials } = useGLTF(FILE_URL) as GLTFResult;
return (
<group ref={group} {...props} dispose={null}>
<group rotation={[-Math.PI / 2, 0, 0]}>
<group position={[0, -2.89, 0]}>
<mesh
castShadow
receiveShadow
geometry={nodes["_x0023_RISERbig-oaktexjpg1111"].geometry}
material={materials["x0023_RISERbig-oaktex.jpg1111"]}
/>
<mesh
castShadow
receiveShadow
geometry={nodes["_x0023_STRINGbig-oaktexjpg1111"].geometry}
material={materials["x0023_STRINGbig-oaktex.jpg1111"]}
/>
<mesh
castShadow
receiveShadow
geometry={nodes["_x0023_TREADbig-oaktexjpg1111"].geometry}
material={materials["x0023_TREADbig-oaktex.jpg1111"]}
/>
</group>
</group>
</group>
);
}
useGLTF.preload(FILE_URL);
I store the scene.gltf at here: /Users/name/Desktop/three-project/examples/assets/staircase
When I run the server, it shows the error:
Uncaught Could not load ./assets/staircase/scene.gltf: fetch for "http://localhost:3000/assets/staircase/scene.gltf"
I’m not sure if that is the wrong path or something else. Thanks.