# Environment texutre doesn't work when develop with react-babylonjs

**URL:** <https://forum.babylonjs.com/t/environment-texutre-doesnt-work-when-develop-with-react-babylonjs/20936>\
**Category:** Questions\
**Tags:** material\
**Created:** [May 19, 2021, 2:10pm UTC](https://forum.babylonjs.com/t/environment-texutre-doesnt-work-when-develop-with-react-babylonjs/20936 "2021-05-19T14:10:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franco](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/franco/32/16275_2.png) [@Franco](https://forum.babylonjs.com/u/Franco)\
**Post date:** [May 19, 2021, 2:10pm UTC](https://forum.babylonjs.com/t/environment-texutre-doesnt-work-when-develop-with-react-babylonjs/20936/1 "2021-05-19T14:10:08Z")

</div>

I try to use the .env format environment texture for my model, I can see the source has been loaded in the source but haven’t seen any effect.

### The part of react code:

 ![CleanShot 2021-05-19 at 22.07.28@2x](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/7/e7270842e7f61a8d98514a20cd54d0ba88788f66.png)

I am sure that the source path is fine cause the sources have been loaded. Please help! 🙏

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [May 19, 2021, 3:15pm UTC](https://forum.babylonjs.com/t/environment-texutre-doesnt-work-when-develop-with-react-babylonjs/20936/2 "2021-05-19T15:15:57Z")

</div>

Hello and welcome!

I don’t use React but here is how it is performed with Babylon.js - [https://playground.babylonjs.com/#0Q38WW#3](https://playground.babylonjs.com/#0Q38WW#3)

```
var hdrTexture = new BABYLON.CubeTexture("https://assets.babylonjs.com/environments/environmentSpecular.env", scene);
hdrTexture.gammaSpace = false;
scene.environmentTexture = hdrTexture;
```

---

<div class="post-metadata">

**Author:** ![Franco](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/franco/32/16275_2.png) [@Franco](https://forum.babylonjs.com/u/Franco)\
**Post date:** [May 19, 2021, 3:30pm UTC](https://forum.babylonjs.com/t/environment-texutre-doesnt-work-when-develop-with-react-babylonjs/20936/3 "2021-05-19T15:30:24Z")

</div>

Hi @labris , thank you for your feedback.

I also use vallina JavaScript version before, and it works fine. But I really want to know how to fix this when work with React.

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [May 19, 2021, 7:47pm UTC](https://forum.babylonjs.com/t/environment-texutre-doesnt-work-when-develop-with-react-babylonjs/20936/4 "2021-05-19T19:47:43Z")

</div>

hi Franco. That’s a good question. Would this syntax be an acceptable solution?

```auto
<Scene ...>
  <cubeTexture ... assignTo="environmentTexture" />
</Scene>

```

The thing about having a texture as a child of a component is that `react-babylonjs` doesn’t know _where_ to attach it. So, if you have multiple textures as children, you can assign them to emissive, diffuse (this is default, if you don’t specify), bump, etc in the case of Materials. Actually, materials are automatically assigned to a mesh.material, because they can be applied without ambiguity. Here is an example with textures being assigned to different properties of materials:  
[react-babylonjs/image-texture.stories.js at master · brianzinn/react-babylonjs (github.com)](https://github.com/brianzinn/react-babylonjs/blob/master/stories/babylonjs/Textures/image-texture.stories.js#L24)

Having said that I can tell you that the texture probably won’t attach to the scene, but it should. The reason it won’t is here (that code needs to be relaxed I think):  
[react-babylonjs/TexturesLifecycleListener.ts at master · brianzinn/react-babylonjs (github.com)](https://github.com/brianzinn/react-babylonjs/blob/master/src/customHosts/TexturesLifecycleListener.ts#L15)

The way to get it to attach will end up being the same as the fixes done in March for post-processing that can attach configurations to ie: “Scene.imageProcessingConfiguration”. Do you mind @Franco to create an issue in the `react-babylonjs` repo?

If environmentTexture is the only texture prop on Scene object then it could perhaps be automatic.
