瀏覽代碼

Merge pull request #2583 from bghgary/loader-fixes

Small glTF loader fixes
David Catuhe 8 年之前
父節點
當前提交
2e49c60923

+ 1 - 0
loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts

@@ -45,6 +45,7 @@ module BABYLON.GLTF2.Extensions {
 
             if (properties.specularGlossinessTexture) {
                 babylonMaterial.reflectivityTexture = loader.loadTexture(properties.specularGlossinessTexture);
+                babylonMaterial.reflectivityTexture.hasAlpha = true;
                 babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
             }
 

+ 7 - 10
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -395,11 +395,11 @@ module BABYLON.GLTF2 {
                         this.loadMaterial(primitive.material, (babylonSubMaterial: Material) => {
                             if (this._renderReady) {
                                 babylonSubMaterial.forceCompilation(babylonMesh, babylonSubMaterial => {
-                                    this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
+                                    babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
                                 });
                             }
                             else {
-                                this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
+                                babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
                             }
                         });
                     }
@@ -416,14 +416,6 @@ module BABYLON.GLTF2 {
             }
         }
 
-        private _assignMaterial(multiMaterial: MultiMaterial, index: number, subMaterial: Material): void {
-            multiMaterial.subMaterials[index] = subMaterial;
-
-            if (this._parent.onMaterialLoaded) {
-                this._parent.onMaterialLoaded(subMaterial);
-            }
-        }
-
         private _loadVertexDataAsync(primitive: IGLTFMeshPrimitive, onSuccess: (vertexData: VertexData) => void): void {
             var attributes = primitive.attributes;
             if (!attributes) {
@@ -936,6 +928,11 @@ module BABYLON.GLTF2 {
             this.createPbrMaterial(material);
             this.loadMaterialBaseProperties(material);
             this._loadMaterialMetallicRoughnessProperties(material);
+
+            if (this._parent.onMaterialLoaded) {
+                this._parent.onMaterialLoaded(material.babylonMaterial);
+            }
+
             assign(material.babylonMaterial);
         }