Преглед на файлове

Merge pull request #6456 from TrevorDev/instanceContextLossFix

dispose instances buffer when rebuilding mesh
David Catuhe преди 6 години
родител
ревизия
2531373ed5
променени са 2 файла, в които са добавени 11 реда и са изтрити 1 реда
  1. 1 1
      dist/preview release/what's new.md
  2. 10 0
      src/Meshes/mesh.ts

+ 1 - 1
dist/preview release/what's new.md

@@ -59,7 +59,7 @@
 - Runtime animation `goToFrame` when going back in time now correctly triggers future events when reached ([zakhenry](https://github.com/zakhenry))
 - Fixed bug in Ray.intersectsTriangle where the barycentric coordinates `bu` and `bv` being returned is actually `bv` and `bw`. ([bghgary](https://github.com/bghgary))
 - Do not call onError when creating a texture when falling back to another loader ([TrevorDev](https://github.com/TrevorDev))
-- Context loss should not cause PBR materials to render black ([TrevorDev](https://github.com/TrevorDev))
+- Context loss should not cause PBR materials to render black or instances to stop rendering ([TrevorDev](https://github.com/TrevorDev))
 - Only cast pointer ray input when pointer is locked in webVR ([TrevorDev](https://github.com/TrevorDev))
 - Avoid using default utility layer in gizmo manager to support multiple scenes ([TrevorDev](https://github.com/TrevorDev))
 

+ 10 - 0
src/Meshes/mesh.ts

@@ -1546,6 +1546,16 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
     }
 
     /** @hidden */
+    public _rebuild(): void {
+        if (this._instanceDataStorage.instancesBuffer) {
+            // Dispose instance buffer to be recreated in _renderWithInstances when rendered
+            this._instanceDataStorage.instancesBuffer.dispose();
+            this._instanceDataStorage.instancesBuffer = null;
+        }
+        super._rebuild();
+    }
+
+    /** @hidden */
     public _freeze() {
         if (!this.subMeshes) {
             return;