After mastering the art of applying texture to my 3D-models in WebGL using .mtl files (and .obj files), the process works seamlessly when the images are saved on my local computer. Below is an excerpt from my .mtl file showcasing how the texture is applied:
newmtl Earth_MATERIAL
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd Earth.png
Although everything works smoothly on my local machine, the challenge arises when I aim to publish my simulation and need to reference the image source. I initially tried uploading the image to Dropbox and using the link, but encountered an issue:
...
map_Kd https://dl.dropbox.com/s/t4cm3vzsbx21crc/Earth.png?dl=0
The error message I received when attempting to run this code was:
Error: WebGL warning: texImage2D: Element is write-only, thus cannot be uploaded.
To load the texture and model, I rely on an MTLloader and OBJloader. The following are the loaders I'm utilizing:
MTLloader: link
OBJloader: link
In addition, I make use of the ThreeJS Library:
ThreeJS: link
UPDATE: Thanks to Jave, the problem has been resolved! For those interested, here is the outcome: