소스 검색

Editor: Fix black textures when loading JSON scenes.

Mugen87 5 년 전
부모
커밋
49b76ebb09
2개의 변경된 파일13개의 추가작업 그리고 17개의 파일을 삭제
  1. 5 11
      editor/js/Editor.js
  2. 8 6
      editor/js/Loader.js

+ 5 - 11
editor/js/Editor.js

@@ -644,16 +644,6 @@ Editor.prototype = {
 	fromJSON: function ( json ) {
 	fromJSON: function ( json ) {
 
 
 		var loader = new THREE.ObjectLoader();
 		var loader = new THREE.ObjectLoader();
-
-		// backwards
-
-		if ( json.scene === undefined ) {
-
-			this.setScene( loader.parse( json ) );
-			return;
-
-		}
-
 		var camera = loader.parse( json.camera );
 		var camera = loader.parse( json.camera );
 
 
 		this.camera.copy( camera );
 		this.camera.copy( camera );
@@ -663,7 +653,11 @@ Editor.prototype = {
 		this.history.fromJSON( json.history );
 		this.history.fromJSON( json.history );
 		this.scripts = json.scripts;
 		this.scripts = json.scripts;
 
 
-		this.setScene( loader.parse( json.scene ) );
+		loader.parse( json.scene, ( scene ) => {
+
+			this.setScene( scene );
+
+		} );
 
 
 	},
 	},
 
 

+ 8 - 6
editor/js/Loader.js

@@ -540,17 +540,19 @@ var Loader = function ( editor ) {
 				var loader = new THREE.ObjectLoader();
 				var loader = new THREE.ObjectLoader();
 				loader.setResourcePath( scope.texturePath );
 				loader.setResourcePath( scope.texturePath );
 
 
-				var result = loader.parse( data );
+				loader.parse( data, function ( result ) {
 
 
-				if ( result.isScene ) {
+					if ( result.isScene ) {
 
 
-					editor.execute( new SetSceneCommand( editor, result ) );
+						editor.execute( new SetSceneCommand( editor, result ) );
 
 
-				} else {
+					} else {
 
 
-					editor.execute( new AddObjectCommand( editor, result ) );
+						editor.execute( new AddObjectCommand( editor, result ) );
 
 
-				}
+					}
+
+				} );
 
 
 				break;
 				break;