# Cube environment map not working on meshStandardMaterial.envMap & scene.environment

**URL:** <https://discourse.threejs.org/t/cube-environment-map-not-working-on-meshstandardmaterial-envmap-scene-environment/33352>\
**Category:** Questions\
**Tags:** webxr, cube-map, cube-texture\
**Created:** [January 6, 2022, 3:06pm UTC](https://discourse.threejs.org/t/cube-environment-map-not-working-on-meshstandardmaterial-envmap-scene-environment/33352 "2022-01-06T15:06:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![orion\_prime](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/orion_prime/32/15785_2.png) [@orion\_prime](https://discourse.threejs.org/u/orion_prime)\
**Post date:** [January 6, 2022, 3:06pm UTC](https://discourse.threejs.org/t/cube-environment-map-not-working-on-meshstandardmaterial-envmap-scene-environment/33352/1 "2022-01-06T15:06:17Z")

</div>

so in webr xr lighting estimation we get `xrLight.environment` cubeMap as seen in this webxr example [three.js examples](https://threejs.org/examples/?q=webx#webxr_ar_lighting)

which  
when used on `meshPhongMaterial.envMap` and `scene.background` works fine  
but  
when used on `scene.environment` or `meshStandardMaterial.envMap` does not work

am i missing something here ?

i tried material.needsUpdate=true after updating envMap but no luck

---

<div class="post-metadata">

**Author:** ![orion\_prime](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/orion_prime/32/15785_2.png) [@orion\_prime](https://discourse.threejs.org/u/orion_prime)\
**Post date:** [January 6, 2022, 3:11pm UTC](https://discourse.threejs.org/t/cube-environment-map-not-working-on-meshstandardmaterial-envmap-scene-environment/33352/2 "2022-01-06T15:11:53Z")

</div>

[https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/4/8/48f7c7a5aa8ad5f791ef3a5222a3b5bb37ca394e.mp4](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/4/8/48f7c7a5aa8ad5f791ef3a5222a3b5bb37ca394e.mp4)
  
 ![Screenshot_2022-01-06-20-20-19-82_40deb401b9ffe8e1df2f1cc5ba480b12](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/d/1/d1fb4450e8c74581beb1a21b48e253b9ed585212.jpeg)

Top sphere : cubemap on meshPhong.envMap  
Bottom sphere: cubemap on meshStandard.envMap  
Background : cubemap on scene.background

---

<div class="post-metadata">

**Author:** ![orion\_prime](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/orion_prime/32/15785_2.png) [@orion\_prime](https://discourse.threejs.org/u/orion_prime)\
**Post date:** [January 7, 2022, 7:58am UTC](https://discourse.threejs.org/t/cube-environment-map-not-working-on-meshstandardmaterial-envmap-scene-environment/33352/3 "2022-01-07T07:58:35Z")

</div>

Using PMREMGenerator .fromCubemap() texture as environment i’m able to get this output (bottom sphere is meshstandard mat)

also there’s some warnings `three.module.js:27070 WebGL: INVALID_OPERATION: drawBuffers: COLOR_ATTACHMENTi_EXT or NONE`

&

using ` texture.mapping = THREE.CubeReflectionMapping` gives black

 ![Screenshot_2022-01-07-13-22-52-07_40deb401b9ffe8e1df2f1cc5ba480b12](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/d/f/df572fa39cab2797dec815a4cfc93e22d0e806fe.jpeg)

@Mugen87 any idea what can be done here ?

---

<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:** [January 7, 2022, 10:39am UTC](https://discourse.threejs.org/t/cube-environment-map-not-working-on-meshstandardmaterial-envmap-scene-environment/33352/4 "2022-01-07T10:39:54Z")

</div>

This use case is currently not supported. However, there is a PR trying to fix this:

> <https://github.com/mrdoob/three.js/pull/23171>
>
> Related issue: -
> 
> \*\*Description\*\*
> 
> This PR restores the PBR materials suppor…t of \`XREstimatedLight\` . I have some concerns though: 
> 
> The WebXR API returns an environment map which seems to be an irradiance environment map. I'm not sure but is this type of map the intended input of \`PMREMGenerator\`? 
> 
> Wouldn't it be more correct to transform the irradiance environment map to an instance of \`LightProbe\` (since we can't directly sample irradiance environment maps right now) and add it to the scene?
> 
> Besides, \`XREstimatedLight\` uses an instance of \`LightProbe\` and \`DirectionalLight\` for representing the estimated lighting. Does it make sense to add an instance of \`XREstimatedLight\` \_and\_ the irradiance environment map to the scene? Isn't the irradiance added twice now?
> 
> /cc @toji
