|
@@ -104,13 +104,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
if ( ! _gl.isWebGL2 ) return glFormat;
|
|
if ( ! _gl.isWebGL2 ) return glFormat;
|
|
|
|
|
|
- if ( glFormat === _gl.RED ) {
|
|
|
|
|
|
+ if ( glFormat === _gl.RED ) {
|
|
|
|
|
|
- if ( glType === _gl.FLOAT ) return _gl.R32F;
|
|
|
|
- if ( glType === _gl.HALF_FLOAT ) return _gl.R16F;
|
|
|
|
- if ( glType === _gl.UNSIGNED_BYTE ) return _gl.R8;
|
|
|
|
|
|
+ if ( glType === _gl.FLOAT ) return _gl.R32F;
|
|
|
|
+ if ( glType === _gl.HALF_FLOAT ) return _gl.R16F;
|
|
|
|
+ if ( glType === _gl.UNSIGNED_BYTE ) return _gl.R8;
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
if ( glFormat === _gl.RGB ) {
|
|
if ( glFormat === _gl.RGB ) {
|
|
|
|
|
|
@@ -281,21 +281,24 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- function setTexture3D( texture, slot ) {
|
|
|
|
|
|
+ function setTexture3D( texture, slot ) {
|
|
|
|
|
|
- var textureProperties = properties.get( texture );
|
|
|
|
|
|
+ var textureProperties = properties.get( texture );
|
|
|
|
+
|
|
|
|
+ if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
|
|
|
|
- if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
|
|
uploadTexture( textureProperties, texture, slot );
|
|
uploadTexture( textureProperties, texture, slot );
|
|
return;
|
|
return;
|
|
- }
|
|
|
|
|
|
|
|
- state.activeTexture( _gl.TEXTURE0 + slot );
|
|
|
|
- state.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture );
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ state.activeTexture( _gl.TEXTURE0 + slot );
|
|
|
|
+ state.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
- function setTextureCube( texture, slot ) {
|
|
|
|
|
|
+ function setTextureCube( texture, slot ) {
|
|
|
|
|
|
var textureProperties = properties.get( texture );
|
|
var textureProperties = properties.get( texture );
|
|
|
|
|
|
@@ -483,12 +486,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
}
|
|
}
|
|
|
|
|
|
function uploadTexture( textureProperties, texture, slot ) {
|
|
function uploadTexture( textureProperties, texture, slot ) {
|
|
|
|
+
|
|
var textureType;
|
|
var textureType;
|
|
|
|
|
|
- if(texture.isTexture3D) {
|
|
|
|
- textureType = _gl.TEXTURE_3D;
|
|
|
|
- } else {
|
|
|
|
- textureType = _gl.TEXTURE_2D;
|
|
|
|
|
|
+ if ( texture.isTexture3D ) {
|
|
|
|
+
|
|
|
|
+ textureType = _gl.TEXTURE_3D;
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ textureType = _gl.TEXTURE_2D;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -640,9 +648,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
textureProperties.__maxMipLevel = mipmaps.length - 1;
|
|
textureProperties.__maxMipLevel = mipmaps.length - 1;
|
|
|
|
|
|
- } else if ( texture.isTexture3D) {
|
|
|
|
- state.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.length, 0, glFormat, glType, image.data );
|
|
|
|
- textureProperties.__maxMipLevel = 0;
|
|
|
|
|
|
+ } else if ( texture.isTexture3D ) {
|
|
|
|
+
|
|
|
|
+ state.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.length, 0, glFormat, glType, image.data );
|
|
|
|
+ textureProperties.__maxMipLevel = 0;
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
|
|
|
|
// regular Texture (image, video, canvas)
|
|
// regular Texture (image, video, canvas)
|
|
@@ -926,7 +936,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
}
|
|
}
|
|
|
|
|
|
this.setTexture2D = setTexture2D;
|
|
this.setTexture2D = setTexture2D;
|
|
- this.setTexture3D = setTexture3D;
|
|
|
|
|
|
+ this.setTexture3D = setTexture3D;
|
|
this.setTextureCube = setTextureCube;
|
|
this.setTextureCube = setTextureCube;
|
|
this.setTextureCubeDynamic = setTextureCubeDynamic;
|
|
this.setTextureCubeDynamic = setTextureCubeDynamic;
|
|
this.setupRenderTarget = setupRenderTarget;
|
|
this.setupRenderTarget = setupRenderTarget;
|