1 | Menubar.Edit = function ( editor ) {
|
---|
2 |
|
---|
3 | var container = new UI.Panel();
|
---|
4 | container.setClass( 'menu' );
|
---|
5 |
|
---|
6 | var title = new UI.Panel();
|
---|
7 | title.setTextContent( 'Edit' );
|
---|
8 | title.setMargin( '0px' );
|
---|
9 | title.setPadding( '8px' );
|
---|
10 | container.add( title );
|
---|
11 |
|
---|
12 | //
|
---|
13 |
|
---|
14 | var options = new UI.Panel();
|
---|
15 | options.setClass( 'options' );
|
---|
16 | container.add( options );
|
---|
17 |
|
---|
18 | // clone
|
---|
19 |
|
---|
20 | var option = new UI.Panel();
|
---|
21 | option.setClass( 'option' );
|
---|
22 | option.setTextContent( 'Clone' );
|
---|
23 | option.onClick( function () {
|
---|
24 |
|
---|
25 | var object = editor.selected;
|
---|
26 |
|
---|
27 | if ( object.parent === undefined ) return; // avoid cloning the camera or scene
|
---|
28 |
|
---|
29 | object = object.clone();
|
---|
30 |
|
---|
31 | editor.addObject( object );
|
---|
32 | editor.select( object );
|
---|
33 |
|
---|
34 | } );
|
---|
35 | options.add( option );
|
---|
36 |
|
---|
37 | // delete
|
---|
38 |
|
---|
39 | var option = new UI.Panel();
|
---|
40 | option.setClass( 'option' );
|
---|
41 | option.setTextContent( 'Delete' );
|
---|
42 | option.onClick( function () {
|
---|
43 |
|
---|
44 | editor.removeObject( editor.selected );
|
---|
45 | editor.deselect();
|
---|
46 |
|
---|
47 | } );
|
---|
48 | options.add( option );
|
---|
49 |
|
---|
50 | options.add( new UI.HorizontalRule() );
|
---|
51 |
|
---|
52 | // convert to BufferGeometry
|
---|
53 |
|
---|
54 | var option = new UI.Panel();
|
---|
55 | option.setClass( 'option' );
|
---|
56 | option.setTextContent( 'Convert' );
|
---|
57 | option.onClick( function () {
|
---|
58 |
|
---|
59 | var object = editor.selected;
|
---|
60 |
|
---|
61 | if ( object.geometry instanceof THREE.Geometry ) {
|
---|
62 |
|
---|
63 | if ( object.parent === undefined ) return; // avoid flattening the camera or scene
|
---|
64 |
|
---|
65 | if ( confirm( 'Convert ' + object.name + ' to BufferGeometry?' ) === false ) return;
|
---|
66 |
|
---|
67 | delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
|
---|
68 |
|
---|
69 | object.geometry = THREE.BufferGeometryUtils.fromGeometry( object.geometry );
|
---|
70 |
|
---|
71 | editor.signals.objectChanged.dispatch( object );
|
---|
72 |
|
---|
73 | }
|
---|
74 |
|
---|
75 | } );
|
---|
76 | options.add( option );
|
---|
77 |
|
---|
78 | // flatten
|
---|
79 |
|
---|
80 | var option = new UI.Panel();
|
---|
81 | option.setClass( 'option' );
|
---|
82 | option.setTextContent( 'Flatten' );
|
---|
83 | option.onClick( function () {
|
---|
84 |
|
---|
85 | var object = editor.selected;
|
---|
86 |
|
---|
87 | if ( object.parent === undefined ) return; // avoid flattening the camera or scene
|
---|
88 |
|
---|
89 | if ( confirm( 'Flatten ' + object.name + '?' ) === false ) return;
|
---|
90 |
|
---|
91 | delete object.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
|
---|
92 |
|
---|
93 | var geometry = object.geometry.clone();
|
---|
94 | geometry.applyMatrix( object.matrix );
|
---|
95 |
|
---|
96 | object.geometry = geometry;
|
---|
97 |
|
---|
98 | object.position.set( 0, 0, 0 );
|
---|
99 | object.rotation.set( 0, 0, 0 );
|
---|
100 | object.scale.set( 1, 1, 1 );
|
---|
101 |
|
---|
102 | editor.signals.objectChanged.dispatch( object );
|
---|
103 |
|
---|
104 | } );
|
---|
105 | options.add( option );
|
---|
106 |
|
---|
107 |
|
---|
108 | //
|
---|
109 |
|
---|
110 | return container;
|
---|
111 |
|
---|
112 | }
|
---|