瀏覽代碼

Revert "Texture.mipmaps serialization"

This reverts commit f5ab28e6d3aea4506198f16391dcc2f7a64c1ae6.
Takahiro 7 年之前
父節點
當前提交
51dbe2afe6
共有 2 個文件被更改,包括 16 次插入76 次删除
  1. 1 37
      src/loaders/ObjectLoader.js
  2. 15 39
      src/textures/Texture.js

+ 1 - 37
src/loaders/ObjectLoader.js

@@ -570,43 +570,7 @@ Object.assign( ObjectLoader.prototype, {
 				if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER );
 				if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER );
 				if ( data.anisotropy !== undefined ) texture.anisotropy = data.anisotropy;
-
-				if ( data.mipmaps !== undefined ) {
-
-					var TYPED_ARRAYS = {
-						Int8Array: Int8Array,
-						Uint8Array: Uint8Array,
-						// Workaround for IE11 pre KB2929437. See #11440
-						Uint8ClampedArray: typeof Uint8ClampedArray !== 'undefined' ? Uint8ClampedArray : Uint8Array,
-						Int16Array: Int16Array,
-						Uint16Array: Uint16Array,
-						Int32Array: Int32Array,
-						Uint32Array: Uint32Array,
-						Float32Array: Float32Array,
-						Float64Array: Float64Array
-					};
-
-					for ( var j = 0, jl = data.mipmaps.length; j < jl; j ++ ) {
-
-						var mipmap = data.mipmaps[ j ];
-
-						if ( mipmap.array !== undefined ) {
-
-							texture.mipmaps.push( {
-								width: mipmap.width,
-								height: mipmap.height,
-								data: new TYPED_ARRAYS[ mipmap.type ]( mipmap.array )
-							} );
-
-						} else {
-
-							texture.mipmaps.push( images[ mipmap ] );
-
-						}
-
-					}
-
-				}
+				if ( data.mipmaps !== undefined ) texture.mipmaps = data.mipmaps;
 
 				if ( data.flipY !== undefined ) texture.flipY = data.flipY;
 

+ 15 - 39
src/textures/Texture.js

@@ -170,29 +170,6 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
 
 		}
 
-		function addImage( image ) {
-
-			// TODO: Move to THREE.Image
-
-			if ( image.uuid === undefined ) {
-
-				image.uuid = _Math.generateUUID(); // UGH
-
-			}
-
-			if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {
-
-				meta.images[ image.uuid ] = {
-					uuid: image.uuid,
-					url: getDataURL( image )
-				};
-
-			}
-
-			return image.uuid;
-
-		}
-
 		var output = {
 
 			metadata: {
@@ -220,6 +197,7 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
 			minFilter: this.minFilter,
 			magFilter: this.magFilter,
 			anisotropy: this.anisotropy,
+			mipmaps: this.mipmaps.slice(),
 
 			flipY: this.flipY,
 
@@ -228,32 +206,30 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
 
 		};
 
-		var mipmaps = [];
+		if ( this.image !== undefined ) {
 
-		for ( var i = 0, il = this.mipmaps.length; i < il; i ++ ) {
+			// TODO: Move to THREE.Image
 
-			var mipmap = this.mipmaps[ i ];
+			var image = this.image;
 
-			if ( mipmap.data !== undefined ) {
+			if ( image.uuid === undefined ) {
 
-				mipmaps.push( {
-					width: mipmap.width,
-					height: mipmap.height,
-					type: mipmap.data.constructor.name,
-					array:  Array.prototype.slice.call( mipmap.data )
-				} );
+				image.uuid = _Math.generateUUID(); // UGH
 
-			} else {
+			}
 
-				mipmaps.push( addImage( mipmap ) );
+			if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {
 
-			}
+				meta.images[ image.uuid ] = {
+					uuid: image.uuid,
+					url: getDataURL( image )
+				};
 
-		}
+			}
 
-		if ( mipmaps.length > 0 ) output.mipmaps = mipmaps;
+			output.image = image.uuid;
 
-		if ( this.image !== undefined ) output.image = addImage( this.image );
+		}
 
 		if ( ! isRootObject ) {