RGBELoader vs TextureLoader and data: urls

I’m new to three.js (and javascript, to be honest). I’ve gone delving into the code and have drawn a conclusion. I’m seeking either confirmation for the conclusion or, more optimistically, a correction that’ll unblock me. Here’s my conclusion:

I can use TextureLoader to load a texture from a data url (e.g., data:image/png;base64,....) but I can’t do the same thing with RGBELoader. To use the RGBELoader the image must be specified by path and it runs back to the server, asking for the bits (to create the buffer that gets, eventually, passed to RGBELoader.parse. Is that correct?

So, the only way to load an hdr/rgbe image is to host the file on the server and serve the file upon request? I can’t simply pass in a data URI and extract the buffer from that?

Thanks in advance, and sorry if my question exposes multiple levels of ignorance.

Also, I find that attempting to do so doesn’t trigger my onError callback, which I found quite surprising.

The three.js editor allows to import HDR textures via file input (e.g. when defining a HDR scene background). Check out how the respective editor source uses FileReader, readAsDataURL() and RGBELoader for importing textures. Maybe you can use it as an orientation for your app.

1 Like