Przeglądaj źródła

Integrating inspector

David Catuhe 8 lat temu
rodzic
commit
17237acc82

Plik diff jest za duży
+ 12 - 12
dist/preview release/babylon.core.js


Plik diff jest za duży
+ 3559 - 3559
dist/preview release/babylon.d.ts


Plik diff jest za duży
+ 21 - 21
dist/preview release/babylon.js


+ 18 - 12
dist/preview release/babylon.max.js

@@ -5035,17 +5035,23 @@ var BABYLON;
          * Load a script (identified by an url). When the url returns, the
          * content of this file is added into a new script element, attached to the DOM (body element)
          */
-        Tools.LoadScript = function (scriptUrl, callback, progressCallBack, onError) {
-            // Load file
-            BABYLON.Tools.LoadFile(scriptUrl, function (scriptContent) {
-                // Create script element
-                var scriptElem = window.document.createElement('script');
-                scriptElem.textContent = scriptContent;
-                // attach the script to the body
-                var body = window.document.body;
-                body.appendChild(scriptElem);
-                callback();
-            }, progressCallBack, null, null, onError);
+        Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
+            var head = document.getElementsByTagName('head')[0];
+            var script = document.createElement('script');
+            script.type = 'text/javascript';
+            script.src = scriptUrl;
+            var self = this;
+            script.onload = function () {
+                if (onSuccess) {
+                    onSuccess();
+                }
+            };
+            script.onerror = function () {
+                if (onError) {
+                    onError();
+                }
+            };
+            head.appendChild(script);
         };
         Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
             var reader = new FileReader();
@@ -54861,7 +54867,7 @@ var BABYLON;
                 this._createInspector();
             }
         };
-        DebugLayer.InspectorURL = 'http://www.babylonjs.com/inspector.js';
+        DebugLayer.InspectorURL = 'http://www.babylonjs.com/babylon.inspector.bundle.js';
         return DebugLayer;
     }());
     BABYLON.DebugLayer = DebugLayer;

Plik diff jest za duży
+ 21 - 21
dist/preview release/babylon.noworker.js


Plik diff jest za duży
+ 1 - 1
dist/preview release/materialsLibrary/babylon.gridMaterial.js


+ 1 - 1
src/Debug/babylon.debugLayer.ts

@@ -5,7 +5,7 @@ module BABYLON {
 
     export class DebugLayer {
         private _scene: Scene;
-        public static InspectorURL = 'http://www.babylonjs.com/inspector.js'
+        public static InspectorURL = 'http://www.babylonjs.com/babylon.inspector.bundle.js'
 
         constructor(scene: Scene) {
             this._scene = scene;

+ 19 - 15
src/Tools/babylon.tools.ts

@@ -443,22 +443,26 @@
          * Load a script (identified by an url). When the url returns, the 
          * content of this file is added into a new script element, attached to the DOM (body element)
          */
-        public static LoadScript(
-            scriptUrl:string, 
-            callback: (data?: any) => void, 
-            progressCallBack?: () => void,
-            onError?: () => void) {
-                // Load file
-                BABYLON.Tools.LoadFile(scriptUrl, (scriptContent:string) => {
-                    // Create script element
-                    let scriptElem         = window.document.createElement('script');
-                    scriptElem.textContent = scriptContent;        
-                    // attach the script to the body
-                    let body               = window.document.body;
-                    body.appendChild(scriptElem);
-                    callback();
-                }, progressCallBack, null, null, onError);
+        public static LoadScript(scriptUrl:string, onSuccess: () => void, onError?: () => void) {
+            var head = document.getElementsByTagName('head')[0];
+            var script = document.createElement('script');
+            script.type = 'text/javascript';
+            script.src = scriptUrl;
+
+            var self = this;
+            script.onload = () => {
+                if (onSuccess) {
+                    onSuccess();
+                }
+            };
+
+            script.onerror = () => {
+                if (onError) {
+                    onError();
+                }
+            };
 
+            head.appendChild(script);
         }
 
         public static ReadFileAsDataURL(fileToLoad, callback, progressCallback): void {