Assuming “public” is the root directory the app is serving files from for your browser to read, try loading
I already tried, it still doesn’t work
Well, in that case, it should be
/public/textures/scene.gltf. Assuming that since your
index.html file sits at the root of your project directory structure. No idea otherwise
Upload scene.gltf to “root” or “public”
Or change path to
There are two ways you can load what you want:
1: import x from path
That same exact pattern works with three, react three, and drei.
If its in the public folder, just copy the relative path by right clicking the file name and select “copy relative path”, but be sure to delete the word “public” after pasting.
gltfloader has to be instructed where to look for additional files. if your gltf is within /public/textures and it’s relying on externals (scene.bin etc) then GLTFloader will look for them under / by default, not /textures. there is a method you have to call on the loader to give it the correct folder. setResourcePath, setPath, something like that.
it would be a mistake to use gltf on the web. use a compressed glb which contains all of these assets in one. it will be a lot smaller and that problem will go away.
open shell, type
npx gltfjsx scene.gltf --transform
throw scene-transformed.glb into /public and load it as “/scene-transformed.glb”