Mr.doob 10 éve
szülő
commit
ba5e171d00
4 módosított fájl, 12 hozzáadás és 13 törlés
  1. 1 1
      src/core/BufferGeometry.js
  2. 1 1
      src/core/Geometry.js
  3. 9 10
      src/core/Object3D.js
  4. 1 1
      src/materials/Material.js

+ 1 - 1
src/core/BufferGeometry.js

@@ -1107,8 +1107,8 @@ THREE.BufferGeometry.prototype = {
 
 		// standard BufferGeometry serialization
 
-		data.type = this.type;
 		data.uuid = this.uuid;
+		data.type = this.type;
 		if ( this.name !== '' ) data.name = this.name;
 
 		if ( this.parameters !== undefined ) {

+ 1 - 1
src/core/Geometry.js

@@ -803,8 +803,8 @@ THREE.Geometry.prototype = {
 
 		// standard Geometry serialization
 
-		data.type = this.type;
 		data.uuid = this.uuid;
+		data.type = this.type;
 		if ( this.name !== '' ) data.name = this.name;
 
 		if ( this.parameters !== undefined ) {

+ 9 - 10
src/core/Object3D.js

@@ -597,8 +597,8 @@ THREE.Object3D.prototype = {
 
 		// standard Object3D serialization
 
-		data.type = this.type;
 		data.uuid = this.uuid;
+		data.type = this.type;
 		if ( this.name !== '' ) data.name = this.name;
 		if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;
 		if ( this.visible !== true ) data.visible = this.visible;
@@ -619,23 +619,22 @@ THREE.Object3D.prototype = {
 
 		// wrap serialized object with additional data
 
-		var output;
+		var output = {};
 
 		if ( isRootObject ) {
 
-			output = {
-				metadata: metadata,
-				geometries: extractFromCache(meta.geometries),
-				materials: extractFromCache(meta.materials),
-				object: data
-			};
+			output.metadata = metadata;
 
-		} else {
+			var geometries = extractFromCache( meta.geometries );
+			var materials = extractFromCache( meta.materials );
 
-			output = { object: data };
+			if ( geometries.length > 0 ) output.geometries = geometries;
+			if ( materials.length > 0 ) output.materials = materials;
 
 		}
 
+		output.object = data;
+
 		return output;
 
 		// extract data from the cache hash

+ 1 - 1
src/materials/Material.js

@@ -121,8 +121,8 @@ THREE.Material.prototype = {
 		};
 
 		// standard Material serialization
-		data.type = this.type;
 		data.uuid = this.uuid;
+		data.type = this.type;
 		if ( this.name !== '' ) data.name = this.name;
 
 		if ( this.opacity < 1 ) data.opacity = this.opacity;