提交 99e34385 编写于 作者: M Mr.doob

GUI: Adding some code for loading scenes.

This is unlikely to work properly in the short term though.
上级 e186dd95
......@@ -107,12 +107,27 @@
case 'js':
var geometry = new THREE.GeometryLoader().parse( JSON.parse( contents ) );
var material = new THREE.MeshLambertMaterial( { color: 0xffffff } );
var mesh = new THREE.Mesh( geometry, material );
var data = JSON.parse( contents );
signals.objectAdded.dispatch( mesh );
signals.objectSelected.dispatch( mesh );
if ( data.metadata.type === 'scene' ) {
new THREE.SceneLoader().parse( data, function ( scene ) {
signals.objectAdded.dispatch( scene );
signals.objectSelected.dispatch( scene );
}, '' );
} else {
var geometry = new THREE.GeometryLoader().parse( data );
var material = new THREE.MeshLambertMaterial( { color: 0xffffff } );
var mesh = new THREE.Mesh( geometry, material );
signals.objectAdded.dispatch( mesh );
signals.objectSelected.dispatch( mesh );
}
break;
......
......@@ -17,7 +17,7 @@ THREE.SceneLoader.prototype.constructor = THREE.SceneLoader;
THREE.SceneLoader.prototype.load = function( url, callbackFinished ) {
var context = this;
var scope = this;
var xhr = new XMLHttpRequest();
......@@ -28,7 +28,7 @@ THREE.SceneLoader.prototype.load = function( url, callbackFinished ) {
if ( xhr.status === 200 || xhr.status === 0 ) {
var json = JSON.parse( xhr.responseText );
context.createScene( json, callbackFinished, url );
scope.parse( json, callbackFinished, url );
} else {
......@@ -47,7 +47,7 @@ THREE.SceneLoader.prototype.load = function( url, callbackFinished ) {
};
THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url ) {
THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
var scope = this;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册