CubeTexture from canvas

Hi,

Is it possible to create CubeTextures from either a single or multiple canvasses?

If not, can we wrap a plain webgl texture in the Babylon texture class?

We do not support cubeTexture from multiple canvases so far, but you could use engine.wrapWebGLTexture to wrap an external texture in an InternalTexture.

Thanks, I was searching the Texture classes and forgot to look in the engine class. This should make it possible to do what I want

The material.setTexture() requires a BaseTexture. Is there a function to wrap the InternalTexture so that we can use it in setTexture or do we have to do this manually (i.e, copy Babylon.js/dynamicTexture.ts at master · BabylonJS/Babylon.js · GitHub and change function implementations)?

you can do:

const baseTexture = new BaseTexture(scene);
baseTexture._texture = yourInternalTexture;

This should work correctly.

Thanks, that seems easy.

It would make sense to me though, to be able to pass it in the constructor, or have a static constructor method for it.

yup if it all works, I ll add this for you

I created a quick playground example. It seems to work perfectly.

This will be in the next nightly Allow creation of baseTexture from internalTexture by sebavan · Pull Request #12804 · BabylonJS/Babylon.js · GitHub

2 Likes