Menubar.Edit.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Menubar.Edit = function ( editor ) {
  5. var container = new UI.Panel();
  6. container.setClass( 'menu' );
  7. var title = new UI.Panel();
  8. title.setClass( 'title' );
  9. title.setTextContent( 'Edit' );
  10. container.add( title );
  11. var options = new UI.Panel();
  12. options.setClass( 'options' );
  13. container.add( options );
  14. // Clone
  15. var option = new UI.Panel();
  16. option.setClass( 'option' );
  17. option.setTextContent( 'Clone' );
  18. option.onClick( function () {
  19. var object = editor.selected;
  20. if ( object.parent === undefined ) return; // avoid cloning the camera or scene
  21. object = object.clone();
  22. editor.addObject( object );
  23. editor.select( object );
  24. } );
  25. options.add( option );
  26. // Delete
  27. var option = new UI.Panel();
  28. option.setClass( 'option' );
  29. option.setTextContent( 'Delete' );
  30. option.onClick( function () {
  31. var object = editor.selected;
  32. if ( confirm( 'Delete ' + object.name + '?' ) === false ) return;
  33. var parent = object.parent;
  34. editor.removeObject( object );
  35. editor.select( parent );
  36. } );
  37. options.add( option );
  38. return container;
  39. };