瀏覽代碼

Merge pull request #3491 from vanRepin/master

fix gltf loader to respect vertexAlpha
David Catuhe 7 年之前
父節點
當前提交
0c2c0efff1
共有 2 個文件被更改,包括 7 次插入3 次删除
  1. 6 3
      loaders/src/glTF/2.0/babylon.glTFLoader.ts
  2. 1 0
      loaders/src/glTF/2.0/babylon.glTFLoaderInterfaces.ts

+ 6 - 3
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -358,7 +358,6 @@ module BABYLON.GLTF2 {
             }
 
             node.babylonMesh = new Mesh(node.name || "mesh" + node.index, this._babylonScene);
-            node.babylonMesh.hasVertexAlpha = true;
 
             this._loadTransform(node);
 
@@ -426,7 +425,7 @@ module BABYLON.GLTF2 {
                 for (const primitive of primitives) {
                     vertexData.merge(primitive.vertexData);
                 }
-
+                node.babylonMesh.hasVertexAlpha = mesh.hasVertexAlpha;
                 new Geometry(node.babylonMesh.name, this._babylonScene, vertexData, false, node.babylonMesh);
 
                 // TODO: optimize this so that sub meshes can be created without being overwritten after setting vertex data.
@@ -647,6 +646,10 @@ module BABYLON.GLTF2 {
                         }
                         case "COLOR_0": {
                             vertexData.colors = this._convertToFloat4ColorArray(context, data, accessor);
+                            const hasVertexAlpha = GLTFLoader._GetNumComponents(context, accessor.type) === 4;
+                            if (!mesh.hasVertexAlpha && hasVertexAlpha) {
+                                mesh.hasVertexAlpha = hasVertexAlpha;
+                            }
                             break;
                         }
                         default: {
@@ -678,7 +681,7 @@ module BABYLON.GLTF2 {
                 });
             }
         }
-
+        
         private _createMorphTargets(context: string, node: IGLTFNode, mesh: IGLTFMesh): void {
             const primitives = mesh.primitives;
 

+ 1 - 0
loaders/src/glTF/2.0/babylon.glTFLoaderInterfaces.ts

@@ -217,6 +217,7 @@ module BABYLON.GLTF2 {
 
         // Runtime values
         index: number;
+        hasVertexAlpha: boolean;
     }
 
     export interface IGLTFNode extends IGLTFChildRootProperty {