I am trying to learn babylonjs at the moment, but for some reason local resources are returning 404 all the time when trying to apply a texture to my ground element.
Code:
const groundMaterial = new BackgroundMaterial('mat',scene); groundMaterial.diffuseTexture = new Texture("./textures/test.jpg", scene); ground.material = groundMaterial;
For some reason, when using online resources it works fine, but when loading local uri it returns 404 on chrome console:
Project structure looks like this:
I have tried changing the file to the assets folder, I have also tried different routes like:
- "../assets/test.jpg"
- "./assets/test.jpg"
- "../../public/test.jpg"
At this moment, none of them have worked, I looked online but didnt find anyone with this problem, even tried to follow This guide from 2021 in a different version but he seems to have 0 issues.
I have only tried to run the code on localhost, using npm run serve.
(Update) update in case anyone sees this in the future, I have also researched about hosting, it seems that the route "./textures/test.jpg" works (with this file structure moved under the public folder of the vue project) when deployed in a webpage like github pages. I assume then that the issue lies within the npm run serve command i use for the terminal, I will update this post if I find more info.