Преглед изворни кода

Break Default Loading Screen Dependency

sebavan пре 6 година
родитељ
комит
f626560375
2 измењених фајлова са 16 додато и 7 уклоњено
  1. 13 7
      src/Engines/engine.ts
  2. 3 0
      src/Loading/loadingScreen.ts

+ 13 - 7
src/Engines/engine.ts

@@ -25,7 +25,7 @@ import { PassPostProcess } from "../PostProcesses/passPostProcess";
 import { _TimeToken } from "../Instrumentation/timeToken";
 import { IAudioEngine } from "../Audio/audioEngine";
 import { IOfflineProvider } from "../Offline/IOfflineProvider";
-import { ILoadingScreen, DefaultLoadingScreen } from "../Loading/loadingScreen";
+import { ILoadingScreen } from "../Loading/loadingScreen";
 import { _DepthCullingState, _StencilState, _AlphaState } from "../States/index";
 import { Constants } from "./constants";
 import { DomManagement } from "../Misc/domManagement";
@@ -517,10 +517,6 @@ declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTex
         public static CollisionsEpsilon = 0.001;
 
         /**
-         * Gets or sets the relative url used to load code if using the engine in non-minified mode
-         */
-        public static CodeRepository = "src/";
-        /**
          * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
          */
         public static get ShadersRepository(): string {
@@ -530,6 +526,16 @@ declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTex
             Effect.ShadersRepository = value;
         }
 
+        /**
+         * Method called to create the default loading screen.
+         * This can be overriden in your own app.
+         * @param canvas The rendering canvas element
+         * @returns The loading screen
+         */
+        public static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen {
+            throw "Import LoadingScreen or set DefaultLoadingScreenFactory on engine before using the loading screen";
+        }
+
         // Public members
 
         /**
@@ -7040,8 +7046,8 @@ declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTex
          * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
          */
         public get loadingScreen(): ILoadingScreen {
-            if (!this._loadingScreen && DefaultLoadingScreen && this._renderingCanvas) {
-                this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas);
+            if (!this._loadingScreen && this._renderingCanvas) {
+                this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
             }
             return this._loadingScreen;
         }

+ 3 - 0
src/Loading/loadingScreen.ts

@@ -1,6 +1,7 @@
 import { Nullable } from "../types";
 import { _TimeToken } from "../Instrumentation/timeToken";
 import { _DepthCullingState, _StencilState, _AlphaState } from "../States/index";
+import { Engine } from 'Engines';
     /**
      * Interface used to present a loading screen while loading a scene
      * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
@@ -192,3 +193,5 @@ import { _DepthCullingState, _StencilState, _AlphaState } from "../States/index"
             this._loadingDiv.style.height = canvasRect.height + "px";
         }
     }
+
+    Engine.DefaultLoadingScreenFactory = (canvas: HTMLCanvasElement) => { return new DefaultLoadingScreen(canvas); };