Problem with page not loading static texture asset checker.png.
I have added my texture image into root/public/checker.png, it works on dev server loading it like: const texture = loader.load(‘/checker.png’).
My source code
dist folder
However when i build with vite, it creates dist folder and puts the texture in root/checker.png but the code wont load it. In preview neither when i deploy to githubpages. When deployed it throws error: GET https://jendahorak.github.io/checker.png. I dont understand why it cannot be found, when the checker.png is in the root.
my gh-pages subtree with dist folder for deployment
Well I have figured it out. Vite for some reason does not prepend the /base/ string to the path when loading the image from .js code. This can be solved by importing the image from the public folder like so:
And then referencing it like this:
I apologize for posting Vite problems to three.js forum. Hope this helps for other clueless peeps.
@jendahorak glad you figured it out. I think I’m running into a similar issue (not sure, just started learning three.js). I’m building a loader for stl file and it can load in my localhost, but after running ‘npx vite build’ and ‘npx vite preview’. The file is missing. You mentioned you made changes to vite config file but I cannot seem to find mine. Any suggestion is appreciated.