Browse Source

Further unneeded BABYLON references.

Raanan Weber 7 years ago
parent
commit
ba37dcca98
50 changed files with 1203 additions and 1202 deletions
  1. 18 18
      loaders/src/glTF/1.0/babylon.glTFLoader.ts
  2. 1 1
      loaders/src/glTF/2.0/babylon.glTFLoader.ts
  3. 3 2
      src/Actions/babylon.actionManager.ts
  4. 47 47
      src/Animations/babylon.animation.ts
  5. 121 121
      src/Behaviors/Cameras/babylon.bouncingBehavior.ts
  6. 298 298
      src/Behaviors/Cameras/babylon.framingBehavior.ts
  7. 135 135
      src/Bones/babylon.boneLookController.ts
  8. 2 2
      src/Cameras/Inputs/babylon.freeCameraDeviceOrientationInput.ts
  9. 101 101
      src/Cameras/VR/babylon.vrExperienceHelper.ts
  10. 35 35
      src/Cameras/VR/babylon.webVRCamera.ts
  11. 5 5
      src/Cameras/babylon.camera.ts
  12. 7 7
      src/Cameras/babylon.cameraInputsManager.ts
  13. 1 1
      src/Cameras/babylon.targetCamera.ts
  14. 1 1
      src/Collisions/babylon.collisionWorker.ts
  15. 4 4
      src/Collisions/babylon.pickingInfo.ts
  16. 13 13
      src/Engine/babylon.engine.ts
  17. 7 7
      src/Engine/babylon.webgl2.ts
  18. 8 8
      src/Gamepad/Controllers/babylon.poseEnabledController.ts
  19. 8 8
      src/Gamepad/Controllers/babylon.windowsMotionController.ts
  20. 22 22
      src/Helpers/babylon.environmentHelper.ts
  21. 4 4
      src/Layer/babylon.highlightlayer.ts
  22. 4 4
      src/Lights/babylon.shadowLight.ts
  23. 11 11
      src/Loading/Plugins/babylon.babylonFileLoader.ts
  24. 32 32
      src/Materials/Background/babylon.backgroundMaterial.ts
  25. 1 1
      src/Materials/PBR/babylon.pbrBaseMaterial.ts
  26. 7 7
      src/Materials/Textures/babylon.colorGradingTexture.ts
  27. 1 1
      src/Materials/Textures/babylon.cubeTexture.ts
  28. 11 11
      src/Materials/Textures/babylon.hdrCubeTexture.ts
  29. 5 5
      src/Materials/Textures/babylon.mirrorTexture.ts
  30. 1 1
      src/Materials/Textures/babylon.multiRenderTarget.ts
  31. 16 16
      src/Materials/Textures/babylon.videoTexture.ts
  32. 8 8
      src/Materials/babylon.imageProcessingConfiguration.ts
  33. 30 30
      src/Materials/babylon.material.ts
  34. 20 20
      src/Math/babylon.math.ts
  35. 2 2
      src/Mesh/babylon.abstractMesh.ts
  36. 1 1
      src/Mesh/babylon.groundMesh.ts
  37. 3 3
      src/Mesh/babylon.mesh.ts
  38. 12 12
      src/Mesh/babylon.subMesh.ts
  39. 2 2
      src/Mesh/babylon.transformNode.ts
  40. 2 2
      src/Physics/babylon.physicsImpostor.ts
  41. 104 104
      src/PostProcess/RenderPipeline/Pipelines/babylon.defaultRenderingPipeline.ts
  42. 1 1
      src/PostProcess/RenderPipeline/Pipelines/babylon.ssao2RenderingPipeline.ts
  43. 2 2
      src/PostProcess/RenderPipeline/Pipelines/babylon.ssaoRenderingPipeline.ts
  44. 14 14
      src/PostProcess/RenderPipeline/Pipelines/babylon.standardRenderingPipeline.ts
  45. 1 1
      src/PostProcess/babylon.fxaaPostProcess.ts
  46. 4 4
      src/PostProcess/babylon.imageProcessingPostProcess.ts
  47. 14 14
      src/PostProcess/babylon.volumetricLightScatteringPostProcess.ts
  48. 8 8
      src/Tools/babylon.earcut.ts
  49. 43 43
      src/Tools/babylon.textureTools.ts
  50. 2 2
      src/Tools/babylon.tools.ts

+ 18 - 18
loaders/src/glTF/1.0/babylon.glTFLoader.ts

@@ -543,7 +543,7 @@ module BABYLON.GLTF1 {
         // Polish
         var bones = newSkeleton.bones;
         newSkeleton.bones = [];
-        
+
         for (var i = 0; i < skins.jointNames.length; i++) {
             var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);
 
@@ -582,7 +582,7 @@ module BABYLON.GLTF1 {
             return newMesh;
         }
 
-        const subMaterials : Material[] = [];
+        const subMaterials: Material[] = [];
 
         var vertexData = new VertexData();
         var geometry = new Geometry(id, gltfRuntime.scene, vertexData, false, newMesh);
@@ -626,7 +626,7 @@ module BABYLON.GLTF1 {
                         (<Float32Array>tempVertexData.normals).set(buffer);
                     }
                     else if (semantic === "POSITION") {
-                        if (BABYLON.GLTFFileLoader.HomogeneousCoordinates) {
+                        if (GLTFFileLoader.HomogeneousCoordinates) {
                             tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4);
 
                             for (var j = 0; j < buffer.length; j += 4) {
@@ -696,7 +696,7 @@ module BABYLON.GLTF1 {
                 indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
             }
         }
-        let material : StandardMaterial | MultiMaterial;
+        let material: StandardMaterial | MultiMaterial;
         if (subMaterials.length > 1) {
             material = new MultiMaterial("multimat" + id, gltfRuntime.scene);
             (material as MultiMaterial).subMaterials = subMaterials;
@@ -906,10 +906,10 @@ module BABYLON.GLTF1 {
                         persCamera.minZ = perspectiveCamera.znear;
                     }
 
-                     lastNode = persCamera;
-                 }
-             }
-         }
+                    lastNode = persCamera;
+                }
+            }
+        }
 
         // Empty node
         if (!node.jointName) {
@@ -1010,7 +1010,7 @@ module BABYLON.GLTF1 {
     /**
     * onBind shaderrs callback to set uniforms and matrices
     */
-    var onBindShaderMaterial = (mesh: Mesh, gltfRuntime: IGLTFRuntime, unTreatedUniforms: {[key: string]: IGLTFTechniqueParameter}, shaderMaterial: ShaderMaterial, technique: IGLTFTechnique, material: IGLTFMaterial, onSuccess: (shaderMaterial: ShaderMaterial) => void) => {
+    var onBindShaderMaterial = (mesh: Mesh, gltfRuntime: IGLTFRuntime, unTreatedUniforms: { [key: string]: IGLTFTechniqueParameter }, shaderMaterial: ShaderMaterial, technique: IGLTFTechnique, material: IGLTFMaterial, onSuccess: (shaderMaterial: ShaderMaterial) => void) => {
         var materialValues = material.values || technique.parameters;
 
         for (var unif in unTreatedUniforms) {
@@ -1061,7 +1061,7 @@ module BABYLON.GLTF1 {
     * Prepare uniforms to send the only one time
     * Loads the appropriate textures
     */
-    var prepareShaderMaterialUniforms = (gltfRuntime: IGLTFRuntime, shaderMaterial: ShaderMaterial, technique: IGLTFTechnique, material: IGLTFMaterial, unTreatedUniforms: {[key: string]: IGLTFTechniqueParameter}) => {
+    var prepareShaderMaterialUniforms = (gltfRuntime: IGLTFRuntime, shaderMaterial: ShaderMaterial, technique: IGLTFTechnique, material: IGLTFMaterial, unTreatedUniforms: { [key: string]: IGLTFTechniqueParameter }) => {
         var materialValues = material.values || technique.parameters;
         var techniqueUniforms = technique.uniforms;
 
@@ -1119,7 +1119,7 @@ module BABYLON.GLTF1 {
     /**
     * Shader compilation success
     */
-    var onShaderCompileSuccess = (gltfRuntime: IGLTFRuntime, shaderMaterial: ShaderMaterial, technique: IGLTFTechnique, material: IGLTFMaterial, unTreatedUniforms: {[key: string]: IGLTFTechniqueParameter}, onSuccess: (shaderMaterial: ShaderMaterial) => void) => {
+    var onShaderCompileSuccess = (gltfRuntime: IGLTFRuntime, shaderMaterial: ShaderMaterial, technique: IGLTFTechnique, material: IGLTFMaterial, unTreatedUniforms: { [key: string]: IGLTFTechniqueParameter }, onSuccess: (shaderMaterial: ShaderMaterial) => void) => {
         return (_: Effect) => {
             prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);
 
@@ -1132,7 +1132,7 @@ module BABYLON.GLTF1 {
     /**
     * Returns the appropriate uniform if already handled by babylon
     */
-    var parseShaderUniforms = (tokenizer: Tokenizer, technique: IGLTFTechnique, unTreatedUniforms: {[key: string]: IGLTFTechniqueParameter}): string => {
+    var parseShaderUniforms = (tokenizer: Tokenizer, technique: IGLTFTechnique, unTreatedUniforms: { [key: string]: IGLTFTechniqueParameter }): string => {
         for (var unif in technique.uniforms) {
             var uniform = technique.uniforms[unif];
             var uniformParameter: IGLTFTechniqueParameter = technique.parameters[uniform];
@@ -1410,7 +1410,7 @@ module BABYLON.GLTF1 {
             var vertexTokenizer = new Tokenizer(vertexShader);
             var pixelTokenizer = new Tokenizer(pixelShader);
 
-            var unTreatedUniforms: {[key: string]: IGLTFTechniqueParameter} = {};
+            var unTreatedUniforms: { [key: string]: IGLTFTechniqueParameter } = {};
             var uniforms = [];
             var attributes = [];
             var samplers = [];
@@ -1610,13 +1610,13 @@ module BABYLON.GLTF1 {
                         importMaterials(gltfRuntime);
                         postLoad(gltfRuntime);
 
-                        if (!BABYLON.GLTFFileLoader.IncrementalLoading && onSuccess) {
+                        if (!GLTFFileLoader.IncrementalLoading && onSuccess) {
                             onSuccess(meshes, [], skeletons);
                         }
                     });
                 }, onProgress);
 
-                if (BABYLON.GLTFFileLoader.IncrementalLoading && onSuccess) {
+                if (GLTFFileLoader.IncrementalLoading && onSuccess) {
                     onSuccess(meshes, [], skeletons);
                 }
             }, onError);
@@ -1639,13 +1639,13 @@ module BABYLON.GLTF1 {
                             importMaterials(gltfRuntime);
                             postLoad(gltfRuntime);
 
-                            if (!BABYLON.GLTFFileLoader.IncrementalLoading) {
+                            if (!GLTFFileLoader.IncrementalLoading) {
                                 onSuccess();
                             }
                         });
                     });
 
-                    if (BABYLON.GLTFFileLoader.IncrementalLoading) {
+                    if (GLTFFileLoader.IncrementalLoading) {
                         onSuccess();
                     }
                 }, onError);
@@ -1750,5 +1750,5 @@ module BABYLON.GLTF1 {
         }
     };
 
-    BABYLON.GLTFFileLoader.CreateGLTFLoaderV1 = () => new GLTFLoader();
+    GLTFFileLoader.CreateGLTFLoaderV1 = () => new GLTFLoader();
 }

+ 1 - 1
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -1840,5 +1840,5 @@ module BABYLON.GLTF2 {
         }
     }
 
-    BABYLON.GLTFFileLoader.CreateGLTFLoaderV2 = parent => new GLTFLoader(parent);
+    GLTFFileLoader.CreateGLTFLoaderV2 = parent => new GLTFLoader(parent);
 }

+ 3 - 2
src/Actions/babylon.actionManager.ts

@@ -142,7 +142,7 @@
             return ActionManager._OnKeyUpTrigger;
         }
 
-        public static Triggers: { [key: string]: number} = {};
+        public static Triggers: { [key: string]: number } = {};
 
         // Members
         public actions = new Array<Action>();
@@ -416,7 +416,7 @@
         }
 
         public static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene) {
-            var actionManager = new BABYLON.ActionManager(scene);
+            var actionManager = new ActionManager(scene);
             if (object === null)
                 scene.actionManager = actionManager;
             else
@@ -424,6 +424,7 @@
 
             // instanciate a new object
             var instanciate = (name: string, params: Array<any>): any => {
+                // TODO: We will need to find a solution for the next line when using commonjs / es6 .
                 var newInstance: Object = Object.create(Tools.Instantiate("BABYLON." + name).prototype);
                 newInstance.constructor.apply(newInstance, params);
                 return newInstance;

+ 47 - 47
src/Animations/babylon.animation.ts

@@ -84,7 +84,7 @@
     export class Animation {
         public static AllowMatricesInterpolation = false;
 
-        private _keys: Array<{frame:number, value: any, inTangent?: any, outTangent?: any}>;
+        private _keys: Array<{ frame: number, value: any, inTangent?: any, outTangent?: any }>;
         private _easingFunction: IEasingFunction;
 
         public _runtimeAnimations = new Array<RuntimeAnimation>();
@@ -122,7 +122,7 @@
 
             var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
 
-            var keys: Array<{frame: number, value:any}> = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
+            var keys: Array<{ frame: number, value: any }> = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
             animation.setKeys(keys);
 
             if (easingFunction !== undefined) {
@@ -139,17 +139,17 @@
 		 * @param easingFunction the easing function used in the animation
 		 * @returns The created animation
 		 */
-		public static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: BABYLON.EasingFunction): BABYLON.Animation {
-			var animation: BABYLON.Animation = new BABYLON.Animation(property + "Animation",
-				property,
-				framePerSecond,
-				animationType,
-				BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+        public static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation {
+            var animation: Animation = new Animation(property + "Animation",
+                property,
+                framePerSecond,
+                animationType,
+                Animation.ANIMATIONLOOPMODE_CONSTANT);
 
-			animation.setEasingFunction(easingFunction);
+            animation.setEasingFunction(easingFunction);
 
-			return animation;
-		}
+            return animation;
+        }
 
         public static CreateAndStartAnimation(name: string, node: Node, targetProperty: string,
             framePerSecond: number, totalFrame: number,
@@ -190,38 +190,38 @@
 		 * @param duration The duration of the animation, in milliseconds
 		 * @param onAnimationEnd Call back trigger at the end of the animation.
 		 */
-		public static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number,	onAnimationEnd: Nullable<() => void> = null): Nullable<Animatable> {
+        public static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd: Nullable<() => void> = null): Nullable<Animatable> {
 
-			if (duration <= 0) {
-				host[property] = targetValue;
-				if (onAnimationEnd) {
+            if (duration <= 0) {
+                host[property] = targetValue;
+                if (onAnimationEnd) {
                     onAnimationEnd();
                 }
-				return null;
-			}
+                return null;
+            }
 
-			var endFrame: number = frameRate * (duration / 1000);
+            var endFrame: number = frameRate * (duration / 1000);
 
-			transition.setKeys([{
-				frame: 0,
-				value: host[property].clone ? host[property].clone() : host[property]
-			},
-			{
-				frame: endFrame,
-				value: targetValue
-			}]);
+            transition.setKeys([{
+                frame: 0,
+                value: host[property].clone ? host[property].clone() : host[property]
+            },
+            {
+                frame: endFrame,
+                value: targetValue
+            }]);
 
-			if (!host.animations) {
-				host.animations = [];
-			}
+            if (!host.animations) {
+                host.animations = [];
+            }
 
-			host.animations.push(transition);
+            host.animations.push(transition);
 
-			var animation: BABYLON.Animatable = scene.beginAnimation(host, 0, endFrame, false);
-			animation.onAnimationEnd = onAnimationEnd;
-			return animation;
+            var animation: Animatable = scene.beginAnimation(host, 0, endFrame, false);
+            animation.onAnimationEnd = onAnimationEnd;
+            return animation;
         }
-        
+
         /**
          * Return the array of runtime animations currently using this animation
          */
@@ -249,7 +249,7 @@
         /**
          * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
          */
-        public toString(fullDetails? : boolean) : string {
+        public toString(fullDetails?: boolean): string {
             var ret = "Name: " + this.name + ", property: " + this.targetProperty;
             ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
             ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
@@ -260,15 +260,15 @@
                 for (var name in this._ranges) {
                     if (first) {
                         ret += ", ";
-                        first = false; 
+                        first = false;
                     }
-                    ret += name; 
+                    ret += name;
                 }
                 ret += "}";
             }
             return ret;
-        } 
-        
+        }
+
         /**
          * Add an event to this animation.
          */
@@ -318,7 +318,7 @@
                 }
             }
             this._ranges[name] = null; // said much faster than 'delete this._range[name]' 
-        
+
         }
 
         public getRange(name: string): Nullable<AnimationRange> {
@@ -326,7 +326,7 @@
         }
 
 
-        public getKeys(): Array<{frame:number, value: any, inTangent?: any, outTangent?: any}> {
+        public getKeys(): Array<{ frame: number, value: any, inTangent?: any, outTangent?: any }> {
             return this._keys;
         }
 
@@ -458,7 +458,7 @@
 
             serializationObject.ranges = [];
             for (var name in this._ranges) {
-                let source  =this._ranges[name];
+                let source = this._ranges[name];
 
                 if (!source) {
                     continue;
@@ -529,7 +529,7 @@
             var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
 
             var dataType = parsedAnimation.dataType;
-            var keys: Array<{ frame: number, value: any, inTangent:any, outTangent:any }> = [];
+            var keys: Array<{ frame: number, value: any, inTangent: any, outTangent: any }> = [];
             var data;
             var index: number;
 
@@ -543,8 +543,8 @@
 
             for (index = 0; index < parsedAnimation.keys.length; index++) {
                 var key = parsedAnimation.keys[index];
-                var inTangent:any;
-                var outTangent:any;
+                var inTangent: any;
+                var outTangent: any;
 
                 switch (dataType) {
                     case Animation.ANIMATIONTYPE_FLOAT:
@@ -583,7 +583,7 @@
                         break;
                 }
 
-                var keyData:any = {};
+                var keyData: any = {};
                 keyData.frame = key.frame;
                 keyData.value = data;
 
@@ -619,6 +619,6 @@
             }
         }
     }
-} 
+}
 
 

+ 121 - 121
src/Behaviors/Cameras/babylon.bouncingBehavior.ts

@@ -5,18 +5,18 @@ module BABYLON {
     export class BouncingBehavior implements Behavior<ArcRotateCamera> {
         public get name(): string {
             return "Bouncing";
-        }        
+        }
 
 		/**
 		 * The easing function used by animations
 		 */
-		public static EasingFunction = new BackEase(0.3);
+        public static EasingFunction = new BackEase(0.3);
 
 		/**
 		 * The easing mode used by animations
 		 */
-        public static EasingMode = EasingFunction.EASINGMODE_EASEOUT;   
-        
+        public static EasingMode = EasingFunction.EASINGMODE_EASEOUT;
+
         /**
          * The duration of the animation, in milliseconds
          */
@@ -25,100 +25,100 @@ module BABYLON {
         /**
          * Length of the distance animated by the transition when lower radius is reached
          */
-        public lowerRadiusTransitionRange = 2;     
-        
+        public lowerRadiusTransitionRange = 2;
+
         /**
          * Length of the distance animated by the transition when upper radius is reached
          */
-        public upperRadiusTransitionRange = -2;          
+        public upperRadiusTransitionRange = -2;
 
-		private _autoTransitionRange = false;
+        private _autoTransitionRange = false;
 
 		/**
 		 * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
 		 */
-		public get autoTransitionRange(): boolean {
-			return this._autoTransitionRange;
-		}
+        public get autoTransitionRange(): boolean {
+            return this._autoTransitionRange;
+        }
 
 		/**
 		 * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
 		 * Transition ranges will be set to 5% of the bounding box diagonal in world space
 		 */
-		public set autoTransitionRange(value: boolean) {
-			if (this._autoTransitionRange === value) {
-				return;
-			}
-
-			this._autoTransitionRange = value;
-
-			let camera = this._attachedCamera;
-			if (!camera) {
-				return;
-			}
-
-			if (value) {
-				this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((mesh) => {
-					if (!mesh) {
-						return;
-					}
-
-					mesh.computeWorldMatrix(true);
-					let diagonal = mesh.getBoundingInfo().diagonalLength;
-
-					this.lowerRadiusTransitionRange = diagonal * 0.05;
-					this.upperRadiusTransitionRange = diagonal * 0.05;
-				});
-			} else if (this._onMeshTargetChangedObserver) {
-				camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
-			}
-		}
-        
+        public set autoTransitionRange(value: boolean) {
+            if (this._autoTransitionRange === value) {
+                return;
+            }
+
+            this._autoTransitionRange = value;
+
+            let camera = this._attachedCamera;
+            if (!camera) {
+                return;
+            }
+
+            if (value) {
+                this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((mesh) => {
+                    if (!mesh) {
+                        return;
+                    }
+
+                    mesh.computeWorldMatrix(true);
+                    let diagonal = mesh.getBoundingInfo().diagonalLength;
+
+                    this.lowerRadiusTransitionRange = diagonal * 0.05;
+                    this.upperRadiusTransitionRange = diagonal * 0.05;
+                });
+            } else if (this._onMeshTargetChangedObserver) {
+                camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
+            }
+        }
+
         // Connection
         private _attachedCamera: Nullable<ArcRotateCamera>;
-		private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;	
-		private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<AbstractMesh>>>;
+        private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;
+        private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<AbstractMesh>>>;
+
+        public init(): void {
+            // Do notihng
+        }
 
-		public init(): void {
-			// Do notihng
-		}
-		
         public attach(camera: ArcRotateCamera): void {
             this._attachedCamera = camera;
             this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {
-				if (!this._attachedCamera) {
-					return;
-				}
-
-				// Add the bounce animation to the lower radius limit
-				if (this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)) {
-					this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange);
-				}
-
-				// Add the bounce animation to the upper radius limit
-				if (this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)) {
-					this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange);
-				}
+                if (!this._attachedCamera) {
+                    return;
+                }
+
+                // Add the bounce animation to the lower radius limit
+                if (this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)) {
+                    this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange);
+                }
+
+                // Add the bounce animation to the upper radius limit
+                if (this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)) {
+                    this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange);
+                }
             });
         }
-        
+
         public detach(): void {
-			if (!this._attachedCamera) {
-				return;
-			}			
-			if (this._onAfterCheckInputsObserver) {
-				this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
-			}
-			if (this._onMeshTargetChangedObserver) {
-				this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
-			}
-			this._attachedCamera = null;
+            if (!this._attachedCamera) {
+                return;
+            }
+            if (this._onAfterCheckInputsObserver) {
+                this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
+            }
+            if (this._onMeshTargetChangedObserver) {
+                this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
+            }
+            this._attachedCamera = null;
         }
 
         // Animations
         private _radiusIsAnimating: boolean = false;
         private _radiusBounceTransition: Nullable<Animation> = null;
-        private _animatables = new Array<BABYLON.Animatable>();
+        private _animatables = new Array<Animatable>();
         private _cachedWheelPrecision: number;
 
         /**
@@ -126,69 +126,69 @@ module BABYLON {
 		 * @param radiusLimit The limit to check against.
 		 * @return Bool to indicate if at limit.
 		 */
-		private _isRadiusAtLimit(radiusLimit: Nullable<number>): boolean {
-			if (!this._attachedCamera) {
-				return false;
-			}
-
-			if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
-				return true;
-			}
-			return false;
-        }     
-        
+        private _isRadiusAtLimit(radiusLimit: Nullable<number>): boolean {
+            if (!this._attachedCamera) {
+                return false;
+            }
+
+            if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
+                return true;
+            }
+            return false;
+        }
+
         /**
 		 * Applies an animation to the radius of the camera, extending by the radiusDelta.
 		 * @param radiusDelta The delta by which to animate to. Can be negative.
 		 */
