소스 검색

Optimized if statement inside of getMaterial

Michael Schlotfeldt 7 년 전
부모
커밋
6b0ad016f7
1개의 변경된 파일3개의 추가작업 그리고 5개의 파일을 삭제
  1. 3 5
      src/Mesh/babylon.subMesh.ts

+ 3 - 5
src/Mesh/babylon.subMesh.ts

@@ -101,7 +101,9 @@
         public getMaterial(): Nullable<Material> {
             var rootMaterial = this._renderingMesh.material;
 
-            if (rootMaterial && (<MultiMaterial>rootMaterial).getSubMaterial) {
+            if (rootMaterial === null || rootMaterial === undefined) {
+                return this._mesh.getScene().defaultMaterial;
+            } else if ((<MultiMaterial>rootMaterial).getSubMaterial) {
                 var multiMaterial = <MultiMaterial>rootMaterial;
                 var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
 
@@ -113,10 +115,6 @@
                 return effectiveMaterial;
             }
 
-            if (!rootMaterial) {
-                return this._mesh.getScene().defaultMaterial;
-            }
-
             return rootMaterial;
         }