فهرست منبع

Fix insector tabs reloading issues

ameuleman 8 سال پیش
والد
کامیت
1498061c1c
4فایلهای تغییر یافته به همراه26 افزوده شده و 16 حذف شده
  1. 14 9
      inspector/src/tabs/ConsoleTab.ts
  2. 8 4
      inspector/src/tabs/StatsTab.ts
  3. 0 1
      inspector/src/tabs/TabBar.ts
  4. 4 2
      inspector/test/index.js

+ 14 - 9
inspector/src/tabs/ConsoleTab.ts

@@ -47,15 +47,6 @@ module INSPECTOR {
             this._consolePanelContent = Helpers.CreateDiv('console-panel-content', consolePanel) as HTMLDivElement;
             this._bjsPanelContent     = Helpers.CreateDiv('console-panel-content', bjsPanel) as HTMLDivElement;
 
-            // save old console.log
-            this._oldConsoleLog       = console.log;
-            this._oldConsoleWarn      = console.warn;
-            this._oldConsoleError     = console.error;
-
-            console.log               = this._addConsoleLog.bind(this);
-            console.warn              = this._addConsoleWarn.bind(this);
-            console.error             = this._addConsoleError.bind(this);
-
             // Bjs logs
             this._bjsPanelContent.innerHTML = BABYLON.Tools.LogCache;
             BABYLON.Tools.OnNewCacheEntry = (entry: string) => {
@@ -83,6 +74,20 @@ module INSPECTOR {
             console.error = this._oldConsoleError;
 
         }
+        
+        public active(b: boolean){
+            super.active(b);
+            if(b){
+                // save old console.log
+                this._oldConsoleLog       = console.log;
+                this._oldConsoleWarn      = console.warn;
+                this._oldConsoleError     = console.error;
+
+                console.log               = this._addConsoleLog.bind(this);
+                console.warn              = this._addConsoleWarn.bind(this);
+                console.error             = this._addConsoleError.bind(this);
+            }
+        }
 
         private _message(type:string, message:any, caller:string) {
             let callerLine = Helpers.CreateDiv('caller', this._consolePanelContent);

+ 8 - 4
inspector/src/tabs/StatsTab.ts

@@ -267,11 +267,8 @@ module INSPECTOR {
                     updateFct:() => { return "WebGL v" + this._engine.webGLVersion + " - " + this._glInfo.version + " - "+this._glInfo.renderer}
                 });
             }
-
-
-            // Register the update loop
-            this._scene.registerAfterRender(this._updateLoopHandler);
         }
+        
         private _createStatLabel(content:string, parent: HTMLElement) : HTMLElement {
             let elem = Helpers.CreateDiv('stat-label', parent);
             elem.textContent = content;
@@ -288,5 +285,12 @@ module INSPECTOR {
         public dispose() {
             this._scene.unregisterAfterRender(this._updateLoopHandler);
         }
+
+        public active(b: boolean){
+            super.active(b);
+            if(b){
+                this._scene.registerAfterRender(this._updateLoopHandler);
+            }
+        }
     }
 }

+ 0 - 1
inspector/src/tabs/TabBar.ts

@@ -47,7 +47,6 @@ module INSPECTOR {
             //Check initialTab is defined and between tabs bounds
             if (!initialTab || initialTab < 0 || initialTab >= this._tabs.length) {
                 initialTab = 0;
-                console.warn('');
             }
 
             this._tabs[initialTab].active(true);

+ 4 - 2
inspector/test/index.js

@@ -249,7 +249,7 @@ var Test = (function () {
         sphere_3.parent = assets_mesh;
 
         for (var i=0; i<10 ; i++){
-            var inst = sphere_1.clone("C_" + i + "clone");
+            var inst = sphere_1.createInstance("C_" + i + "clone");
             inst.isVisible = true;
             inst.setEnabled = true;
             inst.parent = scene_mesh;
@@ -317,7 +317,9 @@ var Test = (function () {
         advancedTexture.addControl(checkbox);    
         advancedTexture.addControl(slider);    
         advancedTexture.addControl(line);    
-        advancedTexture.addControl(checkbox);    
+        advancedTexture.addControl(checkbox);  
+        
+        window.addEventListener('click', function() {console.log('coucou');});
 
 
         this.scene = scene;