Browse Source

Tools Logger Cyclic Ref

sebastien 6 years ago
parent
commit
31cd1bc029
59 changed files with 475 additions and 342 deletions
  1. 2 1
      src/Actions/actionManager.ts
  2. 2 2
      src/Actions/directActions.ts
  3. 2 2
      src/Actions/interpolateValueAction.ts
  4. 2 2
      src/Audio/audioEngine.ts
  5. 11 10
      src/Audio/sound.ts
  6. 3 3
      src/Audio/weightedsound.ts
  7. 3 2
      src/Bones/skeleton.ts
  8. 6 6
      src/Cameras/VR/vrExperienceHelper.ts
  9. 2 2
      src/Cameras/XR/webXRSessionManager.ts
  10. 2 1
      src/Cameras/camera.ts
  11. 2 2
      src/Cameras/cameraInputsManager.ts
  12. 29 22
      src/Engines/engine.ts
  13. 2 2
      src/Engines/nullEngine.ts
  14. 2 2
      src/Gamepads/Controllers/daydreamController.ts
  15. 12 12
      src/Gamepads/Controllers/windowsMotionController.ts
  16. 2 1
      src/Gamepads/gamepadManager.ts
  17. 2 2
      src/Gizmos/boundingBoxGizmo.ts
  18. 2 2
      src/Gizmos/positionGizmo.ts
  19. 2 2
      src/Gizmos/rotationGizmo.ts
  20. 2 2
      src/Gizmos/scaleGizmo.ts
  21. 2 2
      src/Helpers/sceneHelpers.ts
  22. 2 1
      src/Layers/highlightLayer.ts
  23. 9 9
      src/Loading/Plugins/babylonFileLoader.ts
  24. 9 8
      src/Loading/sceneLoader.ts
  25. 2 2
      src/Materials/Background/backgroundMaterial.ts
  26. 3 2
      src/Materials/PBR/pbrBaseMaterial.ts
  27. 4 3
      src/Materials/Textures/Procedurals/customProceduralTexture.ts
  28. 2 2
      src/Materials/Textures/dynamicTexture.ts
  29. 3 2
      src/Materials/Textures/videoTexture.ts
  30. 31 27
      src/Materials/effect.ts
  31. 2 1
      src/Materials/material.ts
  32. 2 2
      src/Materials/materialHelper.ts
  33. 2 2
      src/Materials/uniformBuffer.ts
  34. 2 1
      src/Meshes/instancedMesh.ts
  35. 6 5
      src/Meshes/mesh.ts
  36. 2 2
      src/Meshes/polygonMesh.ts
  37. 3 2
      src/Misc/assetsManager.ts
  38. 4 4
      src/Misc/dds.ts
  39. 32 0
      src/Misc/domManagement.ts
  40. 3 2
      src/Misc/environmentTextureTools.ts
  41. 3 2
      src/Misc/filesInput.ts
  42. 6 6
      src/Misc/khronosTextureContainer.ts
  43. 144 0
      src/Misc/logger.ts
  44. 3 3
      src/Misc/tga.ts
  45. 36 111
      src/Misc/tools.ts
  46. 2 2
      src/Morph/morphTargetManager.ts
  47. 19 18
      src/Offline/database.ts
  48. 4 4
      src/Physics/Plugins/cannonJSPlugin.ts
  49. 5 5
      src/Physics/Plugins/oimoJSPlugin.ts
  50. 2 2
      src/Physics/physicsEngineComponent.ts
  51. 7 7
      src/Physics/physicsHelper.ts
  52. 7 7
      src/Physics/physicsImpostor.ts
  53. 3 2
      src/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts
  54. 2 2
      src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts
  55. 4 3
      src/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts
  56. 2 2
      src/PostProcesses/circleOfConfusionPostProcess.ts
  57. 2 2
      src/PostProcesses/motionBlurPostProcess.ts
  58. 3 3
      src/PostProcesses/volumetricLightScatteringPostProcess.ts
  59. 4 2
      src/scene.ts

+ 2 - 1
src/Actions/actionManager.ts

@@ -11,6 +11,7 @@ import { Engine } from "Engines/engine";
 import { Constants } from "Engines/constants";
 import { Tools } from "Misc/tools";
 import { ActionEvent } from "Actions/actionEvent";
