Przeglądaj źródła

Deal with core debug namespaces

sebastien 6 lat temu
rodzic
commit
be311ee6d4
2 zmienionych plików z 25 dodań i 1 usunięć
  1. 6 0
      Tools/Gulp/config.json
  2. 19 1
      src/Legacy/legacy.ts

+ 6 - 0
Tools/Gulp/config.json

@@ -75,6 +75,12 @@
                 "filename": "babylon.module.d.ts",
                 "packageName": "babylonjs",
                 "moduleName": "BABYLON",
+                "moduleSpecifics": [
+                    {
+                        "path": "babylonjs/Debug",
+                        "namespace": "BABYLON.Debug"
+                    }
+                ],
                 "importsToRemove": [],
                 "classMap": {
                     "babylonjs": "BABYLON"

+ 19 - 1
src/Legacy/legacy.ts

@@ -1,4 +1,5 @@
-import * as BABYLON from "../index";
+import * as Babylon from "../index";
+import * as Debug from "../Debug/index";
 
 /**
  * Legacy support, defining window.BABYLON (global variable).
@@ -9,6 +10,23 @@ import * as BABYLON from "../index";
 var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
 if (typeof globalObject !== "undefined") {
     (<any>globalObject).BABYLON = BABYLON;
+    (<any>globalObject).BABYLON = (<any>globalObject).BABYLON || {};
+    var BABYLON = (<any>globalObject).BABYLON;
+    BABYLON.Debug = BABYLON.Debug || {};
+
+    const keys = [];
+    for (var key in Debug) {
+        BABYLON.Debug[key] = (<any>Debug)[key];
+        keys.push(key);
+    }
+    for (var key in Babylon) {
+        // Prevent Reassignment.
+        if (keys.indexOf(key) > -1) {
+            continue;
+        }
+
+        BABYLON[key] = (<any>Babylon)[key];
+    }
 }
 
 export * from "../index";