CubeCamera update lag after upgrade from v110 to v115

I’m using 2 CubeCameras to generate the textures to be used as envMap for my materials. When the envMap of materials is bound to a CubeCamera render target I use the other CubeCamera to generate the next envMap and the assign it to materials. This technique was working fine and did not have lag in V110.

After upgrading to V115 i see a lag in CubeCamera.update which freezes the UI.
This is the code I use to create the cameras:

const options: THREE.WebGLRenderTargetOptions = { minFilter: THREE.LinearMipMapLinearFilter };
let camera = new THREE.CubeCamera(0.01, 10, 512, options);
camera.renderTarget.texture.generateMipmaps = true;

My goal is to generate a cubemap after the user changes the scene and assign it to my materials.
Do you have any advice on how to solve this performance issue?

Couldn’t you just follow the approach presented in this demo:

1 Like

the example does exactly what I’m doing. (probably i took the code skeleton from the example).
The only difference is the texture size (I use 512, the example 256) and the fact that i do not add the 2 cameras to the scene. I also execute a loop to assign the newly generated texture to the materials envMap property (not just one as in the example).

Looking with the profiler i see that when the cubemap is updated it takes about 250ms, and also the classic render of the scene takes other 250ms. When the cubemap update is skipped the classic render takes about 2ms.

I execute the cubemap update only when the scene changes.

There was a mismatch between the renderer.outputEncoding and the CubeCamera renderTarget encoding.