+import { Logger } from "Misc/logger";
 
     /**
      * Action Manager manages all events to be triggered on a given mesh or the global scene.
@@ -312,7 +313,7 @@ import { ActionEvent } from "Actions/actionEvent";
         public registerAction(action: Action): Nullable<Action> {
             if (action.trigger === ActionManager.OnEveryFrameTrigger) {
                 if (this.getScene().actionManager !== this) {
-                    Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
+                    Logger.Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
                     return null;
                 }
             }

+ 2 - 2
src/Actions/directActions.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Vector3 } from "Maths/math";
 import { Action } from "./action";
 import { Condition } from "./condition";
@@ -221,7 +221,7 @@ declare type ActionEvent = import("./actionEvent").ActionEvent;
             this._property = this._getProperty(this.propertyPath);
 
             if (typeof this._effectiveTarget[this._property] !== "number") {
-                Tools.Warn("Warning: IncrementValueAction can only be used with number values");
+                Logger.Warn("Warning: IncrementValueAction can only be used with number values");
             }
         }
 

+ 2 - 2
src/Actions/interpolateValueAction.ts

@@ -1,7 +1,7 @@
 import { Action } from "./action";
 import { Condition } from "./condition";
 
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observable } from "Misc/observable";
 import { Color3, Vector3, Matrix, Quaternion } from "Maths/math";
 import { Animation } from "Animations/animation";
@@ -102,7 +102,7 @@ import { Animation } from "Animations/animation";
             } else if (this.value instanceof Quaternion) {
                 dataType = Animation.ANIMATIONTYPE_QUATERNION;
             } else {
-                Tools.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
+                Logger.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
                 return;
             }
 

+ 2 - 2
src/Audio/audioEngine.ts

@@ -3,7 +3,7 @@ import { Analyser } from "./analyser";
 
 import { Nullable } from "types";
 import { Observable } from "Misc/observable";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Engine } from "Engines/engine";
 
     /**
@@ -233,7 +233,7 @@ import { Engine } from "Engines/engine";
             }
             catch (e) {
                 this.canUseWebAudio = false;
-                Tools.Error("Web Audio: " + e.message);
+                Logger.Error("Web Audio: " + e.message);
             }
         }
 

+ 11 - 10
src/Audio/sound.ts

@@ -8,6 +8,7 @@ import { AudioSceneComponent } from "Audio/audioSceneComponent";
 import { AbstractMesh } from "Meshes/abstractMesh";
 import { TransformNode } from "Meshes/transformNode";
 import { SceneComponentConstants } from "sceneComponent";
+import { Logger } from "Misc/logger";
 
     /**
      * Defines a sound that can be played in the application.
@@ -230,9 +231,9 @@ import { SceneComponentConstants } from "sceneComponent";
                                                 this._soundLoaded(data as ArrayBuffer);
                                             }, undefined, true, true, (exception) => {
                                                 if (exception) {
-                                                    Tools.Error("XHR " + exception.status + " error on: " + url + ".");
+                                                    Logger.Error("XHR " + exception.status + " error on: " + url + ".");
                                                 }
-                                                Tools.Error("Sound creation aborted.");
+                                                Logger.Error("Sound creation aborted.");
                                                 this._scene.mainSoundTrack.RemoveSound(this);
                                             });
                                         }
@@ -265,7 +266,7 @@ import { SceneComponentConstants } from "sceneComponent";
                         }
 
                         if (!validParameter) {
-                            Tools.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
+                            Logger.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
                         }
                         else {
                             if (!codecSupportedFound) {
@@ -282,7 +283,7 @@ import { SceneComponentConstants } from "sceneComponent";
                         }
                     }
                     catch (ex) {
-                        Tools.Error("Unexpected error. Sound creation aborted.");
+                        Logger.Error("Unexpected error. Sound creation aborted.");
                         this._scene.mainSoundTrack.RemoveSound(this);
                     }
                 }
@@ -291,7 +292,7 @@ import { SceneComponentConstants } from "sceneComponent";
                 // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
                 this._scene.mainSoundTrack.AddSound(this);
                 if (!Engine.audioEngine.WarnedWebAudioUnsupported) {
-                    Tools.Error("Web Audio is not supported by your browser.");
+                    Logger.Error("Web Audio is not supported by your browser.");
                     Engine.audioEngine.WarnedWebAudioUnsupported = true;
                 }
                 // Simulating a ready to play event to avoid breaking code for non web audio browsers
@@ -368,7 +369,7 @@ import { SceneComponentConstants } from "sceneComponent";
                 this._isReadyToPlay = true;
                 if (this.autoplay) { this.play(); }
                 if (this._readyToPlayCallback) { this._readyToPlayCallback(); }
-            }, (err: any) => { Tools.Error("Error while decoding audio data for: " + this.name + " / Error: " + err); });
+            }, (err: any) => { Logger.Error("Error while decoding audio data for: " + this.name + " / Error: " + err); });
         }
 
         /**
@@ -489,7 +490,7 @@ import { SceneComponentConstants } from "sceneComponent";
         */
         public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void {
             if (coneOuterAngle < coneInnerAngle) {
-                Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
+                Logger.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
                 return;
             }
             this._coneInnerAngle = coneInnerAngle;
@@ -516,7 +517,7 @@ import { SceneComponentConstants } from "sceneComponent";
         public set directionalConeInnerAngle(value: number) {
             if (value != this._coneInnerAngle) {
                 if (this._coneOuterAngle < value) {
-                    Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
+                    Logger.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
                     return;
                 }
 
@@ -540,7 +541,7 @@ import { SceneComponentConstants } from "sceneComponent";
         public set directionalConeOuterAngle(value: number) {
             if (value != this._coneOuterAngle) {
                 if (value < this._coneInnerAngle) {
-                    Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
+                    Logger.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
                     return;
                 }
 
@@ -685,7 +686,7 @@ import { SceneComponentConstants } from "sceneComponent";
                     this.isPaused = false;
                 }
                 catch (ex) {
-                    Tools.Error("Error while trying to play audio: " + this.name + ", " + ex.message);
+                    Logger.Error("Error while trying to play audio: " + this.name + ", " + ex.message);
                 }
             }
         }

+ 3 - 3
src/Audio/weightedsound.ts

@@ -1,5 +1,5 @@
 import { Sound } from "Audio/sound";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 
     /**
      * Wraps one or more Sound objects and selects one with random weight for playback.
@@ -60,7 +60,7 @@ import { Tools } from "Misc/tools";
         public set directionalConeInnerAngle(value: number) {
             if (value !== this._coneInnerAngle) {
                 if (this._coneOuterAngle < value) {
-                    Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
+                    Logger.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
                     return;
                 }
 
@@ -86,7 +86,7 @@ import { Tools } from "Misc/tools";
         public set directionalConeOuterAngle(value: number) {
             if (value !== this._coneOuterAngle) {
                 if (value < this._coneInnerAngle) {
-                    Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
+                    Logger.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
                     return;
                 }
 

+ 3 - 2
src/Bones/skeleton.ts

@@ -12,6 +12,7 @@ import { AnimationPropertiesOverride } from "Animations/animationPropertiesOverr
 import { AnimationRange, Animation } from "Animations/animation";
 import { Engine } from "Engines/engine";
 import { Constants } from "Engines/constants";
+import { Logger } from "Misc/logger";
 
     /**
      * Class used to handle skinning animations
@@ -270,7 +271,7 @@ import { Constants } from "Engines/constants";
             }
 
             if (this.bones.length !== sourceBones.length) {
-                Tools.Warn(`copyAnimationRange: this rig has ${this.bones.length} bones, while source as ${sourceBones.length}`);
+                Logger.Warn(`copyAnimationRange: this rig has ${this.bones.length} bones, while source as ${sourceBones.length}`);
                 ret = false;
             }
 
@@ -282,7 +283,7 @@ import { Constants } from "Engines/constants";
                 if (sourceBone) {
                     ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
                 } else {
-                    Tools.Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
+                    Logger.Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
                     ret = false;
                 }
             }

+ 6 - 6
src/Cameras/VR/vrExperienceHelper.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observer, Observable } from "Misc/observable";
 import { Nullable } from "types";
 import { Camera } from "Cameras/camera";
@@ -798,7 +798,7 @@ import { Animation } from "Animations/animation";
                 this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
             }
             catch (err) {
-                Tools.Warn("Error in your custom logic onControllerMeshLoaded: " + err);
+                Logger.Warn("Error in your custom logic onControllerMeshLoaded: " + err);
             }
         }
 
@@ -847,7 +847,7 @@ import { Animation } from "Animations/animation";
                     this.exitVR();
                 }
             } else {
-                Tools.Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
+                Logger.Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
             }
 
             this.updateButtonVisibility();
@@ -900,7 +900,7 @@ import { Animation } from "Animations/animation";
                     this.onEnteringVRObservable.notifyObservers(this);
                 }
                 catch (err) {
-                    Tools.Warn("Error in your custom logic onEnteringVR: " + err);
+                    Logger.Warn("Error in your custom logic onEnteringVR: " + err);
                 }
             }
 
@@ -979,7 +979,7 @@ import { Animation } from "Animations/animation";
                         this.onExitingVRObservable.notifyObservers(this);
                     }
                     catch (err) {
-                        Tools.Warn("Error in your custom logic onExitingVR: " + err);
+                        Logger.Warn("Error in your custom logic onExitingVR: " + err);
                     }
                 }
                 if (this._webVRpresenting) {
@@ -1864,7 +1864,7 @@ import { Animation } from "Animations/animation";
                             this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
                         }
                         catch (err) {
-                            Tools.Warn("Error in your custom logic onNewMeshSelected: " + err);
+                            Logger.Warn("Error in your custom logic onNewMeshSelected: " + err);
                         }
                     }
                     else {

+ 2 - 2
src/Cameras/XR/webXRSessionManager.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observable } from "Misc/observable";
 import { Nullable } from "types";
 import { IDisposable, Scene } from "scene";
@@ -46,7 +46,7 @@ import { Ray } from "Culling/ray";
          * @returns Promise which resolves after it is initialized
          */
         public initializeAsync(): Promise<void> {
-            Tools.Warn("The WebXR APIs are still under development and are subject to change in the future.");
+            Logger.Warn("The WebXR APIs are still under development and are subject to change in the future.");
             // Check if the browser supports webXR
             this._xrNavigator = navigator;
             if (!this._xrNavigator.xr) {

+ 2 - 1
src/Cameras/camera.ts

@@ -19,6 +19,7 @@ import { StereoscopicInterlacePostProcess } from "PostProcesses/stereoscopicInte
 import { VRDistortionCorrectionPostProcess } from "PostProcesses/vrDistortionCorrectionPostProcess";
 import { Animation } from "Animations/animation";
 import { VRCameraMetrics } from "Cameras/VR/vrCameraMetrics";
+import { Logger } from "Misc/logger";
 
 declare type FreeCamera = import("./freeCamera").FreeCamera;
 declare type TargetCamera = import("./targetCamera").TargetCamera;
@@ -585,7 +586,7 @@ declare type TargetCamera = import("./targetCamera").TargetCamera;
          */
         public attachPostProcess(postProcess: PostProcess, insertAt: Nullable<number> = null): number {
             if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
-                Tools.Error("You're trying to reuse a post process not defined as reusable.");
+                Logger.Error("You're trying to reuse a post process not defined as reusable.");
                 return 0;
             }
 

+ 2 - 2
src/Cameras/cameraInputsManager.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { SerializationHelper } from "Misc/decorators";
 import { Nullable } from "types";
 import { Camera } from "./camera";
@@ -111,7 +111,7 @@ import { Camera } from "./camera";
         public add(input: ICameraInput<TCamera>): void {
             var type = input.getSimpleName();
             if (this.attached[type]) {
-                Tools.Warn("camera input of type " + type + " already exists on camera");
+                Logger.Warn("camera input of type " + type + " already exists on camera");
                 return;
             }
 

+ 29 - 22
src/Engines/engine.ts

@@ -28,6 +28,8 @@ import { IOfflineProvider } from "Offline/IOfflineProvider";
 import { ILoadingScreen, DefaultLoadingScreen } from "Loading/loadingScreen";
 import { _DepthCullingState, _StencilState, _AlphaState } from "States";
 import { Constants } from "./constants";
+import { DomManagement } from "Misc/domManagement";
+import { Logger } from "Misc/logger";
 declare type Texture = import("Materials/Textures/texture").Texture;
 declare type VideoTexture = import("Materials/Textures/videoTexture").VideoTexture;
 declare type RenderTargetTexture = import("Materials/Textures/renderTargetTexture").RenderTargetTexture;
@@ -544,7 +546,12 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
         /**
          * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
          */
-        public static ShadersRepository = "src/Shaders/";
+        public static get ShadersRepository(): string {
+            return Effect.ShadersRepository;
+        }
+        public static set ShadersRepository(value: string) {
+            Effect.ShadersRepository = value;
+        }
 
         // Public members
 
@@ -1134,7 +1141,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
                     this.onCanvasPointerOutObservable.notifyObservers(ev);
                 };
 
-                if (Tools.IsWindowObjectExist()) {
+                if (DomManagement.IsWindowObjectExist()) {
                     window.addEventListener("blur", this._onBlur);
                     window.addEventListener("focus", this._onFocus);
                 }
@@ -1146,7 +1153,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
                     this._onContextLost = (evt: Event) => {
                         evt.preventDefault();
                         this._contextWasLost = true;
-                        Tools.Warn("WebGL context lost.");
+                        Logger.Warn("WebGL context lost.");
 
                         this.onContextLostObservable.notifyObservers(this);
                     };
@@ -1164,7 +1171,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
                             this._rebuildBuffers();
                             // Cache
                             this.wipeCaches(true);
-                            Tools.Warn("WebGL context successfully restored.");
+                            Logger.Warn("WebGL context successfully restored.");
                             this.onContextRestoredObservable.notifyObservers(this);
                             this._contextWasLost = false;
                         }, 0);
@@ -1188,7 +1195,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
             }
 
             // Viewport
-            const devicePixelRatio = Tools.IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
+            const devicePixelRatio = DomManagement.IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
 
             var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
             this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
@@ -1252,7 +1259,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
                     document.exitPointerLock();
                 };
 
-                if (Tools.IsWindowObjectExist()) {
+                if (DomManagement.IsWindowObjectExist()) {
                     window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
                     window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
                 }
@@ -4331,7 +4338,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
                         // Add Back
                         customFallback = true;
                         excludeLoaders.push(loader);
-                        Tools.Warn((loader.constructor as any).name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
+                        Logger.Warn((loader.constructor as any).name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
                         this.createTexture(urlArg, noMipmap, invertY, scene, samplingMode, null, onError, buffer, texture, undefined, undefined, excludeLoaders);
                     }
                 }
@@ -4774,7 +4781,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
          */
         public updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void {
             if (this.webGLVersion === 1) {
-                Tools.Error("WebGL 1 does not support texture comparison.");
+                Logger.Error("WebGL 1 does not support texture comparison.");
                 return;
             }
 
@@ -4873,7 +4880,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
             var internalTexture = new InternalTexture(this, InternalTexture.DATASOURCE_DEPTHTEXTURE);
 
             if (!this._caps.depthTextureExtension) {
-                Tools.Error("Depth texture is not supported by your browser or hardware.");
+                Logger.Error("Depth texture is not supported by your browser or hardware.");
                 return internalTexture;
             }
 
@@ -4923,7 +4930,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
             internalTexture.isCube = true;
 
             if (this.webGLVersion === 1) {
-                Tools.Error("Depth cube texture is not supported by WebGL 1.");
+                Logger.Error("Depth cube texture is not supported by WebGL 1.");
                 return internalTexture;
             }
 
@@ -5033,7 +5040,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
 
             if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
                 fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
-                Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
+                Logger.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
             }
 
             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
@@ -5145,7 +5152,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
                 var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
                 if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
                     type = Engine.TEXTURETYPE_UNSIGNED_INT;
-                    Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
+                    Logger.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
                 }
 
                 var texture = new InternalTexture(this, InternalTexture.DATASOURCE_MULTIRENDERTARGET);
@@ -5537,7 +5544,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
 
             if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
                 fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
-                Tools.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
+                Logger.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
             }
 
             gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
@@ -5666,7 +5673,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
                         DDSTools.UploadDDSLevels(this, glTextureFromLod, data, info, true, 6, mipmapIndex);
                     }
                     else {
-                        Tools.Warn("DDS is the only prefiltered cube map supported so far.");
+                        Logger.Warn("DDS is the only prefiltered cube map supported so far.");
                     }
 
                     this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
