Loading EXR from GLB buffer doesn't work (loading from path does)

32 views Asked by At

I am trying to load a GLB model with a custom embedded EXR file, I use the following code to try and load it from the buffer. However this does not work...

When I try to load the EXR directly with the EXRLoader().load(url) function that does work, leading me to believe the EXR is not corrupt... Are there other step requirements when parsing an EXR file to get lighting into the scene?

var parser = gltf.parser;
var bufferPromises = parser.getDependency("bufferView", parser.json.images[2].bufferView);

bufferPromises.then(function (buffer) {
    var texData = that.assetLoader.parseEXR(buffer);
    var texture = new THREE.DataTexture()

    texture.image = texData.image;
    texture.image.width = texData.width;
    texture.image.height = texData.height;
    texture.image.data = texData.data;
             
    texture.format = texData.format;
    texture.type = texData.type;
    texture.colorSpace = THREE.LinearSRGBColorSpace;
    texture.minFilter = THREE.LinearFilter;
    texture.magFilter = THREE.LinearFilter;
    texture.generateMipmaps = false;
    texture.flipY = false;

    var envMap = that.pmremGenerator.fromEquirectangular(texture)
    that.exr = envMap.texture;
    that.scene.environment = envMap;
    that.scene.background = envMap.texture;
});
0

There are 0 answers