123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- Menubar.Edit = function ( editor ) {
- var container = new UI.Panel();
- container.setClass( 'menu' );
- var title = new UI.Panel();
- title.setTextContent( 'Edit' );
- title.setMargin( '0px' );
- title.setPadding( '8px' );
- 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 () {
- editor.removeObject( editor.selected );
- editor.deselect();
- } );
- options.add( option );
- options.add( new UI.HorizontalRule() );
- // convert to BufferGeometry
- var option = new UI.Panel();
- option.setClass( 'option' );
- option.setTextContent( 'Convert' );
- option.onClick( function () {
- 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;
- delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
- object.geometry = THREE.BufferGeometryUtils.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;
- delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
- 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 );
- editor.signals.objectChanged.dispatch( object );
- } );
- options.add( option );
- //
- return container;
- }
|