Browse Source

Added callback

Fernando Serrano 8 years ago
parent
commit
c97101fe77
2 changed files with 5 additions and 6 deletions
  1. 3 1
      examples/gltf_exporter.html
  2. 2 5
      examples/js/exporters/GLTFExporter.js

+ 3 - 1
examples/gltf_exporter.html

@@ -190,7 +190,9 @@
 				var gltfExporter = new THREE.GLTFExporter();
 				var gltfExporter = new THREE.GLTFExporter();
 				// gltfExporter.parse(scene);
 				// gltfExporter.parse(scene);
 				//console.log(JSON.stringify(gltfExporter.parse(scene), null, 2));
 				//console.log(JSON.stringify(gltfExporter.parse(scene), null, 2));
-				saveString( JSON.stringify(gltfExporter.parse(scene),null, 2), 'scene.gltf' );
+				gltfExporter.parse(scene, function(result){
+					saveString( JSON.stringify(result,null, 2), 'scene.gltf' );
+				});
 
 
 				//
 				//
 
 

+ 2 - 5
examples/js/exporters/GLTFExporter.js

@@ -608,7 +608,7 @@ THREE.GLTFExporter = function () {};
 THREE.GLTFExporter.prototype = {
 THREE.GLTFExporter.prototype = {
 
 
 	constructor: THREE.GLTFExporter,
 	constructor: THREE.GLTFExporter,
-	parse: function ( input ) {
+	parse: function ( input, onDone ) {
 
 
 		var outputJSON = {
 		var outputJSON = {
 /*
 /*
@@ -939,10 +939,7 @@ THREE.GLTFExporter.prototype = {
 			 base64data = reader.result;
 			 base64data = reader.result;
 			 outputJSON.buffers[0].uri = base64data;
 			 outputJSON.buffers[0].uri = base64data;
 			 console.log(JSON.stringify(outputJSON, null, 2));
 			 console.log(JSON.stringify(outputJSON, null, 2));
+			 onDone(outputJSON);
 		 }
 		 }
-
-		return outputJSON;
-
 	}
 	}
-
 };
 };