-		private _applyBoundRadiusAnimation(radiusDelta: number): void {
-			if (!this._attachedCamera) {
-				return;
-			}
-
-			if (!this._radiusBounceTransition) {
-				BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
-				this._radiusBounceTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
-			}
+        private _applyBoundRadiusAnimation(radiusDelta: number): void {
+            if (!this._attachedCamera) {
+                return;
+            }
+
+            if (!this._radiusBounceTransition) {
+                BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
+                this._radiusBounceTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
+            }
             // Prevent zoom until bounce has completed
             this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
-			this._attachedCamera.wheelPrecision = Infinity;
-			this._attachedCamera.inertialRadiusOffset = 0;
-
-			// Animate to the radius limit
-			this.stopAllAnimations();
-			this._radiusIsAnimating = true;
-			let animatable = Animation.TransitionTo("radius", this._attachedCamera.radius + radiusDelta, this._attachedCamera, this._attachedCamera.getScene(), 60, 
-			this._radiusBounceTransition, this.transitionDuration, () => this._clearAnimationLocks());
-
-			if (animatable) {
-				this._animatables.push(animatable);
-			}
+            this._attachedCamera.wheelPrecision = Infinity;
+            this._attachedCamera.inertialRadiusOffset = 0;
+
+            // Animate to the radius limit
+            this.stopAllAnimations();
+            this._radiusIsAnimating = true;
+            let animatable = Animation.TransitionTo("radius", this._attachedCamera.radius + radiusDelta, this._attachedCamera, this._attachedCamera.getScene(), 60,
+                this._radiusBounceTransition, this.transitionDuration, () => this._clearAnimationLocks());
+
+            if (animatable) {
+                this._animatables.push(animatable);
+            }
         }
 
         /**
 		 * Removes all animation locks. Allows new animations to be added to any of the camera properties.
 		 */
-		protected _clearAnimationLocks(): void {
-			this._radiusIsAnimating = false;
-
-			if (this._attachedCamera) {
-				this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
-			}			
-		}        
-        
+        protected _clearAnimationLocks(): void {
+            this._radiusIsAnimating = false;
+
+            if (this._attachedCamera) {
+                this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
+            }
+        }
+
 		/**
 		 * Stops and removes all animations that have been applied to the camera
-		 */        
+		 */
         public stopAllAnimations(): void {
-			if (this._attachedCamera) {
-				this._attachedCamera.animations = [];
-			}
-			while (this._animatables.length) {
-				this._animatables[0].onAnimationEnd = null;
-				this._animatables[0].stop();
-				this._animatables.shift();
-			}
-		}
+            if (this._attachedCamera) {
+                this._attachedCamera.animations = [];
+            }
+            while (this._animatables.length) {
+                this._animatables[0].onAnimationEnd = null;
+                this._animatables[0].stop();
+                this._animatables.shift();
+            }
+        }
     }
 }

+ 298 - 298
src/Behaviors/Cameras/babylon.framingBehavior.ts

@@ -11,152 +11,152 @@ module BABYLON {
         private _elevationReturnTime = 1500;
         private _elevationReturnWaitTime = 1000;
         private _zoomStopsAnimation = false;
-		private _framingTime = 1500;
-		
+        private _framingTime = 1500;
+
 		/**
 		 * The easing function used by animations
 		 */
-		public static EasingFunction = new ExponentialEase();
-		
+        public static EasingFunction = new ExponentialEase();
+
 		/**
 		 * The easing mode used by animations
 		 */
-		public static EasingMode = EasingFunction.EASINGMODE_EASEINOUT;   		
+        public static EasingMode = EasingFunction.EASINGMODE_EASEINOUT;
 
         /**
 		 * Sets the current mode used by the behavior
 		 */
-		public set mode(mode: number) {
-			this._mode = mode;
-		}
+        public set mode(mode: number) {
+            this._mode = mode;
+        }
 
 		/**
 		 * Gets current mode used by the behavior.
 		 */
-		public get mode(): number {
-			return this._mode;
+        public get mode(): number {
+            return this._mode;
         }
-        
+
 	    /**
 		 * Sets the scale applied to the radius (1 by default)
 		 */
-		public set radiusScale(radius: number) {
-			this._radiusScale = radius;
-		}
+        public set radiusScale(radius: number) {
+            this._radiusScale = radius;
+        }
 
 		/**
 		 * Gets the scale applied to the radius
 		 */
-		public get radiusScale(): number {
-			return this._radiusScale;
-		}
+        public get radiusScale(): number {
+            return this._radiusScale;
+        }
 
 		/**
 		 * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
 		 */
-		public set positionScale(scale: number) {
-			this._positionScale = scale;
-		}
+        public set positionScale(scale: number) {
+            this._positionScale = scale;
+        }
 
 		/**
 		 * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
 		 */
-		public get positionScale(): number {
-			return this._positionScale;
-		}
+        public get positionScale(): number {
+            return this._positionScale;
+        }
 
 		/**
 		* Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
 		* behaviour is triggered, in radians.
 		*/
-		public set defaultElevation(elevation: number) {
-			this._defaultElevation = elevation;
-		}
+        public set defaultElevation(elevation: number) {
+            this._defaultElevation = elevation;
+        }
 
 		/**
 		* Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
 		* behaviour is triggered, in radians.
 		*/
-		public get defaultElevation() {
-			return this._defaultElevation;
-		}
+        public get defaultElevation() {
+            return this._defaultElevation;
+        }
 
 		/**
 		 * Sets the time (in milliseconds) taken to return to the default beta position.
 		 * Negative value indicates camera should not return to default.
 		 */
-		public set elevationReturnTime(speed: number) {
-			this._elevationReturnTime = speed;
-		}
+        public set elevationReturnTime(speed: number) {
+            this._elevationReturnTime = speed;
+        }
 
 		/**
 		 * Gets the time (in milliseconds) taken to return to the default beta position.
 		 * Negative value indicates camera should not return to default.
 		 */
-		public get elevationReturnTime(): number {
-			return this._elevationReturnTime;
-		}
+        public get elevationReturnTime(): number {
+            return this._elevationReturnTime;
+        }
 
 		/**
 		 * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
 		 */
-		public set elevationReturnWaitTime(time: number) {
-			this._elevationReturnWaitTime = time;
-		}
+        public set elevationReturnWaitTime(time: number) {
+            this._elevationReturnWaitTime = time;
+        }
 
 		/**
 		 * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
 		 */
-		public get elevationReturnWaitTime(): number {
-			return this._elevationReturnWaitTime;
-		}
+        public get elevationReturnWaitTime(): number {
+            return this._elevationReturnWaitTime;
+        }
 
 		/**
 		* Sets the flag that indicates if user zooming should stop animation.
 		*/
-		public set zoomStopsAnimation(flag: boolean) {
-			this._zoomStopsAnimation = flag;
-		}
+        public set zoomStopsAnimation(flag: boolean) {
+            this._zoomStopsAnimation = flag;
+        }
 
 		/**
 		* Gets the flag that indicates if user zooming should stop animation.
 		*/
-		public get zoomStopsAnimation(): boolean {
-			return this._zoomStopsAnimation;
-        }       
-        	
+        public get zoomStopsAnimation(): boolean {
+            return this._zoomStopsAnimation;
+        }
+
 		/**
 		 * Sets the transition time when framing the mesh, in milliseconds
 		*/
-		public set framingTime(time: number) {
-			this._framingTime = time;
-		}
+        public set framingTime(time: number) {
+            this._framingTime = time;
+        }
 
         /**
          * Gets the transition time when framing the mesh, in milliseconds
         */
         public get framingTime() {
             return this._framingTime;
-		}        
-        
+        }
+
         // Default behavior functions
         private _onPrePointerObservableObserver: Nullable<Observer<PointerInfoPre>>;
-		private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;
-		private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<AbstractMesh>>>;
+        private _onAfterCheckInputsObserver: Nullable<Observer<Camera>>;
+        private _onMeshTargetChangedObserver: Nullable<Observer<Nullable<AbstractMesh>>>;
         private _attachedCamera: Nullable<ArcRotateCamera>;
         private _isPointerDown = false;
-		private _lastInteractionTime = -Infinity;
-		
-		public init(): void {
-			// Do notihng
-		}
-		
+        private _lastInteractionTime = -Infinity;
+
+        public init(): void {
+            // Do notihng
+        }
+
         public attach(camera: ArcRotateCamera): void {
             this._attachedCamera = camera;
-			let scene = this._attachedCamera.getScene();
-			
-			FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
-			
+            let scene = this._attachedCamera.getScene();
+
+            FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
+
             this._onPrePointerObservableObserver = scene.onPrePointerObservable.add((pointerInfoPre) => {
                 if (pointerInfoPre.type === PointerEventTypes.POINTERDOWN) {
                     this._isPointerDown = true;
@@ -166,53 +166,53 @@ module BABYLON {
                 if (pointerInfoPre.type === PointerEventTypes.POINTERUP) {
                     this._isPointerDown = false;
                 }
-			});
-			
-			this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((mesh) => {
-				if (mesh) {
-					this.zoomOnMesh(mesh);
-				}
-			});
-
-            this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {      
+            });
+
+            this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add((mesh) => {
+                if (mesh) {
+                    this.zoomOnMesh(mesh);
+                }
+            });
+
+            this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(() => {
                 // Stop the animation if there is user interaction and the animation should stop for this interaction
                 this._applyUserInteraction();
-       
+
                 // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
                 // back to the default position after a given timeout
-                this._maintainCameraAboveGround();                
+                this._maintainCameraAboveGround();
             });
         }
-             
+
         public detach(): void {
-			if (!this._attachedCamera) {
-				return;
-			}
+            if (!this._attachedCamera) {
+                return;
+            }
 
             let scene = this._attachedCamera.getScene();
-			
-			if (this._onPrePointerObservableObserver) {
-				scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
-			}
 
-			if (this._onAfterCheckInputsObserver) {
-				this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
-			}
+            if (this._onPrePointerObservableObserver) {
+                scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
+            }
 
-			if (this._onMeshTargetChangedObserver) {
-				this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
-			}
+            if (this._onAfterCheckInputsObserver) {
+                this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
+            }
 
-			this._attachedCamera = null;
+            if (this._onMeshTargetChangedObserver) {
+                this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
+            }
+
+            this._attachedCamera = null;
         }
 
         // Framing control
         private _animatables = new Array<Animatable>();
         private _betaIsAnimating = false;
-		private _betaTransition: Animation;
-		private _radiusTransition: Animation;
-		private _vectorTransition: Animation;
-		
+        private _betaTransition: Animation;
+        private _radiusTransition: Animation;
+        private _vectorTransition: Animation;
+
 		/**
 		 * Targets the given mesh and updates zoom level accordingly.
 		 * @param mesh  The mesh to target.
@@ -221,12 +221,12 @@ module BABYLON {
 		 * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
 		 * @param onAnimationEnd Callback triggered at the end of the framing animation
 		 */
-		public zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
-			mesh.computeWorldMatrix(true);
+        public zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
+            mesh.computeWorldMatrix(true);
 
-			let boundingBox = mesh.getBoundingInfo().boundingBox;
-			this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
-		}
+            let boundingBox = mesh.getBoundingInfo().boundingBox;
+            this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
+        }
 
 		/**
 		 * Targets the given mesh with its children and updates zoom level accordingly.
@@ -236,12 +236,12 @@ module BABYLON {
 		 * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
 		 * @param onAnimationEnd Callback triggered at the end of the framing animation
 		 */
-		public zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
-			mesh.computeWorldMatrix(true);
+        public zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
+            mesh.computeWorldMatrix(true);
 
-			let boundingBox = mesh.getHierarchyBoundingVectors(true);
-			this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
-		}
+            let boundingBox = mesh.getHierarchyBoundingVectors(true);
+            this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
+        }
 
 		/**
 		 * Targets the given meshes with their children and updates zoom level accordingly.
@@ -251,18 +251,18 @@ module BABYLON {
 		 * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
 		 * @param onAnimationEnd Callback triggered at the end of the framing animation
 		 */
-		public zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
-			let min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
-            let max = new BABYLON.Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
-            
-			for (let i = 0; i < meshes.length; i++) {
-				let boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
-				BABYLON.Tools.CheckExtends(boundingInfo.min, min, max);
-                BABYLON.Tools.CheckExtends(boundingInfo.max, min, max);
-			}
-	
-			this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
-		}
+        public zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
+            let min = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            let max = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
+
+            for (let i = 0; i < meshes.length; i++) {
+                let boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
+                Tools.CheckExtends(boundingInfo.min, min, max);
+                Tools.CheckExtends(boundingInfo.max, min, max);
+            }
+
+            this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
+        }
 
 		/**
 		 * Targets the given mesh and updates zoom level accordingly.
@@ -272,76 +272,76 @@ module BABYLON {
 		 * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
 		 * @param onAnimationEnd Callback triggered at the end of the framing animation
 		 */
-		public zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
-			let zoomTarget: BABYLON.Vector3;
-
-			if (!this._attachedCamera) {
-				return;
-			}
-
-			// Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
-			let bottom = minimumWorld.y;
-			let top = maximumWorld.y;
-			let zoomTargetY = bottom + (top - bottom) * this._positionScale;
-			let radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
-
-			if (focusOnOriginXZ) {	
-				zoomTarget = new BABYLON.Vector3(0, zoomTargetY, 0);
-			} else {
-				let centerWorld = minimumWorld.add(radiusWorld);
-				zoomTarget = new BABYLON.Vector3(centerWorld.x, zoomTargetY, centerWorld.z);
-			}
-
-			if (!this._vectorTransition) {
-				this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
-			}			
-
-			this._betaIsAnimating = true;
-			let animatable = Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
-			if (animatable) {
-				this._animatables.push(animatable);
-			}
-
-			// sets the radius and lower radius bounds
-			// Small delta ensures camera is not always at lower zoom limit.
-			let radius = 0;
-			if (this._mode === FramingBehavior.FitFrustumSidesMode) {
-				let position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
-				this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
-				radius = position;
-			} else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
-				radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
-				if (this._attachedCamera.lowerRadiusLimit === null) {
-					this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
-				}
-			}
-
-			// Set sensibilities
-			let extend = maximumWorld.subtract(minimumWorld).length();
-			this._attachedCamera.panningSensibility = 5000 / extend;
-			this._attachedCamera.wheelPrecision = 100 / radius;
-
-			// transition to new radius
-			if (!this._radiusTransition) {
-				this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
-			}
-
-			animatable = Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 
-			60, this._radiusTransition, this._framingTime, () => {
-				if (onAnimationEnd) {
-					onAnimationEnd();
-				}
-
-				if (this._attachedCamera) {
-					this._attachedCamera.storeState();
-				}
-			});
-
-			if (animatable) {
-				this._animatables.push(animatable);
-			}
-		}
-		
+        public zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ: boolean = false, onAnimationEnd: Nullable<() => void> = null): void {
+            let zoomTarget: Vector3;
+
+            if (!this._attachedCamera) {
+                return;
+            }
+
+            // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
+            let bottom = minimumWorld.y;
+            let top = maximumWorld.y;
+            let zoomTargetY = bottom + (top - bottom) * this._positionScale;
+            let radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
+
+            if (focusOnOriginXZ) {
+                zoomTarget = new Vector3(0, zoomTargetY, 0);
+            } else {
+                let centerWorld = minimumWorld.add(radiusWorld);
+                zoomTarget = new Vector3(centerWorld.x, zoomTargetY, centerWorld.z);
+            }
+
+            if (!this._vectorTransition) {
+                this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
+            }
+
+            this._betaIsAnimating = true;
+            let animatable = Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
+            if (animatable) {
+                this._animatables.push(animatable);
+            }
+
+            // sets the radius and lower radius bounds
+            // Small delta ensures camera is not always at lower zoom limit.
+            let radius = 0;
+            if (this._mode === FramingBehavior.FitFrustumSidesMode) {
+                let position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
+                this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
+                radius = position;
+            } else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
+                radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
+                if (this._attachedCamera.lowerRadiusLimit === null) {
+                    this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
+                }
+            }
+
+            // Set sensibilities
+            let extend = maximumWorld.subtract(minimumWorld).length();
+            this._attachedCamera.panningSensibility = 5000 / extend;
+            this._attachedCamera.wheelPrecision = 100 / radius;
+
+            // transition to new radius
+            if (!this._radiusTransition) {
+                this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
+            }
+
+            animatable = Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(),
+                60, this._radiusTransition, this._framingTime, () => {
+                    if (onAnimationEnd) {
+                        onAnimationEnd();
+                    }
+
+                    if (this._attachedCamera) {
+                        this._attachedCamera.storeState();
+                    }
+                });
+
+            if (animatable) {
+                this._animatables.push(animatable);
+            }
+        }
+
 		/**
 		 * Calculates the lowest radius for the camera based on the bounding box of the mesh.
 		 * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
@@ -349,154 +349,154 @@ module BABYLON {
 		 * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
 		 *		 to fully enclose the mesh in the viewing frustum.
 		 */
-		protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number {
-			let size = maximumWorld.subtract(minimumWorld);
+        protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number {
+            let size = maximumWorld.subtract(minimumWorld);
             let boxVectorGlobalDiagonal = size.length();
-			let frustumSlope: BABYLON.Vector2 = this._getFrustumSlope();
-
-			// Formula for setting distance
-			// (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
-			let radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
-
-			// Horizon distance
-			let radius = radiusWithoutFraming * this._radiusScale;
-			let distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
-			let distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
-			let distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
-			let camera = this._attachedCamera;
-
-			if (!camera) {
-				return 0;
-			}
-
-			if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
-				// Don't exceed the requested limit
-				distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
-			}
-
-			// Don't exceed the upper radius limit
-			if (camera.upperRadiusLimit) {
-				distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
-			}
-
-			return distance;
-		}		
+            let frustumSlope: Vector2 = this._getFrustumSlope();
+
+            // Formula for setting distance
+            // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
+            let radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
+
+            // Horizon distance
+            let radius = radiusWithoutFraming * this._radiusScale;
+            let distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
+            let distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
+            let distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
+            let camera = this._attachedCamera;
+
+            if (!camera) {
+                return 0;
+            }
+
+            if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
+                // Don't exceed the requested limit
+                distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
+            }
+
+            // Don't exceed the upper radius limit
+            if (camera.upperRadiusLimit) {
+                distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
+            }
+
+            return distance;
+        }
 
 		/**
 		 * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
 		 * is automatically returned to its default position (expected to be above ground plane). 
 		 */
-		private _maintainCameraAboveGround(): void {
-			if (this._elevationReturnTime < 0) {
-				return;
-			}
-
-			let timeSinceInteraction = Tools.Now - this._lastInteractionTime;
-			let defaultBeta = Math.PI * 0.5 - this._defaultElevation;
-			let limitBeta = Math.PI * 0.5;
-			
-			// Bring the camera back up if below the ground plane
-			if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
+        private _maintainCameraAboveGround(): void {
+            if (this._elevationReturnTime < 0) {
+                return;
+            }
+
+            let timeSinceInteraction = Tools.Now - this._lastInteractionTime;
+            let defaultBeta = Math.PI * 0.5 - this._defaultElevation;
+            let limitBeta = Math.PI * 0.5;
+
+            // Bring the camera back up if below the ground plane
+            if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
                 this._betaIsAnimating = true;
-                
-				//Transition to new position
+
+                //Transition to new position
                 this.stopAllAnimations();
-                
+
                 if (!this._betaTransition) {
                     this._betaTransition = Animation.CreateAnimation("beta", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
-				}
-				
-				let animatabe = Animation.TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60,
-				this._betaTransition, this._elevationReturnTime, 
-				() => {
-					this._clearAnimationLocks();
-					this.stopAllAnimations();
-				});
-
-				if (animatabe) {
-					this._animatables.push(animatabe);
-				}
-			}
-		}        
+                }
+
+                let animatabe = Animation.TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60,
+                    this._betaTransition, this._elevationReturnTime,
+                    () => {
+                        this._clearAnimationLocks();
+                        this.stopAllAnimations();
+                    });
+
+                if (animatabe) {
+                    this._animatables.push(animatabe);
+                }
+            }
+        }
 
 		/**
 		 * Returns the frustum slope based on the canvas ratio and camera FOV
 		 * @returns The frustum slope represented as a Vector2 with X and Y slopes
 		 */
-		private _getFrustumSlope(): Vector2 {
-			// Calculate the viewport ratio
-			// Aspect Ratio is Height/Width.
-			let camera = this._attachedCamera;
+        private _getFrustumSlope(): Vector2 {
+            // Calculate the viewport ratio
+            // Aspect Ratio is Height/Width.
+            let camera = this._attachedCamera;
 
-			if (!camera) {
-				return Vector2.Zero();
-			}
+            if (!camera) {
+                return Vector2.Zero();
+            }
 
-			let engine = camera.getScene().getEngine();
-			var aspectRatio = engine.getAspectRatio(camera);
+            let engine = camera.getScene().getEngine();
+            var aspectRatio = engine.getAspectRatio(camera);
 
-			// Camera FOV is the vertical field of view (top-bottom) in radians.
-			// Slope of the frustum top/bottom planes in view space, relative to the forward vector.
-			var frustumSlopeY = Math.tan(camera.fov / 2);
+            // Camera FOV is the vertical field of view (top-bottom) in radians.
+            // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
+            var frustumSlopeY = Math.tan(camera.fov / 2);
 
-			// Slope of the frustum left/right planes in view space, relative to the forward vector.
-			// Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
-			// along the forward vector.
-			var frustumSlopeX = frustumSlopeY * aspectRatio;
+            // Slope of the frustum left/right planes in view space, relative to the forward vector.
+            // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
+            // along the forward vector.
+            var frustumSlopeX = frustumSlopeY * aspectRatio;
 
-			return new Vector2(frustumSlopeX, frustumSlopeY);
-		}		
+            return new Vector2(frustumSlopeX, frustumSlopeY);
+        }
 
 		/**
 		 * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
 		 */
-		private _clearAnimationLocks(): void {
-			this._betaIsAnimating = false;
-		}		
+        private _clearAnimationLocks(): void {
+            this._betaIsAnimating = false;
+        }
 
 		/**
 		 *  Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
-		 */          
+		 */
         private _applyUserInteraction(): void {
-			if (this.isUserIsMoving) {
+            if (this.isUserIsMoving) {
                 this._lastInteractionTime = Tools.Now;
-				this.stopAllAnimations();				
-				this._clearAnimationLocks();
-			}
-        }                
-        
+                this.stopAllAnimations();
+                this._clearAnimationLocks();
+            }
+        }
+
 		/**
 		 * Stops and removes all animations that have been applied to the camera
-		 */        
+		 */
         public stopAllAnimations(): void {
-			if (this._attachedCamera) {
-				this._attachedCamera.animations = [];
-			}
-
-			while (this._animatables.length) {
-				if (this._animatables[0]) {
-					this._animatables[0].onAnimationEnd = null;
-					this._animatables[0].stop();
-				}
-				this._animatables.shift();
-			}
-		}        
+            if (this._attachedCamera) {
+                this._attachedCamera.animations = [];
+            }
+
+            while (this._animatables.length) {
+                if (this._animatables[0]) {
+                    this._animatables[0].onAnimationEnd = null;
+                    this._animatables[0].stop();
+                }
+                this._animatables.shift();
+            }
+        }
 
         /**
 		 * Gets a value indicating if the user is moving the camera
 		 */
         public get isUserIsMoving(): boolean {
-			if (!this._attachedCamera) {
-				return false;
-			}
-			
-			return this._attachedCamera.inertialAlphaOffset !== 0 ||
-				this._attachedCamera.inertialBetaOffset !== 0 ||
-				this._attachedCamera.inertialRadiusOffset !== 0 ||
-				this._attachedCamera.inertialPanningX !== 0 ||
-				this._attachedCamera.inertialPanningY !== 0 ||
-				this._isPointerDown;
-		}
+            if (!this._attachedCamera) {
+                return false;
+            }
+
+            return this._attachedCamera.inertialAlphaOffset !== 0 ||
+                this._attachedCamera.inertialBetaOffset !== 0 ||
+                this._attachedCamera.inertialRadiusOffset !== 0 ||
+                this._attachedCamera.inertialPanningX !== 0 ||
+                this._attachedCamera.inertialPanningY !== 0 ||
+                this._isPointerDown;
+        }
 
         // Statics
 

+ 135 - 135
src/Bones/babylon.boneLookController.ts

