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

Fix material dispose when instances are before source mesh

David Catuhe 6 лет назад
Родитель
Сommit
e575fd96ec
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/Materials/material.ts

+ 3 - 1
src/Materials/material.ts

@@ -19,7 +19,9 @@ import { Constants } from "../Engines/constants";
 import { Logger } from "../Misc/logger";
 import { IInspectable } from '../Misc/iInspectable';
 
+
 declare type Animation = import("../Animations/animation").Animation;
+declare type InstancedMesh = import('../Meshes/instancedMesh').InstancedMesh;
 
 declare var BABYLON: any;
 
@@ -1091,7 +1093,7 @@ export class Material implements IAnimatable {
             else {
                 const meshes = scene.meshes;
                 for (let mesh of meshes) {
-                    if (mesh.material === this) {
+                    if (mesh.material === this && !(mesh as InstancedMesh).sourceMesh) {
                         mesh.material = null;
                         this.releaseVertexArrayObject(mesh, forceDisposeEffect);
                     }