Big increase of initialisation time after upgrade from v135 to v136 (RGBELoader)

Hi all,

We are currently upgrading to the latest three version.
After upgrading from 135 to 136, I realised a massive time increase (from 1 sec to about 4 sec) of the initial scene loading on my local development machine (after loading, the scene still works).

We are using HDR lighting and I guess the reason is the change around the RGBELoader and the different encodings.

I think we are not doing anything special when loading the HDR (HDR is about 1,5 MB). Following our code:

    const pmremGenerator = new PMREMGenerator(renderer);
    pmremGenerator.compileCubemapShader();
    if (scene.environment) { scene.environment.dispose() }
    // 3D Environment
    new RGBELoader()
      .setDataType(HalfFloatType)
      .load(`data/HDRI/${file}.hdr`, function (texture : CubeTexture ) {
        const envMap = pmremGenerator.fromEquirectangular( texture ).texture;
        EnvironmentManager.hdrTexture = envMap;
        scene.environment = envMap;
        texture.dispose();
        pmremGenerator.dispose();
    });

Has anybody else encountered a similar problem after the upgrade?
Is there anything I can do about it, or do I have a problem in the loading code?
Please let me know if you need additonal information.

Thanks in advance for any help,

Heinz

Try to rewrite your code like so:

if (scene.environment) { scene.environment.dispose() }

new RGBELoader()
    .load(`data/HDRI/${file}.hdr`, function (texture : CubeTexture ) {
    texture.mapping = EquirectangularReflectionMapping;
    EnvironmentManager.hdrTexture = texture;
    scene.environment = texture;
});

Since r131, PMREMGenerator is used internally by the renderer to prepare environment maps. No need to use it on app level anymore.

BTW: The type of the texture returned by RGBELoader is not of type CubeTexture. It’s a DataTexture.

2 Likes

Thanks Mugen87,

That helped. Loading the environment map is now as fast as before.

I still have quite some delay compared to 135.
I figured out the reason is setting map.encoding = sRGBEncoding at maps in MeshStandardMaterials.

It seems that this is not necessary starting with 136. Removing it fixed my problem completely.

Thanks again :slight_smile:

Not when loading your assets via GLTFLoader since the property is already configured.

If you are manually loading textures and use a sRGB workflow, you need the line of code.

1 Like