瀏覽代碼

Merge pull request #1303 from nockawa/master

Fixing cleanup issue for GroupInstanceInfo
Loïc Baumann 9 年之前
父節點
當前提交
1301111627

+ 7 - 0
src/Canvas2d/babylon.canvas2d.ts

@@ -253,6 +253,9 @@
 
                 // Register the observable
                 this._scenePrePointerObserver = this.scene.onPrePointerObservable.add((e, s) => {
+                    if (this.isVisible === false) {
+                        return;
+                    }
                     let hs = 1 / this.engine.getHardwareScalingLevel();
                     let localPos = e.localPosition.multiplyByFloats(hs, hs);
                     this._handlePointerEventForInteraction(e, localPos, s);
@@ -266,6 +269,10 @@
                     scene.constantlyUpdateMeshUnderPointer = true;
                     this._scenePointerObserver = scene.onPointerObservable.add((e, s) => {
 
+                        if (this.isVisible === false) {
+                            return;
+                        }
+
                         if (e.pickInfo.hit && e.pickInfo.pickedMesh === this._worldSpaceNode && this.worldSpaceToNodeLocal) {
                             let localPos = this.worldSpaceToNodeLocal(e.pickInfo.pickedPoint);
                             this._handlePointerEventForInteraction(e, localPos, s);

+ 14 - 3
src/Canvas2d/babylon.modelRenderCache.ts

@@ -25,13 +25,24 @@
 
             if (this.modelRenderCache) {
                 this.modelRenderCache.dispose();
+                this.modelRenderCache = null;
             }
 
             let engine = this.owner.owner.engine;
 
-            if (this.opaqueData) {
-                this.opaqueData.forEach(d => d.dispose(engine));
-                this.opaqueData = null;
+            if (this._opaqueData) {
+                this._opaqueData.forEach(d => d.dispose(engine));
+                this._opaqueData = null;
+            }
+
+            if (this._alphaTestData) {
+                this._alphaTestData.forEach(d => d.dispose(engine));
+                this._alphaTestData = null;
+            }
+
+            if (this._transparentData) {
+                this._transparentData.forEach(d => d.dispose(engine));
+                this._transparentData = null;
             }
 
             this.partIndexFromId = null;

+ 7 - 1
src/Canvas2d/babylon.renderablePrim2d.ts

@@ -454,8 +454,14 @@
 
                 if (usedCount === 0) {
                     this.renderGroup._renderableData._renderGroupInstancesInfo.remove(gii.modelRenderCache.modelKey);
+                    gii.dispose();
                 }
-                gii.modelRenderCache.dispose();
+
+                if (this._modelRenderCache) {
+                    this._modelRenderCache.dispose();
+                    this._modelRenderCache = null;
+                }
+
             }
             this._instanceDataParts = null;
         }