@@ -5738,7 +5745,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
             let onInternalError = (request?: XMLHttpRequest, exception?: any) => {
                 if (loader) {
                     const fallbackUrl = loader.getFallbackTextureUrl(texture.url, this._textureFormatInUse);
-                    Tools.Warn((loader.constructor as any).name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
+                    Logger.Warn((loader.constructor as any).name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
                     if (fallbackUrl) {
                         excludeLoaders.push(loader);
                         this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
@@ -5936,20 +5943,20 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
             if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
                 generateMipMaps = false;
                 samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
-                Tools.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
+                Logger.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
             }
             else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
                 generateMipMaps = false;
                 samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
-                Tools.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
+                Logger.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
             }
             else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
                 generateMipMaps = false;
-                Tools.Warn("Render to float textures is not supported. Mipmap generation forced to false.");
+                Logger.Warn("Render to float textures is not supported. Mipmap generation forced to false.");
             }
             else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
                 generateMipMaps = false;
-                Tools.Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
+                Logger.Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
             }
 
             var width = size;
@@ -6933,7 +6940,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
             this.disableVR();
 
             // Events
-            if (Tools.IsWindowObjectExist()) {
+            if (DomManagement.IsWindowObjectExist()) {
                 window.removeEventListener("blur", this._onBlur);
                 window.removeEventListener("focus", this._onFocus);
                 window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
@@ -7007,7 +7014,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
          * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
          */
         public displayLoadingUI(): void {
-            if (!Tools.IsWindowObjectExist()) {
+            if (!DomManagement.IsWindowObjectExist()) {
                 return;
             }
             const loadingScreen = this.loadingScreen;
@@ -7021,7 +7028,7 @@ declare type RenderTargetTexture = import("Materials/Textures/renderTargetTextur
          * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
          */
         public hideLoadingUI(): void {
-            if (!Tools.IsWindowObjectExist()) {
+            if (!DomManagement.IsWindowObjectExist()) {
                 return;
             }
             const loadingScreen = this.loadingScreen;

+ 2 - 2
src/Engines/nullEngine.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable, FloatArray, IndicesArray } from "types";
 import { Scene } from "scene";
 import { Matrix, Color3, Color4, Viewport } from "Maths/math";
@@ -125,7 +125,7 @@ import { Constants } from "./constants";
             this._caps.vertexArrayObject = false;
             this._caps.instancedArrays = false;
 
-            Tools.Log(`Babylon.js v${Engine.Version} - Null engine`);
+            Logger.Log(`Babylon.js v${Engine.Version} - Null engine`);
 
             // Wrappers
             if (typeof URL === "undefined") {

+ 2 - 2
src/Gamepads/Controllers/daydreamController.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Scene } from "scene";
 import { AbstractMesh } from "Meshes/abstractMesh";
 import { _TimeToken } from "Instrumentation/timeToken";
@@ -68,7 +68,7 @@ import { PoseEnabledControllerType, ExtendedGamepadButton } from "./poseEnabledC
                 }
             } else {
                 // If the app or home buttons are ever made available
-                Tools.Warn(`Unrecognized Daydream button index: ${buttonIdx}`);
+                Logger.Warn(`Unrecognized Daydream button index: ${buttonIdx}`);
             }
         }
     }

+ 12 - 12
src/Gamepads/Controllers/windowsMotionController.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observable } from "Misc/observable";
 import { Nullable } from "types";
 import { Scene } from "scene";
@@ -346,7 +346,7 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
 
                 path = WindowsMotionController.MODEL_BASE_URL + device + '/';
             } else {
-                Tools.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models");
+                Logger.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models");
                 path = GenericController.MODEL_BASE_URL;
                 filename = GenericController.MODEL_FILENAME;
             }
@@ -366,8 +366,8 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
                     meshLoaded(this._defaultModel);
                 }
             }, null, (scene: Scene, message: string) => {
-                Tools.Log(message);
-                Tools.Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
+                Logger.Log(message);
+                Logger.Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
                 if (!forceDefault) {
                     this.initControllerMesh(scene, meshLoaded, true);
                 }
@@ -409,7 +409,7 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
                 // Create our mesh info. Note that this method will always return non-null.
                 loadedMeshInfo = this.createMeshInfo(parentMesh);
             } else {
-                Tools.Warn('Could not find root node in model file.');
+                Logger.Warn('Could not find root node in model file.');
             }
 
             return loadedMeshInfo;
@@ -428,13 +428,13 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
             for (i = 0; i < this._mapping.buttons.length; i++) {
                 var buttonMeshName = (<any>this._mapping.buttonMeshNames)[this._mapping.buttons[i]];
                 if (!buttonMeshName) {
-                    Tools.Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
+                    Logger.Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
                     continue;
                 }
 
                 var buttonMesh = getChildByName(rootNode, buttonMeshName);
                 if (!buttonMesh) {
-                    Tools.Warn('Missing button mesh with name: ' + buttonMeshName);
+                    Logger.Warn('Missing button mesh with name: ' + buttonMeshName);
                     continue;
                 }
 
@@ -448,7 +448,7 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
                     loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
                 } else {
                     // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
-                    Tools.Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
+                    Logger.Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
                         '(VALUE: ' + !!buttonMeshInfo.value +
                         ', PRESSED: ' + !!buttonMeshInfo.pressed +
                         ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
@@ -460,13 +460,13 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
             for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
                 var axisMeshName = this._mapping.axisMeshNames[i];
                 if (!axisMeshName) {
-                    Tools.Log('Skipping unknown axis at index: ' + i);
+                    Logger.Log('Skipping unknown axis at index: ' + i);
                     continue;
                 }
 
                 var axisMesh = getChildByName(rootNode, axisMeshName);
                 if (!axisMesh) {
-                    Tools.Warn('Missing axis mesh with name: ' + axisMeshName);
+                    Logger.Warn('Missing axis mesh with name: ' + axisMeshName);
                     continue;
                 }
 
@@ -480,7 +480,7 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
                     loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
                 } else {
                     // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
-                    Tools.Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
+                    Logger.Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
                         '(VALUE: ' + !!axisMeshInfo.value +
                         ', MIN: ' + !!axisMeshInfo.min +
                         ', MAX:' + !!axisMeshInfo.max +
@@ -491,7 +491,7 @@ import { StickValues, GamepadButtonChanges } from "Gamepads/gamepad";
             // Pointing Ray
             loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
             if (!loadedMeshInfo.pointingPoseNode) {
-                Tools.Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
+                Logger.Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
             }else {
                 this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
             }

+ 2 - 1
src/Gamepads/gamepadManager.ts

@@ -1,5 +1,6 @@
 import { Tools } from "Misc/tools";
 import { Observable } from "Misc/observable";
+import { DomManagement } from "Misc/domManagement";
 import { Nullable } from "types";
 import { Scene } from "scene";
 import { _TimeToken } from "Instrumentation/timeToken";
@@ -38,7 +39,7 @@ import { Gamepad, GenericPad } from "./gamepad";
          * @param _scene BabylonJS scene
          */
         constructor(private _scene?: Scene) {
-            if (!Tools.IsWindowObjectExist()) {
+            if (!DomManagement.IsWindowObjectExist()) {
                 this._gamepadEventSupported = false;
             } else {
                 this._gamepadEventSupported = 'GamepadEvent' in window;

+ 2 - 2
src/Gizmos/boundingBoxGizmo.ts

@@ -1,5 +1,5 @@
 import { Observer, Observable } from "Misc/observable";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { PointerInfo } from "Events/pointerEvents";
 import { Scene } from "scene";
@@ -529,6 +529,6 @@ import { StandardMaterial } from "Materials/standardMaterial";
          * @param mesh The mesh to replace the default mesh of the gizmo
          */
         public setCustomMesh(mesh: Mesh) {
-            Tools.Error("Custom meshes are not supported on this gizmo");
+            Logger.Error("Custom meshes are not supported on this gizmo");
         }
     }

+ 2 - 2
src/Gizmos/positionGizmo.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observable } from "Misc/observable";
 import { Nullable } from "types";
 import { Vector3, Color3 } from "Maths/math";
@@ -116,6 +116,6 @@ import { UtilityLayerRenderer } from "Rendering/utilityLayerRenderer";
          * @param mesh The mesh to replace the default mesh of the gizmo
          */
         public setCustomMesh(mesh: Mesh) {
-            Tools.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)");
+            Logger.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)");
         }
     }

+ 2 - 2
src/Gizmos/rotationGizmo.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observable } from "Misc/observable";
 import { Nullable } from "types";
 import { Vector3, Color3 } from "Maths/math";
@@ -117,6 +117,6 @@ import { UtilityLayerRenderer } from "Rendering/utilityLayerRenderer";
          * @param mesh The mesh to replace the default mesh of the gizmo
          */
         public setCustomMesh(mesh: Mesh) {
-            Tools.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)");
+            Logger.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)");
         }
     }

+ 2 - 2
src/Gizmos/scaleGizmo.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observable } from "Misc/observable";
 import { Nullable } from "types";
 import { Vector3, Color3 } from "Maths/math";
@@ -79,7 +79,7 @@ import { UtilityLayerRenderer } from "Rendering/utilityLayerRenderer";
 
         public set updateGizmoRotationToMatchAttachedMesh(value: boolean) {
             if (!value) {
-                Tools.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
+                Logger.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
             }
             if (this.xGizmo) {
                 this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;

+ 2 - 2
src/Helpers/sceneHelpers.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { Scene } from "scene";
 import { Vector3 } from "Maths/math";
@@ -151,7 +151,7 @@ declare module "scene" {
     Scene.prototype.createDefaultSkybox = function(environmentTexture?: BaseTexture, pbr = false, scale = 1000, blur = 0, setGlobalEnvTexture = true): Nullable<Mesh> {
 
         if (!environmentTexture) {
-            Tools.Warn("Can not create default skybox without environment texture.");
+            Logger.Warn("Can not create default skybox without environment texture.");
             return null;
         }
 

+ 2 - 1
src/Layers/highlightLayer.ts

@@ -22,6 +22,7 @@ import { _DepthCullingState, _StencilState, _AlphaState } from "States";
 import { EffectLayer } from "./effectLayer";
 import { AbstractScene } from "abstractScene";
 import { Constants } from "Engines/constants";
+import { Logger } from "Misc/logger";
 
 declare module "abstractScene" {
     export interface AbstractScene {
@@ -264,7 +265,7 @@ declare module "abstractScene" {
 
             // Warn on stencil
             if (!this._engine.isStencilEnable) {
-                Tools.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }");
+                Logger.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }");
             }
 
             // Adapt options

+ 9 - 9
src/Loading/Plugins/babylonFileLoader.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { Camera } from "Cameras";
 import { Scene } from "scene";
@@ -353,12 +353,12 @@ import { CannonJSPlugin, OimoJSPlugin } from "Physics";
             if (onError) {
                 onError(msg, err);
             } else {
-                Tools.Log(msg);
+                Logger.Log(msg);
                 throw err;
             }
         } finally {
             if (log !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING) {
-                Tools.Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? log : ""));
+                Logger.Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? log : ""));
             }
         }
 
@@ -451,7 +451,7 @@ import { CannonJSPlugin, OimoJSPlugin } from "Physics";
                                         }
                                     });
                                     if (found === false) {
-                                        Tools.Warn("Geometry not found for mesh " + parsedMesh.id);
+                                        Logger.Warn("Geometry not found for mesh " + parsedMesh.id);
                                     }
                                 }
                             }
@@ -486,7 +486,7 @@ import { CannonJSPlugin, OimoJSPlugin } from "Physics";
                                     loadedMaterialsIds.push(parsedMesh.materialId);
                                     var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
                                     if (!mat) {
-                                        Tools.Warn("Material not found for mesh " + parsedMesh.id);
+                                        Logger.Warn("Material not found for mesh " + parsedMesh.id);
                                     } else {
                                         log += "\n\tMaterial " + mat.toString(fullDetails);
                                     }
@@ -564,12 +564,12 @@ import { CannonJSPlugin, OimoJSPlugin } from "Physics";
                 if (onError) {
                     onError(msg, err);
                 } else {
-                    Tools.Log(msg);
+                    Logger.Log(msg);
                     throw err;
                 }
             } finally {
                 if (log !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING) {
-                    Tools.Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? log : ""));
+                    Logger.Log(logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? log : ""));
                 }
             }
 
@@ -684,12 +684,12 @@ import { CannonJSPlugin, OimoJSPlugin } from "Physics";
                 if (onError) {
                     onError(msg, err);
                 } else {
-                    Tools.Log(msg);
+                    Logger.Log(msg);
                     throw err;
                 }
             } finally {
                 if (log !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING) {
-                    Tools.Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? log : ""));
+                    Logger.Log(logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? log : ""));
                 }
             }
             return false;

