[React Native] engine.createRenderTargetCube - undefined is not an object (evaluating gl.TEXTURE_CUBE_MAP)

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:

The full error is:

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
[...]

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

1 Like

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?).

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

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

2 Likes

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!

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
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 ?

We can use an equirectangular texture for the reflection texture.

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

1 Like

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

      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!

This code should be portable. let me know:

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

So once I call

BABYLON.VideoTexture.CreateFromWebCam

the camera background in AR and the tracking stop.

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

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