소스 검색

Added callback

Fernando Serrano 8 년 전
부모
커밋
c97101fe77
2개의 변경된 파일5개의 추가작업 그리고 6개의 파일을 삭제
  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();
 				// gltfExporter.parse(scene);
 				//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 = {
 
 	constructor: THREE.GLTFExporter,
-	parse: function ( input ) {
+	parse: function ( input, onDone ) {
 
 		var outputJSON = {
 /*
@@ -939,10 +939,7 @@ THREE.GLTFExporter.prototype = {
 			 base64data = reader.result;
 			 outputJSON.buffers[0].uri = base64data;
 			 console.log(JSON.stringify(outputJSON, null, 2));
+			 onDone(outputJSON);
 		 }
-
-		return outputJSON;
-
 	}
-
 };