File diff suppressed because it is too large
+ 9 - 8
src/Loading/sceneLoader.ts


+ 2 - 2
src/Materials/Background/backgroundMaterial.ts

@@ -1,7 +1,7 @@
 import { SerializationHelper, serialize, serializeAsColor3, expandToProperty, serializeAsTexture, serializeAsVector3, serializeAsImageProcessingConfiguration } from "Misc/decorators";
 import { SmartArray } from "Misc/smartArray";
 import { Observer } from "Misc/observable";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable, int, float } from "types";
 import { Scene } from "scene";
 import { Matrix, Vector3, Color3, Vector4 } from "Maths/math";
@@ -816,7 +816,7 @@ import { Constants } from "Engines/constants";
                 if (mesh) {
                     if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
                         mesh.createNormals(true);
-                        Tools.Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
+                        Logger.Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
                     }
                 }
             }

+ 3 - 2
src/Materials/PBR/pbrBaseMaterial.ts

@@ -1,6 +1,7 @@
 import { serialize, serializeAsImageProcessingConfiguration } from "Misc/decorators";
 import { Observer } from "Misc/observable";
-import { Tools, IAnimatable } from "Misc/tools";
+import { IAnimatable } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { SmartArray } from "Misc/smartArray";
 import { TextureTools } from "Misc/textureTools";
 import { Nullable } from "types";
@@ -916,7 +917,7 @@ import { Constants } from "Engines/constants";
 
             if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
                 mesh.createNormals(true);
-                Tools.Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
+                Logger.Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
             }
 
             let previousEffect = subMesh.effect;

+ 4 - 3
src/Materials/Textures/Procedurals/customProceduralTexture.ts

@@ -1,4 +1,5 @@
 import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Scene } from "scene";
 import { Vector3, Vector2, Color3, Color4 } from "Maths/math";
 import { _TimeToken } from "Instrumentation/timeToken";
@@ -39,12 +40,12 @@ import { ProceduralTexture } from "./proceduralTexture";
 
         private _loadJson(jsonUrl: string): void {
             let noConfigFile = () => {
-                Tools.Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
+                Logger.Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
                 try {
                     this.setFragment(this._texturePath);
                 }
                 catch (ex) {
-                    Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
+                    Logger.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
                 }
             };
 
@@ -84,7 +85,7 @@ import { ProceduralTexture } from "./proceduralTexture";
                 xhr.send();
             }
             catch (ex) {
-                Tools.Error("CustomProceduralTexture: Error on XHR send request.");
+                Logger.Error("CustomProceduralTexture: Error on XHR send request.");
             }
         }
 

+ 2 - 2
src/Materials/Textures/dynamicTexture.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { Scene } from "scene";
 import { ISize } from "Maths/math";
@@ -193,7 +193,7 @@ import { Constants } from "Engines/constants";
         public serialize(): any {
             const scene = this.getScene();
             if (scene && !scene.isReady()) {
-                Tools.Warn("The scene must be ready before serializing the dynamic texture");
+                Logger.Warn("The scene must be ready before serializing the dynamic texture");
             }
 
             const serializationObject = super.serialize();

+ 3 - 2
src/Materials/Textures/videoTexture.ts

@@ -1,5 +1,6 @@
 import { Observable } from "Misc/observable";
 import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { Scene } from "scene";
 import { Engine } from "Engines/engine";
@@ -374,7 +375,7 @@ import { Texture } from "Materials/Textures/texture";
                         video.play();
                     })
                     .catch(function(err) {
-                        Tools.Error(err.name);
+                        Logger.Error(err.name);
                     });
             }
             else {
@@ -414,7 +415,7 @@ import { Texture } from "Materials/Textures/texture";
                             }
                         },
                         function(e: MediaStreamError) {
-                            Tools.Error(e.name);
+                            Logger.Error(e.name);
                         }
                     );
                 }

+ 31 - 27
src/Materials/effect.ts

@@ -1,16 +1,16 @@
-import { Tools } from "Misc/tools";
 import { Observable } from "Misc/observable";
 import { Nullable } from "types";
 import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "Maths/math";
-import { Engine } from "Engines/engine";
-import { AbstractMesh } from "Meshes/abstractMesh";
-import { PostProcess } from "PostProcesses/postProcess";
-
-import { InternalTexture } from "Materials/Textures/internalTexture";
-import { BaseTexture } from "Materials/Textures/baseTexture";
-import { RenderTargetTexture } from "Materials/Textures/renderTargetTexture";
 import { Constants } from "Engines/constants";
