Browse Source

Added support for multiple scenes

Fernando Serrano 8 years ago
parent
commit
c4fa2dd00b
2 changed files with 12 additions and 2 deletions
  1. 10 1
      examples/gltf_exporter.html
  2. 2 1
      examples/js/exporters/GLTFExporter.js

+ 10 - 1
examples/gltf_exporter.html

@@ -66,6 +66,7 @@
 				camera.position.y = 400;
 
 				scene = new THREE.Scene();
+				scene.name = 'Scene1';
 
 				var light, object;
 
@@ -188,8 +189,16 @@
 				scene.add( object );
 */
 
+				var scene2 = new THREE.Scene();
+				object = new THREE.Mesh( new THREE.BoxBufferGeometry( 100, 100, 100 ), material );
+				object.position.set( 0, 0, 0 );
+				object.name = "Cube2ndScene";
+				scene2.name = 'Scene2';
+				scene2.add(object);
+
+
 				var gltfExporter = new THREE.GLTFExporter();
-				gltfExporter.parse( scene, function( result ) {
+				gltfExporter.parse( [scene, scene2], function( result ) {
 					console.log( JSON.stringify( result, null, 2 ) );
 				} );
 

+ 2 - 1
examples/js/exporters/GLTFExporter.js

@@ -420,7 +420,8 @@ THREE.GLTFExporter.prototype = {
 		 * @param  {THREE.Scene} node Scene to process
 		 */
 		function processScene( scene ) {
-			if ( !outputJSON.scene ) {
+			console.log('Processing scene');
+			if ( !outputJSON.scenes ) {
 				outputJSON.scenes = [];
 				outputJSON.scene = 0;
 			}