2
0
Эх сурвалжийг харах

Object3D: Let .toJSON serialize .metadata to root.

tschw 10 жил өмнө
parent
commit
bbc3ea232c

+ 2 - 5
src/core/Object3D.js

@@ -596,6 +596,7 @@ THREE.Object3D.prototype = {
 		var isRootObject = ( meta === undefined );
 		var isRootObject = ( meta === undefined );
 
 
 		var data = {};
 		var data = {};
+		var output = { object: data };
 
 
 		// meta is a hash used to collect geometries, materials.
 		// meta is a hash used to collect geometries, materials.
 		// not providing it implies that this is the root object
 		// not providing it implies that this is the root object
@@ -610,7 +611,7 @@ THREE.Object3D.prototype = {
 				images: {}
 				images: {}
 			};
 			};
 
 
-			data.metadata = {
+			output.metadata = {
 				version: 4.4,
 				version: 4.4,
 				type: 'Object',
 				type: 'Object',
 				generator: 'Object3D.toJSON'
 				generator: 'Object3D.toJSON'
@@ -641,8 +642,6 @@ THREE.Object3D.prototype = {
 
 
 		}
 		}
 
 
-		var output = {};
-
 		if ( isRootObject ) {
 		if ( isRootObject ) {
 
 
 			var geometries = extractFromCache( meta.geometries );
 			var geometries = extractFromCache( meta.geometries );
@@ -657,8 +656,6 @@ THREE.Object3D.prototype = {
 
 
 		}
 		}
 
 
-		output.object = data;
-
 		return output;
 		return output;
 
 
 		// extract data from the cache hash
 		// extract data from the cache hash