Browse Source

Merge pull request #12036 from fernandojsg/alphaCut

GLTF Added alphaCutoff support in exporter and loader
Mr.doob 8 years ago
parent
commit
72afe269c0
2 changed files with 13 additions and 1 deletions
  1. 7 1
      examples/js/exporters/GLTFExporter.js
  2. 6 0
      examples/js/loaders/GLTFLoader.js

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

@@ -555,7 +555,13 @@ THREE.GLTFExporter.prototype = {
 			// alphaMode
 			if ( material.transparent ) {
 
-				gltfMaterial.alphaMode = 'BLEND'; // @FIXME We should detect MASK or BLEND
+				gltfMaterial.alphaMode = 'MASK'; // @FIXME We should detect MASK or BLEND
+
+				if ( material.alphaTest !== 0.5 ) {
+
+					gltfMaterial.alphaCutoff = material.alphaTest;
+
+				}
 
 			}
 

+ 6 - 0
examples/js/loaders/GLTFLoader.js

@@ -1603,6 +1603,12 @@ THREE.GLTFLoader = ( function () {
 
 				materialParams.transparent = true;
 
+				if ( alphaMode === ALPHA_MODES.MASK ) {
+
+				  materialParams.alphaTest = material.alphaCutoff || 0.5;
+
+				}
+
 			} else {
 
 				materialParams.transparent = false;