提交 2c6fa874 编写于 作者: M Mr.doob

Editor improvements and fixes.

上级 3e7939eb
......@@ -151,8 +151,6 @@
var editor = new Editor();
var loader = new Loader( editor );
var viewport = new Viewport( editor );
viewport.setTop( '32px' );
viewport.setLeft( '0px' );
......@@ -216,7 +214,7 @@
} else {
loader.loadLocalStorage();
editor.loader.loadLocalStorage();
}
......
......@@ -33,6 +33,8 @@ var Editor = function () {
};
this.loader = new Loader( this );
this.scene = new THREE.Scene();
this.sceneHelpers = new THREE.Scene();
......
......@@ -13,14 +13,7 @@ var Loader = function ( editor ) {
document.addEventListener( 'drop', function ( event ) {
event.preventDefault();
var file = event.dataTransfer.files[ 0 ];
var chunks = file.name.split( '.' );
var extension = chunks.pop().toLowerCase();
var filename = chunks.join( '.' );
scope.parseFile( file, filename, extension );
scope.loadFile( event.dataTransfer.files[ 0 ] );
}, false );
......@@ -57,7 +50,10 @@ var Loader = function ( editor ) {
signals.objectChanged.add( this.saveLocalStorage );
signals.objectRemoved.add( this.saveLocalStorage );
this.parseFile = function ( file, filename, extension ) {
this.loadFile = function ( file ) {
var filename = file.name;
var extension = filename.split( '.' ).pop().toLowerCase();
switch ( extension ) {
......@@ -306,6 +302,12 @@ var Loader = function ( editor ) {
break;
default:
alert( 'Unsupported file format.' );
break;
}
}
......
......@@ -19,21 +19,11 @@ Menubar.File = function ( editor ) {
options.setDisplay( 'none' );
container.add( options );
/*
// open
// new
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Open' );
option.onClick( function () { alert( 'Open' ) } );
options.add( option );
*/
// reset
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Reset' );
option.setTextContent( 'New' );
option.onClick( function () {
if ( confirm( 'Are you sure?' ) ) {
......@@ -54,16 +44,22 @@ Menubar.File = function ( editor ) {
options.add( new UI.HorizontalRule() );
// share
// import
var input = document.createElement( 'input' );
input.type = 'file';
input.addEventListener( 'change', function ( event ) {
editor.loader.loadFile( input.files[ 0 ] );
} );
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Share' );
option.setTextContent( 'Import' );
option.onClick( function () {
var exporter = new THREE.ObjectExporter();
var string = JSON.stringify( exporter.parse( editor.scene ) );
window.location.hash = 'A/' + window.btoa( RawDeflate.deflate( string ) );
input.click();
} );
options.add( option );
......@@ -201,6 +197,24 @@ Menubar.File = function ( editor ) {
};
options.add( new UI.HorizontalRule() );
// share
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Share' );
option.onClick( function () {
var exporter = new THREE.ObjectExporter();
var string = JSON.stringify( exporter.parse( editor.scene ) );
window.location.hash = 'A/' + window.btoa( RawDeflate.deflate( string ) );
} );
options.add( option );
return container;
}
......@@ -119,7 +119,8 @@ var Viewport = function ( editor ) {
if ( object.userData.object !== undefined ) {
// helper
editor.select( object.userData.object );
} else {
......
......@@ -364,6 +364,7 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
this.detach = function ( object ) {
this.object = undefined;
this.hovered = false;
this.hide();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册