Blender + GLTF + scene environments

I’m trying to export a scene from blender as a GLTF with a scene environment texture (HDRI background).
Essentially I just want the HDRI in my Blend’s world shader to be exported along with everything else.
However it doesn’t appear to be possible with the blender addon.

I’m thinking I could export a dummy mesh with a material attached that contains the HDR texture in an additional scene, then in my Three.js app, add a little bit of code that runs immediately after the GLTF is parsed to find the texture and apply it to scene.environment…
But I’m just wondering is there a simpler way and I’m just not seeing it?

This won’t be possible, even with a dummy mesh – Blender can’t export HDRI formats (.exr, .hdr) in models, and I’d strongly recommend against using LDR formats (.png, .jpg, …) for an HDRI.

Unfortunately this requires either exporting the HDRI separately, or building a custom pipeline (addon to Blender exporter, addon to THREE.GLTFLoader). Both do have plugin APIs, but it’s a more advanced process for sure.

There has been some discussion of adding the feature to the glTF format, most recently in https://github.com/KhronosGroup/glTF/pull/1956.

Considering that I’m just using the environment map so I can see some kind of reflection in metallic objects, what would you recommend?

Plenty of ways to get an environment map into three.js, embedding in the model just isn’t one of them… Most of the three.js examples using an environment map will load it from a .hdr or .exr file separately:

https://threejs.org/examples/?q=gltf#webgl_loader_gltf