I’m running into a strange issue where when I run npm run build on my create-react-app project running three (using react-three-fiber) it builds everything except for the GLTF model.
Its size is 95% a single texture, so you really just need an image compressor. Unpack the .glb with glTF-Pipeline or similar, run the texture through https://squoosh.app/, and then repack it to a .glb with the same tool. Should get it down to 200-300kb pretty quickly. If you change the texture from PNG to JPG (which would also help reduce size) then you’d also have to edit the unpacked .gltf to update that file extension. There’s a VS Code extension for editing .gltf files that would help if you need to do that.
you need a server to run html, the browser doesnt allow you to make local fetch requests.
i dont understand what you mean by it doesnt build the gltf though? if you put the glb into public it will be part of the distro. alternatively you can import it, then it can be inside your “src” folder
but then you also need the draco loader present in your public folder. here’s a full example: https://codesandbox.io/s/jovial-williamson-9p4j7 if you look into public you should see the “draco-gltf” folder, and you need to tell the loader about that, too (see Bottles.js).
In this particular case Draco won’t help — the model’s size is all textures, and only 90kb of geometry, which is less than the size of the Draco decoder. So usually I’d recommend checking the source of the file’s size first — you can do that with gltf-transform inspect model.glb.
I don’t know of any CLI tool that optimizes PNG/JPG textures within a glTF file, yet. I have some plans of doing that in glTF-Transform later this year. Otherwise gltfpack is probably the most flexible optimizer… it has a long list of options including:
It is a bit hard to optimize images from a CLI, though. Often lossless compression isn’t very effective, and lossy compression requires visual inspection and tradeoffs. I like squoosh.app/ for that.