-
+import { DomManagement } from "Misc/domManagement";
+import { Logger } from "Misc/logger";
+
+declare type Engine = import("Engines/engine").Engine;
+declare type InternalTexture = import("Materials/Textures/internalTexture").InternalTexture;
+declare type BaseTexture  = import("Materials/Textures/baseTexture").BaseTexture;
+declare type RenderTargetTexture = import("Materials/Textures/renderTargetTexture").RenderTargetTexture;
+declare type PostProcess = import("PostProcesses/postProcess").PostProcess;
+declare type AbstractMesh = import("Meshes/abstractMesh").AbstractMesh;
     /**
      * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
      * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
@@ -183,6 +183,10 @@ import { Constants } from "Engines/constants";
      */
     export class Effect {
         /**
+         * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
+         */
+        public static ShadersRepository = "src/Shaders/";
+        /**
          * Name of the effect.
          */
         public name: any;
@@ -500,10 +504,10 @@ import { Constants } from "Engines/constants";
 
         /** @hidden */
         public _loadVertexShader(vertex: any, callback: (data: any) => void): void {
-            if (Tools.IsWindowObjectExist()) {
+            if (DomManagement.IsWindowObjectExist()) {
                 // DOM element ?
                 if (vertex instanceof HTMLElement) {
-                    var vertexCode = Tools.GetDOMTextContent(vertex);
+                    var vertexCode = DomManagement.GetDOMTextContent(vertex);
                     callback(vertexCode);
                     return;
                 }
@@ -527,7 +531,7 @@ import { Constants } from "Engines/constants";
             if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
                 vertexShaderUrl = vertex;
             } else {
-                vertexShaderUrl = Engine.ShadersRepository + vertex;
+                vertexShaderUrl = Effect.ShadersRepository + vertex;
             }
 
             // Vertex shader
@@ -536,10 +540,10 @@ import { Constants } from "Engines/constants";
 
         /** @hidden */
         public _loadFragmentShader(fragment: any, callback: (data: any) => void): void {
-            if (Tools.IsWindowObjectExist()) {
+            if (DomManagement.IsWindowObjectExist()) {
                 // DOM element ?
                 if (fragment instanceof HTMLElement) {
-                    var fragmentCode = Tools.GetDOMTextContent(fragment);
+                    var fragmentCode = DomManagement.GetDOMTextContent(fragment);
                     callback(fragmentCode);
                     return;
                 }
@@ -568,7 +572,7 @@ import { Constants } from "Engines/constants";
             if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
                 fragmentShaderUrl = fragment;
             } else {
-                fragmentShaderUrl = Engine.ShadersRepository + fragment;
+                fragmentShaderUrl = Effect.ShadersRepository + fragment;
             }
 
             // Fragment shader
@@ -592,16 +596,16 @@ import { Constants } from "Engines/constants";
 
             // Dump shaders name and formatted source code
             if (this.name.vertexElement) {
-                Tools.Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
-                Tools.Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
+                Logger.Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
+                Logger.Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
             }
             else if (this.name.vertex) {
-                Tools.Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
-                Tools.Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
+                Logger.Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
+                Logger.Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
             }
             else {
-                Tools.Error("Vertex shader: " + this.name + formattedVertexCode);
-                Tools.Error("Fragment shader: " + this.name + formattedFragmentCode);
+                Logger.Error("Vertex shader: " + this.name + formattedVertexCode);
+                Logger.Error("Fragment shader: " + this.name + formattedFragmentCode);
             }
         }
 
@@ -719,7 +723,7 @@ import { Constants } from "Engines/constants";
                     // Replace
                     returnValue = returnValue.replace(match[0], includeContent);
                 } else {
-                    var includeShaderUrl = Engine.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
+                    var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
 
                     this._engine._loadFile(includeShaderUrl, (fileContent) => {
                         Effect.IncludesShadersStore[includeFile] = fileContent as string;
@@ -863,14 +867,14 @@ import { Constants } from "Engines/constants";
                 this._compilationError = e.message;
 
                 // Let's go through fallbacks then
-                Tools.Error("Unable to compile effect:");
-                Tools.Error("Uniforms: " + this._uniformsNames.map(function(uniform) {
+                Logger.Error("Unable to compile effect:");
+                Logger.Error("Uniforms: " + this._uniformsNames.map(function(uniform) {
                     return " " + uniform;
                 }));
-                Tools.Error("Attributes: " + attributesNames.map(function(attribute) {
+                Logger.Error("Attributes: " + attributesNames.map(function(attribute) {
                     return " " + attribute;
                 }));
-                Tools.Error("Error: " + this._compilationError);
+                Logger.Error("Error: " + this._compilationError);
                 if (previousProgram) {
                     this._program = previousProgram;
                     this._isReady = true;
@@ -881,7 +885,7 @@ import { Constants } from "Engines/constants";
                 }
 
                 if (fallbacks && fallbacks.isMoreFallbacks) {
-                    Tools.Error("Trying next fallback.");
+                    Logger.Error("Trying next fallback.");
                     this.defines = fallbacks.reduce(this.defines, this);
                     this._prepareEffect();
                 } else { // Sorry we did everything we can

+ 2 - 1
src/Materials/material.ts

@@ -17,6 +17,7 @@ import { RenderTargetTexture } from "Materials/Textures/renderTargetTexture";
 import { Animation } from "Animations/animation";
 import { MaterialDefines } from "./materialDefines";
 import { Constants } from "Engines/constants";
+import { Logger } from "Misc/logger";
 
 declare var BABYLON: any;
 
@@ -1201,7 +1202,7 @@ declare var BABYLON: any;
             else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
                 parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
                 if (!BABYLON.LegacyPBRMaterial) {
-                    Tools.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
+                    Logger.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
                     return;
                 }
             }

+ 2 - 2
src/Materials/materialHelper.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { Camera } from "Cameras/camera";
 import { Scene } from "scene";
@@ -488,7 +488,7 @@ import { BaseTexture } from "Materials/Textures/baseTexture";
                     }
 
                     if (attribs.length > maxAttributesCount) {
-                        Tools.Error("Cannot add more vertex attributes for mesh " + mesh.name);
+                        Logger.Error("Cannot add more vertex attributes for mesh " + mesh.name);
                     }
                 }
             }

+ 2 - 2
src/Materials/uniformBuffer.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable, FloatArray } from "types";
 import { Matrix, Vector3, Color3, Vector4 } from "Maths/math";
 import { Engine } from "Engines/engine";
@@ -425,7 +425,7 @@ import { BaseTexture } from "Materials/Textures/baseTexture";
             if (location === undefined) {
                 if (this._buffer) {
                     // Cannot add an uniform if the buffer is already created
-                    Tools.Error("Cannot add an uniform after UBO has been created.");
+                    Logger.Error("Cannot add an uniform after UBO has been created.");
                     return;
                 }
                 this.addUniform(uniformName, size);

+ 2 - 1
src/Meshes/instancedMesh.ts

@@ -1,6 +1,7 @@
 import { Nullable, FloatArray, IndicesArray } from "types";
 import { Vector3 } from "Maths/math";
 import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Camera } from "Cameras/camera";
 import { Node } from "node";
 import { AbstractMesh } from "Meshes/abstractMesh";
@@ -94,7 +95,7 @@ Mesh._instancedMeshFactory = (name: string, mesh: Mesh): InstancedMesh => {
             }
 
             //no-op with warning
-            Tools.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
+            Logger.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
         }
 
         /**

+ 6 - 5
src/Meshes/mesh.ts

@@ -24,6 +24,7 @@ import { MorphTargetManager } from "Morph/morphTargetManager";
 import { PhysicsImpostor } from "Physics/physicsImpostor";
 import { Constants } from "Engines/constants";
 import { SerializationHelper } from "Misc/decorators";
+import { Logger } from "Misc/logger";
 
 declare type LinesMesh = import("./linesMesh").LinesMesh;
 declare type InstancedMesh = import("./instancedMesh").InstancedMesh;
@@ -499,7 +500,7 @@ declare type GroundMesh = import("./groundMesh").GroundMesh;
          */
         public addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh {
             if (mesh && mesh._masterMesh) {
-                Tools.Warn("You cannot use a mesh as LOD level twice");
+                Logger.Warn("You cannot use a mesh as LOD level twice");
                 return this;
             }
 
@@ -2109,7 +2110,7 @@ declare type GroundMesh = import("./groundMesh").GroundMesh;
             if (!this.isVerticesDataPresent(VertexBuffer.PositionKind)
                 || !this.isVerticesDataPresent(VertexBuffer.NormalKind)
                 || !this.isVerticesDataPresent(VertexBuffer.UVKind)) {
-                Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
+                Logger.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
                 return this;
             }
 
@@ -2600,7 +2601,7 @@ declare type GroundMesh = import("./groundMesh").GroundMesh;
             let morphTargetManager = this._morphTargetManager;
             if (morphTargetManager && morphTargetManager.vertexCount) {
                 if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
-                    Tools.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
+                    Logger.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
                     this.morphTargetManager = null;
                     return;
                 }
@@ -2610,7 +2611,7 @@ declare type GroundMesh = import("./groundMesh").GroundMesh;
 
                     const positions = morphTarget.getPositions();
                     if (!positions) {
-                        Tools.Error("Invalid morph target. Target must have positions.");
+                        Logger.Error("Invalid morph target. Target must have positions.");
                         return;
                     }
 
@@ -3548,7 +3549,7 @@ declare type GroundMesh = import("./groundMesh").GroundMesh;
                         totalVertices += meshes[index].getTotalVertices();
 
                         if (totalVertices > 65536) {
-                            Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
+                            Logger.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices");
                             return null;
                         }
                     }

+ 2 - 2
src/Meshes/polygonMesh.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Scene } from "scene";
 import { Vector3, Vector2, Path2 } from "Maths/math";
 import { VertexBuffer } from "Meshes/buffer";
@@ -187,7 +187,7 @@ import { Mesh } from "Meshes/mesh";
             this._outlinepoints.add(points);
 
             if (typeof earcut === 'undefined') {
-                Tools.Warn("Earcut was not found, the polygon will not be built.");
+                Logger.Warn("Earcut was not found, the polygon will not be built.");
             }
         }
 

+ 3 - 2
src/Misc/assetsManager.ts

@@ -9,6 +9,7 @@ import { BaseTexture } from "Materials/Textures/baseTexture";
 import { Texture } from "Materials/Textures/texture";
 import { CubeTexture } from "Materials/Textures/cubeTexture";
 import { HDRCubeTexture } from "Materials/Textures/hdrCubeTexture";
+import { Logger } from "Misc/logger";
 
     /**
      * Defines the list of states available for a task inside a AssetsManager
@@ -882,7 +883,7 @@ import { HDRCubeTexture } from "Materials/Textures/hdrCubeTexture";
                     )
                 );
             } catch (e) {
-                Tools.Error("Error running progress callbacks.");
+                Logger.Error("Error running progress callbacks.");
                 console.log(e);
             }
 
@@ -906,7 +907,7 @@ import { HDRCubeTexture } from "Materials/Textures/hdrCubeTexture";
 
                     this.onTasksDoneObservable.notifyObservers(this._tasks);
                 } catch (e) {
-                    Tools.Error("Error running tasks-done callbacks.");
+                    Logger.Error("Error running tasks-done callbacks.");
                     console.log(e);
                 }
                 this._isLoading = false;

+ 4 - 4
src/Misc/dds.ts

@@ -3,7 +3,7 @@ import { SphericalPolynomial } from "Maths/sphericalPolynomial";
 import { Constants } from "Engines/constants";
 import { InternalTexture } from "Materials/Textures/internalTexture";
 import { Nullable } from "types";
-import { Tools } from "./tools";
+import { Logger } from "Misc/logger";
 import { CubeMapToSphericalPolynomialTools } from "Misc/HighDynamicRange/cubemapToSphericalPolynomial";
 
 declare type Engine = import("Engines/engine").Engine;
@@ -451,17 +451,17 @@ declare type Engine = import("Engines/engine").Engine;
             let blockBytes = 1;
 
             if (header[off_magic] !== DDS_MAGIC) {
-                Tools.Error("Invalid magic number in DDS header");
+                Logger.Error("Invalid magic number in DDS header");
                 return;
             }
 
             if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
-                Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
+                Logger.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
                 return;
             }
 
             if (info.isCompressed && !ext) {
-                Tools.Error("Compressed textures are not supported on this platform.");
+                Logger.Error("Compressed textures are not supported on this platform.");
                 return;
             }
 

+ 32 - 0
src/Misc/domManagement.ts

@@ -0,0 +1,32 @@
+/**
+ * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
+ * Babylon.js
+ */
+export class DomManagement {
+    /**
+     * Checks if the window object exists
+     * @returns true if the window object exists
+     */
+    public static IsWindowObjectExist(): boolean {
+        return (typeof window) !== "undefined";
+    }
+
+    /**
+     * Extracts text content from a DOM element hierarchy
+     * @param element defines the root element
+     * @returns a string
+     */
+    public static GetDOMTextContent(element: HTMLElement): string {
+        var result = "";
+        var child = element.firstChild;
+
+        while (child) {
+            if (child.nodeType === 3) {
+                result += child.textContent;
+            }
+            child = <any>(child.nextSibling);
+        }
+
+        return result;
+    }
+}

+ 3 - 2
src/Misc/environmentTextureTools.ts

@@ -9,6 +9,7 @@ import { CubeTexture } from "Materials/Textures/cubeTexture";
 import { Constants } from "Engines/constants";
 import { Scene } from "scene";
 import { PostProcess } from "PostProcesses/postProcess";
+import { Logger } from "Misc/logger";
 
     /**
      * Raw texture data and descriptor sufficient for WebGL texture upload
@@ -109,7 +110,7 @@ import { PostProcess } from "PostProcesses/postProcess";
 
             for (let i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
                 if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
-                    Tools.Error('Not a babylon environment map');
+                    Logger.Error('Not a babylon environment map');
                     return null;
                 }
             }
@@ -585,7 +586,7 @@ import { PostProcess } from "PostProcesses/postProcess";
          */
         public static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void {
             if (info.version !== 1) {
-                Tools.Warn('Unsupported babylon environment map version "' + info.version + '"');
+                Logger.Warn('Unsupported babylon environment map version "' + info.version + '"');
             }
 
             let irradianceInfo = info.irradiance as EnvironmentTextureIrradianceInfoV1;

+ 3 - 2
src/Misc/filesInput.ts

@@ -2,6 +2,7 @@ import { Engine } from "Engines/engine";
 import { Scene } from "scene";
 import { SceneLoaderProgressEvent, SceneLoader } from "Loading/sceneLoader";
 import { Tools } from "./tools";
+import { Logger } from "Misc/logger";
 
     /**
      * Class used to help managing file picking and drag'n'drop
@@ -256,7 +257,7 @@ import { Tools } from "./tools";
             // If a scene file has been provided
             if (this._sceneFileToLoad) {
                 if (this._currentScene) {
-                    if (Tools.errorsCount > 0) {
+                    if (Logger.errorsCount > 0) {
                         Tools.ClearLogCache();
                     }
                     this._engine.stopRenderLoop();
@@ -290,7 +291,7 @@ import { Tools } from "./tools";
                 });
             }
             else {
-                Tools.Error("Please provide a valid .babylon file.");
+                Logger.Error("Please provide a valid .babylon file.");
             }
         }
     }

+ 6 - 6
src/Misc/khronosTextureContainer.ts

@@ -1,4 +1,4 @@
-import { Tools } from "./tools";
+import { Logger } from "Misc/logger";
 import { InternalTexture } from "Materials/Textures/internalTexture";
 
     /**
@@ -89,7 +89,7 @@ import { InternalTexture } from "Materials/Textures/internalTexture";
             if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
                 identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
                 this.isInvalid = true;
-                    Tools.Error("texture missing KTX identifier");
+                    Logger.Error("texture missing KTX identifier");
                 return;
             }
 
@@ -115,7 +115,7 @@ import { InternalTexture } from "Materials/Textures/internalTexture";
 
             // Make sure we have a compressed type.  Not only reduces work, but probably better to let dev know they are not compressing.
             if (this.glType !== 0) {
-                Tools.Error("only compressed formats currently supported");
+                Logger.Error("only compressed formats currently supported");
                 return;
             } else {
                 // value of zero is an indication to generate mipmaps @ runtime.  Not usually allowed for compressed, so disregard.
@@ -123,17 +123,17 @@ import { InternalTexture } from "Materials/Textures/internalTexture";
             }
 
             if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
-                Tools.Error("only 2D textures currently supported");
+                Logger.Error("only 2D textures currently supported");
                 return;
             }
 
             if (this.numberOfArrayElements !== 0) {
-                Tools.Error("texture arrays not currently supported");
+                Logger.Error("texture arrays not currently supported");
                 return;
             }
 
             if (this.numberOfFaces !== facesExpected) {
-                Tools.Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
+                Logger.Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
                 return;
             }
 

+ 144 - 0
src/Misc/logger.ts

@@ -0,0 +1,144 @@
+/**
+ * Logger used througouht the application to allow configuration of
+ * the log level required for the messages.
+ */
+export class Logger {
+    /**
+     * No log
+     */
+    public static readonly NoneLogLevel = 0;
+    /**
+     * Only message logs
+     */
+    public static readonly MessageLogLevel = 1;
+    /**
+     * Only warning logs
+     */
+    public static readonly WarningLogLevel = 2;
+    /**
+     * Only error logs
+     */
+    public static readonly ErrorLogLevel = 4;
+    /**
+     * All logs
+     */
+    public static readonly AllLogLevel = 7;
+
+    private static _LogCache = "";
+
+    /**
+     * Gets a value indicating the number of loading errors
+     * @ignorenaming
+     */
+    public static errorsCount = 0;
+
+    /**
+     * Callback called when a new log is added
+     */
+    public static OnNewCacheEntry: (entry: string) => void;
+
+    private static _AddLogEntry(entry: string) {
+        Logger._LogCache = entry + Logger._LogCache;
+
+        if (Logger.OnNewCacheEntry) {
+            Logger.OnNewCacheEntry(entry);
+        }
+    }
+
+    private static _FormatMessage(message: string): string {
+        var padStr = (i: number) => (i < 10) ? "0" + i : "" + i;
+
+        var date = new Date();
+        return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
+    }
+
+    private static _LogDisabled(message: string): void {
+        // nothing to do
+    }
+    private static _LogEnabled(message: string): void {
+        var formattedMessage = Logger._FormatMessage(message);
+        console.log("BJS - " + formattedMessage);
+
+        var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
+        Logger._AddLogEntry(entry);
+    }
+
+    private static _WarnDisabled(message: string): void {
+        // nothing to do
+    }
+    private static _WarnEnabled(message: string): void {
+        var formattedMessage = Logger._FormatMessage(message);
+        console.warn("BJS - " + formattedMessage);
+
+        var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
+        Logger._AddLogEntry(entry);
+    }
+
+    private static _ErrorDisabled(message: string): void {
+        // nothing to do
+    }
+    private static _ErrorEnabled(message: string): void {
+        Logger.errorsCount++;
+        var formattedMessage = Logger._FormatMessage(message);
+        console.error("BJS - " + formattedMessage);
+
+        var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
+        Logger._AddLogEntry(entry);
+    }
+
+    /**
+     * Log a message to the console
+     */
+    public static Log: (message: string) => void = Logger._LogEnabled;
+
+    /**
+     * Write a warning message to the console
+     */
+    public static Warn: (message: string) => void = Logger._WarnEnabled;
+
+    /**
+     * Write an error message to the console
+     */
+    public static Error: (message: string) => void = Logger._ErrorEnabled;
+
+    /**
+     * Gets current log cache (list of logs)
+     */
+    public static get LogCache(): string {
+        return Logger._LogCache;
+    }
+
+    /**
+     * Clears the log cache
+     */
+    public static ClearLogCache(): void {
+        Logger._LogCache = "";
+        Logger.errorsCount = 0;
+    }
+
+    /**
+     * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
+     */
+    public static set LogLevels(level: number) {
+        if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
+            Logger.Log = Logger._LogEnabled;
+        }
+        else {
+            Logger.Log = Logger._LogDisabled;
+        }
+
+        if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
+            Logger.Warn = Logger._WarnEnabled;
+        }
+        else {
+            Logger.Warn = Logger._WarnDisabled;
+        }
+
+        if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
+            Logger.Error = Logger._ErrorEnabled;
+        }
+        else {
+            Logger.Error = Logger._ErrorDisabled;
+        }
+    }
+}

+ 3 - 3
src/Misc/tga.ts

@@ -1,5 +1,5 @@
 import { InternalTexture } from "Materials/Textures/internalTexture";
-import { Tools } from "./tools";
+import { Logger } from "Misc/logger";
 
     /**
      * Based on jsTGALoader - Javascript loader for TGA file
@@ -57,7 +57,7 @@ import { Tools } from "./tools";
         public static UploadContent(texture: InternalTexture, data: Uint8Array): void {
             // Not enough data to contain header ?
             if (data.length < 19) {
-                Tools.Error("Unable to load TGA file - Not enough data to contain header");
+                Logger.Error("Unable to load TGA file - Not enough data to contain header");
                 return;
             }
 
@@ -67,7 +67,7 @@ import { Tools } from "./tools";
 
             // Assume it's a valid Targa file.
             if (header.id_length + offset > data.length) {
-                Tools.Error("Unable to load TGA file - Not enough data");
+                Logger.Error("Unable to load TGA file - Not enough data");
                 return;
             }
 

+ 36 - 111
src/Misc/tools.ts

@@ -11,6 +11,8 @@ import { Observable } from "./observable";
 import { FilesInput } from "./filesInput";
 import { TGATools } from "./tga";
 import { Constants } from "Engines/constants";
+import { DomManagement } from "./domManagement";
+import { Logger } from "./logger";
 
 declare type Engine = import("Engines/engine").Engine;
 
@@ -336,7 +338,7 @@ declare type Engine = import("Engines/engine").Engine;
          * @param action defines the action to execute after the current execution block
          */
         public static SetImmediate(action: () => void) {
-            if (Tools.IsWindowObjectExist() && window.setImmediate) {
+            if (DomManagement.IsWindowObjectExist() && window.setImmediate) {
                 window.setImmediate(action);
             } else {
                 setTimeout(action, 1);
@@ -478,19 +480,7 @@ declare type Engine = import("Engines/engine").Engine;
          * @param element defines the root element
          * @returns a string
          */
-        public static GetDOMTextContent(element: HTMLElement): string {
-            var result = "";
-            var child = element.firstChild;
-
-            while (child) {
-                if (child.nodeType === 3) {
-                    result += child.textContent;
-                }
-                child = <any>(child.nextSibling);
-            }
-
-            return result;
-        }
+        public static GetDOMTextContent = DomManagement.GetDOMTextContent;
 
         /**
          * Convert an angle in radians to degrees
@@ -643,7 +633,7 @@ declare type Engine = import("Engines/engine").Engine;
             var eventPrefix = "pointer";
 
             // Check if pointer events are supported
-            if (Tools.IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
+            if (DomManagement.IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
                 eventPrefix = "mouse";
             }
 
@@ -657,7 +647,7 @@ declare type Engine = import("Engines/engine").Engine;
          * @returns frame number
          */
         public static QueueNewFrame(func: () => void, requester?: any): number {
-            if (!Tools.IsWindowObjectExist()) {
+            if (!DomManagement.IsWindowObjectExist()) {
                 return setTimeout(func, 16);
             }
 
@@ -801,7 +791,7 @@ declare type Engine = import("Engines/engine").Engine;
                 img.removeEventListener("load", loadHandler);
                 img.removeEventListener("error", errorHandler);
 
-                Tools.Error("Error while trying to load image: " + input);
+                Logger.Error("Error while trying to load image: " + input);
 
                 if (onError) {
                     onError("Error while trying to load image: " + input, err);
@@ -930,7 +920,7 @@ declare type Engine = import("Engines/engine").Engine;
                             // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
                             request.removeEventListener("readystatechange", onReadyStateChange);
 
-                            if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!Tools.IsWindowObjectExist() || Tools.IsFileURL()))) {
+                            if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!DomManagement.IsWindowObjectExist() || Tools.IsFileURL()))) {
                                 onSuccess(!useArrayBuffer ? request.responseText : <ArrayBuffer>request.response, request.responseURL);
                                 return;
                             }
@@ -1020,7 +1010,7 @@ declare type Engine = import("Engines/engine").Engine;
          * @param onError defines the callback to call if an error occurs
          */
         public static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void) {
-            if (!Tools.IsWindowObjectExist()) {
+            if (!DomManagement.IsWindowObjectExist()) {
                 return;
             }
             var head = document.getElementsByTagName('head')[0];
@@ -1091,7 +1081,7 @@ declare type Engine = import("Engines/engine").Engine;
 
             reader.onloadend = (e) => request.onCompleteObservable.notifyObservers(request);
             reader.onerror = (e) => {
-                Tools.Log("Error while reading file: " + fileToLoad.name);
+                Logger.Log("Error while reading file: " + fileToLoad.name);
                 callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
             };
             reader.onload = (e) => {
@@ -1441,7 +1431,7 @@ declare type Engine = import("Engines/engine").Engine;
                 width = size;
             }
             else {
-                Tools.Error("Invalid 'size' parameter !");
+                Logger.Error("Invalid 'size' parameter !");
                 return;
             }
 
@@ -1524,7 +1514,7 @@ declare type Engine = import("Engines/engine").Engine;
                 width = size;
             }
             else {
-                Tools.Error("Invalid 'size' parameter !");
+                Logger.Error("Invalid 'size' parameter !");
                 return;
             }
 
@@ -1538,7 +1528,7 @@ declare type Engine = import("Engines/engine").Engine;
 
             var renderCanvas = engine.getRenderingCanvas();
             if (!renderCanvas) {
-                Tools.Error("No rendering canvas found !");
+                Logger.Error("No rendering canvas found !");
                 return;
             }
 
@@ -1659,140 +1649,77 @@ declare type Engine = import("Engines/engine").Engine;
         /**
          * No log
          */
-        public static readonly NoneLogLevel = 0;
+        public static readonly NoneLogLevel = Logger.NoneLogLevel;
         /**
          * Only message logs
          */
-        public static readonly MessageLogLevel = 1;
+        public static readonly MessageLogLevel = Logger.MessageLogLevel;
         /**
          * Only warning logs
          */
-        public static readonly WarningLogLevel = 2;
+        public static readonly WarningLogLevel = Logger.WarningLogLevel;
         /**
          * Only error logs
          */
-        public static readonly ErrorLogLevel = 4;
+        public static readonly ErrorLogLevel = Logger.ErrorLogLevel;
         /**
          * All logs
          */
-        public static readonly AllLogLevel = 7;
-
-        private static _LogCache = "";
+        public static readonly AllLogLevel = Logger.AllLogLevel;
 
         /**
          * Gets a value indicating the number of loading errors
          * @ignorenaming
          */
-        public static errorsCount = 0;
+        public static get errorsCount(): number {
+            return Logger.errorsCount;
+        }
 
         /**
          * Callback called when a new log is added
          */
         public static OnNewCacheEntry: (entry: string) => void;
 
-        private static _AddLogEntry(entry: string) {
-            Tools._LogCache = entry + Tools._LogCache;
-
-            if (Tools.OnNewCacheEntry) {
-                Tools.OnNewCacheEntry(entry);
-            }
-        }
-
-        private static _FormatMessage(message: string): string {
-            var padStr = (i: number) => (i < 10) ? "0" + i : "" + i;
-
-            var date = new Date();
-            return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
-        }
-
-        private static _LogDisabled(message: string): void {
-            // nothing to do
-        }
-        private static _LogEnabled(message: string): void {
-            var formattedMessage = Tools._FormatMessage(message);
-            console.log("BJS - " + formattedMessage);
-
-            var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
-            Tools._AddLogEntry(entry);
-        }
-
-        private static _WarnDisabled(message: string): void {
-            // nothing to do
-        }
-        private static _WarnEnabled(message: string): void {
-            var formattedMessage = Tools._FormatMessage(message);
-            console.warn("BJS - " + formattedMessage);
-
-            var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
-            Tools._AddLogEntry(entry);
-        }
-
-        private static _ErrorDisabled(message: string): void {
-            // nothing to do
-        }
-        private static _ErrorEnabled(message: string): void {
-            Tools.errorsCount++;
-            var formattedMessage = Tools._FormatMessage(message);
-            console.error("BJS - " + formattedMessage);
-
-            var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
-            Tools._AddLogEntry(entry);
-        }
-
         /**
          * Log a message to the console
          */
-        public static Log: (message: string) => void = Tools._LogEnabled;
+        public static Log(message: string): void {
+            Logger.Log(message);
+        }
 
         /**
          * Write a warning message to the console
          */
-        public static Warn: (message: string) => void = Tools._WarnEnabled;
+        public static Warn(message: string): void {
+            Logger.Warn(message);
+        }
 
         /**
          * Write an error message to the console
          */
-        public static Error: (message: string) => void = Tools._ErrorEnabled;
+        public static Error(message: string): void {
+            Logger.Error(message);
+        }
 
         /**
          * Gets current log cache (list of logs)
          */
         public static get LogCache(): string {
-            return Tools._LogCache;
+            return Logger.LogCache;
         }
 
         /**
          * Clears the log cache
          */
         public static ClearLogCache(): void {
-            Tools._LogCache = "";
-            Tools.errorsCount = 0;
+            Logger.ClearLogCache();
         }
 
         /**
          * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
          */
         public static set LogLevels(level: number) {
-            if ((level & Tools.MessageLogLevel) === Tools.MessageLogLevel) {
-                Tools.Log = Tools._LogEnabled;
-            }
-            else {
-                Tools.Log = Tools._LogDisabled;
-            }
-
-            if ((level & Tools.WarningLogLevel) === Tools.WarningLogLevel) {
-                Tools.Warn = Tools._WarnEnabled;
-            }
-            else {
-                Tools.Warn = Tools._WarnDisabled;
-            }
-
-            if ((level & Tools.ErrorLogLevel) === Tools.ErrorLogLevel) {
-                Tools.Error = Tools._ErrorEnabled;
-            }
-            else {
-                Tools.Error = Tools._ErrorDisabled;
-            }
+            Logger.LogLevels = level;
         }
 
         /**
@@ -1807,9 +1734,7 @@ declare type Engine = import("Engines/engine").Engine;
          * Checks if the window object exists
          * @returns true if the window object exists
          */
-        public static IsWindowObjectExist(): boolean {
-            return (typeof window) !== "undefined";
-        }
+        public static IsWindowObjectExist = DomManagement.IsWindowObjectExist;
 
         // Performances
 
@@ -1856,7 +1781,7 @@ declare type Engine = import("Engines/engine").Engine;
 
         private static _StartUserMark(counterName: string, condition = true): void {
             if (!Tools._performance) {
-                if (!Tools.IsWindowObjectExist()) {
+                if (!DomManagement.IsWindowObjectExist()) {
                     return;
                 }
                 Tools._performance = window.performance;
@@ -1927,7 +1852,7 @@ declare type Engine = import("Engines/engine").Engine;
          * Gets either window.performance.now() if supported or Date.now() else
          */
         public static get Now(): number {
-            if (Tools.IsWindowObjectExist() && window.performance && window.performance.now) {
+            if (DomManagement.IsWindowObjectExist() && window.performance && window.performance.now) {
                 return window.performance.now();
             }
 

+ 2 - 2
src/Morph/morphTargetManager.ts

@@ -1,6 +1,6 @@
 import { Observer } from "Misc/observable";
 import { SmartArray } from "Misc/smartArray";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { Scene } from "scene";
 import { Engine } from "Engines/engine";
@@ -179,7 +179,7 @@ import { MorphTarget } from "./morphTarget";
                         this._vertexCount = vertexCount;
                     }
                     else if (this._vertexCount !== vertexCount) {
-                        Tools.Error("Incompatible target. Targets must all have the same vertices count.");
+                        Logger.Error("Incompatible target. Targets must all have the same vertices count.");
                         return;
                     }
                 }

+ 19 - 18
src/Offline/database.ts

@@ -1,4 +1,5 @@
 import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Nullable } from "types";
 import { Engine } from "Engines/engine";
 import { IOfflineProvider } from "./IOfflineProvider";
@@ -162,7 +163,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                 xhr.send();
             }
             catch (ex) {
-                Tools.Error("Error on XHR send request.");
+                Logger.Error("Error on XHR send request.");
                 this._callbackManifestChecked(false);
             }
         }
@@ -198,7 +199,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
 
                     // executes when a version change transaction cannot complete due to other active transactions
                     request.onblocked = () => {
-                        Tools.Error("IDB request blocked. Please reload the page.");
+                        Logger.Error("IDB request blocked. Please reload the page.");
                         handleError();
                     };
 
@@ -218,7 +219,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                                 this._db.createObjectStore("textures", { keyPath: "textureUrl" });
                             }
                             catch (ex) {
-                                Tools.Error("Error while creating object stores. Exception: " + ex.message);
+                                Logger.Error("Error while creating object stores. Exception: " + ex.message);
                                 handleError();
                             }
                         }
@@ -275,7 +276,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                         var URL = window.URL || window.webkitURL;
                         blobTextureURL = URL.createObjectURL(texture.data);
                         image.onerror = () => {
-                            Tools.Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
+                            Logger.Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
                             image.src = url;
                         };
                         image.src = blobTextureURL;
@@ -291,12 +292,12 @@ import { IOfflineProvider } from "./IOfflineProvider";
                     texture = (<any>(event.target)).result;
                 };
                 getRequest.onerror = () => {
-                    Tools.Error("Error loading texture " + url + " from DB.");
+                    Logger.Error("Error loading texture " + url + " from DB.");
                     image.src = url;
                 };
             }
             else {
-                Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
+                Logger.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
                 image.src = url;
             }
         }
