Преглед изворни кода

Merge pull request #11971 from fernandojsg/noShaderMaterial

GLTFExporter: prevent exporting ShaderMaterial
Mr.doob пре 8 година
родитељ
комит
f5fa63a856
1 измењених фајлова са 17 додато и 2 уклоњено
  1. 17 2
      examples/js/exporters/GLTFExporter.js

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

@@ -387,9 +387,17 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
+			if ( material instanceof THREE.ShaderMaterial ) {
+
+				console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' );
+				return null;
+
+			}
+
+
 			if ( !( material instanceof THREE.MeshStandardMaterial ) ) {
 
-				console.warn( 'Currently just THREE.StandardMaterial is supported. Material conversion may lose information.' );
+				console.warn( 'GLTFExporter: Currently just THREE.StandardMaterial is supported. Material conversion may lose information.' );
 
 			}
 
@@ -576,11 +584,18 @@ THREE.GLTFExporter.prototype = {
 					{
 						mode: mode,
 						attributes: {},
-						material: processMaterial( mesh.material )
 					}
 				]
 			};
 
+			var material = processMaterial( mesh.material );
+			if ( material ) {
+
+				gltfMesh.primitives[ 0 ].material = material;
+
+			}
+
+
 			if ( geometry.index ) {
 
 				gltfMesh.primitives[ 0 ].indices = processAccessor( geometry.index );