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

Editor improvements and fixes.

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