@@ -381,7 +382,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                     }, false);
 
                     xhr.addEventListener("error", () => {
-                        Tools.Error("Error in XHR request in BABYLON.Database.");
+                        Logger.Error("Error in XHR request in BABYLON.Database.");
                         image.src = url;
                     }, false);
 
@@ -396,7 +397,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                 }
             }
             else {
-                Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
+                Logger.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
                 image.src = url;
             }
         }
@@ -443,17 +444,17 @@ import { IOfflineProvider } from "./IOfflineProvider";
                         version = (<any>(event.target)).result;
                     };
                     getRequest.onerror = () => {
-                        Tools.Error("Error loading version for scene " + url + " from DB.");
+                        Logger.Error("Error loading version for scene " + url + " from DB.");
                         callback(-1);
                     };
                 }
                 catch (ex) {
-                    Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
+                    Logger.Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
                     callback(-1);
                 }
             }
             else {
-                Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
+                Logger.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
                 callback(-1);
             }
         }
@@ -487,11 +488,11 @@ import { IOfflineProvider } from "./IOfflineProvider";
                     addRequest.onsuccess = () => {
                     };
                     addRequest.onerror = () => {
-                        Tools.Error("Error in DB add version request in BABYLON.Database.");
+                        Logger.Error("Error in DB add version request in BABYLON.Database.");
                     };
                 }
                 catch (ex) {
-                    Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
+                    Logger.Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
                     callback(-1);
                 }
             }
