I have simple .gltf 3D models, using three js loader to load all the models. The demo works fine in my local server when I run it. But when I deploy to netlify I started to get errors that the paths to the 3D models could not be found. If anyone could point me in the right direction it would be great. I tried Building for Production | Vite and Static Asset Handling | Vite but still couldn’t work it out and I am new to this so If one of these links is the solution, could you do an example of how to set that up? Thank you so much in advance. the following are my build structures and screenshots of the demo should look like. (by the way, I am using vite bundler)
in your screen grabs it shows your are trying to download your files from the /src/ folder and not from a reference related to where the bundle is served from or accessible via the web server.
Thanks for answering. I tried to drop the scene.gltf and scene.bin and it said “Something went wrong: TypeError: Cannot read properties of undefined (reading ‘length’).” I tried and drop all three files (scene.bin, scene.gltf, and the textures folder) but the converter didn’t take them
Thanks for the response @seanwasere. Sorry, I am not familiar with the terminology. Could you suggest what I should do? This is my first time deploying (for a demo only) a demo on a web server and I am not familiar with the environment. I tried and moved all three 3D models files (factory_machine, factory_machine_noColor, old_oil_tank_.2) out of the src directory but netlify still couldn’t find the path to the scene.gltf files.
@seanwasere and @sww314
Thank you for both of your responses, I really appreciate them. But I fixed the problem since the files are in my local machine and when I deploy the demo on netlify, netlify didn’t have access to them so by moving all of the 3D models’ folders to the public directory, it resolved the issue.
the reason for that is that “src” does not exist in production. the bundler pulls out all the parts your app relies on and forms a bundle. you can never use relative urls (../ or ./) unless you import/require them, as in: