Hello, as the title says i’m really struggling with displaying my own resources in to a three js project.
I’ve managed to set up a local project with a local server with node js/vite, i built a really basic scene with a cube and a plane and i can already test it with a localhost.
The issues arise when i try to use some textures or custom model imported as GLB file placed in my public folder, basically the models and the textures are not rendered.
The console is not printing any error or warning and under the network tab all the mentioned resources seem to be loaded without status errors.
I’ve also created a light and an ambient light just to ensure that is not a lighting issue and so, if i load a flat coloured cube it works perfectly but if i load a texture instead of the colour i can only see the black silhouette of the model.
Could anybody help me? I really want to study three.js since i’m already a Unity technical artist and i’d like to expand my 3D knowledge but this situation is driving me nuts, i thought it was just a matter of 3D developmnent/coding but i have to admit that from the web side everything is really tricky…
hello @supaworst
Could you show me loading part of the code in detail? or screenshot of the material of the mesh in console?
some reasons may be exist.
Hi @supaworst
yes. thanks for sharing.
It seems that path is wrong in the loading part of the texture.
Let’s fix like this.
const colorMap = textureLoader.load ( ‘./textures/Test.png’ )
thanks.
It seems to me that for some reasons the browsers decide to not rendering local assets. I’ve tried both on mozilla and chrome and i get the same result.
Can it be a path formatting issue? I can’t understand the difference between ‘./textures/Test.png’ and “./textures/Test.png” in javascript, i’ve tried both with no results…
Thanks again but unfortunately your fix didn’t work.
Probably i’m missing something regarding the vite setup, i’ll try in the next days other local server solution
Ok, i think i’ve found out the real fix to the issue and (of course) it was my fault. Apparently, if i don’t run an animate function at the end of the code in case of using imported resources it ends in not rendering them.
I thought it was not necessary since the models in my case are static but as soon as i’ve addet that part of code everything started to work.