Browse Source

Editor: moved scene export logic from Outliner to Viewport.

alteredq 12 years ago
parent
commit
7ab30ca13b
3 changed files with 17 additions and 10 deletions
  1. 1 0
      editor/index.html
  2. 1 10
      editor/js/ui/Sidebar.Outliner.js
  3. 15 0
      editor/js/ui/Viewport.js

+ 1 - 0
editor/index.html

@@ -61,6 +61,7 @@
 				// actions
 				// actions
 
 
 				removeSelectedObject: new SIGNALS.Signal(),
 				removeSelectedObject: new SIGNALS.Signal(),
+				exportScene: new SIGNALS.Signal(),
 
 
 				// notifications
 				// notifications
 
 

+ 1 - 10
editor/js/ui/Sidebar.Outliner.js

@@ -25,9 +25,6 @@ Sidebar.Outliner = function ( signals ) {
 
 
 	var scene = null;
 	var scene = null;
 
 
-	var clearColor = new THREE.Color( 0xaaaaaa );
-	var clearAlpha = 1;
-
 	function update() {
 	function update() {
 
 
 		var id = parseInt( sceneGraph.getValue() );
 		var id = parseInt( sceneGraph.getValue() );
@@ -102,13 +99,7 @@ Sidebar.Outliner = function ( signals ) {
 
 
 	function exportScene() {
 	function exportScene() {
 
 
-		var output = new THREE.SceneExporter().parse( scene, clearColor, clearAlpha );
-
-		var blob = new Blob( [ output ], { type: 'text/plain' } );
-		var objectURL = URL.createObjectURL( blob );
-
-		window.open( objectURL, '_blank' );
-		window.focus();
+		signals.exportScene.dispatch( scene );
 
 
 	}
 	}
 
 

+ 15 - 0
editor/js/ui/Viewport.js

@@ -488,6 +488,21 @@ var Viewport = function ( signals ) {
 
 
 	} );
 	} );
 
 
+	signals.exportScene.add( function ( root ) {
+
+		var clearColor = renderer.getClearColor();
+		var clearAlpha = renderer.getClearAlpha();
+
+		var output = new THREE.SceneExporter().parse( root, clearColor, clearAlpha );
+
+		var blob = new Blob( [ output ], { type: 'text/plain' } );
+		var objectURL = URL.createObjectURL( blob );
+
+		window.open( objectURL, '_blank' );
+		window.focus();
+
+	} );
+
 	//
 	//
 
 
 	var renderer = new THREE.WebGLRenderer( { antialias: true, alpha: false, clearColor: 0xaaaaaa, clearAlpha: 1 } );
 	var renderer = new THREE.WebGLRenderer( { antialias: true, alpha: false, clearColor: 0xaaaaaa, clearAlpha: 1 } );