소스 검색

New property in Scene that contains all instances of canvas2d

Temechon 9 년 전
부모
커밋
14b791d9e6
2개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      src/Canvas2d/babylon.canvas2d.ts
  2. 3 0
      src/babylon.scene.ts

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

@@ -183,6 +183,9 @@
                         //this._supprtInstancedArray = false; // TODO REMOVE!!!
 
             this._setupInteraction(enableInteraction);
+
+            // Register the canvas into the scene
+            this._scene.canvas2ds.push(this);
         }
 
         public get drawCallsOpaqueCounter(): PerfCounter {
@@ -818,6 +821,12 @@
                 this._groupCacheMaps.forEach((k, m) => m.forEach(e => e.dispose()));
                 this._groupCacheMaps = null;
             }
+
+            // Unregister this canvas from the scene
+            let index = this._scene.canvas2ds.indexOf(this);
+            if (index > -1) {
+                this._scene.canvas2ds.splice(index, 1);
+            }            
         }
 
         /**

+ 3 - 0
src/babylon.scene.ts

@@ -339,6 +339,9 @@
         */
         public meshes = new Array<AbstractMesh>();
 
+        // Contain all canvas2D used in the scene
+        public canvas2ds = new Array<Canvas2D>();
+
         // Geometries
         private _geometries = new Array<Geometry>();