@@ -566,12 +567,12 @@ import { IOfflineProvider } from "./IOfflineProvider";
                     file = (<any>(event.target)).result;
                 };
                 getRequest.onerror = () => {
-                    Tools.Error("Error loading file " + url + " from DB.");
+                    Logger.Error("Error loading file " + url + " from DB.");
                     notInDBCallback();
                 };
             }
             else {
-                Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
+                Logger.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
                 callback();
             }
         }
@@ -639,7 +640,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                                 addRequest.onsuccess = () => {
                                 };
                                 addRequest.onerror = () => {
-                                    Tools.Error("Error in DB add file request in BABYLON.Database.");
+                                    Logger.Error("Error in DB add file request in BABYLON.Database.");
                                 };
                             }
                             catch (ex) {
@@ -660,7 +661,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                 }, false);
 
                 xhr.addEventListener("error", () => {
-                    Tools.Error("error on XHR request.");
+                    Logger.Error("error on XHR request.");
                     callback();
                 }, false);
 
@@ -671,7 +672,7 @@ import { IOfflineProvider } from "./IOfflineProvider";
                 xhr.send();
             }
             else {
-                Tools.Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
+                Logger.Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
                 callback();
             }
         }

+ 4 - 4
src/Physics/Plugins/cannonJSPlugin.ts

@@ -1,5 +1,5 @@
 import { Nullable, FloatArray } from "types";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Vector3, Matrix, Quaternion } from "Maths/math";
 import { VertexBuffer } from "Meshes/buffer";
 import { AbstractMesh } from "Meshes/abstractMesh";
@@ -20,7 +20,7 @@ import { IPhysicsEnginePlugin, PhysicsImpostor, PhysicsImpostorJoint, PhysicsJoi
 
         public constructor(private _useDeltaForWorldStep: boolean = true, iterations: number = 10) {
             if (!this.isSupported()) {
-                Tools.Error("CannonJS is not available. Please make sure you included the js file.");
+                Logger.Error("CannonJS is not available. Please make sure you included the js file.");
                 return;
             }
 
@@ -273,7 +273,7 @@ import { IPhysicsEnginePlugin, PhysicsImpostor, PhysicsImpostorJoint, PhysicsJoi
                     returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
                     break;
                 case PhysicsImpostor.PlaneImpostor:
-                    Tools.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
+                    Logger.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
                     returnValue = new this.BJSCANNON.Plane();
                     break;
                 case PhysicsImpostor.MeshImpostor:
@@ -299,7 +299,7 @@ import { IPhysicsEnginePlugin, PhysicsImpostor, PhysicsImpostorJoint, PhysicsJoi
                         Vector3.TransformCoordinates(Vector3.FromArray(rawVerts, index), transform).toArray(temp, index);
                     }
 
-                    Tools.Warn("MeshImpostor only collides against spheres.");
+                    Logger.Warn("MeshImpostor only collides against spheres.");
                     returnValue = new this.BJSCANNON.Trimesh(temp, <number[]>rawFaces);
                     //now set back the transformation!
                     object.position.copyFrom(oldPosition);

+ 5 - 5
src/Physics/Plugins/oimoJSPlugin.ts

@@ -2,7 +2,7 @@ import { IPhysicsEnginePlugin, PhysicsImpostor, IPhysicsEnabledObject, PhysicsEn
 import { AbstractMesh } from "Meshes/abstractMesh";
 import { Vector3, Quaternion } from "Maths/math";
 import { Nullable } from "types";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 
     declare var OIMO: any;
 
@@ -78,7 +78,7 @@ import { Tools } from "Misc/tools";
             impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
         }
         public applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3) {
-            Tools.Warn("Oimo doesn't support applying force. Using impule instead.");
+            Logger.Warn("Oimo doesn't support applying force. Using impule instead.");
             this.applyImpulse(impostor, force, contactPoint);
         }
         public generatePhysicsBody(impostor: PhysicsImpostor) {
@@ -170,7 +170,7 @@ import { Tools } from "Misc/tools";
                     // register mesh
                     switch (i.type) {
                         case PhysicsImpostor.ParticleImpostor:
-                            Tools.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
+                            Logger.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
                         case PhysicsImpostor.SphereImpostor:
                             var radiusX = extendSize.x;
                             var radiusY = extendSize.y;
@@ -277,7 +277,7 @@ import { Tools } from "Misc/tools";
                     type = "jointBall";
                     break;
                 case PhysicsJoint.SpringJoint:
-                    Tools.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
+                    Logger.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
                     var springData = <SpringJointData>jointData;
                     nativeJointData.min = springData.length || nativeJointData.min;
                     //Max should also be set, just make sure it is at least min
@@ -311,7 +311,7 @@ import { Tools } from "Misc/tools";
             try {
                 this.world.removeJoint(impostorJoint.joint.physicsJoint);
             } catch (e) {
-                Tools.Warn(e);
+                Logger.Warn(e);
             }
 
         }

+ 2 - 2
src/Physics/physicsEngineComponent.ts

@@ -1,5 +1,5 @@
 import { Nullable } from "types";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Observable, Observer } from "Misc/observable";
 import { Vector3 } from "Maths/math";
 import { Mesh } from "Meshes/mesh";
@@ -91,7 +91,7 @@ declare module "scene" {
             this._physicsEngine = new PhysicsEngine(gravity, plugin);
             return true;
         } catch (e) {
-            Tools.Error(e.message);
+            Logger.Error(e.message);
             return false;
         }
     };

+ 7 - 7
src/Physics/physicsHelper.ts

@@ -1,5 +1,5 @@
 import { Nullable } from "types";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Vector3 } from "Maths/math";
 import { AbstractMesh } from "Meshes/abstractMesh";
 import { Mesh } from "Meshes/mesh";
