|
@@ -2768,6 +2768,8 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {
|
|
|
|
|
|
+ if ( level === undefined ) level = 0;
|
|
|
+
|
|
|
var width = srcTexture.image.width;
|
|
|
var height = srcTexture.image.height;
|
|
|
var glFormat = utils.convert( dstTexture.format );
|
|
@@ -2777,14 +2779,25 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
if ( srcTexture.isDataTexture ) {
|
|
|
|
|
|
- _gl.texSubImage2D( _gl.TEXTURE_2D, level || 0, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
|
|
|
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- _gl.texSubImage2D( _gl.TEXTURE_2D, level || 0, position.x, position.y, glFormat, glType, srcTexture.image );
|
|
|
+ if ( srcTexture.isCompressedTexture ) {
|
|
|
+
|
|
|
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // Generate mipmaps only when copying level 0
|
|
|
+ if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
|
|
|
+
|
|
|
state.unbindTexture();
|
|
|
|
|
|
};
|