瀏覽代碼

Fix vertex colors and alpha mode to conform with spec

Gary Hsu 8 年之前
父節點
當前提交
601edae397
共有 1 個文件被更改,包括 21 次插入16 次删除
  1. 21 16
      loaders/src/glTF/babylon.glTFFileLoader.ts

+ 21 - 16
loaders/src/glTF/babylon.glTFFileLoader.ts

@@ -570,10 +570,13 @@ module BABYLON {
                     tempVertexData.matricesWeights = new Float32Array(buffer.length);
                     (<Float32Array>tempVertexData.matricesWeights).set(buffer);
                 }
-                else if (semantic === "COLOR") {
+                else if (semantic === "COLOR_0") {
                     tempVertexData.colors = new Float32Array(buffer.length);
                     (<Float32Array>tempVertexData.colors).set(buffer);
                 }
+                else {
+                    Tools.Warn("Ignoring unrecognized semantic '" + semantic + "'");
+                }
             }
 
             // Indices
@@ -981,21 +984,23 @@ module BABYLON {
         }
 
         public static LoadAlphaProperties(runtime: IGLTFRuntime, material: IGLTFMaterial): void {
-            if (material.alphaMode) {
-                material.babylonMaterial.albedoTexture.hasAlpha = true;
-
-                switch (material.alphaMode) {
-                    case "MASK":
-                        material.babylonMaterial.useAlphaFromAlbedoTexture = false;
-                        material.babylonMaterial.alphaMode = Engine.ALPHA_DISABLE;
-                        break;
-                    case "BLEND":
-                        material.babylonMaterial.useAlphaFromAlbedoTexture = true;
-                        material.babylonMaterial.alphaMode = Engine.ALPHA_COMBINE;
-                        break;
-                    default:
-                        Tools.Error("Invalid alpha mode '" + material.alphaMode + "'");
-                }
+            var alphaMode = material.alphaMode || "OPAQUE";
+            switch (alphaMode) {
+                case "OPAQUE":
+                    // default is opaque
+                    break;
+                case "MASK":
+                    material.babylonMaterial.albedoTexture.hasAlpha = true;
+                    material.babylonMaterial.useAlphaFromAlbedoTexture = false;
+                    material.babylonMaterial.alphaMode = Engine.ALPHA_DISABLE;
+                    break;
+                case "BLEND":
+                    material.babylonMaterial.albedoTexture.hasAlpha = true;
+                    material.babylonMaterial.useAlphaFromAlbedoTexture = true;
+                    material.babylonMaterial.alphaMode = Engine.ALPHA_COMBINE;
+                    break;
+                default:
+                    Tools.Error("Invalid alpha mode '" + material.alphaMode + "'");
             }
         }