CubeTexture files array bug

Hi. It looks like there is a bug in the CubeTexture when using the files array to define the 6 sides of the cubemap. If you create multiple such cube textures you always get the first one created back. I made a small repro which can be found here: Babylon.js Playground

If you use the url parameter though everything works as expected. Please let me know if you need more info.

Oh, that’s not a bug.

This is because babylon caches and reuses textures bases on the texture name. This is a silly approach to naming texture, but if you give random names, you will see the texture changes when needed - CubeTexture files issue | Babylon.js Playground (babylonjs-playground.com)

Of course, a better approach would be to call it based on the index.

2 Likes

While waiting for an answer I already looked into your code and saw

this._texture = this._getFromCache(this.url, this._noMipmap, undefined, undefined, this._useSRGBBuffer, this.isCube);

which is called from CubeTexture::_loadTexture(). After checking _getFromCache() it was quite clear. :slight_smile:

Thx for the quick response though!

1 Like