Browse Source

Started SceneExporter2.

Mr.doob 12 years ago
parent
commit
d2aed74fa2

+ 1 - 0
editor/index.html

@@ -81,6 +81,7 @@
 		<script src="../examples/js/loaders/ctm/CTMLoader.js"></script>
 		<script src="../examples/js/exporters/GeometryExporter.js"></script>
 		<script src="../examples/js/exporters/SceneExporter.js"></script>
+		<script src="../examples/js/exporters/SceneExporter2.js"></script>
 		<script src="../examples/js/exporters/OBJExporter.js"></script>
 
 		<script src="js/libs/signals.min.js"></script>

+ 9 - 1
editor/js/ui/Menubar.File.js

@@ -46,7 +46,15 @@ Menubar.File = function ( signals ) {
 	var option = new UI.Panel();
 	option.setClass( 'option' );
 	option.setTextContent( 'Export Scene' );
-	option.onClick( function () { signals.exportScene.dispatch(); } );
+	option.onClick( function () { signals.exportScene.dispatch( { exporter: THREE.SceneExporter } ); } );
+	options.add( option );
+
+	// export scene 2
+
+	var option = new UI.Panel();
+	option.setClass( 'option' );
+	option.setTextContent( 'Export Scene 2' );
+	option.onClick( function () { signals.exportScene.dispatch( { exporter: THREE.SceneExporter2 } ); } );
 	options.add( option );
 
 	// export OBJ

+ 5 - 3
editor/js/ui/Viewport.js

@@ -676,7 +676,8 @@ var Viewport = function ( signals ) {
 
 		}
 
-		var output = new object.exporter().parse( selected.geometry );
+		var exporter = new object.exporter();
+		var output = exporter.parse( selected.geometry );
 
 		var blob = new Blob( [ output ], { type: 'text/plain' } );
 		var objectURL = URL.createObjectURL( blob );
@@ -686,9 +687,10 @@ var Viewport = function ( signals ) {
 
 	} );
 
-	signals.exportScene.add( function () {
+	signals.exportScene.add( function ( object ) {
 
-		var output = new THREE.SceneExporter().parse( scene );
+		var exporter = new object.exporter();
+		var output = exporter.parse( scene );
 
 		var blob = new Blob( [ output ], { type: 'text/plain' } );
 		var objectURL = URL.createObjectURL( blob );

+ 27 - 0
examples/js/exporters/SceneExporter2.js

@@ -0,0 +1,27 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.SceneExporter2 = function () {};
+
+THREE.SceneExporter2.prototype = {
+
+	constructor: THREE.SceneExporter2,
+
+	parse: function ( scene ) {
+
+		var output = {
+			metadata: {
+				formatVersion : 4.0,
+				type : "scene",
+				generatedBy : "SceneExporter2"
+			}
+		};
+
+		console.log( scene );
+
+		return JSON.stringify( output );
+
+	}
+
+}