# HDR Texture does not load in as a equirectangular map

**URL:** <https://discourse.threejs.org/t/hdr-texture-does-not-load-in-as-a-equirectangular-map/42563>\
**Category:** Questions\
**Tags:** map, hdr\
**Created:** [September 15, 2022, 12:14pm UTC](https://discourse.threejs.org/t/hdr-texture-does-not-load-in-as-a-equirectangular-map/42563 "2022-09-15T12:14:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kemura](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/kemura/32/27932_2.png) [@Kemura](https://discourse.threejs.org/u/Kemura)\
**Post date:** [September 15, 2022, 12:14pm UTC](https://discourse.threejs.org/t/hdr-texture-does-not-load-in-as-a-equirectangular-map/42563/1 "2022-09-15T12:14:24Z")

</div>

I’m following the markup code from **webgl\_loader\_gltf.html** in order to recreate the same map in my own project. The HDR image does not get split up into a cube as it should, rather it gets displayed as a texture that covers the whole scene.

 ![image_2022-09-15_140325070](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/3/03711f4c5b3b190d35c757194867197212cdbf95.jpeg)

This is my code.

```javascript
  function loadEnvironment(url) {
    let rgbeLoader = new RGBELoader();

    rgbeLoader.load(
      "../images/EquirecMap/royal_esplanade_1k.hdr",
      (texture) => {
        let pmremGenerator = new THREE.PMREMGenerator(renderer);
        pmremGenerator.compileEquirectangularShader();

        envMap = pmremGenerator.fromEquirectangular(texture).texture;
        pmremGenerator.dispose();

        texture.mapping = THREE.EquirectangularReflectionMapping;
        scene.background = texture;
        scene.environment = envMap;
        render();
      }
    );
  }
  
  loadEnvironment();

```

What am I missing?

---

<div class="post-metadata">

**Author:** ![Kemura](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/kemura/32/27932_2.png) [@Kemura](https://discourse.threejs.org/u/Kemura)\
**Post date:** [September 15, 2022, 12:25pm UTC](https://discourse.threejs.org/t/hdr-texture-does-not-load-in-as-a-equirectangular-map/42563/2 "2022-09-15T12:25:49Z")

</div>

**UPDATE**

I set `scene.background = envMap` instead and now it works.  
But I read somewhere that Mugen87 doesn’t recommend it. Why doesn’t it work when I set it to `texture`?

// Thankful noob

---

<div class="post-metadata">

**Author:** ![D13](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@D13](https://discourse.threejs.org/u/D13)\
**Post date:** [September 15, 2022, 2:13pm UTC](https://discourse.threejs.org/t/hdr-texture-does-not-load-in-as-a-equirectangular-map/42563/3 "2022-09-15T14:13:53Z")

</div>

You created the texture successfully. Then you applied the texture to the envMap. You then set your scene background to the envMap and it worked.

So, materials can also us an envMap property. So now, you make a geometry, like maybe a box? Then when you apply a material to the box you can set the materials envMap the same way you did with the scene background and your equirectangular material will work the same way.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [September 15, 2022, 4:29pm UTC](https://discourse.threejs.org/t/hdr-texture-does-not-load-in-as-a-equirectangular-map/42563/4 "2022-09-15T16:29:53Z")

</div>

> [@Kemura](#):
>
> But I read somewhere that Mugen87 doesn’t recommend it.

Please always link to the resource before making such statements.

Using `PMREMGenerator` on app level is not necessary anymore. Do it like in [three.js webgl - GLTFloader](https://threejs.org/examples/webgl_loader_gltf). You normally want to assign the same texture to `Scene.background` and `Scene.environment`.
