浏览代码

Editor: Added Edit/Flatten.

Mr.doob 12 年之前
父节点
当前提交
647fd93ddd
共有 4 个文件被更改,包括 34 次插入11 次删除
  1. 1 0
      editor/index.html
  2. 8 0
      editor/js/Menubar.Edit.js
  3. 4 11
      editor/js/Sidebar.Geometry.js
  4. 21 0
      editor/js/Viewport.js

+ 1 - 0
editor/index.html

@@ -144,6 +144,7 @@
 
 
 				// actions
 				// actions
 
 
+				flattenSelectedObject: new SIGNALS.Signal(),
 				cloneSelectedObject: new SIGNALS.Signal(),
 				cloneSelectedObject: new SIGNALS.Signal(),
 				removeSelectedObject: new SIGNALS.Signal(),
 				removeSelectedObject: new SIGNALS.Signal(),
 				playAnimations: new SIGNALS.Signal(),
 				playAnimations: new SIGNALS.Signal(),

+ 8 - 0
editor/js/Menubar.Edit.js

@@ -19,6 +19,14 @@ Menubar.Edit = function ( signals ) {
 	options.setDisplay( 'none' );
 	options.setDisplay( 'none' );
 	container.add( options );
 	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
 	// clone
 
 
 	var option = new UI.Panel();
 	var option = new UI.Panel();

+ 4 - 11
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 ) {
 		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 );
 
 
 	//
 	//
 
 

+ 21 - 0
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 () {
 	signals.cloneSelectedObject.add( function () {
 
 
 		if ( selected === camera ) return;
 		if ( selected === camera ) return;