# \[React Native\] engine.createRenderTargetCube - undefined is not an object (evaluating gl.TEXTURE\_CUBE\_MAP)

**URL:** <https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790>\
**Category:** Bugs\
**Tags:** react, babylon-native, render-target, ios\
**Created:** [September 9, 2022, 3:36am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790 "2022-09-09T03:36:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![clem](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clem/32/26575_2.png) [@clem](https://forum.babylonjs.com/u/clem)\
**Post date:** [September 9, 2022, 3:36am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/1 "2022-09-09T03:36:53Z")

</div>

Hello everyone,

Versions:

- `@babylon/js/core -> 5.21.0`
- `@babylonjs/react-native-iosandroid-0-65`

My project is using react native (iOS) and I’m getting an error while running a sample code with a reflection probe:

> **[Babylon.js Playground](https://playground.babylonjs.com/#4R1H1U%2331)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

The full error is:

```auto
TypeError: undefined is not an object (evaluating 'gl.TEXTURE_CUBE_MAP')

ThinEngine.prototype.createRenderTargetCubeTexture
-> engine.renderTargetCube.js:20:33
RenderTargetTexture
-> renderTargetTexture.js:148:39
ReflectionProbe
-> reflectionProbe.js:75:37
[...]

```

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [September 9, 2022, 7:53am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/2 "2022-09-09T07:53:36Z")

</div>

Hi @clem  
Rendering to a cubemap is not currently supported in BabylonNative/BabylonReactNative  
We have to ETA yet. Sorry for that.

---

<div class="post-metadata">

**Author:** ![clem](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clem/32/26575_2.png) [@clem](https://forum.babylonjs.com/u/clem)\
**Post date:** [September 9, 2022, 6:32pm UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/3 "2022-09-09T18:32:04Z")

</div>

Hey @Cedric, thanks for the quick response, I’m curious, is the work required to support this significant? I can consider doing a patch if you point me in the right direction. In the meantime, I’m thinking of generating the environment file offline (maybe that can actually be done with the babylon web editor?).

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [September 12, 2022, 8:17am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/4 "2022-09-12T08:17:21Z")

</div>

It’s quite a difficult change. I’ve started a PR some time ago :

> <https://github.com/BabylonJS/BabylonNative/pull/816>
>
> For use with pointlight shadows.
> Also fixes invertY for RTT and cubemap loading….
> 
> \`FrameBuffer\` can refer to a 2D Framebuffer or it can holds 6 framebuffers for cubemap. A boolean propery \`m\_cubeFrameBuffer\` is used to determine its nature. 
> 
> This PR will be updated once https://github.com/BabylonJS/Babylon.js/pull/10581 is in a new NPM.

But I didn’t finish it (priorities…)  
I think @sebavan worked on env file filtering some time ago.

---

<div class="post-metadata">

**Author:** ![rformato](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@rformato](https://forum.babylonjs.com/u/rformato)\
**Post date:** [August 9, 2023, 7:06pm UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/5 "2023-08-09T19:06:13Z")

</div>

Thanks Cedric for all your hard work! Is there any way to get a envTexture from the phone camera, so it can be used with reflections and refractions and PBR materials? I’ve seen some implementations using ReflectionProbes to create those using the phone camera image but at this stage it cannot be used on BabylonNative/BabylonReactNative.

Thanks!

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [August 10, 2023, 9:31am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/6 "2023-08-10T09:31:43Z")

</div>

Hi @rformato

IIRC Babylon React Native has access to camera on Android and iOS.  
So, this porting this code [https://www.babylonjs-playground.com/#9ZA2CA#0](https://www.babylonjs-playground.com/#9ZA2CA#0)  
with BRN should work.

Once the camera texture is available, it should be possible to use it as a reflection probe, I guess.  
Do you know if it’s possible to use a 2d texture as a reflection probe @Evgeni_Popov ?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 10, 2023, 10:15am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/7 "2023-08-10T10:15:17Z")

</div>

We can use an equirectangular texture for the reflection texture.

See this post to convert a regular texture to an equirectangular texture:

> [@Generate equirectangular 360 panorama from babylon.js scene](https://forum.babylonjs.com/t/generate-equirectangular-360-panorama-from-babylon-js-scene/6899):
>
> I got this to work: [https://playground.babylonjs.com/#E7IT0S#1](https://playground.babylonjs.com/#E7IT0S#1) Based on this three.js code:

---

<div class="post-metadata">

**Author:** ![rformato](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@rformato](https://forum.babylonjs.com/u/rformato)\
**Post date:** [August 11, 2023, 7:34am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/8 "2023-08-11T07:34:01Z")

</div>

Thanks a lot Cedric!  
I’m still struggling to understand how to create the VideoTexture from the native camera in BRN.

I have tried the following

```auto
      const video = engine.createVideoElement({video: true});

      return new VideoTexture('vt', video, scene);

```

but the resulting texture is not working.

I’ve not been able to find examples. Could you please point me to the right direction?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [August 11, 2023, 7:36am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/9 "2023-08-11T07:36:17Z")

</div>

This code should be portable. let me know:

> <https://github.com/BabylonJS/BabylonNative/blob/master/Apps/Playground/Scripts/experience.js#L78-L98>

---

<div class="post-metadata">

**Author:** ![rformato](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@rformato](https://forum.babylonjs.com/u/rformato)\
**Post date:** [August 11, 2023, 8:42am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/10 "2023-08-11T08:42:27Z")

</div>

Thanks a lot Cedric,  
one thing I fear I was not describing is that I’m using AR.

So once I call

```auto
BABYLON.VideoTexture.CreateFromWebCam

```

the camera background in AR and the tracking stop.

Sorry for that, I should have written since the beginning.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [August 11, 2023, 8:53am UTC](https://forum.babylonjs.com/t/react-native-engine-createrendertargetcube-undefined-is-not-an-object-evaluating-gl-texture-cube-map/33790/11 "2023-08-11T08:53:55Z")

</div>

I’ve not seen a link between the camera texture and any public API for accessing it.  
And light estimation is available in Babylon.js but not yet for BabylonNative

> <https://github.com/BabylonJS/BabylonNative/issues/369>
>
> WebXR Lighting Estimation \[specs\](https://github.com/immersive-web/lighting-esti…mation/blob/master/lighting-estimation-explainer.md)
> 
> This need to get exposed (or some forms of it) such that \[ARKit\](https://developer.apple.com/documentation/arkit/arlightestimate) and \[ARCore\](https://developers.google.com/ar/develop/unity/light-estimation) implementations can get surfaced.
