Browse Source

break sceneloader dependency

sebavan 6 years ago
parent
commit
ff7efdb100

+ 17 - 0
src/Engines/constants.ts

@@ -411,4 +411,21 @@ export class Constants {
      *  If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
      */
     public static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
+
+    /**
+     * No logging while loading
+     */
+    public static readonly SCENELOADER_NO_LOGGING = 0;
+    /**
+     * Minimal logging while loading
+     */
+    public static readonly SCENELOADER_MINIMAL_LOGGING = 1;
+    /**
+     * Summary logging while loading
+     */
+    public static readonly SCENELOADER_SUMMARY_LOGGING = 2;
+    /**
+     * Detailled logging while loading
+     */
+    public static readonly SCENELOADER_DETAILED_LOGGING = 3;
 }

+ 2 - 1
src/Loading/index.ts

@@ -1,3 +1,4 @@
 export * from "./loadingScreen";
 export * from "./Plugins/index";
-export * from "./sceneLoader";
+export * from "./sceneLoader";
+export * from "./sceneLoaderFlags";

+ 14 - 19
src/Loading/sceneLoader.ts

@@ -14,6 +14,8 @@ import { AssetContainer } from "../assetContainer";
 import { IParticleSystem } from "../Particles/IParticleSystem";
 import { Skeleton } from "../Bones/skeleton";
 import { Logger } from "../Misc/logger";
+import { Constants } from "../Engines/constants";
+import { SceneLoaderFlags } from "./sceneLoaderFlags";
     /**
      * Class used to represent data loading progression
      */