@@ -27,7 +27,7 @@ import { PhysicsImpostor } from "./physicsImpostor";
             this._physicsEngine = this._scene.getPhysicsEngine();
 
             if (!this._physicsEngine) {
-                Tools.Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
+                Logger.Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
             }
         }
 
@@ -41,7 +41,7 @@ import { PhysicsImpostor } from "./physicsImpostor";
          */
         public applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff = PhysicsRadialImpulseFalloff.Constant): Nullable<PhysicsRadialExplosionEvent> {
             if (!this._physicsEngine) {
-                Tools.Warn('Physics engine not enabled. Please enable the physics before you call this method.');
+                Logger.Warn('Physics engine not enabled. Please enable the physics before you call this method.');
                 return null;
             }
 
@@ -76,7 +76,7 @@ import { PhysicsImpostor } from "./physicsImpostor";
          */
         public applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff = PhysicsRadialImpulseFalloff.Constant): Nullable<PhysicsRadialExplosionEvent> {
             if (!this._physicsEngine) {
-                Tools.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
+                Logger.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
                 return null;
             }
 
@@ -111,7 +111,7 @@ import { PhysicsImpostor } from "./physicsImpostor";
          */
         public gravitationalField(origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff = PhysicsRadialImpulseFalloff.Constant): Nullable<PhysicsGravitationalFieldEvent> {
             if (!this._physicsEngine) {
-                Tools.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
+                Logger.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
                 return null;
             }
 
@@ -138,7 +138,7 @@ import { PhysicsImpostor } from "./physicsImpostor";
          */
         public updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode: PhysicsUpdraftMode = PhysicsUpdraftMode.Center): Nullable<PhysicsUpdraftEvent> {
             if (!this._physicsEngine) {
-                Tools.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
+                Logger.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
                 return null;
             }
 
@@ -164,7 +164,7 @@ import { PhysicsImpostor } from "./physicsImpostor";
          */
         public vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent> {
             if (!this._physicsEngine) {
-                Tools.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
+                Logger.Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
                 return null;
             }
 

+ 7 - 7
src/Physics/physicsImpostor.ts

@@ -1,5 +1,5 @@
 import { Nullable, IndicesArray } from "types";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { ArrayTools } from "Misc/arrayTools";
 import { Vector3, Matrix, Quaternion, Space } from "Maths/math";
 import { TransformNode } from "Meshes/transformNode";
@@ -261,7 +261,7 @@ import { PhysicsJoint, PhysicsJointData } from "./physicsJoint";
 
             //sanity check!
             if (!this.object) {
-                Tools.Error("No object was provided. A physics object is obligatory");
+                Logger.Error("No object was provided. A physics object is obligatory");
                 return;
             }
 
@@ -276,7 +276,7 @@ import { PhysicsJoint, PhysicsJointData } from "./physicsJoint";
 
             this._physicsEngine = this._scene.getPhysicsEngine();
             if (!this._physicsEngine) {
-                Tools.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
+                Logger.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
             } else {
                 //set the object's quaternion, if not set
                 if (!this.object.rotationQuaternion) {
@@ -297,7 +297,7 @@ import { PhysicsJoint, PhysicsJointData } from "./physicsJoint";
                 if (!this.object.parent || this._options.ignoreParent) {
                     this._init();
                 } else if (this.object.parent.physicsImpostor) {
-                    Tools.Warn("You must affect impostors to children before affecting impostor to parent.");
+                    Logger.Warn("You must affect impostors to children before affecting impostor to parent.");
                 }
             }
         }
@@ -537,7 +537,7 @@ import { PhysicsJoint, PhysicsJointData } from "./physicsJoint";
             if (index > -1) {
                 this._onBeforePhysicsStepCallbacks.splice(index, 1);
             } else {
-                Tools.Warn("Function to remove was not found");
+                Logger.Warn("Function to remove was not found");
             }
         }
 
@@ -559,7 +559,7 @@ import { PhysicsJoint, PhysicsJointData } from "./physicsJoint";
             if (index > -1) {
                 this._onAfterPhysicsStepCallbacks.splice(index, 1);
             } else {
-                Tools.Warn("Function to remove was not found");
+                Logger.Warn("Function to remove was not found");
             }
         }
 
@@ -598,7 +598,7 @@ import { PhysicsJoint, PhysicsJointData } from "./physicsJoint";
             if (found) {
                 this._onPhysicsCollideCallbacks.splice(index, 1);
             } else {
-                Tools.Warn("Function to remove was not found");
+                Logger.Warn("Function to remove was not found");
             }
         }
 

+ 3 - 2
src/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts

@@ -1,7 +1,8 @@
 import { Nullable } from "types";
 import { serialize, SerializationHelper } from "Misc/decorators";
 import { Observer } from "Misc/observable";
-import { IAnimatable, Tools } from "Misc/tools";
+import { IAnimatable } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Camera } from "Cameras/camera";
 import { ImageProcessingConfiguration } from "Materials/imageProcessingConfiguration";
 import { Texture } from "Materials/Textures/texture";
@@ -586,7 +587,7 @@ import { BloomEffect } from "PostProcesses/bloomEffect";
             }
 
             if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
-                Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
+                Logger.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
             }
         }
 

+ 2 - 2
src/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts

@@ -1,4 +1,4 @@
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { serialize, SerializationHelper } from "Misc/decorators";
 import { Vector3, Tmp } from "Maths/math";
 import { Camera } from "Cameras/camera";
@@ -182,7 +182,7 @@ import { Scene } from "scene";
             this._ratio = ratio;
 
             if (!this.isSupported) {
-                Tools.Error("SSAO 2 needs WebGL 2 support.");
+                Logger.Error("SSAO 2 needs WebGL 2 support.");
                 return;
             }
 

+ 4 - 3
src/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts

@@ -1,6 +1,7 @@
 import { Nullable } from "types";
 import { serialize, serializeAsTexture, SerializationHelper } from "Misc/decorators";
-import { IAnimatable, Tools } from "Misc/tools";
+import { IAnimatable } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Vector2, Vector3, Matrix, Vector4 } from "Maths/math";
 import { Scalar } from "Maths/math.scalar";
 import { Camera } from "Cameras/camera";
@@ -367,7 +368,7 @@ import { Constants } from "Engines/constants";
             if (enabled) {
                 var geometry = this._scene.enableGeometryBufferRenderer();
                 if (!geometry) {
-                    Tools.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
+                    Logger.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
                     return;
                 }
             }
@@ -584,7 +585,7 @@ import { Constants } from "Engines/constants";
             }
 
             if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
-                Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
+                Logger.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
             }
         }
 

+ 2 - 2
src/PostProcesses/circleOfConfusionPostProcess.ts

@@ -4,7 +4,7 @@ import { PostProcess, PostProcessOptions } from "./postProcess";
 import { Effect } from "Materials/effect";
 import { RenderTargetTexture } from "Materials/Textures/renderTargetTexture";
 import { Camera } from "Cameras/camera";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Constants } from "Engines/constants";
 
     /**
@@ -46,7 +46,7 @@ import { Constants } from "Engines/constants";
             this._depthTexture = depthTexture;
             this.onApplyObservable.add((effect: Effect) => {
                 if (!this._depthTexture) {
-                    Tools.Warn("No depth texture set on CircleOfConfusionPostProcess");
+                    Logger.Warn("No depth texture set on CircleOfConfusionPostProcess");
                     return;
                 }
                 effect.setTexture("depthSampler", this._depthTexture);

+ 2 - 2
src/PostProcesses/motionBlurPostProcess.ts

@@ -1,5 +1,5 @@
 import { Nullable } from "types";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Vector2 } from "Maths/math";
 import { Camera } from "Cameras/camera";
 import { Effect } from "Materials/effect";
@@ -68,7 +68,7 @@ declare type Engine = import("Engines/engine").Engine;
 
             if (!this._geometryBufferRenderer) {
                 // Geometry buffer renderer is not supported. So, work as a passthrough.
-                Tools.Warn("Multiple Render Target support needed to compute object based motion blur");
+                Logger.Warn("Multiple Render Target support needed to compute object based motion blur");
                 this.updateEffect();
             } else {
                 // Geometry buffer renderer is supported.

+ 3 - 3
src/PostProcesses/volumetricLightScatteringPostProcess.ts

@@ -1,6 +1,6 @@
 import { serializeAsVector3, serialize, serializeAsMeshReference } from "Misc/decorators";
 import { SmartArray } from "Misc/smartArray";
-import { Tools } from "Misc/tools";
+import { Logger } from "Misc/logger";
 import { Color4, Color3, Vector2, Vector3, Matrix, Viewport } from "Maths/math";
 import { VertexBuffer } from "Meshes/buffer";
 import { AbstractMesh } from "Meshes/abstractMesh";
@@ -63,12 +63,12 @@ declare type Engine = import("Engines/engine").Engine;
          * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
          */
         public get useDiffuseColor(): boolean {
-            Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
+            Logger.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
             return false;
         }
 
         public set useDiffuseColor(useDiffuseColor: boolean) {
-            Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
+            Logger.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
         }
 
         /**

+ 4 - 2
src/scene.ts

@@ -48,6 +48,8 @@ import { Ray } from "Culling/ray";
 import { Node } from "node";
 import { MorphTarget } from "Morph/morphTarget";
 import { Constants } from "Engines/constants";
+import { DomManagement } from "Misc/domManagement";
+import { Logger } from "Misc/logger";
 
     /**
      * Define an interface for all classes that will hold resources
@@ -1301,7 +1303,7 @@ import { Constants } from "Engines/constants";
                 this.postProcessManager = new PostProcessManager(this);
             }
 
-            if (Tools.IsWindowObjectExist()) {
+            if (DomManagement.IsWindowObjectExist()) {
                 this.attachControl();
             }
 
@@ -4488,7 +4490,7 @@ import { Constants } from "Engines/constants";
                     if (internalTexture) {
                         engine.bindFramebuffer(internalTexture);
                     } else {
-                        Tools.Error("Camera contains invalid customDefaultRenderTarget");
+                        Logger.Error("Camera contains invalid customDefaultRenderTarget");
                     }
                 } else {
                     engine.restoreDefaultFramebuffer(); // Restore back buffer if needed