diff --git a/packages/core/src/textures/TextureSystem.js b/packages/core/src/textures/TextureSystem.js index b9b3ecc..b24926c 100644 --- a/packages/core/src/textures/TextureSystem.js +++ b/packages/core/src/textures/TextureSystem.js @@ -22,26 +22,7 @@ * @member {PIXI.BaseTexture[]} * @readonly */ - this.boundTextures = [ - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - ]; - + this.boundTextures = []; /** * Current location * @member {number} @@ -68,6 +49,15 @@ this.CONTEXT_UID = this.renderer.CONTEXT_UID; + const maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + + this.boundTextures.length = maxTextures; + + for (let i = 0; i < maxTextures; i++) + { + this.boundTextures[i] = null; + } + // TODO move this.. to a nice make empty textures class.. this.emptyTextures = {}; @@ -81,9 +71,7 @@ gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.emptyTextures[gl.TEXTURE_CUBE_MAP].texture); - let i; - - for (i = 0; i < 6; i++) + for (let i = 0; i < 6; i++) { gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); } @@ -91,7 +79,7 @@ gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - for (i = 0; i < this.boundTextures.length; i++) + for (let i = 0; i < this.boundTextures.length; i++) { this.bind(null, i); }