@@ -233,53 +235,46 @@ import { Logger } from "../Misc/logger";
      * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
      */
     export class SceneLoader {
-        // Flags
-        private static _ForceFullSceneLoadingForIncremental = false;
-        private static _ShowLoadingScreen = true;
-        private static _CleanBoneMatrixWeights = false;
-
         /**
          * No logging while loading
          */
-        public static readonly NO_LOGGING = 0;
+        public static readonly NO_LOGGING = Constants.SCENELOADER_NO_LOGGING;
 
         /**
          * Minimal logging while loading
          */
-        public static readonly MINIMAL_LOGGING = 1;
+        public static readonly MINIMAL_LOGGING = Constants.SCENELOADER_MINIMAL_LOGGING;
 
         /**
          * Summary logging while loading
          */
-        public static readonly SUMMARY_LOGGING = 2;
+        public static readonly SUMMARY_LOGGING = Constants.SCENELOADER_SUMMARY_LOGGING;
 
         /**
          * Detailled logging while loading
          */
-        public static readonly DETAILED_LOGGING = 3;
-
-        private static _loggingLevel = SceneLoader.NO_LOGGING;
+        public static readonly DETAILED_LOGGING = Constants.SCENELOADER_DETAILED_LOGGING;
 
         /**
          * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
          */
         public static get ForceFullSceneLoadingForIncremental() {
-            return SceneLoader._ForceFullSceneLoadingForIncremental;
+            return SceneLoaderFlags.ForceFullSceneLoadingForIncremental;
         }
 
         public static set ForceFullSceneLoadingForIncremental(value: boolean) {
-            SceneLoader._ForceFullSceneLoadingForIncremental = value;
+            SceneLoaderFlags.ForceFullSceneLoadingForIncremental = value;
         }
 
         /**
          * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
          */
         public static get ShowLoadingScreen(): boolean {
-            return SceneLoader._ShowLoadingScreen;
+            return SceneLoaderFlags.ShowLoadingScreen;
         }
 
         public static set ShowLoadingScreen(value: boolean) {
-            SceneLoader._ShowLoadingScreen = value;
+            SceneLoaderFlags.ShowLoadingScreen = value;
         }
 
         /**
@@ -287,22 +282,22 @@ import { Logger } from "../Misc/logger";
          * @ignorenaming
          */
         public static get loggingLevel(): number {
-            return SceneLoader._loggingLevel;
+            return SceneLoaderFlags.loggingLevel;
         }
 
         public static set loggingLevel(value: number) {
-            SceneLoader._loggingLevel = value;
+            SceneLoaderFlags.loggingLevel = value;
         }
 
         /**
          * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
          */
         public static get CleanBoneMatrixWeights(): boolean {
-            return SceneLoader._CleanBoneMatrixWeights;
+            return SceneLoaderFlags.CleanBoneMatrixWeights;
         }
 
         public static set CleanBoneMatrixWeights(value: boolean) {
-            SceneLoader._CleanBoneMatrixWeights = value;
+            SceneLoaderFlags.CleanBoneMatrixWeights = value;
         }
 
         // Members

+ 57 - 0
src/Loading/sceneLoaderFlags.ts

@@ -0,0 +1,57 @@
+import { Constants } from "../Engines/constants";
+
+/**
+ * Class used to represent data loading progression
+ */
+export class SceneLoaderFlags {
+    // Flags
+    private static _ForceFullSceneLoadingForIncremental = false;
+    private static _ShowLoadingScreen = true;
+    private static _CleanBoneMatrixWeights = false;
+    private static _loggingLevel = Constants.SCENELOADER_NO_LOGGING;
+
+    /**
+     * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
+     */
+    public static get ForceFullSceneLoadingForIncremental() {
+        return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
+    }
+
+    public static set ForceFullSceneLoadingForIncremental(value: boolean) {
+        SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
+    }
+
+    /**
+     * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
+     */
+    public static get ShowLoadingScreen(): boolean {
+        return SceneLoaderFlags._ShowLoadingScreen;
+    }
+
+    public static set ShowLoadingScreen(value: boolean) {
+        SceneLoaderFlags._ShowLoadingScreen = value;
+    }
+
+    /**
+     * Defines the current logging level (while loading the scene)
+     * @ignorenaming
+     */
+    public static get loggingLevel(): number {
+        return SceneLoaderFlags._loggingLevel;
+    }
+
+    public static set loggingLevel(value: number) {
+        SceneLoaderFlags._loggingLevel = value;
+    }
+
+    /**
+     * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
+     */
+    public static get CleanBoneMatrixWeights(): boolean {
+        return SceneLoaderFlags._CleanBoneMatrixWeights;
+    }
+
+    public static set CleanBoneMatrixWeights(value: boolean) {
+        SceneLoaderFlags._CleanBoneMatrixWeights = value;
+    }
+}

+ 2 - 2
src/Meshes/geometry.ts

@@ -7,7 +7,7 @@
     import { SubMesh } from "../Meshes/subMesh";
     import { AbstractMesh } from "../Meshes/abstractMesh";
     import { Effect } from "../Materials/effect";
-    import { SceneLoader } from "../Loading/sceneLoader";
+    import { SceneLoaderFlags } from "../Loading/sceneLoaderFlags";
     import { BoundingInfo } from "../Culling/boundingInfo";
     import { Constants } from "../Engines/constants";
     import { Tools } from "../Misc/tools";
@@ -1335,7 +1335,7 @@
 
         private static _CleanMatricesWeights(parsedGeometry: any, mesh: Mesh): void {
             const epsilon: number = 1e-3;
-            if (!SceneLoader.CleanBoneMatrixWeights) {
+            if (!SceneLoaderFlags.CleanBoneMatrixWeights) {
                 return;
             }
             let noInfluenceBoneIndex = 0.0;

+ 2 - 2
src/Meshes/mesh.ts

@@ -19,7 +19,7 @@ import { BoundingSphere } from "../Culling/boundingSphere";
 import { Effect } from "../Materials/effect";
 import { Material } from "../Materials/material";
 import { Animation } from "../Animations/animation";
-import { SceneLoader } from "../Loading/sceneLoader";
+import { SceneLoaderFlags } from "../Loading/sceneLoaderFlags";
 import { Skeleton } from "../Bones/skeleton";
 import { MorphTargetManager } from "../Morph/morphTargetManager";
 import { PhysicsImpostor } from "../Physics/physicsImpostor";
@@ -2812,7 +2812,7 @@ declare type GroundMesh = import("./groundMesh").GroundMesh;
 
                 mesh._delayLoadingFunction = Geometry._ImportGeometry;
 
-                if (SceneLoader.ForceFullSceneLoadingForIncremental) {
+                if (SceneLoaderFlags.ForceFullSceneLoadingForIncremental) {
                     mesh._checkDelayState();
                 }