Просмотр исходного кода

assign effective material only when the material is ready

Julien Barrois 5 лет назад
Родитель
Сommit
da1a4fca90
1 измененных файлов с 5 добавлено и 6 удалено
  1. 5 6
      src/Meshes/mesh.ts

+ 5 - 6
src/Meshes/mesh.ts

@@ -1731,16 +1731,15 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
 
         // Material
         if (!instanceDataStorage.isFrozen || !this._effectiveMaterial || this._effectiveMaterial !== material) {
-
-            this._effectiveMaterial = material;
-
-            if (this._effectiveMaterial._storeEffectOnSubMeshes) {
-                if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
+            if (material._storeEffectOnSubMeshes) {
+                if (!material.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
                     return this;
                 }
-            } else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
+            } else if (!material.isReady(this, hardwareInstancedRendering)) {
                 return this;
             }
+
+            this._effectiveMaterial = material;
         }
 
         // Alpha mode