Pārlūkot izejas kodu

Fix Inspector with AMD loader

sebavan 6 gadi atpakaļ
vecāks
revīzija
f793c38027
2 mainītis faili ar 18 papildinājumiem un 2 dzēšanām
  1. 1 0
      dist/preview release/what's new.md
  2. 17 2
      src/Debug/babylon.debugLayer.ts

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

@@ -141,6 +141,7 @@
 - Fixed bug in SolidParticle BoundingSphere update within the SolidParticleSystem ([barroij](https://github.com/barroij))
 - Update Picking so that when the picked Mesh is a LinesMesh, the index of the picked line is returned in the `faceId` property of the `PickingInfo`, as we do with face index the picked Mesh is made of triangle faces ([barroij](https://github.com/barroij))
 - Do not clone mesh observables ([Sebavan](https://github.com/Sebavan))
+- Fixed Inspector resolution with AMD loader ([Sebavan](https://github.com/Sebavan))
 
 ### Viewer
 

+ 17 - 2
src/Debug/babylon.debugLayer.ts

@@ -114,7 +114,7 @@ module BABYLON {
 
         private _scene: Scene;
 
-        private BJSINSPECTOR = typeof INSPECTOR !== 'undefined' ? INSPECTOR : undefined;
+        private BJSINSPECTOR = this._getGlobalInspector();
 
         /**
          * Observable triggered when a property is changed through the inspector.
@@ -154,11 +154,26 @@ module BABYLON {
                 ...config
             };
 
-            this.BJSINSPECTOR = this.BJSINSPECTOR || typeof INSPECTOR !== 'undefined' ? INSPECTOR : undefined;
+            this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
 
             this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
         }
 
+        /** Get the inspector from bundle or global */
+        private _getGlobalInspector(): any {
+            // UMD Global name detection from Webpack Bundle UMD Name.
+            if (typeof INSPECTOR !== 'undefined') {
+                return INSPECTOR;
+            }
+
+            // In case of module let s check the global emitted from the Inspector entry point.
+            if (BABYLON && (BABYLON as any).Inspector) {
+                return BABYLON;
+            }
+
+            return undefined;
+        }
+
         /**
          * Get if the inspector is visible or not.
          * @returns true if visible otherwise, false