|
@@ -10943,7 +10943,9 @@ THREE.DataTexture.prototype = Object.create( THREE.Texture.prototype );
|
|
|
|
|
|
THREE.DataTexture.prototype.clone = function () {
|
|
|
|
|
|
- var clonedTexture = new THREE.DataTexture( this.image.data, this.image.width, this.image.height, this.format, this.type, this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter, this.anisotropy );
|
|
|
+ var clonedTexture = new THREE.DataTexture( this.image.data, this.image.width, this.image.height, this.format, this.type, this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter, this.anisotropy );
|
|
|
+
|
|
|
+ clonedTexture.mipmaps = this.mipmaps;
|
|
|
|
|
|
clonedTexture.offset.copy( this.offset );
|
|
|
clonedTexture.repeat.copy( this.repeat );
|
|
@@ -22258,9 +22260,37 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
setTextureParameters( _gl.TEXTURE_2D, texture, isImagePowerOfTwo );
|
|
|
|
|
|
- if ( texture instanceof THREE.CompressedTexture ) {
|
|
|
+ var mipmap, mipmaps = texture.mipmaps;
|
|
|
+
|
|
|
+ if ( texture instanceof THREE.DataTexture ) {
|
|
|
+
|
|
|
+ // use manually created mipmaps if available
|
|
|
+ // if there are no manual mipmaps
|
|
|
+ // set 0 level mipmap and then use GL to generate other mipmap levels
|
|
|
+
|
|
|
+ if ( mipmaps && isImagePowerOfTwo ) {
|
|
|
+
|
|
|
+ for ( var i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
|
|
|
|
- var mipmap, mipmaps = texture.mipmaps;
|
|
|
+ mipmap = mipmaps[ i ];
|
|
|
+ _gl.texImage2D( _gl.TEXTURE_2D, i, glFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
|
+
|
|
|
+ console.log( mipmap.width, mipmap.height, mipmap.data );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ texture.generateMipmaps = false;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ _gl.texImage2D( _gl.TEXTURE_2D, 0, glFormat, image.width, image.height, 0, glFormat, glType, image.data );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ( texture instanceof THREE.CompressedTexture ) {
|
|
|
+
|
|
|
+ // compressed textures can only use manually created mipmaps
|
|
|
+ // WebGL can't generate mipmaps for DDS textures
|
|
|
|
|
|
for( var i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
|
|
|
@@ -22269,22 +22299,18 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- } else if ( texture instanceof THREE.DataTexture ) {
|
|
|
-
|
|
|
- _gl.texImage2D( _gl.TEXTURE_2D, 0, glFormat, image.width, image.height, 0, glFormat, glType, image.data );
|
|
|
-
|
|
|
- } else {
|
|
|
+ } else { // regular Texture (image, video, canvas)
|
|
|
|
|
|
- var mipmap, mipmaps = texture.mipmaps;
|
|
|
+ // use manually created mipmaps if available
|
|
|
+ // if there are no manual mipmaps
|
|
|
+ // set 0 level mipmap and then use GL to generate other mipmap levels
|
|
|
|
|
|
if ( mipmaps && isImagePowerOfTwo ) {
|
|
|
|
|
|
- // pre generated mipmaped regular texture
|
|
|
-
|
|
|
for ( var i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
|
|
|
|
mipmap = mipmaps[ i ];
|
|
|
- _gl.texImage2D(_gl.TEXTURE_2D, i, glFormat, glFormat, glType, mipmap );
|
|
|
+ _gl.texImage2D( _gl.TEXTURE_2D, i, glFormat, glFormat, glType, mipmap );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -22292,8 +22318,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- // regular texture
|
|
|
-
|
|
|
_gl.texImage2D( _gl.TEXTURE_2D, 0, glFormat, glFormat, glType, texture.image );
|
|
|
|
|
|
}
|