Browse Source

Merge pull request #12037 from fernandojsg/nodes

GLTFExporter: fix nodes filter
Mr.doob 8 years ago
parent
commit
54b6db5379
2 changed files with 21 additions and 16 deletions
  1. 15 13
      examples/js/exporters/GLTFExporter.js
  2. 6 3
      examples/misc_exporter_gltf.html

+ 15 - 13
examples/js/exporters/GLTFExporter.js

@@ -756,6 +756,13 @@ THREE.GLTFExporter.prototype = {
 		 */
 		function processNode ( object ) {
 
+			if ( object instanceof THREE.Light ) {
+
+				console.warn( 'GLTFExporter: Unsupported node type:', object.constructor.name );
+				return false;
+
+			}
+
 			if ( !outputJSON.nodes ) {
 
 				outputJSON.nodes = [];
@@ -841,13 +848,11 @@ THREE.GLTFExporter.prototype = {
 
 					if ( child.visible || options.onlyVisible === false ) {
 
-						if ( child instanceof THREE.Mesh ||
-							child instanceof THREE.Camera ||
-							child instanceof THREE.Group ||
-							child instanceof THREE.Line ||
-							child instanceof THREE.Points) {
+						var node = processNode( child );
+
+						if ( node !== false ) {
 
-							children.push( processNode( child ) );
+							children.push( node );
 
 						}
 
@@ -905,14 +910,11 @@ THREE.GLTFExporter.prototype = {
 
 				if ( child.visible || options.onlyVisible === false ) {
 
-					// @TODO We don't process lights yet
-					if ( child instanceof THREE.Mesh ||
-						child instanceof THREE.Camera ||
-						child instanceof THREE.Group ||
-						child instanceof THREE.Line ||
-						child instanceof THREE.Points) {
+					var node = processNode( child );
+
+					if ( node !== false ) {
 
-						nodes.push( processNode( child ) );
+						nodes.push( node );
 
 					}
 

+ 6 - 3
examples/misc_exporter_gltf.html

@@ -115,7 +115,7 @@
 
 			var container;
 
-			var camera, scene1, scene2, renderer;
+			var camera, object, scene1, scene2, renderer;
 			var gridHelper, sphere;
 
 			init();
@@ -141,13 +141,16 @@
 				// ---------------------------------------------------------------------
 				// Ambient light
 				// ---------------------------------------------------------------------
-				scene1.add( new THREE.AmbientLight( 0xffffff, 0.2 ) );
+				var light = new THREE.AmbientLight( 0xffffff, 0.2 );
+				light.name = 'AmbientLight';
+				scene1.add( light );
 
 				// ---------------------------------------------------------------------
 				// DirectLight
 				// ---------------------------------------------------------------------
-				var light = new THREE.DirectionalLight( 0xffffff, 1 );
+				light = new THREE.DirectionalLight( 0xffffff, 1 );
 				light.position.set( 1, 1, 0 );
+				light.name = 'DirectionalLight';
 				scene1.add( light );
 
 				// ---------------------------------------------------------------------