diff --git a/editor/index.html b/editor/index.html
index 4e9c9d4c220f2f974fb57f7e8c2a439c48e9332b..93f59b233e22ac5334f884550ffc2638c730af94 100644
--- a/editor/index.html
+++ b/editor/index.html
@@ -144,6 +144,7 @@
// actions
+ flattenSelectedObject: new SIGNALS.Signal(),
cloneSelectedObject: new SIGNALS.Signal(),
removeSelectedObject: new SIGNALS.Signal(),
playAnimations: new SIGNALS.Signal(),
diff --git a/editor/js/Menubar.Edit.js b/editor/js/Menubar.Edit.js
index 5edc2330fd7033d3786852fac6f68d25120db067..fd2403705efe1380f314a691423d578e5b7351c0 100644
--- a/editor/js/Menubar.Edit.js
+++ b/editor/js/Menubar.Edit.js
@@ -19,6 +19,14 @@ Menubar.Edit = function ( signals ) {
options.setDisplay( 'none' );
container.add( options );
+ // flatten
+
+ var option = new UI.Panel();
+ option.setClass( 'option' );
+ option.setTextContent( 'Flatten' );
+ option.onClick( function () { signals.flattenSelectedObject.dispatch(); } );
+ options.add( option );
+
// clone
var option = new UI.Panel();
diff --git a/editor/js/Sidebar.Geometry.js b/editor/js/Sidebar.Geometry.js
index b5e7eac5bcc16dc27b6a20a92fea0e279bba6b86..e4001dd80e4ce8a498d89b7cc893624bec546d6c 100644
--- a/editor/js/Sidebar.Geometry.js
+++ b/editor/js/Sidebar.Geometry.js
@@ -82,7 +82,7 @@ Sidebar.Geometry = function ( signals ) {
}
- signals.objectSelected.add( function ( object ) {
+ function build( object ) {
if ( object && object.geometry ) {
@@ -148,17 +148,10 @@ Sidebar.Geometry = function ( signals ) {
}
- } );
-
- signals.objectChanged.add( function ( object ) {
-
- if ( object && object.geometry ) {
-
- updateFields( object.geometry );
-
- }
+ }
- } );
+ signals.objectSelected.add( build );
+ signals.objectChanged.add( build );
//
diff --git a/editor/js/Viewport.js b/editor/js/Viewport.js
index 52ea5fa7a0d1eb1eba7e16f557844bcf8fb7aa66..b98903ff30cd675125a3e9e94ab145dd921af553 100644
--- a/editor/js/Viewport.js
+++ b/editor/js/Viewport.js
@@ -346,6 +346,27 @@ var Viewport = function ( signals ) {
} );
+ signals.flattenSelectedObject.add( function () {
+
+ var name = selected.name ? '"' + selected.name + '"': "selected object";
+
+ if ( confirm( 'Flatten ' + name + '?' ) === false ) return;
+
+ delete selected.__webglInit; // TODO: Remove hack (WebGLRenderer refactoring)
+
+ var geometry = selected.geometry.clone();
+ geometry.applyMatrix( selected.matrix );
+
+ selected.setGeometry( geometry );
+
+ selected.position.set( 0, 0, 0 );
+ selected.rotation.set( 0, 0, 0 );
+ selected.scale.set( 1, 1, 1 );
+
+ signals.objectChanged.dispatch( selected );
+
+ } );
+
signals.cloneSelectedObject.add( function () {
if ( selected === camera ) return;