Browse Source

Editor: Fixed GLTFExporter alphaMode handling.

Mr.doob 6 years ago
parent
commit
9e0ac8d17c
3 changed files with 21 additions and 17 deletions
  1. 1 1
      editor/sw.js
  2. 10 8
      examples/js/exporters/GLTFExporter.js
  3. 10 8
      examples/jsm/exporters/GLTFExporter.js

+ 1 - 1
editor/sw.js

@@ -1,4 +1,4 @@
-// r108
+// r108.1
 
 const staticAssets = [
 	'./',

+ 10 - 8
examples/js/exporters/GLTFExporter.js

@@ -961,11 +961,11 @@ THREE.GLTFExporter.prototype = {
 
 			// pbrSpecularGlossiness diffuse, specular and glossiness factor
 			if ( material.isGLTFSpecularGlossinessMaterial ) {
-				
+
 				if ( gltfMaterial.pbrMetallicRoughness.baseColorFactor ) {
 
 					gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseFactor = gltfMaterial.pbrMetallicRoughness.baseColorFactor;
-				  
+
 				}
 
 				var specularFactor = [ 1, 1, 1 ];
@@ -973,7 +973,7 @@ THREE.GLTFExporter.prototype = {
 				gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularFactor = specularFactor;
 
 				gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.glossinessFactor = material.glossiness;
-			
+
 			}
 
 			// pbrMetallicRoughness.metallicRoughnessTexture
@@ -1006,7 +1006,7 @@ THREE.GLTFExporter.prototype = {
 				}
 
 				gltfMaterial.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
-				
+
 			}
 
 			// pbrSpecularGlossiness specular map
@@ -1088,13 +1088,15 @@ THREE.GLTFExporter.prototype = {
 			}
 
 			// alphaMode
-			if ( material.transparent || material.alphaTest > 0.0 ) {
+			if ( material.transparent ) {
+
+				gltfMaterial.alphaMode = 'BLEND';
 
-				gltfMaterial.alphaMode = material.opacity < 1.0 ? 'BLEND' : 'MASK';
+			} else {
 
-				// Write alphaCutoff if it's non-zero and different from the default (0.5).
-				if ( material.alphaTest > 0.0 && material.alphaTest !== 0.5 ) {
+				if ( material.alphaTest > 0.0 ) {
 
+					gltfMaterial.alphaMode = 'MASK';
 					gltfMaterial.alphaCutoff = material.alphaTest;
 
 				}

+ 10 - 8
examples/jsm/exporters/GLTFExporter.js

@@ -985,11 +985,11 @@ GLTFExporter.prototype = {
 
 			// pbrSpecularGlossiness diffuse, specular and glossiness factor
 			if ( material.isGLTFSpecularGlossinessMaterial ) {
-				
+
 				if ( gltfMaterial.pbrMetallicRoughness.baseColorFactor ) {
 
 					gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseFactor = gltfMaterial.pbrMetallicRoughness.baseColorFactor;
-				  
+
 				}
 
 				var specularFactor = [ 1, 1, 1 ];
@@ -997,7 +997,7 @@ GLTFExporter.prototype = {
 				gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularFactor = specularFactor;
 
 				gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.glossinessFactor = material.glossiness;
-			
+
 			}
 
 			// pbrMetallicRoughness.metallicRoughnessTexture
@@ -1030,7 +1030,7 @@ GLTFExporter.prototype = {
 				}
 
 				gltfMaterial.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
-				
+
 			}
 
 			// pbrSpecularGlossiness specular map
@@ -1112,13 +1112,15 @@ GLTFExporter.prototype = {
 			}
 
 			// alphaMode
-			if ( material.transparent || material.alphaTest > 0.0 ) {
+			if ( material.transparent ) {
+
+				gltfMaterial.alphaMode = 'BLEND';
 
-				gltfMaterial.alphaMode = material.opacity < 1.0 ? 'BLEND' : 'MASK';
+			} else {
 
-				// Write alphaCutoff if it's non-zero and different from the default (0.5).
-				if ( material.alphaTest > 0.0 && material.alphaTest !== 0.5 ) {
+				if ( material.alphaTest > 0.0 ) {
 
+					gltfMaterial.alphaMode = 'MASK';
 					gltfMaterial.alphaCutoff = material.alphaTest;
 
 				}