HDRI scene.background turns black when camera layer changed

This is the code I used to load HDRI
Full code: GitHub - SadmanYasar/3D-Car-Viewer

new RGBELoader()
    .load('textures/autoshop_01_2k.hdr', (texture: Texture) => {
      texture.mapping = EquirectangularReflectionMapping;

      // background remains same if color used instead of texture
      scene.background = texture;
      scene.environment = texture;


      // load models asynchronously
      const loader = new GLTFLoader();

        .then((gltf) => {
          gltf.scene.traverse((object) => {


Initially the models and HDRI load fine but when I change camera layer, the models for that layer load but the scene background becomes black. I tried console logging scene.background when the layer changed but found no difference between the results. This issue is occurring after I started using Typescript and Webpack on this project. What could be done to solve this issue?

In your render function try first to set camera layer 0
Load hdri
Change the camera layer

I did it after initializing the camera but still it does not work :frowning:
But when I set scene.background to a hex color, the background remains same when I change layers.

I mean chang it in each frame
In this path
Camera with layer0
Set th hdri
Camera with layer 1