提交 4d6c6790 编写于 作者: M Mr.doob

Editor: Notify user that no object has been selected when exporting geometry. Fixes #4295.

上级 8bb0c809
......@@ -292,7 +292,17 @@ Editor.prototype = {
select: function ( object ) {
this.selected = object;
this.config.setKey( 'selected', object.uuid );
if ( object !== null ) {
this.config.setKey( 'selected', object.uuid );
} else {
this.config.setKey( 'selected', null );
}
this.signals.objectSelected.dispatch( object );
},
......
......@@ -69,37 +69,37 @@ Menubar.File = function ( editor ) {
option.setTextContent( 'Export Geometry' );
option.onClick( function () {
var geometry = editor.selected.geometry;
var object = editor.selected;
if ( geometry instanceof THREE.BufferGeometry ) {
if ( object === null ) {
exportGeometry( THREE.BufferGeometryExporter );
alert( 'No object selected.' );
return;
} else if ( geometry instanceof THREE.Geometry ) {
}
exportGeometry( THREE.GeometryExporter );
var geometry = object.geometry;
if ( geometry === undefined ) {
alert( 'The selected object doesn\'t have geometry.' );
return;
}
} );
options.add( option );
if ( geometry instanceof THREE.BufferGeometry ) {
/*
exportGeometry( THREE.BufferGeometryExporter );
// export scene
} else if ( geometry instanceof THREE.Geometry ) {
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Export Scene' );
option.onClick( function () {
exportGeometry( THREE.GeometryExporter );
exportScene( THREE.SceneExporter );
}
} );
options.add( option );
*/
// export object
var option = new UI.Panel();
......@@ -107,6 +107,13 @@ Menubar.File = function ( editor ) {
option.setTextContent( 'Export Object' );
option.onClick( function () {
if ( editor.selected === null ) {
alert( 'No object selected' );
return;
}
exportObject( THREE.ObjectExporter );
} );
......@@ -139,19 +146,12 @@ Menubar.File = function ( editor ) {
var exportGeometry = function ( exporterClass ) {
var object = editor.selected;
if ( object.geometry === undefined ) {
alert( "Selected object doesn't have any geometry" );
return;
}
var exporter = new exporterClass();
var output;
if ( exporter instanceof THREE.BufferGeometryExporter || exporter instanceof THREE.GeometryExporter ) {
if ( exporter instanceof THREE.BufferGeometryExporter ||
exporter instanceof THREE.GeometryExporter ) {
output = JSON.stringify( exporter.parse( object.geometry ), null, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
......@@ -172,9 +172,8 @@ Menubar.File = function ( editor ) {
var exportObject = function ( exporterClass ) {
var exporter = new exporterClass();
var object = editor.selected;
var exporter = new exporterClass();
var output = JSON.stringify( exporter.parse( object ), null, '\t' );
output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
......
......@@ -139,7 +139,7 @@ var Viewport = function ( editor ) {
} else {
editor.select( camera );
editor.select( null );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册