123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- Menubar.Edit = function ( editor ) {
- var container = new UI.Panel();
- container.setClass( 'menu' );
- var title = new UI.Panel();
- title.setClass( 'title' );
- title.setTextContent( 'Edit' );
- container.add( title );
- var options = new UI.Panel();
- options.setClass( 'options' );
- container.add( options );
- // Clone
- var option = new UI.Panel();
- option.setClass( 'option' );
- option.setTextContent( 'Clone' );
- option.onClick( function () {
- var object = editor.selected;
- if ( object.parent === undefined ) return; // avoid cloning the camera or scene
- object = object.clone();
- editor.addObject( object );
- editor.select( object );
- } );
- options.add( option );
- // Delete
- var option = new UI.Panel();
- option.setClass( 'option' );
- option.setTextContent( 'Delete' );
- option.onClick( function () {
- var parent = editor.selected.parent;
- editor.removeObject( editor.selected );
- editor.select( parent );
- } );
- options.add( option );
- //
- options.add( new UI.HorizontalRule() );
- // Convert
- var option = new UI.Panel();
- option.setClass( 'option' );
- option.setTextContent( 'Convert' );
- option.onClick( function () {
- // convert to BufferGeometry
-
- var object = editor.selected;
- if ( object.geometry instanceof THREE.Geometry ) {
- if ( object.parent === undefined ) return; // avoid flattening the camera or scene
- if ( confirm( 'Convert ' + object.name + ' to BufferGeometry?' ) === false ) return;
- object.geometry = new THREE.BufferGeometry().fromGeometry( object.geometry );
- editor.signals.objectChanged.dispatch( object );
- }
- } );
- options.add( option );
- // Flatten
- var option = new UI.Panel();
- option.setClass( 'option' );
- option.setTextContent( 'Flatten' );
- option.onClick( function () {
- var object = editor.selected;
- if ( object.parent === undefined ) return; // avoid flattening the camera or scene
- if ( confirm( 'Flatten ' + object.name + '?' ) === false ) return;
- var geometry = object.geometry.clone();
- geometry.applyMatrix( object.matrix );
- object.geometry = geometry;
- object.position.set( 0, 0, 0 );
- object.rotation.set( 0, 0, 0 );
- object.scale.set( 1, 1, 1 );
-
- object.geometry.buffersNeedUpdate = true;
- editor.signals.objectChanged.dispatch( object );
- } );
- options.add( option );
- return container;
- };
|