Browse Source

Addes support for THREE.Group

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

+ 10 - 5
examples/gltf_exporter.html

@@ -64,6 +64,7 @@
 
 				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
 				camera.position.y = 400;
+				camera.name = "PerspectiveCamera";
 
 				scene1 = new THREE.Scene();
 				scene1.name = 'Scene1';
@@ -147,20 +148,24 @@
 				object.add( object2 );
 */
 
-				object = new THREE.Group();
-				object.name = "Group";
-				scene1.add( object );
+				group1 = new THREE.Group();
+				group1.name = "Group";
+				scene1.add( group1 );
+
+				group2 = new THREE.Group();
+				group2.name = "subGroup";
+				group1.add( group2 );
 
 				object2 = new THREE.Mesh( new THREE.BoxBufferGeometry( 30, 30, 30 ), material );
 				object2.name = "Cube in group";
 				object2.position.set( 0, 100, 100 );
-				object.add( object2 );
-
+				group2.add( object2 );
 
 				scene1.add( camera );
 
 				var cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10, 10 );
 				scene1.add( cameraOrtho );
+				cameraOrtho.name = 'OrthographicCamera';
 
 /*
 				object = new THREE.Mesh( new THREE.CircleGeometry( 50, 20, 0, Math.PI * 2 ), material );

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

@@ -544,7 +544,7 @@ THREE.GLTFExporter.prototype = {
 
 				for ( var i = 0, l = object.children.length; i < l; i ++ ) {
 					var child = object.children[ i ];
-					if ( child instanceof THREE.Mesh ) {
+					if ( child instanceof THREE.Mesh || child instanceof THREE.Camera || child instanceof THREE.Group ) {
 						gltfNode.children.push( processNode( child ) );
 					}
 				}
@@ -580,7 +580,7 @@ THREE.GLTFExporter.prototype = {
 				var child = scene.children[ i ];
 
 				// @TODO Right now we just process meshes and lights
-				if ( child instanceof THREE.Mesh || child instanceof THREE.Camera ) {
+				if ( child instanceof THREE.Mesh || child instanceof THREE.Camera || child instanceof THREE.Group ) {
 					gltfScene.nodes.push( processNode( child ) );
 				}
 			}