@@ -1,10 +1,10 @@
 module BABYLON {
     export class BoneLookController {
 
-        private static _tmpVecs: Vector3[] = [Vector3.Zero(), Vector3.Zero(), Vector3.Zero(),Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero()];
+        private static _tmpVecs: Vector3[] = [Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero(), Vector3.Zero()];
         private static _tmpQuat = Quaternion.Identity();
         private static _tmpMats: Matrix[] = [Matrix.Identity(), Matrix.Identity(), Matrix.Identity(), Matrix.Identity(), Matrix.Identity()];
-        
+
         /**
          * The target Vector3 that the bone will look at.
          */
@@ -50,39 +50,39 @@ module BABYLON {
          */
         public slerpAmount = 1;
 
-        private _minYaw:number;
-        private _maxYaw:number;
-        private _minPitch:number;
-        private _maxPitch:number;
-        private _minYawSin:number;
-        private _minYawCos:number;
-        private _maxYawSin:number;
-        private _maxYawCos:number;
-        private _midYawConstraint:number;
-        private _minPitchTan:number;
-        private _maxPitchTan:number;
-        
-        private _boneQuat:Quaternion = Quaternion.Identity();
+        private _minYaw: number;
+        private _maxYaw: number;
+        private _minPitch: number;
+        private _maxPitch: number;
+        private _minYawSin: number;
+        private _minYawCos: number;
+        private _maxYawSin: number;
+        private _maxYawCos: number;
+        private _midYawConstraint: number;
+        private _minPitchTan: number;
+        private _maxPitchTan: number;
+
+        private _boneQuat: Quaternion = Quaternion.Identity();
         private _slerping = false;
-        private _transformYawPitch:Matrix;
-        private _transformYawPitchInv:Matrix;
+        private _transformYawPitch: Matrix;
+        private _transformYawPitchInv: Matrix;
         private _firstFrameSkipped = false;
-        private _yawRange:number;
+        private _yawRange: number;
         private _fowardAxis: Vector3 = Vector3.Forward();
 
         /**
          * Get/set the minimum yaw angle that the bone can look to.
          */
-        get minYaw():number{
+        get minYaw(): number {
             return this._minYaw;
         }
 
-        set minYaw(value:number){
+        set minYaw(value: number) {
             this._minYaw = value;
             this._minYawSin = Math.sin(value);
             this._minYawCos = Math.cos(value);
-            if(this._maxYaw != null){
-                this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw)*.5 + this._minYaw;
+            if (this._maxYaw != null) {
+                this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
                 this._yawRange = this._maxYaw - this._minYaw;
             }
         }
@@ -90,16 +90,16 @@ module BABYLON {
         /**
          * Get/set the maximum yaw angle that the bone can look to.
          */
-        get maxYaw():number{
+        get maxYaw(): number {
             return this._maxYaw;
         }
 
-        set maxYaw(value:number){
+        set maxYaw(value: number) {
             this._maxYaw = value;
             this._maxYawSin = Math.sin(value);
             this._maxYawCos = Math.cos(value);
-            if(this._minYaw != null){
-                this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw)*.5 + this._minYaw;
+            if (this._minYaw != null) {
+                this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
                 this._yawRange = this._maxYaw - this._minYaw;
             }
         }
@@ -107,11 +107,11 @@ module BABYLON {
         /**
          * Get/set the minimum pitch angle that the bone can look to.
          */
-        get minPitch():number{
+        get minPitch(): number {
             return this._minPitch;
         }
 
-        set minPitch(value:number){
+        set minPitch(value: number) {
             this._minPitch = value;
             this._minPitchTan = Math.tan(value);
         }
@@ -119,11 +119,11 @@ module BABYLON {
         /**
          * Get/set the maximum pitch angle that the bone can look to.
          */
-        get maxPitch():number{
+        get maxPitch(): number {
             return this._maxPitch;
         }
 
-        set maxPitch(value:number){
+        set maxPitch(value: number) {
             this._maxPitch = value;
             this._maxPitchTan = Math.tan(value);
         }
@@ -147,89 +147,89 @@ module BABYLON {
          * - adjustPitch: used to make an adjustment to the pitch of the bone
          * - adjustRoll: used to make an adjustment to the roll of the bone
          **/
-        constructor(mesh: AbstractMesh, 
-                    bone: Bone, 
-                    target: Vector3, 
-                    options?: {
-                        maxYaw?:number, 
-                        minYaw?:number, 
-                        maxPitch?:number, 
-                        minPitch?:number,
-                        slerpAmount?: number, 
-                        upAxis?:Vector3,
-                        upAxisSpace?:Space,
-                        yawAxis?:Vector3,
-                        pitchAxis?:Vector3,
-                        adjustYaw?: number, 
-                        adjustPitch?: number, 
-                        adjustRoll?: number, 
-                    }){
+        constructor(mesh: AbstractMesh,
+            bone: Bone,
+            target: Vector3,
+            options?: {
+                maxYaw?: number,
+                minYaw?: number,
+                maxPitch?: number,
+                minPitch?: number,
+                slerpAmount?: number,
+                upAxis?: Vector3,
+                upAxisSpace?: Space,
+                yawAxis?: Vector3,
+                pitchAxis?: Vector3,
+                adjustYaw?: number,
+                adjustPitch?: number,
+                adjustRoll?: number,
+            }) {
 
             this.mesh = mesh;
             this.bone = bone;
             this.target = target;
 
-            if(options){
+            if (options) {
 
-                if(options.adjustYaw){
+                if (options.adjustYaw) {
                     this.adjustYaw = options.adjustYaw;
                 }
 
-                if(options.adjustPitch){
+                if (options.adjustPitch) {
                     this.adjustPitch = options.adjustPitch;
                 }
 
-                if(options.adjustRoll){
+                if (options.adjustRoll) {
                     this.adjustRoll = options.adjustRoll;
                 }
 
-                if(options.maxYaw != null){
+                if (options.maxYaw != null) {
                     this.maxYaw = options.maxYaw;
-                }else{
+                } else {
                     this.maxYaw = Math.PI;
                 }
 
-                if(options.minYaw != null){
+                if (options.minYaw != null) {
                     this.minYaw = options.minYaw;
-                }else{
+                } else {
                     this.minYaw = -Math.PI;
                 }
 
-                if(options.maxPitch != null){
+                if (options.maxPitch != null) {
                     this.maxPitch = options.maxPitch;
-                }else{
+                } else {
                     this.maxPitch = Math.PI;
                 }
 
-                if(options.minPitch != null){
+                if (options.minPitch != null) {
                     this.minPitch = options.minPitch;
-                }else{
+                } else {
                     this.minPitch = -Math.PI;
                 }
 
-                if(options.slerpAmount != null){
+                if (options.slerpAmount != null) {
                     this.slerpAmount = options.slerpAmount;
                 }
 
-                if(options.upAxis != null){
+                if (options.upAxis != null) {
                     this.upAxis = options.upAxis;
                 }
 
-                if(options.upAxisSpace != null){
+                if (options.upAxisSpace != null) {
                     this.upAxisSpace = options.upAxisSpace;
                 }
 
-                if(options.yawAxis != null || options.pitchAxis != null){
+                if (options.yawAxis != null || options.pitchAxis != null) {
 
                     var newYawAxis = Axis.Y;
                     var newPitchAxis = Axis.X;
 
-                    if(options.yawAxis != null){
+                    if (options.yawAxis != null) {
                         newYawAxis = options.yawAxis.clone();
                         newYawAxis.normalize();
                     }
 
-                    if(options.pitchAxis != null){
+                    if (options.pitchAxis != null) {
                         newPitchAxis = options.pitchAxis.clone();
                         newPitchAxis.normalize();
                     }
@@ -241,12 +241,12 @@ module BABYLON {
 
                     this._transformYawPitchInv = this._transformYawPitch.clone();
                     this._transformYawPitch.invert();
-                    
+
                 }
 
             }
 
-            if(!bone.getParent() && this.upAxisSpace == Space.BONE){
+            if (!bone.getParent() && this.upAxisSpace == Space.BONE) {
                 this.upAxisSpace = Space.LOCAL;
             }
 
@@ -255,10 +255,10 @@ module BABYLON {
         /**
          * Update the bone to look at the target.  This should be called before the scene is rendered (use scene.registerBeforeRender()).
          */
-        public update (): void {
+        public update(): void {
 
             //skip the first frame when slerping so that the mesh rotation is correct
-            if(this.slerpAmount < 1 && !this._firstFrameSkipped){
+            if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
                 this._firstFrameSkipped = true;
                 return;
             }
@@ -270,21 +270,21 @@ module BABYLON {
             var target = this.target;
             var _tmpMat1 = BoneLookController._tmpMats[0];
             var _tmpMat2 = BoneLookController._tmpMats[1];
-            
+
             var mesh = this.mesh;
             var parentBone = bone.getParent();
 
             var upAxis = BoneLookController._tmpVecs[1];
             upAxis.copyFrom(this.upAxis);
 
-            if(this.upAxisSpace == Space.BONE && parentBone){
-                if (this._transformYawPitch){
+            if (this.upAxisSpace == Space.BONE && parentBone) {
+                if (this._transformYawPitch) {
                     Vector3.TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
                 }
                 parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
-            }else if(this.upAxisSpace == Space.LOCAL){
+            } else if (this.upAxisSpace == Space.LOCAL) {
                 mesh.getDirectionToRef(upAxis, upAxis);
-                if(mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1){
+                if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
                     upAxis.normalize();
                 }
             }
@@ -292,38 +292,38 @@ module BABYLON {
             var checkYaw = false;
             var checkPitch = false;
 
-            if(this._maxYaw != Math.PI || this._minYaw != -Math.PI){
+            if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
                 checkYaw = true;
             }
-            if(this._maxPitch != Math.PI || this._minPitch != -Math.PI){
+            if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
                 checkPitch = true;
             }
 
-            if(checkYaw || checkPitch){
+            if (checkYaw || checkPitch) {
 
                 var spaceMat = BoneLookController._tmpMats[2];
                 var spaceMatInv = BoneLookController._tmpMats[3];
 
-                if(this.upAxisSpace == Space.BONE && upAxis.y == 1 && parentBone){
+                if (this.upAxisSpace == Space.BONE && upAxis.y == 1 && parentBone) {
 
                     parentBone.getRotationMatrixToRef(Space.WORLD, this.mesh, spaceMat);
-                    
-                }else if(this.upAxisSpace == Space.LOCAL && upAxis.y == 1 && !parentBone){
+
+                } else if (this.upAxisSpace == Space.LOCAL && upAxis.y == 1 && !parentBone) {
 
                     spaceMat.copyFrom(mesh.getWorldMatrix());
 
-                }else{
+                } else {
 
                     var forwardAxis = BoneLookController._tmpVecs[2];
                     forwardAxis.copyFrom(this._fowardAxis);
-                    
+
                     if (this._transformYawPitch) {
                         Vector3.TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
                     }
 
-                    if(parentBone){
+                    if (parentBone) {
                         parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
-                    }else{
+                    } else {
                         mesh.getDirectionToRef(forwardAxis, forwardAxis);
                     }
 
@@ -332,14 +332,14 @@ module BABYLON {
                     var forwardAxis = Vector3.Cross(rightAxis, upAxis);
 
                     Matrix.FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
-                    
+
                 }
 
                 spaceMat.invertToRef(spaceMatInv);
-                
+
                 var xzlen: Nullable<number> = null;
 
-                if(checkPitch){
+                if (checkPitch) {
                     var localTarget = BoneLookController._tmpVecs[3];
                     target.subtractToRef(bonePos, localTarget);
                     Vector3.TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
@@ -348,22 +348,22 @@ module BABYLON {
                     var pitch = Math.atan2(localTarget.y, xzlen);
                     var newPitch = pitch;
 
-                    if(pitch > this._maxPitch){
-                        localTarget.y = this._maxPitchTan*xzlen;
+                    if (pitch > this._maxPitch) {
+                        localTarget.y = this._maxPitchTan * xzlen;
                         newPitch = this._maxPitch;
-                    }else if(pitch < this._minPitch){
-                        localTarget.y = this._minPitchTan*xzlen;
+                    } else if (pitch < this._minPitch) {
+                        localTarget.y = this._minPitchTan * xzlen;
                         newPitch = this._minPitch;
                     }
-                    
-                    if(pitch != newPitch){
+
+                    if (pitch != newPitch) {
                         Vector3.TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
                         localTarget.addInPlace(bonePos);
                         target = localTarget;
                     }
                 }
 
-                if(checkYaw){
+                if (checkYaw) {
                     var localTarget = BoneLookController._tmpVecs[4];
                     target.subtractToRef(bonePos, localTarget);
                     Vector3.TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
@@ -371,28 +371,28 @@ module BABYLON {
                     var yaw = Math.atan2(localTarget.x, localTarget.z);
                     var newYaw = yaw;
 
-                    if(yaw > this._maxYaw || yaw < this._minYaw){
-                        
-                        if(xzlen == null){
+                    if (yaw > this._maxYaw || yaw < this._minYaw) {
+
+                        if (xzlen == null) {
                             xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
                         }
 
-                        if(this._yawRange > Math.PI){
+                        if (this._yawRange > Math.PI) {
                             if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
                                 localTarget.z = this._maxYawCos * xzlen;
                                 localTarget.x = this._maxYawSin * xzlen;
                                 newYaw = this._maxYaw;
-                            }else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
+                            } else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
                                 localTarget.z = this._minYawCos * xzlen;
                                 localTarget.x = this._minYawSin * xzlen;
                                 newYaw = this._minYaw;
                             }
-                        }else{
+                        } else {
                             if (yaw > this._maxYaw) {
                                 localTarget.z = this._maxYawCos * xzlen;
                                 localTarget.x = this._maxYawSin * xzlen;
                                 newYaw = this._maxYaw;
-                            }else if (yaw < this._minYaw) {
+                            } else if (yaw < this._minYaw) {
                                 localTarget.z = this._minYawCos * xzlen;
                                 localTarget.x = this._minYawSin * xzlen;
                                 newYaw = this._minYaw;
@@ -400,7 +400,7 @@ module BABYLON {
                         }
                     }
 
-                    if(this._slerping && this._yawRange > Math.PI){
+                    if (this._slerping && this._yawRange > Math.PI) {
                         //are we going to be crossing into the min/max region?
                         var boneFwd = BoneLookController._tmpVecs[8];
                         boneFwd.copyFrom(Axis.Z);
@@ -408,17 +408,17 @@ module BABYLON {
                             Vector3.TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
                         }
 
-                        var boneRotMat = BABYLON.BoneLookController._tmpMats[4];
+                        var boneRotMat = BoneLookController._tmpMats[4];
                         this._boneQuat.toRotationMatrix(boneRotMat);
                         this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
-                        BABYLON.Vector3.TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
-                        BABYLON.Vector3.TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
+                        Vector3.TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
+                        Vector3.TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
 
                         var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
                         var angBtwTar = this._getAngleBetween(boneYaw, yaw);
                         var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
 
-                        if(angBtwTar > angBtwMidYaw){
+                        if (angBtwTar > angBtwMidYaw) {
 
                             if (xzlen == null) {
                                 xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
@@ -427,19 +427,19 @@ module BABYLON {
                             var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
                             var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
 
-                            if(angBtwMin < angBtwMax){
-                                newYaw = boneYaw+Math.PI*.75;
+                            if (angBtwMin < angBtwMax) {
+                                newYaw = boneYaw + Math.PI * .75;
                                 localTarget.z = Math.cos(newYaw) * xzlen;
                                 localTarget.x = Math.sin(newYaw) * xzlen;
-                            }else{
-                                newYaw = boneYaw-Math.PI*.75;
+                            } else {
+                                newYaw = boneYaw - Math.PI * .75;
                                 localTarget.z = Math.cos(newYaw) * xzlen;
                                 localTarget.x = Math.sin(newYaw) * xzlen;
                             }
                         }
                     }
 
-                    if(yaw != newYaw){
+                    if (yaw != newYaw) {
                         Vector3.TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
                         localTarget.addInPlace(bonePos);
                         target = localTarget;
@@ -461,15 +461,15 @@ module BABYLON {
             yaxis.normalize();
             Matrix.FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
 
-            if(xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0){
+            if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
                 return;
             }
 
-            if(yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0){
+            if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
                 return;
             }
 
-            if(zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0){
+            if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
                 return;
             }
 
@@ -482,16 +482,16 @@ module BABYLON {
                 if (!this._slerping) {
                     this.bone.getRotationQuaternionToRef(Space.WORLD, this.mesh, this._boneQuat);
                 }
-                if(this._transformYawPitch){
+                if (this._transformYawPitch) {
                     this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
                 }
                 Quaternion.FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
                 Quaternion.SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
-                
+
                 this.bone.setRotationQuaternion(this._boneQuat, Space.WORLD, this.mesh);
                 this._slerping = true;
             } else {
-                if(this._transformYawPitch){
+                if (this._transformYawPitch) {
                     this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
                 }
                 this.bone.setRotationMatrix(_tmpMat1, Space.WORLD, this.mesh);
@@ -500,21 +500,21 @@ module BABYLON {
 
         }
 
-        private _getAngleDiff(ang1: number, ang2: number):number {
+        private _getAngleDiff(ang1: number, ang2: number): number {
 
             var angDiff = ang2 - ang1;
-            angDiff %= Math.PI*2;
-            
-            if(angDiff > Math.PI){
-                angDiff -= Math.PI*2;
-            }else if (angDiff < -Math.PI){
-                angDiff += Math.PI*2;
+            angDiff %= Math.PI * 2;
+
+            if (angDiff > Math.PI) {
+                angDiff -= Math.PI * 2;
+            } else if (angDiff < -Math.PI) {
+                angDiff += Math.PI * 2;
             }
-            
+
             return angDiff;
         }
 
-        private _getAngleBetween(ang1: number, ang2: number):number {
+        private _getAngleBetween(ang1: number, ang2: number): number {
 
             ang1 %= (2 * Math.PI);
             ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
@@ -524,20 +524,20 @@ module BABYLON {
 
             var ab = 0;
 
-            if(ang1 < ang2){
+            if (ang1 < ang2) {
                 ab = ang2 - ang1;
-            }else{
+            } else {
                 ab = ang1 - ang2;
             }
 
-            if(ab > Math.PI){
-                ab = Math.PI*2 - ab;
+            if (ab > Math.PI) {
+                ab = Math.PI * 2 - ab;
             }
 
             return ab;
         }
 
-        private _isAngleBetween(ang: number,ang1: number, ang2: number):boolean {
+        private _isAngleBetween(ang: number, ang1: number, ang2: number): boolean {
 
             ang %= (2 * Math.PI);
             ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
@@ -546,12 +546,12 @@ module BABYLON {
             ang2 %= (2 * Math.PI);
             ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
 
-            if(ang1 < ang2){
-                if(ang > ang1 && ang < ang2){
+            if (ang1 < ang2) {
+                if (ang > ang1 && ang < ang2) {
                     return true;
                 }
-            }else{
-                if(ang > ang2 && ang < ang1){
+            } else {
+                if (ang > ang2 && ang < ang1) {
                     return true;
                 }
             }

+ 2 - 2
src/Cameras/Inputs/babylon.freeCameraDeviceOrientationInput.ts

@@ -55,8 +55,8 @@ module BABYLON {
         public checkInputs() {
             //if no device orientation provided, don't update the rotation.
             //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
-            if(!this._alpha) return;
-            Quaternion.RotationYawPitchRollToRef(BABYLON.Tools.ToRadians(this._alpha), BABYLON.Tools.ToRadians(this._beta), -BABYLON.Tools.ToRadians(this._gamma), this.camera.rotationQuaternion)
+            if (!this._alpha) return;
+            Quaternion.RotationYawPitchRollToRef(Tools.ToRadians(this._alpha), Tools.ToRadians(this._beta), -Tools.ToRadians(this._gamma), this.camera.rotationQuaternion)
             this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
             this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
             //Mirror on XY Plane

+ 101 - 101
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -10,7 +10,7 @@ module BABYLON {
     }
 
     export class VRExperienceHelper {
-        private _scene: BABYLON.Scene;
+        private _scene: Scene;
         private _position: Vector3;
         private _btnVR: HTMLButtonElement;
         private _btnVRDisplayed: boolean;
@@ -69,7 +69,7 @@ module BABYLON {
         private _teleportationBorderColor: string = "#FFFFFF";
         private _rotationAngle: number = 0;
         private _haloCenter = new Vector3(0, 0, 0);
-        private _gazeTracker: BABYLON.Mesh;
+        private _gazeTracker: Mesh;
         private _padSensibilityUp = 0.65;
         private _padSensibilityDown = 0.35;
         private _leftLaserPointer: Nullable<Mesh>;
@@ -140,7 +140,7 @@ module BABYLON {
                 }
             }
             else {
-                if(this._rightLaserPointer) {
+                if (this._rightLaserPointer) {
                     this._rightLaserPointer.isVisible = true;
                 }
                 else if (this._leftLaserPointer) {
@@ -197,18 +197,18 @@ module BABYLON {
             this._defaultHeight = webVROptions.defaultHeight;
 
             // Set position
-            if(this._scene.activeCamera){
+            if (this._scene.activeCamera) {
                 this._position = this._scene.activeCamera.position.clone();
-            }else{
-                this._position = new BABYLON.Vector3(0, this._defaultHeight, 0);
+            } else {
+                this._position = new Vector3(0, this._defaultHeight, 0);
             }
 
             // Set non-vr camera
-            if(webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera){
-                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
-                
+            if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
+                this._deviceOrientationCamera = new DeviceOrientationCamera("deviceOrientationVRHelper", this._position.clone(), scene);
+
                 // Copy data from existing camera
-                if(this._scene.activeCamera){
+                if (this._scene.activeCamera) {
                     this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                     this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
                     // Set rotation from previous camera
@@ -227,15 +227,15 @@ module BABYLON {
                 if (this._canvas) {
                     this._scene.activeCamera.attachControl(this._canvas);
                 }
-            }else{
+            } else {
                 this._existingCamera = this._scene.activeCamera;
             }
 
             // Create VR cameras
             if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
-            this._vrDeviceOrientationCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
+                this._vrDeviceOrientationCamera = new VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
             }
-            this._webVRCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", this._position, this._scene, webVROptions);
+            this._webVRCamera = new WebVRFreeCamera("WebVRHelper", this._position, this._scene, webVROptions);
             this._webVRCamera.useStandingMatrix()
             // Create default button
             if (!this._useCustomVRButton) {
@@ -278,7 +278,7 @@ module BABYLON {
             // Display vr button when headset is connected
             if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
                 this.displayVRButton();
-            }else{
+            } else {
                 this._scene.getEngine().onVRDisplayChangedObservable.add((e) => {
                     if (e.vrDisplay) {
                         this.displayVRButton();
@@ -302,7 +302,7 @@ module BABYLON {
                         this._scene.getEngine().switchFullscreen(true);
                     }
                 }
-            }, BABYLON.PointerEventTypes.POINTERDOUBLETAP, false);
+            }, PointerEventTypes.POINTERDOUBLETAP, false);
 
             // Listen for WebVR display changes
             this._onVRDisplayChanged = (eventArgs: IDisplayChangedEventArgs) => this.onVRDisplayChanged(eventArgs);
@@ -320,7 +320,7 @@ module BABYLON {
             scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
             window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
 
-            scene.onDisposeObservable.add(()=>{
+            scene.onDisposeObservable.add(() => {
                 this.dispose();
             })
 
@@ -332,8 +332,8 @@ module BABYLON {
             this.updateButtonVisibility();
 
             //create easing functions
-            this._circleEase = new BABYLON.CircleEase();
-            this._circleEase.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
+            this._circleEase = new CircleEase();
+            this._circleEase.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT);
         }
 
         // Raised when one of the controller has loaded successfully its associated default mesh
@@ -347,14 +347,14 @@ module BABYLON {
             }
         }
 
-        private _onResize = ()=>{
+        private _onResize = () => {
             this.moveButtonToBottomRight();
             if (this._fullscreenVRpresenting && this._webVRready) {
                 this.exitVR();
             }
         }
 
-        private _onFullscreenChange = ()=>{
+        private _onFullscreenChange = () => {
             if (document.fullscreen !== undefined) {
                 this._fullscreenVRpresenting = document.fullscreen;
             } else if (document.mozFullScreen !== undefined) {
@@ -405,14 +405,14 @@ module BABYLON {
             this.updateButtonVisibility();
         }
 
-        private moveButtonToBottomRight(){
+        private moveButtonToBottomRight() {
             if (this._canvas && !this._useCustomVRButton) {
                 this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
                 this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
             }
         }
 
-        private displayVRButton(){
+        private displayVRButton() {
             if (!this._useCustomVRButton && !this._btnVRDisplayed) {
                 document.body.appendChild(this._btnVR);
                 this._btnVRDisplayed = true;
@@ -621,9 +621,9 @@ module BABYLON {
                 // on the main scene configuration for image processing to reduce setup and spaces 
                 // (gamma/linear) conflicts.
                 const imageProcessingConfiguration = new ImageProcessingConfiguration();
-                imageProcessingConfiguration.vignetteColor = new BABYLON.Color4(0, 0, 0, 0);
+                imageProcessingConfiguration.vignetteColor = new Color4(0, 0, 0, 0);
                 imageProcessingConfiguration.vignetteEnabled = true;
-                this._postProcessMove = new BABYLON.ImageProcessingPostProcess("postProcessMove",
+                this._postProcessMove = new ImageProcessingPostProcess("postProcessMove",
                     1.0,
                     this._webVRCamera,
                     undefined,
@@ -633,7 +633,7 @@ module BABYLON {
                     imageProcessingConfiguration);
 
                 this._webVRCamera.detachPostProcess(this._postProcessMove)
-                this._passProcessMove = new BABYLON.PassPostProcess("pass", 1.0, this._webVRCamera);
+                this._passProcessMove = new PassPostProcess("pass", 1.0, this._webVRCamera);
                 this._teleportationEnabled = true;
                 if (this._isDefaultTeleportationTarget) {
                     this._createTeleportationCircles();
@@ -642,7 +642,7 @@ module BABYLON {
         }
 
         private _onNewGamepadConnected = (gamepad: Gamepad) => {
-            if (gamepad.type !== BABYLON.Gamepad.POSE_ENABLED) {
+            if (gamepad.type !== Gamepad.POSE_ENABLED) {
                 if (gamepad.leftStick) {
                     gamepad.onleftstickchanged((stickValues) => {
                         if (this._teleportationEnabled) {
@@ -663,7 +663,7 @@ module BABYLON {
                         }
                     });
                 }
-                if (gamepad.type === BABYLON.Gamepad.XBOX) {
+                if (gamepad.type === Gamepad.XBOX) {
                     (<Xbox360Pad>gamepad).onbuttondown((buttonPressed: Xbox360Button) => {
                         if (this._interactionsEnabled && buttonPressed === Xbox360Button.A) {
                             this._selectionPointerDown();
@@ -675,14 +675,14 @@ module BABYLON {
                         }
                     });
                 }
-            }else{
+            } else {
                 var webVRController = <WebVRController>gamepad;
                 this._tryEnableInteractionOnController(webVRController);
             }
         }
 
         // This only succeeds if the controller's mesh exists for the controller so this must be called whenever new controller is connected or when mesh is loaded
-        private _tryEnableInteractionOnController = (webVRController:WebVRController) => {
+        private _tryEnableInteractionOnController = (webVRController: WebVRController) => {
             if (webVRController.hand === "left") {
                 this._leftControllerReady = true;
                 if (this._interactionsRequested && !this._interactionsEnabledOnLeftController) {
@@ -727,9 +727,9 @@ module BABYLON {
         private _enableInteractionOnController(webVRController: WebVRController) {
             var controllerMesh = webVRController.mesh;
             if (controllerMesh) {
-                var makeNotPick = (root:AbstractMesh)=>{
+                var makeNotPick = (root: AbstractMesh) => {
                     root.name += " laserPointer";
-                    root.getChildMeshes().forEach((c)=>{
+                    root.getChildMeshes().forEach((c) => {
                         makeNotPick(c);
                     });
                 }
@@ -742,9 +742,9 @@ module BABYLON {
                         break;
                     }
                 }
-                var laserPointer = BABYLON.Mesh.CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, this._scene, false);
-                var laserPointerMaterial = new BABYLON.StandardMaterial("laserPointerMat", this._scene);
-                laserPointerMaterial.emissiveColor = new BABYLON.Color3(0.7, 0.7, 0.7);
+                var laserPointer = Mesh.CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, this._scene, false);
+                var laserPointerMaterial = new StandardMaterial("laserPointerMat", this._scene);
+                laserPointerMaterial.emissiveColor = new Color3(0.7, 0.7, 0.7);
                 laserPointerMaterial.alpha = 0.6;
                 laserPointer.material = laserPointerMaterial;
                 laserPointer.rotation.x = Math.PI / 2;
@@ -790,10 +790,10 @@ module BABYLON {
             }
         }
 
-        private _checkTeleportWithRay(stateObject: StickValues, webVRController:Nullable<WebVRController> = null){
+        private _checkTeleportWithRay(stateObject: StickValues, webVRController: Nullable<WebVRController> = null) {
             if (!this._teleportationRequestInitiated) {
                 if (stateObject.y < -this._padSensibilityUp && this._dpadPressed) {
-                    if(webVRController){
+                    if (webVRController) {
                         // If laser pointer wasn't enabled yet
                         if (this._displayLaserPointer && webVRController.hand === "left" && this._leftLaserPointer) {
                             this._leftLaserPointer.isVisible = true;
@@ -811,10 +811,10 @@ module BABYLON {
                 }
             } else {
                 // Listening to the proper controller values changes to confirm teleportation
-                if (webVRController == null 
-                    ||(webVRController.hand === "left" && this._leftLaserPointer && this._leftLaserPointer.isVisible)
+                if (webVRController == null
+                    || (webVRController.hand === "left" && this._leftLaserPointer && this._leftLaserPointer.isVisible)
                     || (webVRController.hand === "right" && this._rightLaserPointer && this._rightLaserPointer.isVisible)) {
-                    if (Math.sqrt(stateObject.y*stateObject.y + stateObject.x*stateObject.x) < this._padSensibilityDown) {
+                    if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
                         if (this._teleportationAllowed) {
                             this._teleportationAllowed = false;
                             this._teleportCamera();
@@ -824,21 +824,21 @@ module BABYLON {
                 }
             }
         }
-        private _selectionPointerDown(){
+        private _selectionPointerDown() {
             this._pointerDownOnMeshAsked = true;
             if (this._currentMeshSelected && this._currentHit) {
                 this._scene.simulatePointerDown(this._currentHit);
             }
         }
-        private _selectionPointerUp(){
+        private _selectionPointerUp() {
             if (this._currentMeshSelected && this._currentHit) {
                 this._scene.simulatePointerUp(this._currentHit);
             }
             this._pointerDownOnMeshAsked = false;
         }
-        private _checkRotate(stateObject: StickValues){
+        private _checkRotate(stateObject: StickValues) {
             // Only rotate when user is not currently selecting a teleportation location
-            if(this._teleportationRequestInitiated){
+            if (this._teleportationRequestInitiated) {
                 return;
             }
 
@@ -868,15 +868,15 @@ module BABYLON {
                 }
             }
         }
-        private _checkTeleportBackwards(stateObject: StickValues){
+        private _checkTeleportBackwards(stateObject: StickValues) {
             // Only teleport backwards when user is not currently selecting a teleportation location
-            if(this._teleportationRequestInitiated){
+            if (this._teleportationRequestInitiated) {
                 return;
             }
             // Teleport backwards
-            if(stateObject.y > this._padSensibilityUp && this._dpadPressed) {
-                if(!this._teleportationBackRequestInitiated){
-                    if(!this.currentVRCamera){
+            if (stateObject.y > this._padSensibilityUp && this._dpadPressed) {
+                if (!this._teleportationBackRequestInitiated) {
+                    if (!this.currentVRCamera) {
                         return;
                     }
 
@@ -885,7 +885,7 @@ module BABYLON {
                     var position = this.currentVRCamera.position;
 
                     // If the camera has device position, use that instead
-                    if((<WebVRFreeCamera>this.currentVRCamera).devicePosition && (<WebVRFreeCamera>this.currentVRCamera).deviceRotationQuaternion){
+                    if ((<WebVRFreeCamera>this.currentVRCamera).devicePosition && (<WebVRFreeCamera>this.currentVRCamera).deviceRotationQuaternion) {
                         rotation = (<WebVRFreeCamera>this.currentVRCamera).deviceRotationQuaternion;
                         position = (<WebVRFreeCamera>this.currentVRCamera).devicePosition;
                     }
@@ -899,20 +899,20 @@ module BABYLON {
 
                     // Rotate backwards ray by device rotation to cast at the ground behind the user
                     Vector3.TransformCoordinatesToRef(this.teleportBackwardsVector, this._workingMatrix, this._workingVector);
-                    
+
                     // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
-                    var ray = new BABYLON.Ray(position, this._workingVector);
+                    var ray = new Ray(position, this._workingVector);
                     var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
-                    if(hit && hit.pickedPoint && hit.pickedMesh &&this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5){
+                    if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
                         this._teleportCamera(hit.pickedPoint);
                     }
-                    
+
                     this._teleportationBackRequestInitiated = true;
                 }
-            }else{
+            } else {
                 this._teleportationBackRequestInitiated = false;
             }
-            
+
         }
 
         private _enableTeleportationOnController(webVRController: WebVRController) {
@@ -951,24 +951,24 @@ module BABYLON {
 
         // Gaze support used to point to teleport or to interact with an object
         private _createGazeTracker() {
-            this._gazeTracker = BABYLON.Mesh.CreateTorus("gazeTracker", 0.0035, 0.0025, 20, this._scene, false);
+            this._gazeTracker = Mesh.CreateTorus("gazeTracker", 0.0035, 0.0025, 20, this._scene, false);
             this._gazeTracker.bakeCurrentTransformIntoVertices();
             this._gazeTracker.isPickable = false;
             this._gazeTracker.isVisible = false;
 
-            var targetMat = new BABYLON.StandardMaterial("targetMat", this._scene);
-            targetMat.specularColor = BABYLON.Color3.Black();
-            targetMat.emissiveColor = new BABYLON.Color3(0.7, 0.7, 0.7)
+            var targetMat = new StandardMaterial("targetMat", this._scene);
+            targetMat.specularColor = Color3.Black();
+            targetMat.emissiveColor = new Color3(0.7, 0.7, 0.7)
             targetMat.backFaceCulling = false;
             this._gazeTracker.material = targetMat;
         }
 
         private _createTeleportationCircles() {
-            this._teleportationTarget = BABYLON.Mesh.CreateGround("teleportationTarget", 2, 2, 2, this._scene);
+            this._teleportationTarget = Mesh.CreateGround("teleportationTarget", 2, 2, 2, this._scene);
             this._teleportationTarget.isPickable = false;
 
             var length = 512;
-            var dynamicTexture = new BABYLON.DynamicTexture("DynamicTexture", length, this._scene, true);
+            var dynamicTexture = new DynamicTexture("DynamicTexture", length, this._scene, true);
             dynamicTexture.hasAlpha = true;
             var context = dynamicTexture.getContext();
 
@@ -986,15 +986,15 @@ module BABYLON {
             context.closePath();
             dynamicTexture.update();
 
-            var teleportationCircleMaterial = new BABYLON.StandardMaterial("TextPlaneMaterial", this._scene);
+            var teleportationCircleMaterial = new StandardMaterial("TextPlaneMaterial", this._scene);
             teleportationCircleMaterial.diffuseTexture = dynamicTexture;
             this._teleportationTarget.material = teleportationCircleMaterial;
 
-            var torus = BABYLON.Mesh.CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
+            var torus = Mesh.CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
             torus.isPickable = false;
             torus.parent = this._teleportationTarget;
 
-            var animationInnerCircle = new BABYLON.Animation("animationInnerCircle", "position.y", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
+            var animationInnerCircle = new Animation("animationInnerCircle", "position.y", 30, Animation.ANIMATIONTYPE_FLOAT, Animation.ANIMATIONLOOPMODE_CYCLE);
 
             var keys = [];
             keys.push({
@@ -1012,8 +1012,8 @@ module BABYLON {
 
             animationInnerCircle.setKeys(keys);
 
-            var easingFunction = new BABYLON.SineEase();
-            easingFunction.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
+            var easingFunction = new SineEase();
+            easingFunction.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT);
             animationInnerCircle.setEasingFunction(easingFunction);
 
             torus.animations = [];
@@ -1056,10 +1056,10 @@ module BABYLON {
 
             this.currentVRCamera.animations = [];
 
-            var target = BABYLON.Quaternion.FromRotationMatrix(BABYLON.Matrix.RotationY(Math.PI / 4 * this._rotationAngle));
+            var target = Quaternion.FromRotationMatrix(Matrix.RotationY(Math.PI / 4 * this._rotationAngle));
 
-            var animationRotation = new BABYLON.Animation("animationRotation", "rotationQuaternion", 90, BABYLON.Animation.ANIMATIONTYPE_QUATERNION,
-                BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+            var animationRotation = new Animation("animationRotation", "rotationQuaternion", 90, Animation.ANIMATIONTYPE_QUATERNION,
+                Animation.ANIMATIONLOOPMODE_CONSTANT);
 
             var animationRotationKeys = [];
             animationRotationKeys.push({
@@ -1079,8 +1079,8 @@ module BABYLON {
 
             this._postProcessMove.animations = [];
 
-            var animationPP = new BABYLON.Animation("animationPP", "vignetteWeight", 90, BABYLON.Animation.ANIMATIONTYPE_FLOAT,
-                BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+            var animationPP = new Animation("animationPP", "vignetteWeight", 90, Animation.ANIMATIONTYPE_FLOAT,
+                Animation.ANIMATIONLOOPMODE_CONSTANT);
 
             var vignetteWeightKeys = [];
             vignetteWeightKeys.push({
@@ -1100,8 +1100,8 @@ module BABYLON {
             animationPP.setEasingFunction(this._circleEase);
             this._postProcessMove.animations.push(animationPP);
 
-            var animationPP2 = new BABYLON.Animation("animationPP2", "vignetteStretch", 90, BABYLON.Animation.ANIMATIONTYPE_FLOAT,
-                BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+            var animationPP2 = new Animation("animationPP2", "vignetteStretch", 90, Animation.ANIMATIONTYPE_FLOAT,
+                Animation.ANIMATIONLOOPMODE_CONSTANT);
 
             var vignetteStretchKeys = [];
             vignetteStretchKeys.push({
@@ -1144,9 +1144,9 @@ module BABYLON {
                 this._teleportationTarget.position.copyFrom(hit.pickedPoint);
                 var pickNormal = hit.getNormal(true, false);
                 if (pickNormal) {
-                    var axis1 = BABYLON.Vector3.Cross(BABYLON.Axis.Y, pickNormal);
-                    var axis2 = BABYLON.Vector3.Cross(pickNormal, axis1);
-                    BABYLON.Vector3.RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
+                    var axis1 = Vector3.Cross(Axis.Y, pickNormal);
+                    var axis2 = Vector3.Cross(pickNormal, axis1);
+                    Vector3.RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
                 }
                 this._teleportationTarget.position.y += 0.1;
             }
@@ -1154,12 +1154,12 @@ module BABYLON {
         private _workingVector = Vector3.Zero();
         private _workingQuaternion = Quaternion.Identity();
         private _workingMatrix = Matrix.Identity();
-        private _teleportCamera(location:Nullable<Vector3> = null) {
+        private _teleportCamera(location: Nullable<Vector3> = null) {
             if (!(this.currentVRCamera instanceof FreeCamera)) {
                 return;
             }
 
-            if(!location){
+            if (!location) {
                 location = this._haloCenter;
             }
             // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
@@ -1172,15 +1172,15 @@ module BABYLON {
                 this._workingVector.copyFrom(location);
             }
             // Add height to account for user's height offset
-            if(this.isInVRMode){
+            if (this.isInVRMode) {
                 this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround();
-            }else{
+            } else {
                 this._workingVector.y += this._defaultHeight;
             }
 
             // Create animation from the camera's position to the new location
             this.currentVRCamera.animations = [];
-            var animationCameraTeleportation = new BABYLON.Animation("animationCameraTeleportation", "position", 90, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+            var animationCameraTeleportation = new Animation("animationCameraTeleportation", "position", 90, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
             var animationCameraTeleportationKeys = [{
                 frame: 0,
                 value: this.currentVRCamera.position
@@ -1197,8 +1197,8 @@ module BABYLON {
 
             this._postProcessMove.animations = [];
 
-            var animationPP = new BABYLON.Animation("animationPP", "vignetteWeight", 90, BABYLON.Animation.ANIMATIONTYPE_FLOAT,
-                BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+            var animationPP = new Animation("animationPP", "vignetteWeight", 90, Animation.ANIMATIONTYPE_FLOAT,
+                Animation.ANIMATIONLOOPMODE_CONSTANT);
 
             var vignetteWeightKeys = [];
             vignetteWeightKeys.push({
@@ -1217,8 +1217,8 @@ module BABYLON {
             animationPP.setKeys(vignetteWeightKeys);
             this._postProcessMove.animations.push(animationPP);
 
-            var animationPP2 = new BABYLON.Animation("animationPP2", "vignetteStretch", 90, BABYLON.Animation.ANIMATIONTYPE_FLOAT,
-                BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
+            var animationPP2 = new Animation("animationPP2", "vignetteStretch", 90, Animation.ANIMATIONTYPE_FLOAT,
+                Animation.ANIMATIONLOOPMODE_CONSTANT);
 
             var vignetteStretchKeys = [];
             vignetteStretchKeys.push({
@@ -1252,7 +1252,7 @@ module BABYLON {
                 return;
             }
 
-            var ray:Ray;
+            var ray: Ray;
             if (this._leftLaserPointer && this._leftLaserPointer.isVisible && (<any>this.currentVRCamera).leftController) {
                 ray = (<any>this.currentVRCamera).leftController.getForwardRay(this._rayLength);
             }
@@ -1283,9 +1283,9 @@ module BABYLON {
                     let deltaFighting = 0.002;
 
                     if (pickNormal) {
-                        var axis1 = BABYLON.Vector3.Cross(BABYLON.Axis.Y, pickNormal);
-                        var axis2 = BABYLON.Vector3.Cross(pickNormal, axis1);
-                        BABYLON.Vector3.RotationFromAxisToRef(axis2, pickNormal, axis1, this._gazeTracker.rotation);
+                        var axis1 = Vector3.Cross(Axis.Y, pickNormal);
+                        var axis2 = Vector3.Cross(pickNormal, axis1);
+                        Vector3.RotationFromAxisToRef(axis2, pickNormal, axis1, this._gazeTracker.rotation);
                     }
                     this._gazeTracker.position.copyFrom(hit.pickedPoint);
 
@@ -1341,13 +1341,13 @@ module BABYLON {
                     if (this.meshSelectionPredicate(hit.pickedMesh)) {
                         this._currentMeshSelected = hit.pickedMesh;
                         if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
-                            this.changeGazeColor(new BABYLON.Color3(0, 0, 1));
-                            this.changeLaserColor(new BABYLON.Color3(0.2, 0.2, 1));
+                            this.changeGazeColor(new Color3(0, 0, 1));
+                            this.changeLaserColor(new Color3(0.2, 0.2, 1));
                             this._isActionableMesh = true;
                         }
                         else {
-                            this.changeGazeColor(new BABYLON.Color3(0.7, 0.7, 0.7));
-                            this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
+                            this.changeGazeColor(new Color3(0.7, 0.7, 0.7));
+                            this.changeLaserColor(new Color3(0.7, 0.7, 0.7));
                             this._isActionableMesh = false;
                         }
                         try {
@@ -1359,8 +1359,8 @@ module BABYLON {
                     }
                     else {
                         this._currentMeshSelected = null;
-                        this.changeGazeColor(new BABYLON.Color3(0.7, 0.7, 0.7));
-                        this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
+                        this.changeGazeColor(new Color3(0.7, 0.7, 0.7));
+                        this.changeLaserColor(new Color3(0.7, 0.7, 0.7));
                     }
                 }
             }
@@ -1369,8 +1369,8 @@ module BABYLON {
                 this._currentMeshSelected = null;
                 this._teleportationAllowed = false;
                 this._hideTeleportationTarget();
-                this.changeGazeColor(new BABYLON.Color3(0.7, 0.7, 0.7));
-                this.changeLaserColor(new BABYLON.Color3(0.7, 0.7, 0.7));
+                this.changeGazeColor(new Color3(0.7, 0.7, 0.7));
+                this.changeLaserColor(new Color3(0.7, 0.7, 0.7));
             }
         }
 
@@ -1416,11 +1416,11 @@ module BABYLON {
                 this._deviceOrientationCamera.dispose();
             }
 
-            if(this._gazeTracker){
+            if (this._gazeTracker) {
                 this._gazeTracker.dispose();
             }
-            
-            if(this._teleportationTarget){
+
+            if (this._teleportationTarget) {
                 this._teleportationTarget.dispose();
             }
 
@@ -1428,7 +1428,7 @@ module BABYLON {
 
             document.removeEventListener("keydown", this._onKeyDown);
             window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
-            
+
             window.removeEventListener("resize", this._onResize);
             document.removeEventListener("fullscreenchange", this._onFullscreenChange);
             document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);

+ 35 - 35
src/Cameras/VR/babylon.webVRCamera.ts

@@ -54,13 +54,13 @@ module BABYLON {
 
         // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
         private _deviceRoomPosition = Vector3.Zero();
-        private _deviceRoomRotationQuaternion = Quaternion.Identity(); 
+        private _deviceRoomRotationQuaternion = Quaternion.Identity();
 
-        private _standingMatrix:Nullable<Matrix> = null;
+        private _standingMatrix: Nullable<Matrix> = null;
 
         // Represents device position and rotation in babylon space
         public devicePosition = Vector3.Zero();
-        public deviceRotationQuaternion = Quaternion.Identity();        
+        public deviceRotationQuaternion = Quaternion.Identity();
 
         public deviceScaleFactor: number = 1;
 
@@ -73,17 +73,17 @@ module BABYLON {
 
         public rigParenting: boolean = true; // should the rig cameras be used as parent instead of this camera.
 
-        private _lightOnControllers: BABYLON.HemisphericLight;
+        private _lightOnControllers: HemisphericLight;
 
         private _defaultHeight = 0;
         constructor(name: string, position: Vector3, scene: Scene, private webVROptions: WebVROptions = {}) {
             super(name, position, scene);
             this._cache.position = Vector3.Zero();
-            if(webVROptions.defaultHeight){
+            if (webVROptions.defaultHeight) {
                 this._defaultHeight = webVROptions.defaultHeight;
                 this.position.y = this._defaultHeight;
             }
-            
+
             this.minZ = 0.1;
 
             //legacy support - the compensation boolean was removed.
@@ -127,7 +127,7 @@ module BABYLON {
                 }
             });
 
-            if (typeof(VRFrameData) !== "undefined")
+            if (typeof (VRFrameData) !== "undefined")
                 this._frameData = new VRFrameData();
 
             /**
@@ -164,30 +164,30 @@ module BABYLON {
             });
         }
 
-        public deviceDistanceToRoomGround = ()=>{
-            if(this._standingMatrix){
+        public deviceDistanceToRoomGround = () => {
+            if (this._standingMatrix) {
                 // Add standing matrix offset to get real offset from ground in room
                 this._standingMatrix.getTranslationToRef(this._workingVector);
-                return this._deviceRoomPosition.y+this._workingVector.y
-            }else{
+                return this._deviceRoomPosition.y + this._workingVector.y
+            } else {
                 return this._defaultHeight;
             }
         }
 
-        public useStandingMatrix = (callback = (bool:boolean)=>{})=>{
+        public useStandingMatrix = (callback = (bool: boolean) => { }) => {
             // Use standing matrix if availible
-            if(!navigator || !navigator.getVRDisplays){
+            if (!navigator || !navigator.getVRDisplays) {
                 callback(false);
-            }else{
-                navigator.getVRDisplays().then((displays:any)=>{
-                    if(!displays || !displays[0] || !displays[0].stageParameters || !displays[0].stageParameters.sittingToStandingTransform){
+            } else {
+                navigator.getVRDisplays().then((displays: any) => {
+                    if (!displays || !displays[0] || !displays[0].stageParameters || !displays[0].stageParameters.sittingToStandingTransform) {
                         callback(false);
-                    }else{
-                        this._standingMatrix = new BABYLON.Matrix();
-                        BABYLON.Matrix.FromFloat32ArrayToRefScaled(displays[0].stageParameters.sittingToStandingTransform, 0, 1, this._standingMatrix);
+                    } else {
+                        this._standingMatrix = new Matrix();
+                        Matrix.FromFloat32ArrayToRefScaled(displays[0].stageParameters.sittingToStandingTransform, 0, 1, this._standingMatrix);
                         if (!this.getScene().useRightHandedSystem) {
                             [2, 6, 8, 9, 14].forEach((num) => {
-                                if(this._standingMatrix){
+                                if (this._standingMatrix) {
                                     this._standingMatrix.m[num] *= -1;
                                 }
                             });
@@ -232,7 +232,7 @@ module BABYLON {
         };
 
 
-        
+
         public getForwardRay(length = 100): Ray {
             if (this.leftCamera) {
                 // Use left eye to avoid computation to compute center on every call
@@ -326,7 +326,7 @@ module BABYLON {
         private _oneVector = Vector3.One();
         private _workingMatrix = Matrix.Identity();
         public _updateCache(ignoreParentClass?: boolean): void {
-            if(!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)){
+            if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
                 // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
                 this.update();
 
@@ -336,8 +336,8 @@ module BABYLON {
 
                 // Subtract this vector from the current device position in world to get the translation for the device world matrix
                 this.devicePosition.subtractToRef(this._workingVector, this._workingVector)
-                Matrix.ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);             
-                
+                Matrix.ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
+
                 // Add translation from anchor position
                 this._deviceToWorld.getTranslationToRef(this._workingVector)
                 this._workingVector.addInPlace(this.position);
@@ -346,9 +346,9 @@ module BABYLON {
 
                 // Set an inverted matrix to be used when updating the camera
                 this._deviceToWorld.invertToRef(this._worldToDevice)
-                
+
                 // Update the gamepad to ensure the mesh is updated on the same frame as camera
-                this.controllers.forEach((controller)=>{
+                this.controllers.forEach((controller) => {
                     controller._deviceToWorld = this._deviceToWorld;
                     controller.update();
                 })
@@ -362,7 +362,7 @@ module BABYLON {
         public update() {
             // Get current device position in babylon world
             Vector3.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
-            
+
             // Get current device rotation in babylon world
             Matrix.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
             this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix)
@@ -411,7 +411,7 @@ module BABYLON {
 
                 this._webvrViewMatrix.invert();
             }
-            
+
             parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
             return this._webvrViewMatrix;
         }
@@ -444,17 +444,17 @@ module BABYLON {
 
             let manager = this.getScene().gamepadManager;
             this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add((gamepad) => {
-                if (gamepad.type === BABYLON.Gamepad.POSE_ENABLED) {
+                if (gamepad.type === Gamepad.POSE_ENABLED) {
                     let webVrController: WebVRController = <WebVRController>gamepad;
 
                     if (webVrController.defaultModel) {
                         webVrController.defaultModel.setEnabled(false);
                     }
 
-                    if(webVrController.hand === "right"){
+                    if (webVrController.hand === "right") {
                         this._rightController = null;
                     }
-                    if(webVrController.hand === "left"){
+                    if (webVrController.hand === "left") {
                         this._rightController = null;
                     }
                     const controllerIndex = this.controllers.indexOf(webVrController);
@@ -465,7 +465,7 @@ module BABYLON {
             });
 
             this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add((gamepad) => {
-                if (gamepad.type === BABYLON.Gamepad.POSE_ENABLED) {
+                if (gamepad.type === Gamepad.POSE_ENABLED) {
                     let webVrController: WebVRController = <WebVRController>gamepad;
                     webVrController._deviceToWorld = this._deviceToWorld;
                     if (this.webVROptions.controllerMeshes) {
@@ -477,7 +477,7 @@ module BABYLON {
                                 this.onControllerMeshLoadedObservable.notifyObservers(webVrController);
                                 if (this.webVROptions.defaultLightingOnControllers) {
                                     if (!this._lightOnControllers) {
-                                        this._lightOnControllers = new BABYLON.HemisphericLight("vrControllersLight", new BABYLON.Vector3(0, 1, 0), this.getScene());
+                                        this._lightOnControllers = new HemisphericLight("vrControllersLight", new Vector3(0, 1, 0), this.getScene());
                                     }
                                     let activateLightOnSubMeshes = function (mesh: AbstractMesh, light: HemisphericLight) {
                                         let children = mesh.getChildren();
@@ -517,8 +517,8 @@ module BABYLON {
                                 }
                             }
                         }
-                        
-                            //did we find enough controllers? Great! let the developer know.
+
+                        //did we find enough controllers? Great! let the developer know.
                         if (this.controllers.length >= 2) {
                             this.onControllersAttachedObservable.notifyObservers(this.controllers);
                         }

+ 5 - 5
src/Cameras/babylon.camera.ts

@@ -558,10 +558,10 @@
             if (!origin) {
                 origin = this.position;
             }
-            var forward = new BABYLON.Vector3(0, 0, 1);
-            var forwardWorld = BABYLON.Vector3.TransformNormal(forward, transform);
+            var forward = new Vector3(0, 0, 1);
+            var forwardWorld = Vector3.TransformNormal(forward, transform);
 
-            var direction = BABYLON.Vector3.Normalize(forwardWorld);
+            var direction = Vector3.Normalize(forwardWorld);
 
             return new Ray(origin, direction, length);
         }
@@ -587,7 +587,7 @@
                 let camera = this._rigCameras.pop();
                 if (camera) {
                     camera.dispose();
-                }                
+                }
             }
 
             // Postprocesses
@@ -665,7 +665,7 @@
             //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target, 
             //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
             this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
-            this._cameraRigParams.stereoHalfAngle = BABYLON.Tools.ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
+            this._cameraRigParams.stereoHalfAngle = Tools.ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
 
             // create the rig cameras, unless none
             if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {

+ 7 - 7
src/Cameras/babylon.cameraInputsManager.ts

@@ -1,7 +1,7 @@
 module BABYLON {
     export var CameraInputTypes = {};
 
-    export interface ICameraInput<TCamera extends BABYLON.Camera> {
+    export interface ICameraInput<TCamera extends Camera> {
         camera: Nullable<TCamera>;
         getClassName(): string;
         getSimpleName(): string;
@@ -10,12 +10,12 @@ module BABYLON {
         checkInputs?: () => void;
     }
 
-    export interface CameraInputsMap<TCamera extends BABYLON.Camera> {
+    export interface CameraInputsMap<TCamera extends Camera> {
         [name: string]: ICameraInput<TCamera>;
         [idx: number]: ICameraInput<TCamera>;
     }
 
-    export class CameraInputsManager<TCamera extends BABYLON.Camera> {
+    export class CameraInputsManager<TCamera extends Camera> {
         attached: CameraInputsMap<TCamera>;
         public attachedElement: Nullable<HTMLElement>;
         public noPreventDefault: boolean;
@@ -38,7 +38,7 @@ module BABYLON {
             this.attached[type] = input;
 
             input.camera = this.camera;
-            
+
             //for checkInputs, we are dynamically creating a function
             //the goal is to avoid the performance penalty of looping for inputs in the render loop
             if (input.checkInputs) {
@@ -139,7 +139,7 @@ module BABYLON {
         }
 
         public serialize(serializedCamera: any) {
-            var inputs: {[key: string]: any} = {};
+            var inputs: { [key: string]: any } = {};
             for (var cam in this.attached) {
                 var input = this.attached[cam];
                 var res = SerializationHelper.Serialize(input);
@@ -162,7 +162,7 @@ module BABYLON {
                         this.add(input as any);
                     }
                 }
-            } else { 
+            } else {
                 //2016-03-08 this part is for managing backward compatibility
                 for (var n in this.attached) {
                     var construct = (<any>CameraInputTypes)[this.attached[n].getClassName()];
@@ -175,5 +175,5 @@ module BABYLON {
             }
         }
     }
-} 
+}
 

+ 1 - 1
src/Cameras/babylon.targetCamera.ts

@@ -273,7 +273,7 @@
             }
 
             //update the up vector!
-            BABYLON.Vector3.TransformNormalToRef(this.upVector, this._cameraRotationMatrix, this._currentUpVector);
+            Vector3.TransformNormalToRef(this.upVector, this._cameraRotationMatrix, this._currentUpVector);
         }
 
         public _getViewMatrix(): Matrix {

+ 1 - 1
src/Collisions/babylon.collisionWorker.ts

@@ -262,7 +262,7 @@ module BABYLON {
             window = <any>{};
 
             //scripts were not included, standalone worker
-            if (!BABYLON.Collider) {
+            if (!Collider) {
                 importScripts("./babylon.collisionCoordinator.js");
                 importScripts("./babylon.collider.js");
                 importScripts("../Math/babylon.math.js");

+ 4 - 4
src/Collisions/babylon.pickingInfo.ts

@@ -54,14 +54,14 @@
                 var p1p2 = vertex1.subtract(vertex2);
                 var p3p2 = vertex3.subtract(vertex2);
 
-                result = BABYLON.Vector3.Cross(p1p2, p3p2);
+                result = Vector3.Cross(p1p2, p3p2);
             }
 
             if (useWorldCoordinates) {
                 result = Vector3.TransformNormal(result, this.pickedMesh.getWorldMatrix());
             }
 
-            return BABYLON.Vector3.Normalize(result);
+            return Vector3.Normalize(result);
         }
 
         public getTextureCoordinates(): Nullable<Vector2> {
@@ -77,7 +77,7 @@
             var uvs = this.pickedMesh.getVerticesData(VertexBuffer.UVKind);
             if (!uvs) {
                 return null;
-            }            
+            }
 
             var uv0 = Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);
             var uv1 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
@@ -90,5 +90,5 @@
             return new Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
         }
     }
-} 
+}
 

+ 13 - 13
src/Engine/babylon.engine.ts

@@ -617,7 +617,7 @@
 
         private _vrDisplay: any = undefined;
         private _vrSupported: boolean = false;
-        private _oldSize: BABYLON.Size;
+        private _oldSize: Size;
         private _oldHardwareScaleFactor: number;
         private _vrExclusivePointerMode = false;
 
@@ -811,14 +811,14 @@
         // Empty texture
         public get emptyTexture(): InternalTexture {
             if (!this._emptyTexture) {
-                this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, BABYLON.Engine.TEXTUREFORMAT_RGBA, false, false, BABYLON.Texture.NEAREST_SAMPLINGMODE);
+                this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Texture.NEAREST_SAMPLINGMODE);
             }
 
             return this._emptyTexture;
         }
         public get emptyTexture3D(): InternalTexture {
             if (!this._emptyTexture3D) {
-                this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, BABYLON.Engine.TEXTUREFORMAT_RGBA, false, false, BABYLON.Texture.NEAREST_SAMPLINGMODE);
+                this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Texture.NEAREST_SAMPLINGMODE);
             }
 
             return this._emptyTexture3D;
@@ -827,7 +827,7 @@
             if (!this._emptyCubeTexture) {
                 var faceData = new Uint8Array(4);
                 var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
-                this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, BABYLON.Engine.TEXTUREFORMAT_RGBA, BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, false, false, BABYLON.Texture.NEAREST_SAMPLINGMODE);
+                this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Texture.NEAREST_SAMPLINGMODE);
             }
 
             return this._emptyCubeTexture;
@@ -1095,7 +1095,7 @@
 
             Tools.Log("Babylon.js engine (v" + Engine.Version + ") launched");
 
-            this.enableOfflineSupport = (BABYLON.Database !== undefined);
+            this.enableOfflineSupport = (Database !== undefined);
         }
 
         private _rebuildInternalTextures(): void {
@@ -1810,7 +1810,7 @@
         private _onVRFullScreenTriggered = () => {
             if (this._vrDisplay && this._vrDisplay.isPresenting) {
                 //get the old size before we change
-                this._oldSize = new BABYLON.Size(this.getRenderWidth(), this.getRenderHeight());
+                this._oldSize = new Size(this.getRenderWidth(), this.getRenderHeight());
                 this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
 
                 //get the width and height, change the render size
@@ -3093,8 +3093,8 @@
                 // fallback for when compressed file not found to try again.  For instance, etc1 does not have an alpha capable type
                 if (isKTX) {
                     this.createTexture(urlArg, noMipmap, invertY, scene, samplingMode, null, onError, buffer, texture);
-                } else if (BABYLON.Tools.UseFallbackTexture) {
-                    this.createTexture(BABYLON.Tools.fallbackTexture, noMipmap, invertY, scene, samplingMode, null, onError, buffer, texture);
+                } else if (Tools.UseFallbackTexture) {
+                    this.createTexture(Tools.fallbackTexture, noMipmap, invertY, scene, samplingMode, null, onError, buffer, texture);
                 }
 
                 if (onError) {
@@ -3221,7 +3221,7 @@
             );
 
             if (!this._rescalePostProcess) {
-                this._rescalePostProcess = new BABYLON.PassPostProcess("rescale", 1, null, Texture.BILINEAR_SAMPLINGMODE, this, false, Engine.TEXTURETYPE_UNSIGNED_INT);
+                this._rescalePostProcess = new PassPostProcess("rescale", 1, null, Texture.BILINEAR_SAMPLINGMODE, this, false, Engine.TEXTURETYPE_UNSIGNED_INT);
             }
 
             this._rescalePostProcess.getEffect().executeWhenCompiled(() => {
@@ -3308,7 +3308,7 @@
             texture.isReady = true;
         }
 
-        public createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string> = null, type: number = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT): InternalTexture {
+        public createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string> = null, type: number = Engine.TEXTURETYPE_UNSIGNED_INT): InternalTexture {
             var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RAW);
             texture.baseWidth = width;
             texture.baseHeight = height;
@@ -5108,7 +5108,7 @@
             this.onBeginFrameObservable.clear();
             this.onEndFrameObservable.clear();
 
-            BABYLON.Effect.ResetCache();
+            Effect.ResetCache();
         }
 
         // Loading screen
@@ -5244,14 +5244,14 @@
             if (this._webGLVersion > 1) {
                 return this._caps.colorBufferFloat;
             }
-            return this._canRenderToFramebuffer(BABYLON.Engine.TEXTURETYPE_FLOAT);
+            return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
         }
 
         private _canRenderToHalfFloatFramebuffer(): boolean {
             if (this._webGLVersion > 1) {
                 return this._caps.colorBufferFloat;
             }
-            return this._canRenderToFramebuffer(BABYLON.Engine.TEXTURETYPE_HALF_FLOAT);
+            return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
         }
 
         // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture

+ 7 - 7
src/Engine/babylon.webgl2.ts

@@ -12,7 +12,7 @@ interface WebGLRenderingContext {
     texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
     texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
     texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
-    
+
     compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
 
     readonly TRANSFORM_FEEDBACK: number;
@@ -20,7 +20,7 @@ interface WebGLRenderingContext {
     readonly TRANSFORM_FEEDBACK_BUFFER: number;
     createTransformFeedback(): WebGLTransformFeedback;
     deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
-    bindTransformFeedback(target: number, transformFeedback: BABYLON.Nullable<WebGLTransformFeedback>): void;
+    bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
     beginTransformFeedback(primitiveMode: number): void;
     endTransformFeedback(): void;
     transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
@@ -37,7 +37,7 @@ interface WebGLQuery extends WebGLObject {
 
 declare var WebGLQuery: {
     prototype: WebGLQuery;
-    new (): WebGLQuery;
+    new(): WebGLQuery;
 };
 
 interface WebGLSampler extends WebGLObject {
@@ -45,7 +45,7 @@ interface WebGLSampler extends WebGLObject {
 
 declare var WebGLSampler: {
     prototype: WebGLSampler;
-    new (): WebGLSampler;
+    new(): WebGLSampler;
 };
 
 interface WebGLSync extends WebGLObject {
@@ -53,7 +53,7 @@ interface WebGLSync extends WebGLObject {
 
 declare var WebGLSync: {
     prototype: WebGLSync;
-    new (): WebGLSync;
+    new(): WebGLSync;
 };
 
 interface WebGLTransformFeedback extends WebGLObject {
@@ -61,7 +61,7 @@ interface WebGLTransformFeedback extends WebGLObject {
 
 declare var WebGLTransformFeedback: {
     prototype: WebGLTransformFeedback;
-    new (): WebGLTransformFeedback;
+    new(): WebGLTransformFeedback;
 };
 
 interface WebGLVertexArrayObject extends WebGLObject {
@@ -69,5 +69,5 @@ interface WebGLVertexArrayObject extends WebGLObject {
 
 declare var WebGLVertexArrayObject: {
     prototype: WebGLVertexArrayObject;
-    new (): WebGLVertexArrayObject;
+    new(): WebGLVertexArrayObject;
 };

+ 8 - 8
src/Gamepad/Controllers/babylon.poseEnabledController.ts

@@ -12,7 +12,7 @@ module BABYLON {
         touched: boolean;
         pressed: boolean;
     }
-    
+
     export interface ExtendedGamepadButton extends GamepadButton {
         readonly pressed: boolean;
         readonly touched: boolean;
@@ -64,7 +64,7 @@ module BABYLON {
         private _poseControlledCamera: TargetCamera;
 
         private _leftHandSystemQuaternion: Quaternion = new Quaternion();
-        
+
         public _deviceToWorld = Matrix.Identity();
 
         constructor(browserGamepad: any) {
@@ -89,7 +89,7 @@ module BABYLON {
             this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
             Quaternion.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
             this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation)
-            
+
             if (this._mesh) {
                 this._mesh.position.copyFrom(this.devicePosition);
 
@@ -166,18 +166,18 @@ module BABYLON {
 
         public getForwardRay(length = 100): Ray {
             if (!this.mesh) {
-                return new Ray(Vector3.Zero(), new BABYLON.Vector3(0, 0, 1), length);
+                return new Ray(Vector3.Zero(), new Vector3(0, 0, 1), length);
             }
 
             var m = this.mesh.getWorldMatrix();
             var origin = m.getTranslation();
 
-            var forward = new BABYLON.Vector3(0, 0, -1);
-            var forwardWorld = BABYLON.Vector3.TransformNormal(forward, m);
+            var forward = new Vector3(0, 0, -1);
+            var forwardWorld = Vector3.TransformNormal(forward, m);
 
-            var direction = BABYLON.Vector3.Normalize(forwardWorld);            
+            var direction = Vector3.Normalize(forwardWorld);
 
             return new Ray(origin, direction, length);
-        } 
+        }
     }
 }

+ 8 - 8
src/Gamepad/Controllers/babylon.windowsMotionController.ts

@@ -154,12 +154,12 @@ module BABYLON {
                 return;
             }
 
-            BABYLON.Quaternion.SlerpToRef(
+            Quaternion.SlerpToRef(
                 meshInfo.unpressed.rotationQuaternion,
                 meshInfo.pressed.rotationQuaternion,
                 buttonValue,
                 meshInfo.value.rotationQuaternion);
-            BABYLON.Vector3.LerpToRef(
+            Vector3.LerpToRef(
                 meshInfo.unpressed.position,
                 meshInfo.pressed.position,
                 buttonValue,
@@ -182,12 +182,12 @@ module BABYLON {
 
             // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
             let lerpValue = axisValue * 0.5 + 0.5;
-            BABYLON.Quaternion.SlerpToRef(
+            Quaternion.SlerpToRef(
                 meshInfo.min.rotationQuaternion,
                 meshInfo.max.rotationQuaternion,
                 lerpValue,
                 meshInfo.value.rotationQuaternion);
-            BABYLON.Vector3.LerpToRef(
+            Vector3.LerpToRef(
                 meshInfo.min.position,
                 meshInfo.max.position,
                 lerpValue,
@@ -263,7 +263,7 @@ module BABYLON {
             let loadedMeshInfo = null;
 
             // Create a new mesh to contain the glTF hierarchy
-            let parentMesh = new BABYLON.Mesh(this.id + " " + this.hand, scene);
+            let parentMesh = new Mesh(this.id + " " + this.hand, scene);
 
             // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
             let childMesh: Nullable<AbstractMesh> = null;
@@ -391,10 +391,10 @@ module BABYLON {
             var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
             var origin = m.getTranslation();
 
-            var forward = new BABYLON.Vector3(0, 0, -1);
-            var forwardWorld = BABYLON.Vector3.TransformNormal(forward, m);
+            var forward = new Vector3(0, 0, -1);
+            var forwardWorld = Vector3.TransformNormal(forward, m);
 
-            var direction = BABYLON.Vector3.Normalize(forwardWorld);
+            var direction = Vector3.Normalize(forwardWorld);
 
             return new Ray(origin, direction, length);
         }

+ 22 - 22
src/Helpers/babylon.environmentHelper.ts

@@ -191,7 +191,7 @@ namespace BABYLON {
                 createGround: true,
                 groundSize: 15,
                 groundTexture: this._groundTextureCDNUrl,
-                groundColor: new BABYLON.Color3(0.2, 0.2, 0.3).toLinearSpace().scale(3),
+                groundColor: new Color3(0.2, 0.2, 0.3).toLinearSpace().scale(3),
                 groundOpacity: 0.9,
                 enableGroundShadow: true,
                 groundShadowLevel: 0.5,
@@ -207,7 +207,7 @@ namespace BABYLON {
                 createSkybox: true,
                 skyboxSize: 20,
                 skyboxTexture: this._skyboxTextureCDNUrl,
-                skyboxColor: new BABYLON.Color3(0.2, 0.2, 0.3).toLinearSpace().scale(3),
+                skyboxColor: new Color3(0.2, 0.2, 0.3).toLinearSpace().scale(3),
 
                 backgroundYRotation: 0,
                 sizeAuto: true,
@@ -260,7 +260,7 @@ namespace BABYLON {
         public get ground(): Nullable<Mesh> {
             return this._ground;
         }
-        
+
         private _groundTexture: Nullable<BaseTexture>;
         /**
          * Gets the ground texture created by the helper.
@@ -268,7 +268,7 @@ namespace BABYLON {
         public get groundTexture(): Nullable<BaseTexture> {
             return this._groundTexture;
         }
-        
+
         private _groundMirror: Nullable<MirrorTexture>;
         /**
          * Gets the ground mirror created by the helper.
@@ -307,7 +307,7 @@ namespace BABYLON {
          * @param options 
          * @param scene The scene to add the material to
          */
-        constructor(options: Partial<IEnvironmentHelperOptions>, scene: BABYLON.Scene) {
+        constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene) {
             this._options = {
                 ...EnvironmentHelper._getDefaultOptions(),
                 ...options
@@ -404,7 +404,7 @@ namespace BABYLON {
             if (this._options.setupImageProcessing) {
                 this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
                 this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
-                this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;                
+                this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
                 this._setupEnvironmentTexture();
             }
         }
@@ -468,7 +468,7 @@ namespace BABYLON {
             if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
                 return { groundSize, skyboxSize, rootPosition };
             }
-            
+
             const sceneExtends = this._scene.getWorldExtends();
             const sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
             let bias = 0.0001;
@@ -508,7 +508,7 @@ namespace BABYLON {
                 this._ground.parent = this._rootMesh;
                 this._ground.onDisposeObservable.add(() => { this._ground = null; })
             }
-            
+
             this._ground.receiveShadows = this._options.enableGroundShadow;
         }
 
@@ -517,10 +517,10 @@ namespace BABYLON {
          */
         private _setupGroundMaterial(): void {
             if (!this._groundMaterial) {
-                this._groundMaterial = new BABYLON.BackgroundMaterial("BackgroundPlaneMaterial", this._scene);
+                this._groundMaterial = new BackgroundMaterial("BackgroundPlaneMaterial", this._scene);
             }
             this._groundMaterial.alpha = this._options.groundOpacity;
-            this._groundMaterial.alphaMode = BABYLON.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;
+            this._groundMaterial.alphaMode = Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;
             this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
             this._groundMaterial.primaryLevel = 1;
             this._groundMaterial.primaryColor = this._options.groundColor;
@@ -528,7 +528,7 @@ namespace BABYLON {
             this._groundMaterial.tertiaryLevel = 0;
             this._groundMaterial.useRGBColor = false;
             this._groundMaterial.enableNoise = true;
-            
+
             if (this._ground) {
                 this._ground.material = this._groundMaterial;
             }
@@ -551,7 +551,7 @@ namespace BABYLON {
                 return;
             }
 
-            const diffuseTexture = new BABYLON.Texture(this._options.groundTexture, this._scene);
+            const diffuseTexture = new Texture(this._options.groundTexture, this._scene);
             diffuseTexture.gammaSpace = false;
             diffuseTexture.hasAlpha = true;
             this._groundMaterial.diffuseTexture = diffuseTexture;
@@ -561,16 +561,16 @@ namespace BABYLON {
          * Setup the ground mirror texture according to the specified options.
          */
         private _setupGroundMirrorTexture(sceneSize: ISceneSize): void {
-            let wrapping = BABYLON.Texture.CLAMP_ADDRESSMODE;
+            let wrapping = Texture.CLAMP_ADDRESSMODE;
             if (!this._groundMirror) {
-                this._groundMirror = new BABYLON.MirrorTexture("BackgroundPlaneMirrorTexture", 
+                this._groundMirror = new MirrorTexture("BackgroundPlaneMirrorTexture",
                     { ratio: this._options.groundMirrorSizeRatio },
                     this._scene,
                     false,
                     this._options.groundMirrorTextureType,
-                    BABYLON.Texture.BILINEAR_SAMPLINGMODE,
+                    Texture.BILINEAR_SAMPLINGMODE,
                     true);
-                this._groundMirror.mirrorPlane = new BABYLON.Plane(0, -1, 0, sceneSize.rootPosition.y);
+                this._groundMirror.mirrorPlane = new Plane(0, -1, 0, sceneSize.rootPosition.y);
                 this._groundMirror.anisotropicFilteringLevel = 1;
                 this._groundMirror.wrapU = wrapping;
                 this._groundMirror.wrapV = wrapping;
@@ -579,7 +579,7 @@ namespace BABYLON {
                 if (this._groundMirror.renderList) {
                     for (let i = 0; i < this._scene.meshes.length; i++) {
                         const mesh = this._scene.meshes[i];
-                        if (mesh !== this._ground && 
+                        if (mesh !== this._ground &&
                             mesh !== this._skybox &&
                             mesh !== this._rootMesh) {
                             this._groundMirror.renderList.push(mesh);
@@ -587,8 +587,8 @@ namespace BABYLON {
                     }
                 }
             }
-            
-            this._groundMirror.clearColor = new BABYLON.Color4(
+
+            this._groundMirror.clearColor = new Color4(
                 this._options.groundColor.r,
                 this._options.groundColor.g,
                 this._options.groundColor.b,
@@ -614,7 +614,7 @@ namespace BABYLON {
          */
         private _setupSkybox(sceneSize: ISceneSize): void {
             if (!this._skybox) {
-                this._skybox = Mesh.CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, BABYLON.Mesh.BACKSIDE);                
+                this._skybox = Mesh.CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, Mesh.BACKSIDE);
                 this._skybox.onDisposeObservable.add(() => { this._skybox = null; })
             }
             this._skybox.parent = this._rootMesh;
@@ -658,8 +658,8 @@ namespace BABYLON {
                 return;
             }
 
-            this._skyboxTexture = new BABYLON.CubeTexture(this._options.skyboxTexture, this._scene);
-            this._skyboxTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
+            this._skyboxTexture = new CubeTexture(this._options.skyboxTexture, this._scene);
+            this._skyboxTexture.coordinatesMode = Texture.SKYBOX_MODE;
             this._skyboxTexture.gammaSpace = false;
             this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
         }

+ 4 - 4
src/Layer/babylon.highlightlayer.ts

@@ -374,26 +374,26 @@
             });
 
             if (this._options.alphaBlendingMode === Engine.ALPHA_COMBINE) {
-                this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP", new BABYLON.Vector2(1.0, 0), this._options.blurHorizontalSize, 1,
+                this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP", new Vector2(1.0, 0), this._options.blurHorizontalSize, 1,
                     null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
                 this._horizontalBlurPostprocess.onApplyObservable.add(effect => {
                     effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
                 });
 
-                this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP", new BABYLON.Vector2(0, 1.0), this._options.blurVerticalSize, 1,
+                this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP", new Vector2(0, 1.0), this._options.blurVerticalSize, 1,
                     null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
                 this._verticalBlurPostprocess.onApplyObservable.add(effect => {
                     effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
                 });
             }
             else {
-                this._horizontalBlurPostprocess = new BlurPostProcess("HighlightLayerHBP", new BABYLON.Vector2(1.0, 0), this._options.blurHorizontalSize, 1,
+                this._horizontalBlurPostprocess = new BlurPostProcess("HighlightLayerHBP", new Vector2(1.0, 0), this._options.blurHorizontalSize, 1,
                     null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
                 this._horizontalBlurPostprocess.onApplyObservable.add(effect => {
                     effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
                 });
 
-                this._verticalBlurPostprocess = new BlurPostProcess("HighlightLayerVBP", new BABYLON.Vector2(0, 1.0), this._options.blurVerticalSize, 1,
+                this._verticalBlurPostprocess = new BlurPostProcess("HighlightLayerVBP", new Vector2(0, 1.0), this._options.blurVerticalSize, 1,
                     null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine());
                 this._verticalBlurPostprocess.onApplyObservable.add(effect => {
                     effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);

+ 4 - 4
src/Lights/babylon.shadowLight.ts

@@ -26,7 +26,7 @@
          * Gets the minZ used for shadow according to both the scene and the light.
          * @param activeCamera 
          */
-         getDepthMinZ(activeCamera: Camera): number;
+        getDepthMinZ(activeCamera: Camera): number;
 
         /**
          * Gets the minZ used for shadow according to both the scene and the light.
@@ -137,8 +137,8 @@
          */
         public getRotation(): Vector3 {
             this.direction.normalize();
-            var xaxis = BABYLON.Vector3.Cross(this.direction, BABYLON.Axis.Y);
-            var yaxis = BABYLON.Vector3.Cross(xaxis, this.direction);
+            var xaxis = Vector3.Cross(this.direction, Axis.Y);
+            var yaxis = Vector3.Cross(xaxis, this.direction);
             return Vector3.RotationFromAxis(xaxis, yaxis, this.direction);
         }
 
@@ -189,7 +189,7 @@
          * @param activeCamera 
          */
         public getDepthMaxZ(activeCamera: Camera): number {
-             return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
+            return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
         }
 
         /**

+ 11 - 11
src/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -24,7 +24,7 @@
         return false;
     };
 
-    var logOperation = (operation: string, producer: {file: string, name: string, version: string, exporter_version: string}) => {
+    var logOperation = (operation: string, producer: { file: string, name: string, version: string, exporter_version: string }) => {
         return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
     }
 
@@ -237,25 +237,25 @@
 
                 // Scene
                 if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
-                    scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !BABYLON.SceneLoader.ForceFullSceneLoadingForIncremental;
+                    scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !SceneLoader.ForceFullSceneLoadingForIncremental;
                 }
                 if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
                     scene.autoClear = parsedData.autoClear;
                 }
                 if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
-                    scene.clearColor = BABYLON.Color4.FromArray(parsedData.clearColor);
+                    scene.clearColor = Color4.FromArray(parsedData.clearColor);
                 }
                 if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
-                    scene.ambientColor = BABYLON.Color3.FromArray(parsedData.ambientColor);
+                    scene.ambientColor = Color3.FromArray(parsedData.ambientColor);
                 }
                 if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
-                    scene.gravity = BABYLON.Vector3.FromArray(parsedData.gravity);
+                    scene.gravity = Vector3.FromArray(parsedData.gravity);
                 }
 
                 // Fog
                 if (parsedData.fogMode && parsedData.fogMode !== 0) {
                     scene.fogMode = parsedData.fogMode;
-                    scene.fogColor = BABYLON.Color3.FromArray(parsedData.fogColor);
+                    scene.fogColor = Color3.FromArray(parsedData.fogColor);
                     scene.fogStart = parsedData.fogStart;
                     scene.fogEnd = parsedData.fogEnd;
                     scene.fogDensity = parsedData.fogDensity;
@@ -272,13 +272,13 @@
                 if (parsedData.physicsEnabled) {
                     var physicsPlugin;
                     if (parsedData.physicsEngine === "cannon") {
-                        physicsPlugin = new BABYLON.CannonJSPlugin();
+                        physicsPlugin = new CannonJSPlugin();
                     } else if (parsedData.physicsEngine === "oimo") {
-                        physicsPlugin = new BABYLON.OimoJSPlugin();
+                        physicsPlugin = new OimoJSPlugin();
                     }
                     log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
                     //else - default engine, which is currently oimo
-                    var physicsGravity = parsedData.physicsGravity ? BABYLON.Vector3.FromArray(parsedData.physicsGravity) : null;
+                    var physicsGravity = parsedData.physicsGravity ? Vector3.FromArray(parsedData.physicsGravity) : null;
                     scene.enablePhysics(physicsGravity, physicsPlugin);
                 }
 
@@ -440,7 +440,7 @@
                         var parsedTransformNode = parsedData.transformNodes[index];
                         TransformNode.Parse(parsedTransformNode, scene, rootUrl);
                     }
-                }                
+                }
 
                 // Meshes
                 if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
@@ -512,7 +512,7 @@
                         transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
                         transformNode._waitingParentId = null;
                     }
-                }                
+                }
                 for (index = 0, cache = scene.meshes.length; index < cache; index++) {
                     var mesh = scene.meshes[index];
                     if (mesh._waitingParentId) {

+ 32 - 32
src/Materials/Background/babylon.backgroundMaterial.ts

@@ -121,7 +121,7 @@
     /**
      * Background material used to create an efficient environement around your scene.
      */
-    export class BackgroundMaterial extends BABYLON.PushMaterial {
+    export class BackgroundMaterial extends PushMaterial {
 
         /**
          * Standard reflectance value at parallel view angle.
@@ -139,7 +139,7 @@
         @serializeAsColor3()
         protected _primaryColor: Color3;
         @expandToProperty("_markAllSubMeshesAsLightsDirty")
-        public primaryColor = BABYLON.Color3.White();
+        public primaryColor = Color3.White();
 
         /**
          * Key light Level (allowing HDR output of the background)
@@ -154,7 +154,7 @@
         @serializeAsColor3()
         protected _secondaryColor: Color3;
         @expandToProperty("_markAllSubMeshesAsLightsDirty")
-        public secondaryColor = BABYLON.Color3.Gray();
+        public secondaryColor = Color3.Gray();
 
         /**
          * Secondary light Level (allowing HDR output of the background)
@@ -170,7 +170,7 @@
         @serializeAsColor3()
         protected _tertiaryColor: Color3;
         @expandToProperty("_markAllSubMeshesAsLightsDirty")
-        public tertiaryColor = BABYLON.Color3.Black();
+        public tertiaryColor = Color3.Black();
 
         /**
          * Tertiary light Level (allowing HDR output of the background)
@@ -199,7 +199,7 @@
         protected _reflectionBlur: float;
         @expandToProperty("_markAllSubMeshesAsTexturesDirty")
         public reflectionBlur: float = 0;
-        
+
         /**
          * Diffuse Texture used in the material.
          * Should be author in a specific way for the best result (refer to the documentation).
@@ -301,7 +301,7 @@
          */
         public set reflectionStandardFresnelWeight(value: number) {
             let reflectionWeight = value;
-    
+
             if (reflectionWeight < 0.5) {
                 reflectionWeight = reflectionWeight * 2.0;
                 this.reflectionReflectance0 = BackgroundMaterial.standardReflectance0 * reflectionWeight;
@@ -451,7 +451,7 @@
         public set cameraExposure(value: float) {
             this._imageProcessingConfiguration.exposure = value;
         };
-        
+
         /**
          * Gets The camera contrast used on this material.
          */
@@ -465,7 +465,7 @@
         public set cameraContrast(value: float) {
             this._imageProcessingConfiguration.contrast = value;
         }
-        
+
         /**
          * Gets the Color Grading 2D Lookup Texture.
          */
@@ -500,14 +500,14 @@
 
         // Temp values kept as cache in the material.
         private _renderTargets = new SmartArray<RenderTargetTexture>(16);
-        private _reflectionControls = BABYLON.Vector4.Zero();
+        private _reflectionControls = Vector4.Zero();
 
         /**
          * constructor
          * @param name The name of the material
          * @param scene The scene to add the material to
          */
-        constructor(name: string, scene: BABYLON.Scene) {
+        constructor(name: string, scene: Scene) {
             super(name, scene);
 
             // Setup the default processing configuration to the scene.
@@ -550,7 +550,7 @@
          * @param subMesh The submesh to check against
          * @param useInstances Specify wether or not the material is used with instances
          */
-        public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances: boolean = false): boolean { 
+        public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances: boolean = false): boolean {
             if (subMesh.effect && this.isFrozen) {
                 if (this._wasPreviouslyReady) {
                     return true;
@@ -570,11 +570,11 @@
             }
 
             var engine = scene.getEngine();
-            
+
             // Lights
             MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
             defines._needNormals = true;
-            
+
             // Textures
             if (defines._areTexturesDirty) {
                 defines._needUVs = false;
@@ -604,7 +604,7 @@
                         if (!reflectionTexture.isReadyOrNotBlocking()) {
                             return false;
                         }
-                        
+
                         defines.REFLECTION = true;
                         defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
                         defines.REFLECTIONBLUR = this._reflectionBlur > 0;
@@ -701,7 +701,7 @@
             // Values that need to be evaluated on every frame
             MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances, false);
 
-             // Attribs
+            // Attribs
             if (MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
                 if (mesh) {
                     if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
@@ -750,18 +750,18 @@
                 MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
                 MaterialHelper.PrepareAttributesForInstances(attribs, defines);
 
-                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", 
-                        "vFogInfos", "vFogColor", "pointSize",
-                        "vClipPlane", "mBones", 
+                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
+                    "vFogInfos", "vFogColor", "pointSize",
+                    "vClipPlane", "mBones",
 
-                        "vPrimaryColor", "vSecondaryColor", "vTertiaryColor",
-                        "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos",
+                    "vPrimaryColor", "vSecondaryColor", "vTertiaryColor",
+                    "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos",
 
-                        "shadowLevel", "alpha",
+                    "shadowLevel", "alpha",
 
-                        "vBackgroundCenter", "vReflectionControl",
+                    "vBackgroundCenter", "vReflectionControl",
 
-                        "vDiffuseInfos", "diffuseMatrix",
+                    "vDiffuseInfos", "diffuseMatrix",
                 ];
 
                 var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
@@ -771,10 +771,10 @@
                 ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
 
                 MaterialHelper.PrepareUniformsAndSamplersList(<EffectCreationOptions>{
-                    uniformsNames: uniforms, 
+                    uniformsNames: uniforms,
                     uniformBuffersNames: uniformBuffers,
-                    samplers: samplers, 
-                    defines: defines, 
+                    samplers: samplers,
+                    defines: defines,
                     maxSimultaneousLights: this._maxSimultaneousLights
                 });
 
@@ -798,7 +798,7 @@
                     onError: this.onError,
                     indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
                 }, engine), defines);
-                
+
                 this.buildUniformLayout();
             }
 
@@ -830,7 +830,7 @@
             this._uniformBuffer.addUniform("alpha", 1);
             this._uniformBuffer.addUniform("vBackgroundCenter", 3);
             this._uniformBuffer.addUniform("vReflectionControl", 4);
-        
+
             this._uniformBuffer.create();
         }
 
@@ -873,7 +873,7 @@
             var effect = subMesh.effect;
             if (!effect) {
                 return;
-            }            
+            }
             this._activeEffect = effect;
 
             // Matrices
@@ -902,8 +902,8 @@
                             this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
                             this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
 
-                            this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", 
-                                reflectionTexture.getSize().width, 
+                            this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",
+                                reflectionTexture.getSize().width,
                                 reflectionTexture.lodGenerationScale,
                                 reflectionTexture.lodGenerationOffset);
                         }
@@ -952,7 +952,7 @@
 
                 // Clip plane
                 MaterialHelper.BindClipPlane(this._activeEffect, scene);
-                
+
                 MaterialHelper.BindEyePosition(effect, scene);
             }
 

+ 1 - 1
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -707,7 +707,7 @@
                                 break;
                         }
 
-                        if (reflectionTexture.coordinatesMode !== BABYLON.Texture.SKYBOX_MODE) {
+                        if (reflectionTexture.coordinatesMode !== Texture.SKYBOX_MODE) {
                             if (reflectionTexture.sphericalPolynomial) {
                                 defines.USESPHERICALFROMREFLECTIONMAP = true;
                                 if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {

+ 7 - 7
src/Materials/Textures/babylon.colorGradingTexture.ts

@@ -78,10 +78,10 @@ module BABYLON {
             var engine = this._engine;
             var texture: InternalTexture;
             if (engine.webGLVersion === 1) {
-                texture = engine.createRawTexture(null, 1, 1, BABYLON.Engine.TEXTUREFORMAT_RGBA, false, false, Texture.BILINEAR_SAMPLINGMODE);
-            } 
+                texture = engine.createRawTexture(null, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Texture.BILINEAR_SAMPLINGMODE);
+            }
             else {
-                texture = engine.createRawTexture3D(null, 1, 1, 1, BABYLON.Engine.TEXTUREFORMAT_RGBA, false, false, Texture.BILINEAR_SAMPLINGMODE);
+                texture = engine.createRawTexture3D(null, 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Texture.BILINEAR_SAMPLINGMODE);
             }
 
             this._texture = texture;
@@ -149,7 +149,7 @@ module BABYLON {
 
                 if (tempData && data) {
                     for (let i = 0; i < tempData.length; i++) {
-                        if (i > 0 && (i+1) % 4 === 0) {
+                        if (i > 0 && (i + 1) % 4 === 0) {
                             data[i] = 255;
                         }
                         else {
@@ -161,11 +161,11 @@ module BABYLON {
 
                 if (texture.is3D) {
                     texture.updateSize(size, size, size);
-                    engine.updateRawTexture3D(texture, data, BABYLON.Engine.TEXTUREFORMAT_RGBA, false);
+                    engine.updateRawTexture3D(texture, data, Engine.TEXTUREFORMAT_RGBA, false);
                 }
                 else {
                     texture.updateSize(size * size, size);
-                    engine.updateRawTexture(texture, data, BABYLON.Engine.TEXTUREFORMAT_RGBA, false);
+                    engine.updateRawTexture(texture, data, Engine.TEXTUREFORMAT_RGBA, false);
                 }
             }
 
@@ -220,7 +220,7 @@ module BABYLON {
         public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture> {
             var texture = null;
             if (parsedTexture.name && !parsedTexture.isRenderTarget) {
-                texture = new BABYLON.ColorGradingTexture(parsedTexture.name, scene);
+                texture = new ColorGradingTexture(parsedTexture.name, scene);
                 texture.name = parsedTexture.name;
                 texture.level = parsedTexture.level;
             }

+ 1 - 1
src/Materials/Textures/babylon.cubeTexture.ts

@@ -115,7 +115,7 @@
 
         public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture {
             var texture = SerializationHelper.Parse(() => {
-                return new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
+                return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
             }, parsedTexture, scene);
 
             // Animations

+ 11 - 11
src/Materials/Textures/babylon.hdrCubeTexture.ts

@@ -216,9 +216,9 @@ module BABYLON {
 
                             // Put in gamma space if requested.
                             if (this._useInGammaSpace) {
-                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
+                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], ToGammaSpace);
+                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], ToGammaSpace);
+                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], ToGammaSpace);
                             }
 
                             // Convert to int texture for fallback.
@@ -259,7 +259,7 @@ module BABYLON {
             if (scene) {
                 this._texture = (<any>scene.getEngine()).createRawCubeTextureFromUrl(this.url, scene, this._size,
                     Engine.TEXTUREFORMAT_RGB,
-                    scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT,
+                    scene.getEngine().getCaps().textureFloat ? Engine.TEXTURETYPE_FLOAT : Engine.TEXTURETYPE_UNSIGNED_INT,
                     this._noMipmap,
                     callback,
                     mipmapGenerator, this._onLoad, this._onError);
@@ -277,11 +277,11 @@ module BABYLON {
                     return null;
                 }
                 // Extract the raw linear data.
-                var data = BABYLON.Internals.HDRTools.GetCubeMapTextureData(buffer, this._size);
+                var data = Internals.HDRTools.GetCubeMapTextureData(buffer, this._size);
 
                 // Generate harmonics if needed.
                 if (this._generateHarmonics) {
-                    var sphericalPolynomial = BABYLON.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(data);
+                    var sphericalPolynomial = Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(data);
                     this.sphericalPolynomial = sphericalPolynomial;
                 }
 
@@ -306,9 +306,9 @@ module BABYLON {
 
                             // Put in gamma space if requested.
                             if (this._useInGammaSpace) {
-                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
+                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], ToGammaSpace);
+                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], ToGammaSpace);
+                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], ToGammaSpace);
                             }
 
                             // Convert to int texture for fallback.
@@ -369,7 +369,7 @@ module BABYLON {
             if (scene) {
                 this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size,
                     Engine.TEXTUREFORMAT_RGB,
-                    scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT,
+                    scene.getEngine().getCaps().textureFloat ? Engine.TEXTURETYPE_FLOAT : Engine.TEXTURETYPE_UNSIGNED_INT,
                     this._noMipmap,
                     callback,
                     mipmapGenerator, this._onLoad, this._onError);
@@ -434,7 +434,7 @@ module BABYLON {
             var texture = null;
             if (parsedTexture.name && !parsedTexture.isRenderTarget) {
                 var size = parsedTexture.isBABYLONPreprocessed ? null : parsedTexture.size;
-                texture = new BABYLON.HDRCubeTexture(rootUrl + parsedTexture.name, scene, size, parsedTexture.noMipmap,
+                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, size, parsedTexture.noMipmap,
                     parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace, parsedTexture.usePMREMGenerator);
                 texture.name = parsedTexture.name;
                 texture.hasAlpha = parsedTexture.hasAlpha;

+ 5 - 5
src/Materials/Textures/babylon.mirrorTexture.ts

@@ -29,7 +29,7 @@
         public set adaptiveBlurKernel(value: number) {
             this._adaptiveBlurKernel = value;
             this._autoComputeBlurKernel();
-        }        
+        }
 
         public set blurKernel(value: number) {
             this.blurKernelX = value;
@@ -84,7 +84,7 @@
             }
         }
 
-        constructor(name: string, size: number | {width: number, height: number} | {ratio: number}, scene: Scene, generateMipMaps?: boolean, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, samplingMode = Texture.BILINEAR_SAMPLINGMODE, generateDepthBuffer = true) {
+        constructor(name: string, size: number | { width: number, height: number } | { ratio: number }, scene: Scene, generateMipMaps?: boolean, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, samplingMode = Texture.BILINEAR_SAMPLINGMODE, generateDepthBuffer = true) {
             super(name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer);
 
             this.ignoreCameraViewport = true;
@@ -121,7 +121,7 @@
 
                 var textureType = engine.getCaps().textureFloatRender ? Engine.TEXTURETYPE_FLOAT : Engine.TEXTURETYPE_HALF_FLOAT;
 
-                this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernelX, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                this._blurX = new BlurPostProcess("horizontal blur", new Vector2(1.0, 0), this._blurKernelX, this._blurRatio, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurX.autoClear = false;
 
                 if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
@@ -130,14 +130,14 @@
                     this._blurX.alwaysForcePOT = true;
                 }
 
-                this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernelY, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
+                this._blurY = new BlurPostProcess("vertical blur", new Vector2(0, 1.0), this._blurKernelY, this._blurRatio, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
                 this._blurY.autoClear = false;
                 this._blurY.alwaysForcePOT = this._blurRatio !== 1;
 
                 this.addPostProcess(this._blurX);
                 this.addPostProcess(this._blurY);
             }
-            else { 
+            else {
                 if (this._blurY) {
                     this.removePostProcess(this._blurY);
                     this._blurY.dispose();

+ 1 - 1
src/Materials/Textures/babylon.multiRenderTarget.ts

@@ -114,7 +114,7 @@ module BABYLON {
         private _createTextures(): void {
             this._textures = [];
             for (var i = 0; i < this._internalTextures.length; i++) {
-                var texture = new BABYLON.Texture(null, this.getScene());
+                var texture = new Texture(null, this.getScene());
                 texture._texture = this._internalTextures[i];
                 this._textures.push(texture);
             }

+ 16 - 16
src/Materials/Textures/babylon.videoTexture.ts

@@ -27,7 +27,7 @@
                 this.video = <any>urlsOrVideo;
             } else {
                 urls = urlsOrVideo;
-                
+
                 this.video = document.createElement("video");
                 this.video.autoplay = false;
                 this.video.loop = true;
@@ -38,7 +38,7 @@
             this._generateMipMaps = generateMipMaps;
             this._samplingMode = samplingMode;
 
-            if (!this._engine.needPOTTextures ||(Tools.IsExponentOfTwo(this.video.videoWidth) && Tools.IsExponentOfTwo(this.video.videoHeight))) {
+            if (!this._engine.needPOTTextures || (Tools.IsExponentOfTwo(this.video.videoWidth) && Tools.IsExponentOfTwo(this.video.videoHeight))) {
                 this.wrapU = Texture.WRAP_ADDRESSMODE;
                 this.wrapV = Texture.WRAP_ADDRESSMODE;
             } else {
@@ -80,7 +80,7 @@
             this.video.addEventListener("playing", this._setTextureReady);
         }
 
-        
+
         public _rebuild(): void {
             this.update();
         }
@@ -103,25 +103,25 @@
         }
 
         public static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
-                minWidth: number,
-                maxWidth: number,
-                minHeight: number,
-                maxHeight: number,
-                deviceId: string
-            }): void {
+            minWidth: number,
+            maxWidth: number,
+            minHeight: number,
+            maxHeight: number,
+            deviceId: string
+        }): void {
             var video = document.createElement("video");
             var constraintsDeviceId;
-            if (constraints && constraints.deviceId){
+            if (constraints && constraints.deviceId) {
                 constraintsDeviceId = {
                     exact: constraints.deviceId
                 }
             }
 
-		    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
-		    window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
+            navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
+            window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
 
-		    if (navigator.getUserMedia) {
-			    navigator.getUserMedia({
+            if (navigator.getUserMedia) {
+                navigator.getUserMedia({
                     video: {
                         deviceId: constraintsDeviceId,
                         width: {
@@ -144,9 +144,9 @@
                     video.play();
 
                     if (onReady) {
-                        onReady(new BABYLON.VideoTexture("video", video, scene, true, true));
+                        onReady(new VideoTexture("video", video, scene, true, true));
                     }
-			    }, function (e: DOMException) {
+                }, function (e: DOMException) {
                     Tools.Error(e.name);
                 });
             }

+ 8 - 8
src/Materials/babylon.imageProcessingConfiguration.ts

@@ -207,7 +207,7 @@ module BABYLON {
          * if vignetteEnabled is set to true.
          */
         @serializeAsColor4()
-        public vignetteColor: BABYLON.Color4 = new BABYLON.Color4(0, 0, 0, 0);
+        public vignetteColor: Color4 = new Color4(0, 0, 0, 0);
 
         /**
          * Camera field of view used by the Vignette effect.
@@ -293,7 +293,7 @@ module BABYLON {
 
             this._isEnabled = value;
             this._updateParameters();
-        }        
+        }
 
         /**
         * An event triggered when the configuration changes and requires Shader to Update some parameters.
@@ -310,7 +310,7 @@ module BABYLON {
 
         public getClassName(): string {
             return "ImageProcessingConfiguration";
-        }                 
+        }
 
         /**
          * Prepare the list of uniforms associated with the Image Processing effects.
@@ -397,7 +397,7 @@ module BABYLON {
          * Binds the image processing to the shader.
          * @param effect The effect to bind to
          */
-        public bind(effect: Effect, aspectRatio = 1) : void {
+        public bind(effect: Effect, aspectRatio = 1): void {
             // Color Curves
             if (this._colorCurvesEnabled && this.colorCurves) {
                 ColorCurves.Bind(this.colorCurves, effect);
@@ -424,10 +424,10 @@ module BABYLON {
 
             // Exposure
             effect.setFloat("exposureLinear", this.exposure);
-            
+
             // Contrast
             effect.setFloat("contrast", this.contrast);
-            
+
             // Color transform settings
             if (this.colorGradingTexture) {
                 effect.setTexture("txColorTransform", this.colorGradingTexture);
@@ -462,8 +462,8 @@ module BABYLON {
          * Parses the image processing from a json representation.
          * @param source the JSON source to parse
          * @return The parsed image processing
-         */      
-        public static Parse(source: any) : ImageProcessingConfiguration {
+         */
+        public static Parse(source: any): ImageProcessingConfiguration {
             return SerializationHelper.Parse(() => new ImageProcessingConfiguration(), source, null, null);
         }
 

+ 30 - 30
src/Materials/babylon.material.ts

@@ -8,8 +8,8 @@
         public _areAttributesDirty = true;
         public _areTexturesDirty = true;
         public _areFresnelDirty = true;
-        public _areMiscDirty = true;    
-        public _areImageProcessingDirty = true;  
+        public _areMiscDirty = true;
+        public _areImageProcessingDirty = true;
 
         public _normals = false;
         public _uvs = false;
@@ -48,7 +48,7 @@
         public markAsImageProcessingDirty() {
             this._areImageProcessingDirty = true;
             this._isDirty = true;
-        }        
+        }
 
         public markAsLightDirty() {
             this._areLightsDirty = true;
@@ -59,7 +59,7 @@
             this._areAttributesDirty = true;
             this._isDirty = true;
         }
-        
+
         public markAsTexturesDirty() {
             this._areTexturesDirty = true;
             this._isDirty = true;
@@ -89,7 +89,7 @@
 
                 this._keys.push(key);
             }
-        } 
+        }
 
         public isEqual(other: MaterialDefines): boolean {
             if (this._keys.length !== other._keys.length) {
@@ -256,7 +256,7 @@
 
         @serialize("backFaceCulling")
         protected _backFaceCulling = true;
-        public set backFaceCulling(value : boolean) {
+        public set backFaceCulling(value: boolean) {
             if (this._backFaceCulling === value) {
                 return;
             }
@@ -265,7 +265,7 @@
         }
         public get backFaceCulling(): boolean {
             return this._backFaceCulling;
-        }          
+        }
 
         @serialize()
         public sideOrientation: number;
@@ -316,7 +316,7 @@
 
         @serialize("alphaMode")
         private _alphaMode: number = Engine.ALPHA_COMBINE;
-        public set alphaMode(value : number) {
+        public set alphaMode(value: number) {
             if (this._alphaMode === value) {
                 return;
             }
@@ -329,7 +329,7 @@
 
         @serialize()
         private _needDepthPrePass = false;
-        public set needDepthPrePass(value : boolean) {
+        public set needDepthPrePass(value: boolean) {
             if (this._needDepthPrePass === value) {
                 return;
             }
@@ -340,7 +340,7 @@
         }
         public get needDepthPrePass(): boolean {
             return this._needDepthPrePass;
-        }   
+        }
 
         @serialize()
         public disableDepthWrite = false;
@@ -353,7 +353,7 @@
 
         @serialize("fogEnabled")
         private _fogEnabled = true;
-        public set fogEnabled(value : boolean) {
+        public set fogEnabled(value: boolean) {
             if (this._fogEnabled === value) {
                 return;
             }
@@ -362,7 +362,7 @@
         }
         public get fogEnabled(): boolean {
             return this._fogEnabled;
-        }         
+        }
 
         @serialize()
         public pointSize = 1.0;
@@ -435,21 +435,21 @@
          * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
          * subclasses should override adding information pertainent to themselves
          */
-        public toString(fullDetails? : boolean) : string {
+        public toString(fullDetails?: boolean): string {
             var ret = "Name: " + this.name;
-            if (fullDetails){
+            if (fullDetails) {
             }
             return ret;
-        } 
+        }
 
         /**
          * Child classes can use it to update shaders         
          */
-        
+
         public getClassName(): string {
             return "Material";
         }
-        
+
         public get isFrozen(): boolean {
             return this.checkReadyOnlyOnce;
         }
@@ -467,7 +467,7 @@
         }
 
         public isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean {
-            return false;            
+            return false;
         }
 
         public getEffect(): Nullable<Effect> {
@@ -493,12 +493,12 @@
         public getAlphaTestTexture(): Nullable<BaseTexture> {
             return null;
         }
-        
+
         public markDirty(): void {
             this._wasPreviouslyReady = false;
         }
 
-        public _preBind(effect?: Effect, overrideOrientation : Nullable<number> = null): boolean {
+        public _preBind(effect?: Effect, overrideOrientation: Nullable<number> = null): boolean {
             var engine = this._scene.getEngine();
 
             var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
@@ -513,7 +513,7 @@
         public bind(world: Matrix, mesh?: Mesh): void {
         }
 
-        public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {            
+        public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {
         }
 
         public bindOnlyWorldMatrix(world: Matrix): void {
@@ -655,7 +655,7 @@
 
             checkReady();
         }
-       
+
         public markAsDirty(flag: number): void {
             if (flag & Material.TextureDirtyFlag) {
                 this._markAllSubMeshesAsTexturesDirty();
@@ -701,7 +701,7 @@
 
         protected _markAllSubMeshesAsImageProcessingDirty() {
             this._markAllSubMeshesAsDirty(defines => defines.markAsImageProcessingDirty());
-        }        
+        }
 
         protected _markAllSubMeshesAsTexturesDirty() {
             this._markAllSubMeshesAsDirty(defines => defines.markAsTexturesDirty());
@@ -721,7 +721,7 @@
 
         protected _markAllSubMeshesAsMiscDirty() {
             this._markAllSubMeshesAsDirty(defines => defines.markAsMiscDirty());
-        }        
+        }
 
         public dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void {
             // Animations
@@ -739,7 +739,7 @@
 
                 if (mesh.material === this) {
                     mesh.material = null;
-                
+
                     if ((<Mesh>mesh).geometry) {
                         var geometry = <Geometry>((<Mesh>mesh).geometry);
 
@@ -747,7 +747,7 @@
                             for (var subMesh of mesh.subMeshes) {
                                 geometry._releaseVertexArrayObject(subMesh._materialEffect);
                                 if (forceDisposeEffect && subMesh._materialEffect) {
-                                    this._scene.getEngine()._releaseEffect(subMesh._materialEffect); 
+                                    this._scene.getEngine()._releaseEffect(subMesh._materialEffect);
                                 }
                             }
                         } else {
@@ -762,12 +762,12 @@
             // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
             if (forceDisposeEffect && this._effect) {
                 if (!this.storeEffectOnSubMeshes) {
-                    this._scene.getEngine()._releaseEffect(this._effect);                    
+                    this._scene.getEngine()._releaseEffect(this._effect);
                 }
 
                 this._effect = null;
             }
-            
+
             // Callback
             this.onDisposeObservable.notifyObservers(this);
 
@@ -781,7 +781,7 @@
         }
 
         public static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial {
-            var multiMaterial = new BABYLON.MultiMaterial(parsedMultiMaterial.name, scene);
+            var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
 
             multiMaterial.id = parsedMultiMaterial.id;
 
@@ -810,7 +810,7 @@
             if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
                 parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
                 if (!(<any>BABYLON).LegacyPBRMaterial) {
-                    BABYLON.Tools.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
+                    Tools.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.");
                     return;
                 }
             }

+ 20 - 20
src/Math/babylon.math.ts

@@ -520,7 +520,7 @@
             convertedColor.b = Math.pow(this.b, ToGammaSpace);
             convertedColor.a = this.a;
             return this;
-        }        
+        }
 
         // Statics
         /**
@@ -1776,7 +1776,7 @@
             matrix.invert();
             var screenSource = MathTmp.Vector3[0];
             screenSource.x = sourceX / viewportWidth * 2 - 1;
-            screenSource.y = -(sourceY/ viewportHeight * 2 - 1);
+            screenSource.y = -(sourceY / viewportHeight * 2 - 1);
             screenSource.z = 2 * sourceZ - 1.0;
             Vector3.TransformCoordinatesToRef(screenSource, matrix, result);
             var num = screenSource.x * matrix.m[3] + screenSource.y * matrix.m[7] + screenSource.z * matrix.m[11] + matrix.m[15];
@@ -2880,8 +2880,8 @@
          */
         public static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void {
             var rotMat = MathTmp.Matrix[0];
-            BABYLON.Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
-            BABYLON.Quaternion.FromRotationMatrixToRef(rotMat, ref);
+            Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
+            Quaternion.FromRotationMatrixToRef(rotMat, ref);
         }
 
         public static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion {
@@ -2950,7 +2950,7 @@
 
         private _isIdentity = false;
         private _isIdentityDirty = true;
-        public updateFlag: number;        
+        public updateFlag: number;
         public m: Float32Array = new Float32Array(16);
 
         public _markAsUpdated() {
@@ -3475,7 +3475,7 @@
         /**
          * Compute the transpose of the matrix.  
          * Returns a new Matrix.  
-         */        
+         */
         public transpose(): Matrix {
             return Matrix.Transpose(this);
         }
@@ -3483,7 +3483,7 @@
         /**
          * Compute the transpose of the matrix.  
          * Returns the current matrix.  
-         */        
+         */
         public transposeToRef(result: Matrix): Matrix {
             Matrix.TransposeToRef(this, result);
 
@@ -3954,7 +3954,7 @@
             let c = 2.0 / (f - n);
             let d = -(f + n) / (f - n);
 
-            BABYLON.Matrix.FromValuesToRef(
+            Matrix.FromValuesToRef(
                 a, 0.0, 0.0, 0.0,
                 0.0, b, 0.0, 0.0,
                 0.0, 0.0, c, 0.0,
@@ -3986,7 +3986,7 @@
             let i0 = (left + right) / (left - right);
             let i1 = (top + bottom) / (bottom - top);
 
-            BABYLON.Matrix.FromValuesToRef(
+            Matrix.FromValuesToRef(
                 a, 0.0, 0.0, 0.0,
                 0.0, b, 0.0, 0.0,
                 0.0, 0.0, c, 0.0,
@@ -4023,7 +4023,7 @@
             let c = (f + n) / (f - n);
             let d = -2.0 * f * n / (f - n);
 
-            BABYLON.Matrix.FromValuesToRef(
+            Matrix.FromValuesToRef(
                 a, 0.0, 0.0, 0.0,
                 0.0, b, 0.0, 0.0,
                 0.0, 0.0, c, 1.0,
@@ -4054,7 +4054,7 @@
             let c = (f + n) / (f - n);
             let d = -2.0 * f * n / (f - n);
 
-            BABYLON.Matrix.FromValuesToRef(
+            Matrix.FromValuesToRef(
                 a, 0.0, 0.0, 0.0,
                 0.0, b, 0.0, 0.0,
                 0.0, 0.0, c, 1.0,
@@ -4088,7 +4088,7 @@
             let c = -(f + n) / (f - n);
             let d = -2 * f * n / (f - n);
 
-            BABYLON.Matrix.FromValuesToRef(
+            Matrix.FromValuesToRef(
                 a, 0.0, 0.0, 0.0,
                 0.0, b, 0.0, 0.0,
                 0.0, 0.0, c, -1.0,
@@ -4099,7 +4099,7 @@
         /**
          * Sets the passed matrix "result" as a left-handed perspective projection matrix  for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.  
          */
-        public static PerspectiveFovWebVRToRef(fov: {upDegrees: number, downDegrees: number, leftDegrees: number, rightDegrees: number}, znear: number, zfar: number, result: Matrix, rightHanded = false): void {
+        public static PerspectiveFovWebVRToRef(fov: { upDegrees: number, downDegrees: number, leftDegrees: number, rightDegrees: number }, znear: number, zfar: number, result: Matrix, rightHanded = false): void {
 
             var rightHandedFactor = rightHanded ? -1 : 1;
 
@@ -4531,31 +4531,31 @@
             frustumPlane.normal.z = transform.m[11] + transform.m[8];
             frustumPlane.d = transform.m[15] + transform.m[12];
             frustumPlane.normalize();
-        }       
-        
+        }
+
         public static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void {
             frustumPlane.normal.x = transform.m[3] - transform.m[0];
             frustumPlane.normal.y = transform.m[7] - transform.m[4];
             frustumPlane.normal.z = transform.m[11] - transform.m[8];
             frustumPlane.d = transform.m[15] - transform.m[12];
             frustumPlane.normalize();
-        }     
-        
+        }
+
         public static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void {
             frustumPlane.normal.x = transform.m[3] - transform.m[1];
             frustumPlane.normal.y = transform.m[7] - transform.m[5];
             frustumPlane.normal.z = transform.m[11] - transform.m[9];
             frustumPlane.d = transform.m[15] - transform.m[13];
             frustumPlane.normalize();
-        }      
-        
+        }
+
         public static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void {
             frustumPlane.normal.x = transform.m[3] + transform.m[1];
             frustumPlane.normal.y = transform.m[7] + transform.m[5];
             frustumPlane.normal.z = transform.m[11] + transform.m[9];
             frustumPlane.d = transform.m[15] + transform.m[13];
             frustumPlane.normalize();
-        }           
+        }
 
         /**
          * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.  

+ 2 - 2
src/Mesh/babylon.abstractMesh.ts

@@ -1788,9 +1788,9 @@
          * Align the mesh with a normal.
          * Returns the mesh.  
          */
-        public alignWithNormal(normal: BABYLON.Vector3, upDirection?: BABYLON.Vector3): AbstractMesh {
+        public alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh {
             if (!upDirection) {
-                upDirection = BABYLON.Axis.Y;
+                upDirection = Axis.Y;
             }
 
             var axisX = Tmp.Vector3[0];

+ 1 - 1
src/Mesh/babylon.groundMesh.ts

@@ -145,7 +145,7 @@
             this._heightQuads = new Array();
             for (var row = 0; row < subdivisionsY; row++) {
                 for (var col = 0; col < subdivisionsX; col++) {
-                    var quad = { slope: BABYLON.Vector2.Zero(), facet1: new BABYLON.Vector4(0.0, 0.0, 0.0, 0.0), facet2: new BABYLON.Vector4(0.0, 0.0, 0.0, 0.0) };
+                    var quad = { slope: Vector2.Zero(), facet1: new Vector4(0.0, 0.0, 0.0, 0.0), facet2: new Vector4(0.0, 0.0, 0.0, 0.0) };
                     this._heightQuads[row * subdivisionsX + col] = quad;
                 }
             }

+ 3 - 3
src/Mesh/babylon.mesh.ts

@@ -2478,7 +2478,7 @@
 
             // Physics
             if (parsedMesh.physicsImpostor) {
-                mesh.physicsImpostor = new BABYLON.PhysicsImpostor(mesh, parsedMesh.physicsImpostor, {
+                mesh.physicsImpostor = new PhysicsImpostor(mesh, parsedMesh.physicsImpostor, {
                     mass: parsedMesh.physicsMass,
                     friction: parsedMesh.physicsFriction,
                     restitution: parsedMesh.physicsRestitution
@@ -3256,7 +3256,7 @@
          * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
          */
         public static Center(meshesOrMinMaxVector: { min: Vector3; max: Vector3 } | AbstractMesh[]): Vector3 {
-            var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? BABYLON.Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
+            var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
             return Vector3.Center(minMaxVector.min, minMaxVector.max);
         }
 
@@ -3341,7 +3341,7 @@
 
                 //-- aplique la subdivision en fonction du tableau d'indices
                 while (index < indiceArray.length) {
-                    BABYLON.SubMesh.CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
+                    SubMesh.CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
                     offset += indiceArray[index];
                     index++;
                 }

+ 12 - 12
src/Mesh/babylon.subMesh.ts

@@ -5,7 +5,7 @@
 
         public get effect(): Nullable<Effect> {
             return this._materialEffect;
-        }       
+        }
 
         public setEffect(effect: Nullable<Effect>, defines: Nullable<MaterialDefines> = null) {
             if (this._materialEffect === effect) {
@@ -16,7 +16,7 @@
             }
             this._materialDefines = defines;
             this._materialEffect = effect;
-        }         
+        }
     }
 
     export class SubMesh extends BaseSubMesh implements ICullable {
@@ -181,23 +181,23 @@
          */
         public isInFrustum(frustumPlanes: Plane[]): boolean {
             let boundingInfo = this.getBoundingInfo();
-            
+
             if (!boundingInfo) {
                 return false;
-            }            
+            }
             return boundingInfo.isInFrustum(frustumPlanes);
         }
 
         /**
          * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.  
          * Boolean returned.  
-         */        
+         */
         public isCompletelyInFrustum(frustumPlanes: Plane[]): boolean {
             let boundingInfo = this.getBoundingInfo();
-            
+
             if (!boundingInfo) {
                 return false;
-            }                  
+            }
             return boundingInfo.isCompletelyInFrustum(frustumPlanes);
         }
 
@@ -236,10 +236,10 @@
          */
         public canIntersects(ray: Ray): boolean {
             let boundingInfo = this.getBoundingInfo();
-            
+
             if (!boundingInfo) {
                 return false;
-            }            
+            }
             return ray.intersectsBox(boundingInfo.boundingBox);
         }
 
@@ -250,7 +250,7 @@
             var intersectInfo: Nullable<IntersectionInfo> = null;
 
             // LineMesh first as it's also a Mesh...
-            if (BABYLON.LinesMesh && this._mesh instanceof LinesMesh) {
+            if (LinesMesh && this._mesh instanceof LinesMesh) {
                 var lineMesh = <LinesMesh>this._mesh;
 
                 // Line test
@@ -316,10 +316,10 @@
 
             if (!this.IsGlobal) {
                 let boundingInfo = this.getBoundingInfo();
-                
+
                 if (!boundingInfo) {
                     return result;
-                }   
+                }
 
                 result._boundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);
             }

+ 2 - 2
src/Mesh/babylon.transformNode.ts

@@ -650,7 +650,7 @@ module BABYLON {
                 rotationQuaternion = Tmp.Quaternion[1];
                 Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
             }
-            var accumulation = BABYLON.Tmp.Quaternion[0];
+            var accumulation = Tmp.Quaternion[0];
             Quaternion.RotationYawPitchRollToRef(y, x, z, accumulation);
             rotationQuaternion.multiplyInPlace(accumulation);
             if (!this.rotationQuaternion) {
@@ -691,7 +691,7 @@ module BABYLON {
             if (this.rotationQuaternion) {
                 var len = this.rotation.length();
                 if (len) {
-                    this.rotationQuaternion.multiplyInPlace(BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z))
+                    this.rotationQuaternion.multiplyInPlace(Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z))
                     this.rotation.copyFromFloats(0, 0, 0);
                 }
             }

+ 2 - 2
src/Physics/babylon.physicsImpostor.ts

@@ -31,7 +31,7 @@ module BABYLON {
 
     export class PhysicsImpostor {
 
-        public static DEFAULT_OBJECT_SIZE: Vector3 = new BABYLON.Vector3(1, 1, 1);
+        public static DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);
 
         public static IDENTITY_QUATERNION = Quaternion.Identity();
 
@@ -440,7 +440,7 @@ module BABYLON {
         /**
          * Legacy collision detection event support
          */
-        public onCollideEvent: Nullable<(collider: BABYLON.PhysicsImpostor, collidedWith: BABYLON.PhysicsImpostor) => void> = null;
+        public onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void> = null;
 
         //event and body object due to cannon's event-based architecture.
         public onCollide = (e: { body: any }) => {

+ 104 - 104
src/PostProcess/RenderPipeline/Pipelines/babylon.defaultRenderingPipeline.ts

@@ -1,28 +1,28 @@
 module BABYLON {
     export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
-        private _scene: Scene;     
-
-        readonly PassPostProcessId: string = "PassPostProcessEffect";           
-        readonly HighLightsPostProcessId: string = "HighLightsPostProcessEffect";  
-        readonly BlurXPostProcessId: string = "BlurXPostProcessEffect";  
-        readonly BlurYPostProcessId: string = "BlurYPostProcessEffect";  
-        readonly CopyBackPostProcessId: string = "CopyBackPostProcessEffect";  
-        readonly ImageProcessingPostProcessId: string = "ImageProcessingPostProcessEffect";  
-        readonly FxaaPostProcessId: string = "FxaaPostProcessEffect";           
+        private _scene: Scene;
+
+        readonly PassPostProcessId: string = "PassPostProcessEffect";
+        readonly HighLightsPostProcessId: string = "HighLightsPostProcessEffect";
+        readonly BlurXPostProcessId: string = "BlurXPostProcessEffect";
+        readonly BlurYPostProcessId: string = "BlurYPostProcessEffect";
+        readonly CopyBackPostProcessId: string = "CopyBackPostProcessEffect";
+        readonly ImageProcessingPostProcessId: string = "ImageProcessingPostProcessEffect";
+        readonly FxaaPostProcessId: string = "FxaaPostProcessEffect";
         readonly FinalMergePostProcessId: string = "FinalMergePostProcessEffect";
 
         // Post-processes
-		public pass: BABYLON.PassPostProcess;
-		public highlights: BABYLON.HighlightsPostProcess;
-		public blurX: BABYLON.BlurPostProcess;
-		public blurY: BABYLON.BlurPostProcess;
-		public copyBack: BABYLON.PassPostProcess;
+        public pass: PassPostProcess;
+        public highlights: HighlightsPostProcess;
+        public blurX: BlurPostProcess;
+        public blurY: BlurPostProcess;
+        public copyBack: PassPostProcess;
         public fxaa: FxaaPostProcess;
         public imageProcessing: ImageProcessingPostProcess;
-		public finalMerge: BABYLON.PassPostProcess;        
+        public finalMerge: PassPostProcess;
 
         // IAnimatable
-        public animations: Animation[] = [];        
+        public animations: Animation[] = [];
 
         // Values       
         private _bloomEnabled: boolean = false;
@@ -37,13 +37,13 @@
 		 * Specifies the size of the bloom blur kernel, relative to the final output size
 		 */
         @serialize()
-		public bloomKernel: number = 64;
+        public bloomKernel: number = 64;
 
         /**
 		 * Specifies the weight of the bloom in the final rendering
 		 */
         @serialize()
-		private _bloomWeight: number = 0.15;        
+        private _bloomWeight: number = 0.15;
 
         @serialize()
         private _hdr: boolean;
@@ -55,14 +55,14 @@
             this._bloomWeight = value;
 
             if (this._hdr && this.copyBack) {
-                this.copyBack.alphaConstants = new BABYLON.Color4(value, value, value, value);	
+                this.copyBack.alphaConstants = new Color4(value, value, value, value);
             }
-        }   
-        
+        }
+
         @serialize()
         public get bloomWeight(): number {
             return this._bloomWeight;
-        }          
+        }
 
         public set bloomScale(value: number) {
             if (this._bloomScale === value) {
@@ -71,12 +71,12 @@
             this._bloomScale = value;
 
             this._buildPipeline();
-        }   
-        
+        }
+
         @serialize()
         public get bloomScale(): number {
             return this._bloomScale;
-        }          
+        }
 
         public set bloomEnabled(enabled: boolean) {
             if (this._bloomEnabled === enabled) {
@@ -85,12 +85,12 @@
             this._bloomEnabled = enabled;
 
             this._buildPipeline();
-        }   
-        
+        }
+
         @serialize()
         public get bloomEnabled(): boolean {
             return this._bloomEnabled;
-        }        
+        }
 
         public set fxaaEnabled(enabled: boolean) {
             if (this._fxaaEnabled === enabled) {
@@ -118,7 +118,7 @@
         @serialize()
         public get imageProcessingEnabled(): boolean {
             return this._imageProcessingEnabled;
-        }        
+        }
 
         /**
          * @constructor
@@ -130,7 +130,7 @@
          */
         constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild = true) {
             super(scene.getEngine(), name);
-            this._cameras = cameras || [];
+            this._cameras = cameras ||  [];
 
             this._buildAllowed = automaticBuild;
 
@@ -142,10 +142,10 @@
             // Misc
             if (this._hdr) {
                 if (caps.textureHalfFloatRender) {
-                    this._defaultPipelineTextureType  = Engine.TEXTURETYPE_HALF_FLOAT;
+                    this._defaultPipelineTextureType = Engine.TEXTURETYPE_HALF_FLOAT;
                 }
                 else if (caps.textureFloatRender) {
-                    this._defaultPipelineTextureType  = Engine.TEXTURETYPE_FLOAT;
+                    this._defaultPipelineTextureType = Engine.TEXTURETYPE_FLOAT;
                 }
             } else {
                 this._defaultPipelineTextureType = Engine.TEXTURETYPE_UNSIGNED_INT;
@@ -177,95 +177,95 @@
             this._disposePostProcesses();
             this._reset();
 
-			if (this.bloomEnabled) {
-				this.pass = new BABYLON.PassPostProcess("sceneRenderTarget", 1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
+            if (this.bloomEnabled) {
+                this.pass = new PassPostProcess("sceneRenderTarget", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
                 this.addEffect(new PostProcessRenderEffect(engine, this.PassPostProcessId, () => { return this.pass; }, true));
 
-				if (!this._hdr) { // Need to enhance highlights if not using float rendering
-					this.highlights = new BABYLON.HighlightsPostProcess("highlights", this.bloomScale, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
+                if (!this._hdr) { // Need to enhance highlights if not using float rendering
+                    this.highlights = new HighlightsPostProcess("highlights", this.bloomScale, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
                     this.addEffect(new PostProcessRenderEffect(engine, this.HighLightsPostProcessId, () => { return this.highlights; }, true));
-					this.highlights.autoClear = false;
-					this.highlights.alwaysForcePOT = true;
-				}
+                    this.highlights.autoClear = false;
+                    this.highlights.alwaysForcePOT = true;
+                }
 
-				this.blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), 10.0, this.bloomScale, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
+                this.blurX = new BlurPostProcess("horizontal blur", new Vector2(1.0, 0), 10.0, this.bloomScale, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
                 this.addEffect(new PostProcessRenderEffect(engine, this.BlurXPostProcessId, () => { return this.blurX; }, true));
-				this.blurX.alwaysForcePOT = true;
-				this.blurX.autoClear = false;
-				this.blurX.onActivateObservable.add(() => {
-					let dw = this.blurX.width / engine.getRenderWidth(true);
-					this.blurX.kernel = this.bloomKernel * dw;
-				});
-
-				this.blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), 10.0, this.bloomScale, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
+                this.blurX.alwaysForcePOT = true;
+                this.blurX.autoClear = false;
+                this.blurX.onActivateObservable.add(() => {
+                    let dw = this.blurX.width / engine.getRenderWidth(true);
+                    this.blurX.kernel = this.bloomKernel * dw;
+                });
+
+                this.blurY = new BlurPostProcess("vertical blur", new Vector2(0, 1.0), 10.0, this.bloomScale, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
                 this.addEffect(new PostProcessRenderEffect(engine, this.BlurYPostProcessId, () => { return this.blurY; }, true));
-				this.blurY.alwaysForcePOT = true;
-				this.blurY.autoClear = false;
-				this.blurY.onActivateObservable.add(() => {
-					let dh = this.blurY.height / engine.getRenderHeight(true);
-					this.blurY.kernel = this.bloomKernel * dh;
-				});				
-
-				this.copyBack = new BABYLON.PassPostProcess("bloomBlendBlit", this.bloomScale, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);			
+                this.blurY.alwaysForcePOT = true;
+                this.blurY.autoClear = false;
+                this.blurY.onActivateObservable.add(() => {
+                    let dh = this.blurY.height / engine.getRenderHeight(true);
+                    this.blurY.kernel = this.bloomKernel * dh;
+                });
+
+                this.copyBack = new PassPostProcess("bloomBlendBlit", this.bloomScale, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
                 this.addEffect(new PostProcessRenderEffect(engine, this.CopyBackPostProcessId, () => { return this.copyBack; }, true));
-				this.copyBack.alwaysForcePOT = true;
-				if (this._hdr) {
-					this.copyBack.alphaMode = BABYLON.Engine.ALPHA_INTERPOLATE;
-					let w = this.bloomWeight;
-					this.copyBack.alphaConstants = new BABYLON.Color4(w, w, w, w);			
-				} else {
-					this.copyBack.alphaMode = BABYLON.Engine.ALPHA_SCREENMODE;
-				}
-				this.copyBack.autoClear = false;
-			}
+                this.copyBack.alwaysForcePOT = true;
+                if (this._hdr) {
+                    this.copyBack.alphaMode = Engine.ALPHA_INTERPOLATE;
+                    let w = this.bloomWeight;
+                    this.copyBack.alphaConstants = new Color4(w, w, w, w);
+                } else {
+                    this.copyBack.alphaMode = Engine.ALPHA_SCREENMODE;
+                }
+                this.copyBack.autoClear = false;
+            }
 
             if (this._imageProcessingEnabled) {
-                this.imageProcessing = new BABYLON.ImageProcessingPostProcess("imageProcessing",  1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
+                this.imageProcessing = new ImageProcessingPostProcess("imageProcessing", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
                 if (this._hdr) {
                     this.addEffect(new PostProcessRenderEffect(engine, this.ImageProcessingPostProcessId, () => { return this.imageProcessing; }, true));
                 } else {
                     this._scene.imageProcessingConfiguration.applyByPostProcess = false;
                 }
-            } 
+            }
 
-			if (this.fxaaEnabled) {
+            if (this.fxaaEnabled) {
                 this.fxaa = new FxaaPostProcess("fxaa", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
-                this.addEffect(new PostProcessRenderEffect(engine, this.FxaaPostProcessId, () => { return this.fxaa; }, true));  
+                this.addEffect(new PostProcessRenderEffect(engine, this.FxaaPostProcessId, () => { return this.fxaa; }, true));
 
-				this.fxaa.autoClear = !this.bloomEnabled && (!this._hdr || !this.imageProcessing);
-			} else if (this._hdr && this.imageProcessing) {
+                this.fxaa.autoClear = !this.bloomEnabled && (!this._hdr || !this.imageProcessing);
+            } else if (this._hdr && this.imageProcessing) {
                 this.finalMerge = this.imageProcessing;
             }
             else {
-				this.finalMerge = new BABYLON.PassPostProcess("finalMerge", 1.0, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
-                this.addEffect(new PostProcessRenderEffect(engine, this.FinalMergePostProcessId, () => { return this.finalMerge; }, true)); 
-                
-				this.finalMerge.autoClear = !this.bloomEnabled && (!this._hdr || !this.imageProcessing);
-			}
-
-			if (this.bloomEnabled) {
-				if (this._hdr) { // Share render targets to save memory
-					this.copyBack.shareOutputWith(this.blurX);	
-                    if (this.imageProcessing) {	
-					    this.imageProcessing.shareOutputWith(this.pass);			
-					    this.imageProcessing.autoClear = false;
+                this.finalMerge = new PassPostProcess("finalMerge", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, engine, false, this._defaultPipelineTextureType);
+                this.addEffect(new PostProcessRenderEffect(engine, this.FinalMergePostProcessId, () => { return this.finalMerge; }, true));
+
+                this.finalMerge.autoClear = !this.bloomEnabled && (!this._hdr || !this.imageProcessing);
+            }
+
+            if (this.bloomEnabled) {
+                if (this._hdr) { // Share render targets to save memory
+                    this.copyBack.shareOutputWith(this.blurX);
+                    if (this.imageProcessing) {
+                        this.imageProcessing.shareOutputWith(this.pass);
+                        this.imageProcessing.autoClear = false;
                     } else if (this.fxaa) {
-						this.fxaa.shareOutputWith(this.pass);		
-					} else {
-						this.finalMerge.shareOutputWith(this.pass);	
-					} 
-				} else  {
-					if (this.fxaa) {
-						this.fxaa.shareOutputWith(this.pass);		
-					} else {
-						this.finalMerge.shareOutputWith(this.pass);	
-					} 
-				}
-			}
+                        this.fxaa.shareOutputWith(this.pass);
+                    } else {
+                        this.finalMerge.shareOutputWith(this.pass);
+                    }
+                } else {
+                    if (this.fxaa) {
+                        this.fxaa.shareOutputWith(this.pass);
+                    } else {
+                        this.finalMerge.shareOutputWith(this.pass);
+                    }
+                }
+            }
 
             if (this._cameras !== null) {
                 this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
-            }            
+            }
         }
 
         private _disposePostProcesses(): void {
@@ -278,23 +278,23 @@
 
                 if (this.highlights) {
                     this.highlights.dispose(camera);
-                }        
+                }
 
                 if (this.blurX) {
                     this.blurX.dispose(camera);
-                }      
+                }
 
                 if (this.blurY) {
                     this.blurY.dispose(camera);
-                }         
+                }
 
                 if (this.copyBack) {
                     this.copyBack.dispose(camera);
-                }   
+                }
 
                 if (this.imageProcessing) {
                     this.imageProcessing.dispose(camera);
-                }                                                                
+                }
 
                 if (this.fxaa) {
                     this.fxaa.dispose(camera);
@@ -302,7 +302,7 @@
 
                 if (this.finalMerge) {
                     this.finalMerge.dispose(camera);
-                }                
+                }
             }
 
             (<any>this.pass) = null;
@@ -326,7 +326,7 @@
 
         // Serialize rendering pipeline
         public serialize(): any {
-            var serializationObject = SerializationHelper.Serialize(this);   
+            var serializationObject = SerializationHelper.Serialize(this);
             serializationObject.customType = "DefaultRenderingPipeline";
 
             return serializationObject;

+ 1 - 1
src/PostProcess/RenderPipeline/Pipelines/babylon.ssao2RenderingPipeline.ts

@@ -272,7 +272,7 @@
 
             var i = 0;
             while (i < numSamples) {
-                vector = new BABYLON.Vector3(
+                vector = new Vector3(
                     rand(-1.0, 1.0),
                     rand(-1.0, 1.0),
                     rand(0.30, 1.0));

+ 2 - 2
src/PostProcess/RenderPipeline/Pipelines/babylon.ssaoRenderingPipeline.ts

@@ -148,8 +148,8 @@
         private _createBlurPostProcess(ratio: number): void {
             var size = 16;
 
-            this._blurHPostProcess = new BlurPostProcess("BlurH", new Vector2(1, 0), size, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
-            this._blurVPostProcess = new BlurPostProcess("BlurV", new Vector2(0, 1), size, ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
+            this._blurHPostProcess = new BlurPostProcess("BlurH", new Vector2(1, 0), size, ratio, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
+            this._blurVPostProcess = new BlurPostProcess("BlurV", new Vector2(0, 1), size, ratio, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
 
             this._blurHPostProcess.onActivateObservable.add(() => {
                 let dw = this._blurHPostProcess.width / this._scene.getEngine().getRenderWidth();

+ 14 - 14
src/PostProcess/RenderPipeline/Pipelines/babylon.standardRenderingPipeline.ts

@@ -53,7 +53,7 @@
         @serialize()
         public volumetricLightBlurScale: number = 64.0;
 
-        public sourceLight: Nullable<SpotLight | DirectionalLight> = null;
+        public sourceLight: Nullable<SpotLight |  DirectionalLight> = null;
 
         @serialize()
         public hdrMinimumLuminance: number = 1.0;
@@ -187,7 +187,7 @@
                     return;
                 }
             }
-        
+
             this._vlsEnabled = enabled;
             this._buildPipeline();
         }
@@ -211,7 +211,7 @@
             return this._volumetricLightStepsCount;
         }
 
-        public set volumetricLightStepsCount(count: number) {
+        public set volumetricLightStepsCount(count: number)  {
             if (this.volumetricLightPostProcess) {
                 this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
             }
@@ -228,7 +228,7 @@
             if (this.motionBlurPostProcess) {
                 this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
             }
-            
+
             this._motionBlurSamples = samples;
         }
 
@@ -242,7 +242,7 @@
          */
         constructor(name: string, scene: Scene, ratio: number, originalPostProcess: Nullable<PostProcess> = null, cameras?: Camera[]) {
             super(scene.getEngine(), name);
-            this._cameras = cameras || [];
+            this._cameras = cameras ||  [];
 
             // Initialize
             this._scene = scene;
@@ -282,7 +282,7 @@
             if (this._vlsEnabled) {
                 // Create volumetric light
                 this._createVolumetricLightPostProcess(scene, ratio);
-        
+
                 // Create volumetric light final post-process
                 this.volumetricLightFinalPostProcess = new PostProcess("HDRVLSFinal", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_UNSIGNED_INT);
                 this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRVLSFinal", () => { return this.volumetricLightFinalPostProcess; }, true));
@@ -314,7 +314,7 @@
                 this.lensFlareFinalPostProcess = new PostProcess("HDRPostLensFlareDepthOfFieldSource", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_UNSIGNED_INT);
                 this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", () => { return this.lensFlareFinalPostProcess; }, true));
             }
-        
+
             if (this._hdrEnabled) {
                 // Create luminance
                 this._createLuminancePostProcesses(scene, this._floatTextureType);
@@ -401,8 +401,8 @@
         private _createBlurPostProcesses(scene: Scene, ratio: number, indice: number, blurWidthKey: string = "blurWidth"): void {
             var engine = scene.getEngine();
 
-            var blurX = new BlurPostProcess("HDRBlurH" + "_" + indice, new Vector2(1, 0), (<any>this)[blurWidthKey], ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
-            var blurY = new BlurPostProcess("HDRBlurV" + "_" + indice, new Vector2(0, 1), (<any>this)[blurWidthKey], ratio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
+            var blurX = new BlurPostProcess("HDRBlurH" + "_" + indice, new Vector2(1, 0), (<any>this)[blurWidthKey], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
+            var blurY = new BlurPostProcess("HDRBlurV" + "_" + indice, new Vector2(0, 1), (<any>this)[blurWidthKey], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, Engine.TEXTURETYPE_UNSIGNED_INT);
 
             blurX.onActivateObservable.add(() => {
                 let dw = blurX.width / engine.getRenderWidth();
@@ -446,7 +446,7 @@
             // Base post-process
             this.volumetricLightPostProcess = new PostProcess("HDRVLS", "standard",
                 ["shadowViewProjection", "cameraPosition", "sunDirection", "sunColor", "scatteringCoefficient", "scatteringPower", "depthValues"],
-                ["shadowMapSampler", "positionSampler" ],
+                ["shadowMapSampler", "positionSampler"],
                 ratio / 8,
                 null,
                 Texture.BILINEAR_SAMPLINGMODE,
@@ -464,7 +464,7 @@
 
                     effect.setColor3("sunColor", this.sourceLight.diffuse);
                     effect.setVector3("sunDirection", this.sourceLight.getShadowDirection());
-                    
+
                     effect.setVector3("cameraPosition", this._scene.activeCamera.globalPosition);
                     effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
 
@@ -758,13 +758,13 @@
                 if (this.brightPassPostProcess) { this.brightPassPostProcess.dispose(camera); }
                 if (this.textureAdderPostProcess) { this.textureAdderPostProcess.dispose(camera); }
                 if (this.textureAdderFinalPostProcess) { this.textureAdderFinalPostProcess.dispose(camera); }
-                
+
                 if (this.volumetricLightPostProcess) { this.volumetricLightPostProcess.dispose(camera); }
                 if (this.volumetricLightSmoothXPostProcess) { this.volumetricLightSmoothXPostProcess.dispose(camera); }
                 if (this.volumetricLightSmoothYPostProcess) { this.volumetricLightSmoothYPostProcess.dispose(camera); }
                 if (this.volumetricLightMergePostProces) { this.volumetricLightMergePostProces.dispose(camera); }
                 if (this.volumetricLightFinalPostProcess) { this.volumetricLightFinalPostProcess.dispose(camera); }
-            
+
                 if (this.lensFlarePostProcess) { this.lensFlarePostProcess.dispose(camera); }
                 if (this.lensFlareComposePostProcess) { this.lensFlareComposePostProcess.dispose(camera); }
 
@@ -775,7 +775,7 @@
                 if (this.luminancePostProcess) { this.luminancePostProcess.dispose(camera); }
                 if (this.hdrPostProcess) { this.hdrPostProcess.dispose(camera); }
                 if (this.hdrFinalPostProcess) { this.hdrFinalPostProcess.dispose(camera); }
-            
+
                 if (this.depthOfFieldPostProcess) { this.depthOfFieldPostProcess.dispose(camera); }
 
                 if (this.motionBlurPostProcess) { this.motionBlurPostProcess.dispose(camera); }

+ 1 - 1
src/PostProcess/babylon.fxaaPostProcess.ts

@@ -4,7 +4,7 @@
         public texelHeight: number;
 
         constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera> = null, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
-            super(name, "fxaa", ["texelSize"], null, options, camera, samplingMode || BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, reusable, null, textureType, "fxaa");
+            super(name, "fxaa", ["texelSize"], null, options, camera, samplingMode || Texture.BILINEAR_SAMPLINGMODE, engine, reusable, null, textureType, "fxaa");
 
             this.onApplyObservable.add((effect: Effect) => {
                 var texelSize = this.texelSize;

+ 4 - 4
src/PostProcess/babylon.imageProcessingPostProcess.ts

@@ -55,7 +55,7 @@
                     scene = scenes[scenes.length - 1];
                 }
                 else {
-                    scene = BABYLON.Engine.LastCreatedScene;
+                    scene = Engine.LastCreatedScene;
                 }
 
                 this._imageProcessingConfiguration = (<Scene>scene).imageProcessingConfiguration;
@@ -314,7 +314,7 @@
 
         constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera> = null, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, imageProcessingConfiguration?: ImageProcessingConfiguration) {
             super(name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable,
-                                            null, textureType, "postprocess", null, true);
+                null, textureType, "postprocess", null, true);
 
             // Setup the configuration as forced by the constructor. This would then not force the 
             // scene materials output in linear space and let untouched the default forward pass.
@@ -337,7 +337,7 @@
 
         public getClassName(): string {
             return "ImageProcessingPostProcess";
-        }           
+        }
 
         protected _updateParameters(): void {
             this._defines.FROMLINEARSPACE = this._fromLinearSpace;
@@ -364,7 +364,7 @@
             if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
                 this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
             }
-            
+
             this.imageProcessingConfiguration.applyByPostProcess = false;
         }
     }

+ 14 - 14
src/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -42,7 +42,7 @@
         @serializeAsMeshReference()
         public mesh: Mesh;
 
-        
+
         public get useDiffuseColor(): boolean {
             Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
             return false;
@@ -133,7 +133,7 @@
 
         public getClassName(): string {
             return "VolumetricLightScatteringPostProcess";
-        }          
+        }
 
         public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
             var mesh = subMesh.getMesh();
@@ -170,9 +170,9 @@
                 defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
                 defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
             } else {
-                defines.push("#define NUM_BONE_INFLUENCERS 0"); 
+                defines.push("#define NUM_BONE_INFLUENCERS 0");
             }
-            
+
 
             // Instances
             if (useInstances) {
@@ -221,7 +221,7 @@
             if (rttIndex !== -1) {
                 camera.getScene().customRenderTargets.splice(rttIndex, 1);
             }
-                
+
             this._volumetricLightScatteringRTT.dispose();
             super.dispose(camera);
         }
@@ -265,7 +265,7 @@
                 if (this._meshExcluded(mesh)) {
                     return;
                 }
-                
+
                 let material = subMesh.getMaterial();
 
                 if (!material) {
@@ -286,7 +286,7 @@
                 }
 
                 var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
-                
+
                 if (this.isReady(subMesh, hardwareInstancedRendering)) {
                     var effect: Effect = this._volumetricLightScatteringPass;
                     if (mesh === this.mesh) {
@@ -309,7 +309,7 @@
                         // Alpha test
                         if (material && material.needAlphaTesting()) {
                             var alphaTexture = material.getAlphaTestTexture();
-                            
+
                             this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
 
                             if (alphaTexture) {
@@ -341,18 +341,18 @@
             this._volumetricLightScatteringRTT.onAfterRenderObservable.add((): void => {
                 scene.clearColor = savedSceneClearColor;
             });
-            
+
             this._volumetricLightScatteringRTT.customRenderFunction = (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void => {
                 var engine = scene.getEngine();
                 var index: number;
-                
+
                 if (depthOnlySubMeshes.length) {
-                    engine.setColorWrite(false);            
+                    engine.setColorWrite(false);
                     for (index = 0; index < depthOnlySubMeshes.length; index++) {
                         renderSubMesh(depthOnlySubMeshes.data[index]);
                     }
                     engine.setColorWrite(true);
-                }                   
+                }
 
                 for (index = 0; index < opaqueSubMeshes.length; index++) {
                     renderSubMesh(opaqueSubMeshes.data[index]);
@@ -398,11 +398,11 @@
                     });
 
                     // Render sub meshes
-                    engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+                    engine.setAlphaMode(Engine.ALPHA_COMBINE);
                     for (index = 0; index < sortedArray.length; index++) {
                         renderSubMesh(sortedArray[index]);
                     }
-                    engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
+                    engine.setAlphaMode(Engine.ALPHA_DISABLE);
                 }
             };
         }

+ 8 - 8
src/Tools/babylon.earcut.ts

@@ -64,8 +64,8 @@ module Earcut {
 
         public z: any = null;
         public prevZ: any = null;
-        public nextZ: any = null;  
-        
+        public nextZ: any = null;
+
         public steiner: boolean = false;
 
         public constructor(public i: number, public x: number, public y: number) {
@@ -74,7 +74,7 @@ module Earcut {
 
     // create a circular doubly linked list from polygon points in the specified winding order
     function linkedList(data: number[], start: number, end: number, dim: number, clockwise: boolean): Node {
-        var i, last: BABYLON.Nullable<Node> = null;
+        var i, last: Node | null = null;
 
         if (clockwise === (signedArea(data, start, end, dim) > 0)) {
             for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], (<Node>last));
@@ -492,8 +492,8 @@ module Earcut {
     // check if a point lies within a convex triangle
     function pointInTriangle(ax: number, ay: number, bx: number, by: number, cx: number, cy: number, px: number, py: number) {
         return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
-        (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
-        (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
+            (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
+            (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
     }
 
     // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
@@ -519,7 +519,7 @@ module Earcut {
     // check if two segments intersect
     function intersects(p1: Node, q1: Node, p2: Node, q2: Node) {
         if ((equals(p1, q1) && equals(p2, q2)) ||
-        (equals(p1, q2) && equals(p2, q1))) return true;
+            (equals(p1, q2) && equals(p2, q1))) return true;
         return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
             area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
     }
@@ -632,8 +632,8 @@ module Earcut {
             var b = triangles[i + 1] * dim;
             var c = triangles[i + 2] * dim;
             trianglesArea += Math.abs(
-            (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
-            (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
+                (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
+                (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
         }
 
         return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);

File diff suppressed because it is too large
+ 43 - 43
src/Tools/babylon.textureTools.ts


+ 2 - 2
src/Tools/babylon.tools.ts

@@ -425,7 +425,7 @@
             }
 
             if (Tools.CorsBehavior) {
-                if (typeof(Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
+                if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
                     element.crossOrigin = <string>Tools.CorsBehavior;
                 }
                 else {
@@ -977,7 +977,7 @@
             texture.renderList = null;
             texture.samples = samples;
             if (antialiasing) {
-                texture.addPostProcess(new BABYLON.FxaaPostProcess('antialiasing', 1.0, scene.activeCamera));
+                texture.addPostProcess(new FxaaPostProcess('antialiasing', 1.0, scene.activeCamera));
             }
             texture.onAfterRenderObservable.add(() => {
                 Tools.DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);