|
@@ -362,7 +362,7 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
const currentScissor = new Vector4().fromArray( scissorParam );
|
|
|
const currentViewport = new Vector4().fromArray( viewportParam );
|
|
|
|
|
|
- function createTexture( type, target, count ) {
|
|
|
+ function createTexture( type, target, count, dimensions ) {
|
|
|
|
|
|
const data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.
|
|
|
const texture = gl.createTexture();
|
|
@@ -373,7 +373,15 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
|
|
|
for ( let i = 0; i < count; i ++ ) {
|
|
|
|
|
|
- gl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
|
+ if ( isWebGL2 && ( type === gl.TEXTURE_3D || type === gl.TEXTURE_2D_ARRAY ) ) {
|
|
|
+
|
|
|
+ gl.texImage3D( target, 0, gl.RGBA, 1, 1, dimensions, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ gl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -385,6 +393,13 @@ function WebGLState( gl, extensions, capabilities ) {
|
|
|
emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
|
|
|
emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
|
|
|
|
|
|
+ if ( isWebGL2 ) {
|
|
|
+
|
|
|
+ emptyTextures[ gl.TEXTURE_2D_ARRAY ] = createTexture( gl.TEXTURE_2D_ARRAY, gl.TEXTURE_2D_ARRAY, 1, 1 );
|
|
|
+ emptyTextures[ gl.TEXTURE_3D ] = createTexture( gl.TEXTURE_3D, gl.TEXTURE_3D, 1, 1 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// init
|
|
|
|
|
|
colorBuffer.setClear( 0, 0, 0, 1 );
|