Explorar o código

Merge pull request #12692 from donmccurdy/feat-gltfexporter-alphamodes

GLTFExporter: Improve alphaMode support.
Mr.doob %!s(int64=7) %!d(string=hai) anos
pai
achega
1e1dd475e0
Modificáronse 1 ficheiros con 8 adicións e 7 borrados
  1. 8 7
      examples/js/exporters/GLTFExporter.js

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

@@ -529,7 +529,7 @@ THREE.GLTFExporter.prototype = {
 
 
 				gltfMaterial.pbrMetallicRoughness.baseColorTexture = {
 				gltfMaterial.pbrMetallicRoughness.baseColorTexture = {
 
 
-					index: processTexture( material.map )
+					index: processTexture( material.map )
 
 
 				};
 				};
 
 
@@ -555,7 +555,7 @@ THREE.GLTFExporter.prototype = {
 
 
 					gltfMaterial.emissiveTexture = {
 					gltfMaterial.emissiveTexture = {
 
 
-						index: processTexture( material.emissiveMap )
+						index: processTexture( material.emissiveMap )
 
 
 					};
 					};
 
 
@@ -568,7 +568,7 @@ THREE.GLTFExporter.prototype = {
 
 
 				gltfMaterial.normalTexture = {
 				gltfMaterial.normalTexture = {
 
 
-					index: processTexture( material.normalMap )
+					index: processTexture( material.normalMap )
 
 
 				};
 				};
 
 
@@ -591,7 +591,7 @@ THREE.GLTFExporter.prototype = {
 
 
 				gltfMaterial.occlusionTexture = {
 				gltfMaterial.occlusionTexture = {
 
 
-					index: processTexture( material.aoMap )
+					index: processTexture( material.aoMap )
 
 
 				};
 				};
 
 
@@ -604,11 +604,12 @@ THREE.GLTFExporter.prototype = {
 			}
 			}
 
 
 			// alphaMode
 			// alphaMode
-			if ( material.transparent ) {
+			if ( material.transparent || material.alphaTest > 0.0 ) {
 
 
-				gltfMaterial.alphaMode = 'MASK'; // @FIXME We should detect MASK or BLEND
+				gltfMaterial.alphaMode = material.opacity < 1.0 ? 'BLEND' : 'MASK';
 
 
-				if ( material.alphaTest !== 0.5 ) {
+				// Write alphaCutoff if it's non-zero and different from the default (0.5).
+				if ( material.alphaTest > 0.0 && material.alphaTest !== 0.5 ) {
 
 
 					gltfMaterial.alphaCutoff = material.alphaTest;
 					gltfMaterial.alphaCutoff = material.alphaTest;