Ver código fonte

Merge pull request #1393 from Temechon/master

New property in Scene that contains all instances of canvas2d
Loïc Baumann 8 anos atrás
pai
commit
eb7cc95483

Diferenças do arquivo suprimidas por serem muito extensas
+ 2689 - 2687
dist/preview release/babylon.d.ts


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

@@ -26,6 +26,7 @@
  - Text2D super sampling to enhance quality in World Space Canvas
  - World Space Canvas is now rendering in an adaptive way for its resolution to fit the on screen projected one to achieve a good rendering quality
  - Transparent Primitives are now drawn with Instanced Array when supported
+ - New property in Canvas2D (instances) that contains all instances of canvas2d [Temechon](https://github.com/Temechon)
 - WebVR Camera was updated to be conform with the current specs. ([RaananW](https://github.com/RaananW)) 
 
 ### Exporters

+ 16 - 1
src/Canvas2d/babylon.canvas2d.ts

@@ -53,6 +53,8 @@
          */
         public static CACHESTRATEGY_DONTCACHE = 4;
 
+        private static _INSTANCES : Array<Canvas2D> = [];
+
         constructor(scene: Scene, settings?: {
             id?: string,
             children?: Array<Prim2DBase>,
@@ -183,6 +185,9 @@
                         //this._supprtInstancedArray = false; // TODO REMOVE!!!
 
             this._setupInteraction(enableInteraction);
+
+            // Register this instance
+            Canvas2D._INSTANCES.push(this);
         }
 
         public get drawCallsOpaqueCounter(): PerfCounter {
@@ -233,6 +238,10 @@
             return this._boundingInfoRecomputeCounter;
         }
 
+        public static get instances() : Array<Canvas2D> {
+            return Canvas2D._INSTANCES;
+        }
+
         protected _canvasPreInit(settings: any) {
             let cachingStrategy = (settings.cachingStrategy == null) ? Canvas2D.CACHESTRATEGY_DONTCACHE : settings.cachingStrategy;
             this._cachingStrategy = cachingStrategy;
@@ -817,7 +826,13 @@
             if (this._groupCacheMaps) {
                 this._groupCacheMaps.forEach((k, m) => m.forEach(e => e.dispose()));
                 this._groupCacheMaps = null;
-            }
+            }       
+
+            // Unregister this instance
+            let index = Canvas2D._INSTANCES.indexOf(this);
+            if (index > -1) {
+                Canvas2D._INSTANCES.splice(index, 1);
+            }  
         }
 
         /**