Browse Source

Editor: refactored active camera handling for scene exporter (thanks to @mrdoob).

And menubar hover thingies are back ;)

See discussion in https://github.com/alteredq/three.js/commit/fe902e553f5e30e3752398ad1588bcc4ea1f5513
alteredq 12 years ago
parent
commit
15283f7e0f

+ 10 - 11
editor/index.html

@@ -81,17 +81,6 @@
 
 			//
 
-			var menubar = new Menubar( signals );
-			menubar.setWidth( '100%' );
-			menubar.setHeight( '32px' );
-			document.body.appendChild( menubar.dom );
-
-			var sidebar = new Sidebar( signals );
-			sidebar.setLeft( '-webkit-calc(100% - 300px)', '-moz-calc(100% - 300px)', 'calc(100% - 300px)' );
-			sidebar.setTop( '32px' );
-			sidebar.setHeight( '-webkit-calc(100% - 32px)', '-moz-calc(100% - 32px)', 'calc(100% - 32px)' );
-			document.body.appendChild( sidebar.dom );
-
 			var viewport = new Viewport( signals );
 			viewport.setTop( '32px' );
 			viewport.setWidth( '-webkit-calc(100% - 300px)', '-moz-calc(100% - 300px)', 'calc(100% - 300px)' );
@@ -103,6 +92,16 @@
 
 			viewport.dom.focus();
 
+			var menubar = new Menubar( signals );
+			menubar.setWidth( '100%' );
+			menubar.setHeight( '32px' );
+			document.body.appendChild( menubar.dom );
+
+			var sidebar = new Sidebar( signals );
+			sidebar.setLeft( '-webkit-calc(100% - 300px)', '-moz-calc(100% - 300px)', 'calc(100% - 300px)' );
+			sidebar.setTop( '32px' );
+			sidebar.setHeight( '-webkit-calc(100% - 32px)', '-moz-calc(100% - 32px)', 'calc(100% - 32px)' );
+			document.body.appendChild( sidebar.dom );
 
 			document.addEventListener( 'drop', function ( event ) {
 

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

@@ -25,8 +25,6 @@ Sidebar.Outliner = function ( signals ) {
 
 	var scene = null;
 
-	var activeCamera = null;
-
 	var clearColor = new THREE.Color( 0xaaaaaa );
 	var clearAlpha = 1;
 
@@ -101,15 +99,10 @@ Sidebar.Outliner = function ( signals ) {
 
 	} );
 
-	signals.cameraChanged.add( function ( camera ) {
-
-		activeCamera = camera;
-
-	} );
 
 	function exportScene() {
 
-		var output = new THREE.SceneExporter().parse( scene, clearColor, clearAlpha, activeCamera );
+		var output = new THREE.SceneExporter().parse( scene, clearColor, clearAlpha );
 
 		var blob = new Blob( [ output ], { type: 'text/plain' } );
 		var objectURL = URL.createObjectURL( blob );

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

@@ -79,6 +79,10 @@ var Viewport = function ( signals ) {
 	light2.target.name = "Light 2 Target";
 	signals.sceneChanged.dispatch( scene );
 
+	// active objects
+
+	camera.properties.active = true;
+
 	// object picking
 
 	var intersectionPlane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ) );

+ 14 - 2
examples/js/exporters/SceneExporter.js

@@ -8,7 +8,7 @@ THREE.SceneExporter.prototype = {
 
 	constructor: THREE.SceneExporter,
 
-	parse: function ( scene, clearColor, clearAlpha, activeCamera ) {
+	parse: function ( scene, clearColor, clearAlpha ) {
 
 		var position = Vector3String( scene.position );
 		var rotation = Vector3String( scene.rotation );
@@ -139,9 +139,21 @@ THREE.SceneExporter.prototype = {
 
 		// generate defaults
 
+		var activeCamera = null;
+
+		scene.traverse( function ( node ) {
+
+			if ( node instanceof THREE.Camera && node.properties.active ) {
+
+				activeCamera = node;
+
+			}
+
+		} );
+
 		var bgcolor = ColorString( clearColor );
 		var bgalpha = clearAlpha;
-		var defcamera = LabelString( getObjectName( activeCamera ) );
+		var defcamera = LabelString( activeCamera ? getObjectName( activeCamera ) : "" );
 		var deffog = LabelString( scene.fog ? getFogName( scene.fog ) : "" );
 
 		// templates