jbousquie 10 年之前
父节点
当前提交
f6948c15c3
共有 100 个文件被更改,包括 7763 次插入7528 次删除
  1. 2 1
      Babylon/Actions/babylon.action.js
  2. 2 1
      Babylon/Actions/babylon.actionManager.js
  3. 2 1
      Babylon/Actions/babylon.condition.js
  4. 2 1
      Babylon/Actions/babylon.directActions.js
  5. 2 1
      Babylon/Actions/babylon.interpolateValueAction.js
  6. 91 90
      Babylon/Animations/babylon.animatable.js
  7. 357 356
      Babylon/Animations/babylon.animation.js
  8. 2 1
      Babylon/Animations/babylon.easing.js
  9. 2 1
      Babylon/Audio/babylon.analyser.js
  10. 2 1
      Babylon/Audio/babylon.audioengine.js
  11. 2 1
      Babylon/Audio/babylon.sound.js
  12. 2 1
      Babylon/Audio/babylon.soundtrack.js
  13. 2 1
      Babylon/Bones/babylon.bone.js
  14. 2 1
      Babylon/Bones/babylon.skeleton.js
  15. 2 1
      Babylon/Cameras/VR/babylon.oculusCamera.js
  16. 2 1
      Babylon/Cameras/VR/babylon.oculusGamepadCamera.js
  17. 2 1
      Babylon/Cameras/VR/babylon.vrDeviceOrientationCamera.js
  18. 2 1
      Babylon/Cameras/VR/babylon.webVRCamera.js
  19. 2 1
      Babylon/Cameras/babylon.anaglyphCamera.js
  20. 447 446
      Babylon/Cameras/babylon.arcRotateCamera.js
  21. 273 272
      Babylon/Cameras/babylon.camera.js
  22. 2 1
      Babylon/Cameras/babylon.deviceOrientationCamera.js
  23. 2 1
      Babylon/Cameras/babylon.followCamera.js
  24. 213 212
      Babylon/Cameras/babylon.freeCamera.js
  25. 2 1
      Babylon/Cameras/babylon.gamepadCamera.js
  26. 2 1
      Babylon/Cameras/babylon.targetCamera.js
  27. 118 117
      Babylon/Cameras/babylon.touchCamera.js
  28. 2 1
      Babylon/Cameras/babylon.virtualJoysticksCamera.js
  29. 274 273
      Babylon/Collisions/babylon.collider.js
  30. 2 1
      Babylon/Collisions/babylon.pickingInfo.js
  31. 2 1
      Babylon/Culling/Octrees/babylon.octree.js
  32. 2 1
      Babylon/Culling/Octrees/babylon.octreeBlock.js
  33. 107 106
      Babylon/Culling/babylon.boundingInfo.js
  34. 51 50
      Babylon/Culling/babylon.boundingSphere.js
  35. 2 1
      Babylon/Debug/babylon.debugLayer.js
  36. 1 1
      Babylon/Debug/babylon.debugLayer.js.map
  37. 78 77
      Babylon/Layer/babylon.layer.js
  38. 2 1
      Babylon/LensFlare/babylon.lensFlare.js
  39. 2 1
      Babylon/LensFlare/babylon.lensFlareSystem.js
  40. 2 1
      Babylon/Lights/Shadows/babylon.shadowGenerator.js
  41. 56 55
      Babylon/Lights/babylon.directionalLight.js
  42. 39 38
      Babylon/Lights/babylon.hemisphericLight.js
  43. 72 71
      Babylon/Lights/babylon.light.js
  44. 44 43
      Babylon/Lights/babylon.pointLight.js
  45. 64 63
      Babylon/Lights/babylon.spotLight.js
  46. 2 1
      Babylon/Loading/Plugins/babylon.babylonFileLoader.js
  47. 2 1
      Babylon/Loading/babylon.sceneLoader.js
  48. 2 1
      Babylon/Materials/Textures/Procedurals/babylon.customProceduralTexture.js
  49. 2 1
      Babylon/Materials/Textures/Procedurals/babylon.proceduralTexture.js
  50. 2 1
      Babylon/Materials/Textures/Procedurals/babylon.standardProceduralTexture.js
  51. 2 1
      Babylon/Materials/Textures/babylon.baseTexture.js
  52. 2 1
      Babylon/Materials/Textures/babylon.cubeTexture.js
  53. 2 1
      Babylon/Materials/Textures/babylon.dynamicTexture.js
  54. 2 1
      Babylon/Materials/Textures/babylon.mirrorTexture.js
  55. 2 1
      Babylon/Materials/Textures/babylon.rawTexture.js
  56. 2 1
      Babylon/Materials/Textures/babylon.renderTargetTexture.js
  57. 2 1
      Babylon/Materials/Textures/babylon.texture.js
  58. 2 1
      Babylon/Materials/Textures/babylon.videoTexture.js
  59. 344 343
      Babylon/Materials/babylon.effect.js
  60. 128 127
      Babylon/Materials/babylon.material.js
  61. 40 39
      Babylon/Materials/babylon.multiMaterial.js
  62. 2 1
      Babylon/Materials/babylon.shaderMaterial.js
  63. 581 580
      Babylon/Materials/babylon.standardMaterial.js
  64. 2406 2405
      Babylon/Math/babylon.math.js
  65. 2 1
      Babylon/Mesh/babylon.InstancedMesh.js
  66. 2 1
      Babylon/Mesh/babylon.abstractMesh.js
  67. 2 1
      Babylon/Mesh/babylon.csg.js
  68. 2 1
      Babylon/Mesh/babylon.geometry.js
  69. 2 1
      Babylon/Mesh/babylon.groundMesh.js
  70. 2 1
      Babylon/Mesh/babylon.linesMesh.js
  71. 1062 1055
      Babylon/Mesh/babylon.mesh.js
  72. 133 1
      Babylon/Mesh/babylon.mesh.vertexData.js
  73. 2 1
      Babylon/Mesh/babylon.meshLODLevel.js
  74. 2 1
      Babylon/Mesh/babylon.meshSimplification.js
  75. 2 1
      Babylon/Mesh/babylon.polygonmesh.js
  76. 144 143
      Babylon/Mesh/babylon.subMesh.js
  77. 2 1
      Babylon/Mesh/babylon.vertexBuffer.js
  78. 31 30
      Babylon/Particles/babylon.particle.js
  79. 338 337
      Babylon/Particles/babylon.particleSystem.js
  80. 2 1
      Babylon/Physics/Plugins/babylon.cannonJSPlugin.js
  81. 2 1
      Babylon/Physics/Plugins/babylon.oimoJSPlugin.js
  82. 2 1
      Babylon/Physics/babylon.physicsEngine.js
  83. 2 1
      Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderEffect.js
  84. 2 1
      Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPass.js
  85. 2 1
      Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.js
  86. 2 1
      Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPipelineManager.js
  87. 2 1
      Babylon/PostProcess/babylon.anaglyphPostProcess.js
  88. 2 1
      Babylon/PostProcess/babylon.blackAndWhitePostProcess.js
  89. 2 1
      Babylon/PostProcess/babylon.blurPostProcess.js
  90. 2 1
      Babylon/PostProcess/babylon.convolutionPostProcess.js
  91. 2 1
      Babylon/PostProcess/babylon.displayPassPostProcess.js
  92. 2 1
      Babylon/PostProcess/babylon.filterPostProcess.js
  93. 27 26
      Babylon/PostProcess/babylon.fxaaPostProcess.js
  94. 2 1
      Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js
  95. 2 1
      Babylon/PostProcess/babylon.passPostProcess.js
  96. 102 101
      Babylon/PostProcess/babylon.postProcess.js
  97. 2 1
      Babylon/PostProcess/babylon.postProcessManager.js
  98. 2 1
      Babylon/PostProcess/babylon.refractionPostProcess.js
  99. 2 1
      Babylon/PostProcess/babylon.ssaoRenderingPipeline.js
  100. 0 0
      Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js

+ 2 - 1
Babylon/Actions/babylon.action.js

@@ -66,4 +66,5 @@ var BABYLON;
     })();
     BABYLON.Action = Action;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.action.js.map
+
+//# sourceMappingURL=../Actions/babylon.action.js.map

+ 2 - 1
Babylon/Actions/babylon.actionManager.js

@@ -260,4 +260,5 @@ var BABYLON;
     })();
     BABYLON.ActionManager = ActionManager;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.actionManager.js.map
+
+//# sourceMappingURL=../Actions/babylon.actionManager.js.map

+ 2 - 1
Babylon/Actions/babylon.condition.js

@@ -116,4 +116,5 @@ var BABYLON;
     })(Condition);
     BABYLON.StateCondition = StateCondition;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.condition.js.map
+
+//# sourceMappingURL=../Actions/babylon.condition.js.map

+ 2 - 1
Babylon/Actions/babylon.directActions.js

@@ -203,4 +203,5 @@ var BABYLON;
     })(BABYLON.Action);
     BABYLON.StopSoundAction = StopSoundAction;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.directActions.js.map
+
+//# sourceMappingURL=../Actions/babylon.directActions.js.map

+ 2 - 1
Babylon/Actions/babylon.interpolateValueAction.js

@@ -64,4 +64,5 @@ var BABYLON;
     })(BABYLON.Action);
     BABYLON.InterpolateValueAction = InterpolateValueAction;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.interpolateValueAction.js.map
+
+//# sourceMappingURL=../Actions/babylon.interpolateValueAction.js.map

+ 91 - 90
Babylon/Animations/babylon.animatable.js

@@ -1,90 +1,91 @@
-var BABYLON;
-(function (BABYLON) {
-    var Animatable = (function () {
-        function Animatable(scene, target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
-            if (fromFrame === void 0) { fromFrame = 0; }
-            if (toFrame === void 0) { toFrame = 100; }
-            if (loopAnimation === void 0) { loopAnimation = false; }
-            if (speedRatio === void 0) { speedRatio = 1.0; }
-            this.target = target;
-            this.fromFrame = fromFrame;
-            this.toFrame = toFrame;
-            this.loopAnimation = loopAnimation;
-            this.speedRatio = speedRatio;
-            this.onAnimationEnd = onAnimationEnd;
-            this._animations = new Array();
-            this._paused = false;
-            this.animationStarted = false;
-            if (animations) {
-                this.appendAnimations(target, animations);
-            }
-            this._scene = scene;
-            scene._activeAnimatables.push(this);
-        }
-        // Methods
-        Animatable.prototype.appendAnimations = function (target, animations) {
-            for (var index = 0; index < animations.length; index++) {
-                var animation = animations[index];
-                animation._target = target;
-                this._animations.push(animation);
-            }
-        };
-        Animatable.prototype.getAnimationByTargetProperty = function (property) {
-            var animations = this._animations;
-            for (var index = 0; index < animations.length; index++) {
-                if (animations[index].targetProperty === property) {
-                    return animations[index];
-                }
-            }
-            return null;
-        };
-        Animatable.prototype.pause = function () {
-            if (this._paused) {
-                return;
-            }
-            this._paused = true;
-        };
-        Animatable.prototype.restart = function () {
-            this._paused = false;
-        };
-        Animatable.prototype.stop = function () {
-            var index = this._scene._activeAnimatables.indexOf(this);
-            if (index > -1) {
-                this._scene._activeAnimatables.splice(index, 1);
-            }
-            if (this.onAnimationEnd) {
-                this.onAnimationEnd();
-            }
-        };
-        Animatable.prototype._animate = function (delay) {
-            if (this._paused) {
-                if (!this._pausedDelay) {
-                    this._pausedDelay = delay;
-                }
-                return true;
-            }
-            if (!this._localDelayOffset) {
-                this._localDelayOffset = delay;
-            }
-            else if (this._pausedDelay) {
-                this._localDelayOffset += delay - this._pausedDelay;
-                this._pausedDelay = null;
-            }
-            // Animating
-            var running = false;
-            var animations = this._animations;
-            for (var index = 0; index < animations.length; index++) {
-                var animation = animations[index];
-                var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
-                running = running || isRunning;
-            }
-            if (!running && this.onAnimationEnd) {
-                this.onAnimationEnd();
-            }
-            return running;
-        };
-        return Animatable;
-    })();
-    BABYLON.Animatable = Animatable;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.animatable.js.map
+var BABYLON;
+(function (BABYLON) {
+    var Animatable = (function () {
+        function Animatable(scene, target, fromFrame, toFrame, loopAnimation, speedRatio, onAnimationEnd, animations) {
+            if (fromFrame === void 0) { fromFrame = 0; }
+            if (toFrame === void 0) { toFrame = 100; }
+            if (loopAnimation === void 0) { loopAnimation = false; }
+            if (speedRatio === void 0) { speedRatio = 1.0; }
+            this.target = target;
+            this.fromFrame = fromFrame;
+            this.toFrame = toFrame;
+            this.loopAnimation = loopAnimation;
+            this.speedRatio = speedRatio;
+            this.onAnimationEnd = onAnimationEnd;
+            this._animations = new Array();
+            this._paused = false;
+            this.animationStarted = false;
+            if (animations) {
+                this.appendAnimations(target, animations);
+            }
+            this._scene = scene;
+            scene._activeAnimatables.push(this);
+        }
+        // Methods
+        Animatable.prototype.appendAnimations = function (target, animations) {
+            for (var index = 0; index < animations.length; index++) {
+                var animation = animations[index];
+                animation._target = target;
+                this._animations.push(animation);
+            }
+        };
+        Animatable.prototype.getAnimationByTargetProperty = function (property) {
+            var animations = this._animations;
+            for (var index = 0; index < animations.length; index++) {
+                if (animations[index].targetProperty === property) {
+                    return animations[index];
+                }
+            }
+            return null;
+        };
+        Animatable.prototype.pause = function () {
+            if (this._paused) {
+                return;
+            }
+            this._paused = true;
+        };
+        Animatable.prototype.restart = function () {
+            this._paused = false;
+        };
+        Animatable.prototype.stop = function () {
+            var index = this._scene._activeAnimatables.indexOf(this);
+            if (index > -1) {
+                this._scene._activeAnimatables.splice(index, 1);
+            }
+            if (this.onAnimationEnd) {
+                this.onAnimationEnd();
+            }
+        };
+        Animatable.prototype._animate = function (delay) {
+            if (this._paused) {
+                if (!this._pausedDelay) {
+                    this._pausedDelay = delay;
+                }
+                return true;
+            }
+            if (!this._localDelayOffset) {
+                this._localDelayOffset = delay;
+            }
+            else if (this._pausedDelay) {
+                this._localDelayOffset += delay - this._pausedDelay;
+                this._pausedDelay = null;
+            }
+            // Animating
+            var running = false;
+            var animations = this._animations;
+            for (var index = 0; index < animations.length; index++) {
+                var animation = animations[index];
+                var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this.speedRatio);
+                running = running || isRunning;
+            }
+            if (!running && this.onAnimationEnd) {
+                this.onAnimationEnd();
+            }
+            return running;
+        };
+        return Animatable;
+    })();
+    BABYLON.Animatable = Animatable;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Animations/babylon.animatable.js.map

+ 357 - 356
Babylon/Animations/babylon.animation.js

@@ -1,356 +1,357 @@
-var BABYLON;
-(function (BABYLON) {
-    var Animation = (function () {
-        function Animation(name, targetProperty, framePerSecond, dataType, loopMode) {
-            this.name = name;
-            this.targetProperty = targetProperty;
-            this.framePerSecond = framePerSecond;
-            this.dataType = dataType;
-            this.loopMode = loopMode;
-            this._offsetsCache = {};
-            this._highLimitsCache = {};
-            this._stopped = false;
-            this.targetPropertyPath = targetProperty.split(".");
-            this.dataType = dataType;
-            this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
-        }
-        Animation.CreateAndStartAnimation = function (name, mesh, tartgetProperty, framePerSecond, totalFrame, from, to, loopMode) {
-            var dataType = undefined;
-            if (!isNaN(parseFloat(from)) && isFinite(from)) {
-                dataType = Animation.ANIMATIONTYPE_FLOAT;
-            }
-            else if (from instanceof BABYLON.Quaternion) {
-                dataType = Animation.ANIMATIONTYPE_QUATERNION;
-            }
-            else if (from instanceof BABYLON.Vector3) {
-                dataType = Animation.ANIMATIONTYPE_VECTOR3;
-            }
-            else if (from instanceof BABYLON.Vector2) {
-                dataType = Animation.ANIMATIONTYPE_VECTOR2;
-            }
-            else if (from instanceof BABYLON.Color3) {
-                dataType = Animation.ANIMATIONTYPE_COLOR3;
-            }
-            if (dataType == undefined) {
-                return;
-            }
-            var animation = new Animation(name, tartgetProperty, framePerSecond, dataType, loopMode);
-            var keys = [];
-            keys.push({ frame: 0, value: from });
-            keys.push({ frame: totalFrame, value: to });
-            animation.setKeys(keys);
-            mesh.animations.push(animation);
-            return mesh.getScene().beginAnimation(mesh, 0, totalFrame, (animation.loopMode === 1));
-        };
-        // Methods   
-        Animation.prototype.isStopped = function () {
-            return this._stopped;
-        };
-        Animation.prototype.getKeys = function () {
-            return this._keys;
-        };
-        Animation.prototype.getEasingFunction = function () {
-            return this._easingFunction;
-        };
-        Animation.prototype.setEasingFunction = function (easingFunction) {
-            this._easingFunction = easingFunction;
-        };
-        Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
-            return startValue + (endValue - startValue) * gradient;
-        };
-        Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
-            return BABYLON.Quaternion.Slerp(startValue, endValue, gradient);
-        };
-        Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
-            return BABYLON.Vector3.Lerp(startValue, endValue, gradient);
-        };
-        Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
-            return BABYLON.Vector2.Lerp(startValue, endValue, gradient);
-        };
-        Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
-            return BABYLON.Color3.Lerp(startValue, endValue, gradient);
-        };
-        Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient) {
-            var startScale = new BABYLON.Vector3(0, 0, 0);
-            var startRotation = new BABYLON.Quaternion();
-            var startTranslation = new BABYLON.Vector3(0, 0, 0);
-            startValue.decompose(startScale, startRotation, startTranslation);
-            var endScale = new BABYLON.Vector3(0, 0, 0);
-            var endRotation = new BABYLON.Quaternion();
-            var endTranslation = new BABYLON.Vector3(0, 0, 0);
-            endValue.decompose(endScale, endRotation, endTranslation);
-            var resultScale = this.vector3InterpolateFunction(startScale, endScale, gradient);
-            var resultRotation = this.quaternionInterpolateFunction(startRotation, endRotation, gradient);
-            var resultTranslation = this.vector3InterpolateFunction(startTranslation, endTranslation, gradient);
-            var result = BABYLON.Matrix.Compose(resultScale, resultRotation, resultTranslation);
-            return result;
-        };
-        Animation.prototype.clone = function () {
-            var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
-            clone.setKeys(this._keys);
-            return clone;
-        };
-        Animation.prototype.setKeys = function (values) {
-            this._keys = values.slice(0);
-            this._offsetsCache = {};
-            this._highLimitsCache = {};
-        };
-        Animation.prototype._getKeyValue = function (value) {
-            if (typeof value === "function") {
-                return value();
-            }
-            return value;
-        };
-        Animation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
-            if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
-                return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
-            }
-            this.currentFrame = currentFrame;
-            for (var key = 0; key < this._keys.length; key++) {
-                // for each frame, we need the key just before the frame superior
-                if (this._keys[key + 1].frame >= currentFrame) {
-                    var startValue = this._getKeyValue(this._keys[key].value);
-                    var endValue = this._getKeyValue(this._keys[key + 1].value);
-                    // gradient : percent of currentFrame between the frame inf and the frame sup
-                    var gradient = (currentFrame - this._keys[key].frame) / (this._keys[key + 1].frame - this._keys[key].frame);
-                    // check for easingFunction and correction of gradient
-                    if (this._easingFunction != null) {
-                        gradient = this._easingFunction.ease(gradient);
-                    }
-                    switch (this.dataType) {
-                        case Animation.ANIMATIONTYPE_FLOAT:
-                            switch (loopMode) {
-                                case Animation.ANIMATIONLOOPMODE_CYCLE:
-                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
-                                    return this.floatInterpolateFunction(startValue, endValue, gradient);
-                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
-                                    return offsetValue * repeatCount + this.floatInterpolateFunction(startValue, endValue, gradient);
-                            }
-                            break;
-                        case Animation.ANIMATIONTYPE_QUATERNION:
-                            var quaternion = null;
-                            switch (loopMode) {
-                                case Animation.ANIMATIONLOOPMODE_CYCLE:
-                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
-                                    quaternion = this.quaternionInterpolateFunction(startValue, endValue, gradient);
-                                    break;
-                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
-                                    quaternion = this.quaternionInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
-                                    break;
-                            }
-                            return quaternion;
-                        case Animation.ANIMATIONTYPE_VECTOR3:
-                            switch (loopMode) {
-                                case Animation.ANIMATIONLOOPMODE_CYCLE:
-                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
-                                    return this.vector3InterpolateFunction(startValue, endValue, gradient);
-                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
-                                    return this.vector3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
-                            }
-                        case Animation.ANIMATIONTYPE_VECTOR2:
-                            switch (loopMode) {
-                                case Animation.ANIMATIONLOOPMODE_CYCLE:
-                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
-                                    return this.vector2InterpolateFunction(startValue, endValue, gradient);
-                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
-                                    return this.vector2InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
-                            }
-                        case Animation.ANIMATIONTYPE_COLOR3:
-                            switch (loopMode) {
-                                case Animation.ANIMATIONLOOPMODE_CYCLE:
-                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
-                                    return this.color3InterpolateFunction(startValue, endValue, gradient);
-                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
-                                    return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
-                            }
-                        case Animation.ANIMATIONTYPE_MATRIX:
-                            switch (loopMode) {
-                                case Animation.ANIMATIONLOOPMODE_CYCLE:
-                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
-                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
-                                    return startValue;
-                            }
-                        default:
-                            break;
-                    }
-                    break;
-                }
-            }
-            return this._getKeyValue(this._keys[this._keys.length - 1].value);
-        };
-        Animation.prototype.animate = function (delay, from, to, loop, speedRatio) {
-            if (!this.targetPropertyPath || this.targetPropertyPath.length < 1) {
-                this._stopped = true;
-                return false;
-            }
-            var returnValue = true;
-            // Adding a start key at frame 0 if missing
-            if (this._keys[0].frame !== 0) {
-                var newKey = { frame: 0, value: this._keys[0].value };
-                this._keys.splice(0, 0, newKey);
-            }
-            // Check limits
-            if (from < this._keys[0].frame || from > this._keys[this._keys.length - 1].frame) {
-                from = this._keys[0].frame;
-            }
-            if (to < this._keys[0].frame || to > this._keys[this._keys.length - 1].frame) {
-                to = this._keys[this._keys.length - 1].frame;
-            }
-            // Compute ratio
-            var range = to - from;
-            var offsetValue;
-            // ratio represents the frame delta between from and to
-            var ratio = delay * (this.framePerSecond * speedRatio) / 1000.0;
-            var highLimitValue = 0;
-            if (ratio > range && !loop) {
-                returnValue = false;
-                highLimitValue = this._getKeyValue(this._keys[this._keys.length - 1].value);
-            }
-            else {
-                // Get max value if required
-                if (this.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
-                    var keyOffset = to.toString() + from.toString();
-                    if (!this._offsetsCache[keyOffset]) {
-                        var fromValue = this._interpolate(from, 0, Animation.ANIMATIONLOOPMODE_CYCLE);
-                        var toValue = this._interpolate(to, 0, Animation.ANIMATIONLOOPMODE_CYCLE);
-                        switch (this.dataType) {
-                            case Animation.ANIMATIONTYPE_FLOAT:
-                                this._offsetsCache[keyOffset] = toValue - fromValue;
-                                break;
-                            case Animation.ANIMATIONTYPE_QUATERNION:
-                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
-                                break;
-                            case Animation.ANIMATIONTYPE_VECTOR3:
-                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
-                            case Animation.ANIMATIONTYPE_VECTOR2:
-                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
-                            case Animation.ANIMATIONTYPE_COLOR3:
-                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
-                            default:
-                                break;
-                        }
-                        this._highLimitsCache[keyOffset] = toValue;
-                    }
-                    highLimitValue = this._highLimitsCache[keyOffset];
-                    offsetValue = this._offsetsCache[keyOffset];
-                }
-            }
-            if (offsetValue === undefined) {
-                switch (this.dataType) {
-                    case Animation.ANIMATIONTYPE_FLOAT:
-                        offsetValue = 0;
-                        break;
-                    case Animation.ANIMATIONTYPE_QUATERNION:
-                        offsetValue = new BABYLON.Quaternion(0, 0, 0, 0);
-                        break;
-                    case Animation.ANIMATIONTYPE_VECTOR3:
-                        offsetValue = BABYLON.Vector3.Zero();
-                        break;
-                    case Animation.ANIMATIONTYPE_VECTOR2:
-                        offsetValue = BABYLON.Vector2.Zero();
-                        break;
-                    case Animation.ANIMATIONTYPE_COLOR3:
-                        offsetValue = BABYLON.Color3.Black();
-                }
-            }
-            // Compute value
-            var repeatCount = (ratio / range) >> 0;
-            var currentFrame = returnValue ? from + ratio % range : to;
-            var currentValue = this._interpolate(currentFrame, repeatCount, this.loopMode, offsetValue, highLimitValue);
-            // Set value
-            if (this.targetPropertyPath.length > 1) {
-                var property = this._target[this.targetPropertyPath[0]];
-                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
-                    property = property[this.targetPropertyPath[index]];
-                }
-                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
-            }
-            else {
-                this._target[this.targetPropertyPath[0]] = currentValue;
-            }
-            if (this._target.markAsDirty) {
-                this._target.markAsDirty(this.targetProperty);
-            }
-            if (!returnValue) {
-                this._stopped = true;
-            }
-            return returnValue;
-        };
-        Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
-            get: function () {
-                return Animation._ANIMATIONTYPE_FLOAT;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
-            get: function () {
-                return Animation._ANIMATIONTYPE_VECTOR3;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
-            get: function () {
-                return Animation._ANIMATIONTYPE_VECTOR2;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
-            get: function () {
-                return Animation._ANIMATIONTYPE_QUATERNION;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
-            get: function () {
-                return Animation._ANIMATIONTYPE_MATRIX;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
-            get: function () {
-                return Animation._ANIMATIONTYPE_COLOR3;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
-            get: function () {
-                return Animation._ANIMATIONLOOPMODE_RELATIVE;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
-            get: function () {
-                return Animation._ANIMATIONLOOPMODE_CYCLE;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
-            get: function () {
-                return Animation._ANIMATIONLOOPMODE_CONSTANT;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        // Statics
-        Animation._ANIMATIONTYPE_FLOAT = 0;
-        Animation._ANIMATIONTYPE_VECTOR3 = 1;
-        Animation._ANIMATIONTYPE_QUATERNION = 2;
-        Animation._ANIMATIONTYPE_MATRIX = 3;
-        Animation._ANIMATIONTYPE_COLOR3 = 4;
-        Animation._ANIMATIONTYPE_VECTOR2 = 5;
-        Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
-        Animation._ANIMATIONLOOPMODE_CYCLE = 1;
-        Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
-        return Animation;
-    })();
-    BABYLON.Animation = Animation;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.animation.js.map
+var BABYLON;
+(function (BABYLON) {
+    var Animation = (function () {
+        function Animation(name, targetProperty, framePerSecond, dataType, loopMode) {
+            this.name = name;
+            this.targetProperty = targetProperty;
+            this.framePerSecond = framePerSecond;
+            this.dataType = dataType;
+            this.loopMode = loopMode;
+            this._offsetsCache = {};
+            this._highLimitsCache = {};
+            this._stopped = false;
+            this.targetPropertyPath = targetProperty.split(".");
+            this.dataType = dataType;
+            this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
+        }
+        Animation.CreateAndStartAnimation = function (name, mesh, tartgetProperty, framePerSecond, totalFrame, from, to, loopMode) {
+            var dataType = undefined;
+            if (!isNaN(parseFloat(from)) && isFinite(from)) {
+                dataType = Animation.ANIMATIONTYPE_FLOAT;
+            }
+            else if (from instanceof BABYLON.Quaternion) {
+                dataType = Animation.ANIMATIONTYPE_QUATERNION;
+            }
+            else if (from instanceof BABYLON.Vector3) {
+                dataType = Animation.ANIMATIONTYPE_VECTOR3;
+            }
+            else if (from instanceof BABYLON.Vector2) {
+                dataType = Animation.ANIMATIONTYPE_VECTOR2;
+            }
+            else if (from instanceof BABYLON.Color3) {
+                dataType = Animation.ANIMATIONTYPE_COLOR3;
+            }
+            if (dataType == undefined) {
+                return;
+            }
+            var animation = new Animation(name, tartgetProperty, framePerSecond, dataType, loopMode);
+            var keys = [];
+            keys.push({ frame: 0, value: from });
+            keys.push({ frame: totalFrame, value: to });
+            animation.setKeys(keys);
+            mesh.animations.push(animation);
+            return mesh.getScene().beginAnimation(mesh, 0, totalFrame, (animation.loopMode === 1));
+        };
+        // Methods   
+        Animation.prototype.isStopped = function () {
+            return this._stopped;
+        };
+        Animation.prototype.getKeys = function () {
+            return this._keys;
+        };
+        Animation.prototype.getEasingFunction = function () {
+            return this._easingFunction;
+        };
+        Animation.prototype.setEasingFunction = function (easingFunction) {
+            this._easingFunction = easingFunction;
+        };
+        Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
+            return startValue + (endValue - startValue) * gradient;
+        };
+        Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
+            return BABYLON.Quaternion.Slerp(startValue, endValue, gradient);
+        };
+        Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
+            return BABYLON.Vector3.Lerp(startValue, endValue, gradient);
+        };
+        Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
+            return BABYLON.Vector2.Lerp(startValue, endValue, gradient);
+        };
+        Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
+            return BABYLON.Color3.Lerp(startValue, endValue, gradient);
+        };
+        Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient) {
+            var startScale = new BABYLON.Vector3(0, 0, 0);
+            var startRotation = new BABYLON.Quaternion();
+            var startTranslation = new BABYLON.Vector3(0, 0, 0);
+            startValue.decompose(startScale, startRotation, startTranslation);
+            var endScale = new BABYLON.Vector3(0, 0, 0);
+            var endRotation = new BABYLON.Quaternion();
+            var endTranslation = new BABYLON.Vector3(0, 0, 0);
+            endValue.decompose(endScale, endRotation, endTranslation);
+            var resultScale = this.vector3InterpolateFunction(startScale, endScale, gradient);
+            var resultRotation = this.quaternionInterpolateFunction(startRotation, endRotation, gradient);
+            var resultTranslation = this.vector3InterpolateFunction(startTranslation, endTranslation, gradient);
+            var result = BABYLON.Matrix.Compose(resultScale, resultRotation, resultTranslation);
+            return result;
+        };
+        Animation.prototype.clone = function () {
+            var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
+            clone.setKeys(this._keys);
+            return clone;
+        };
+        Animation.prototype.setKeys = function (values) {
+            this._keys = values.slice(0);
+            this._offsetsCache = {};
+            this._highLimitsCache = {};
+        };
+        Animation.prototype._getKeyValue = function (value) {
+            if (typeof value === "function") {
+                return value();
+            }
+            return value;
+        };
+        Animation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
+            if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
+                return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
+            }
+            this.currentFrame = currentFrame;
+            for (var key = 0; key < this._keys.length; key++) {
+                // for each frame, we need the key just before the frame superior
+                if (this._keys[key + 1].frame >= currentFrame) {
+                    var startValue = this._getKeyValue(this._keys[key].value);
+                    var endValue = this._getKeyValue(this._keys[key + 1].value);
+                    // gradient : percent of currentFrame between the frame inf and the frame sup
+                    var gradient = (currentFrame - this._keys[key].frame) / (this._keys[key + 1].frame - this._keys[key].frame);
+                    // check for easingFunction and correction of gradient
+                    if (this._easingFunction != null) {
+                        gradient = this._easingFunction.ease(gradient);
+                    }
+                    switch (this.dataType) {
+                        case Animation.ANIMATIONTYPE_FLOAT:
+                            switch (loopMode) {
+                                case Animation.ANIMATIONLOOPMODE_CYCLE:
+                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
+                                    return this.floatInterpolateFunction(startValue, endValue, gradient);
+                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
+                                    return offsetValue * repeatCount + this.floatInterpolateFunction(startValue, endValue, gradient);
+                            }
+                            break;
+                        case Animation.ANIMATIONTYPE_QUATERNION:
+                            var quaternion = null;
+                            switch (loopMode) {
+                                case Animation.ANIMATIONLOOPMODE_CYCLE:
+                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
+                                    quaternion = this.quaternionInterpolateFunction(startValue, endValue, gradient);
+                                    break;
+                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
+                                    quaternion = this.quaternionInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
+                                    break;
+                            }
+                            return quaternion;
+                        case Animation.ANIMATIONTYPE_VECTOR3:
+                            switch (loopMode) {
+                                case Animation.ANIMATIONLOOPMODE_CYCLE:
+                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
+                                    return this.vector3InterpolateFunction(startValue, endValue, gradient);
+                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
+                                    return this.vector3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
+                            }
+                        case Animation.ANIMATIONTYPE_VECTOR2:
+                            switch (loopMode) {
+                                case Animation.ANIMATIONLOOPMODE_CYCLE:
+                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
+                                    return this.vector2InterpolateFunction(startValue, endValue, gradient);
+                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
+                                    return this.vector2InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
+                            }
+                        case Animation.ANIMATIONTYPE_COLOR3:
+                            switch (loopMode) {
+                                case Animation.ANIMATIONLOOPMODE_CYCLE:
+                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
+                                    return this.color3InterpolateFunction(startValue, endValue, gradient);
+                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
+                                    return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
+                            }
+                        case Animation.ANIMATIONTYPE_MATRIX:
+                            switch (loopMode) {
+                                case Animation.ANIMATIONLOOPMODE_CYCLE:
+                                case Animation.ANIMATIONLOOPMODE_CONSTANT:
+                                case Animation.ANIMATIONLOOPMODE_RELATIVE:
+                                    return startValue;
+                            }
+                        default:
+                            break;
+                    }
+                    break;
+                }
+            }
+            return this._getKeyValue(this._keys[this._keys.length - 1].value);
+        };
+        Animation.prototype.animate = function (delay, from, to, loop, speedRatio) {
+            if (!this.targetPropertyPath || this.targetPropertyPath.length < 1) {
+                this._stopped = true;
+                return false;
+            }
+            var returnValue = true;
+            // Adding a start key at frame 0 if missing
+            if (this._keys[0].frame !== 0) {
+                var newKey = { frame: 0, value: this._keys[0].value };
+                this._keys.splice(0, 0, newKey);
+            }
+            // Check limits
+            if (from < this._keys[0].frame || from > this._keys[this._keys.length - 1].frame) {
+                from = this._keys[0].frame;
+            }
+            if (to < this._keys[0].frame || to > this._keys[this._keys.length - 1].frame) {
+                to = this._keys[this._keys.length - 1].frame;
+            }
+            // Compute ratio
+            var range = to - from;
+            var offsetValue;
+            // ratio represents the frame delta between from and to
+            var ratio = delay * (this.framePerSecond * speedRatio) / 1000.0;
+            var highLimitValue = 0;
+            if (ratio > range && !loop) {
+                returnValue = false;
+                highLimitValue = this._getKeyValue(this._keys[this._keys.length - 1].value);
+            }
+            else {
+                // Get max value if required
+                if (this.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
+                    var keyOffset = to.toString() + from.toString();
+                    if (!this._offsetsCache[keyOffset]) {
+                        var fromValue = this._interpolate(from, 0, Animation.ANIMATIONLOOPMODE_CYCLE);
+                        var toValue = this._interpolate(to, 0, Animation.ANIMATIONLOOPMODE_CYCLE);
+                        switch (this.dataType) {
+                            case Animation.ANIMATIONTYPE_FLOAT:
+                                this._offsetsCache[keyOffset] = toValue - fromValue;
+                                break;
+                            case Animation.ANIMATIONTYPE_QUATERNION:
+                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
+                                break;
+                            case Animation.ANIMATIONTYPE_VECTOR3:
+                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
+                            case Animation.ANIMATIONTYPE_VECTOR2:
+                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
+                            case Animation.ANIMATIONTYPE_COLOR3:
+                                this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
+                            default:
+                                break;
+                        }
+                        this._highLimitsCache[keyOffset] = toValue;
+                    }
+                    highLimitValue = this._highLimitsCache[keyOffset];
+                    offsetValue = this._offsetsCache[keyOffset];
+                }
+            }
+            if (offsetValue === undefined) {
+                switch (this.dataType) {
+                    case Animation.ANIMATIONTYPE_FLOAT:
+                        offsetValue = 0;
+                        break;
+                    case Animation.ANIMATIONTYPE_QUATERNION:
+                        offsetValue = new BABYLON.Quaternion(0, 0, 0, 0);
+                        break;
+                    case Animation.ANIMATIONTYPE_VECTOR3:
+                        offsetValue = BABYLON.Vector3.Zero();
+                        break;
+                    case Animation.ANIMATIONTYPE_VECTOR2:
+                        offsetValue = BABYLON.Vector2.Zero();
+                        break;
+                    case Animation.ANIMATIONTYPE_COLOR3:
+                        offsetValue = BABYLON.Color3.Black();
+                }
+            }
+            // Compute value
+            var repeatCount = (ratio / range) >> 0;
+            var currentFrame = returnValue ? from + ratio % range : to;
+            var currentValue = this._interpolate(currentFrame, repeatCount, this.loopMode, offsetValue, highLimitValue);
+            // Set value
+            if (this.targetPropertyPath.length > 1) {
+                var property = this._target[this.targetPropertyPath[0]];
+                for (var index = 1; index < this.targetPropertyPath.length - 1; index++) {
+                    property = property[this.targetPropertyPath[index]];
+                }
+                property[this.targetPropertyPath[this.targetPropertyPath.length - 1]] = currentValue;
+            }
+            else {
+                this._target[this.targetPropertyPath[0]] = currentValue;
+            }
+            if (this._target.markAsDirty) {
+                this._target.markAsDirty(this.targetProperty);
+            }
+            if (!returnValue) {
+                this._stopped = true;
+            }
+            return returnValue;
+        };
+        Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_FLOAT;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_VECTOR3;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_VECTOR2;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_QUATERNION;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_MATRIX;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_COLOR3;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
+            get: function () {
+                return Animation._ANIMATIONLOOPMODE_RELATIVE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
+            get: function () {
+                return Animation._ANIMATIONLOOPMODE_CYCLE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
+            get: function () {
+                return Animation._ANIMATIONLOOPMODE_CONSTANT;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        // Statics
+        Animation._ANIMATIONTYPE_FLOAT = 0;
+        Animation._ANIMATIONTYPE_VECTOR3 = 1;
+        Animation._ANIMATIONTYPE_QUATERNION = 2;
+        Animation._ANIMATIONTYPE_MATRIX = 3;
+        Animation._ANIMATIONTYPE_COLOR3 = 4;
+        Animation._ANIMATIONTYPE_VECTOR2 = 5;
+        Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
+        Animation._ANIMATIONLOOPMODE_CYCLE = 1;
+        Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
+        return Animation;
+    })();
+    BABYLON.Animation = Animation;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Animations/babylon.animation.js.map

+ 2 - 1
Babylon/Animations/babylon.easing.js

@@ -248,4 +248,5 @@ var BABYLON;
     })(EasingFunction);
     BABYLON.BezierCurveEase = BezierCurveEase;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.easing.js.map
+
+//# sourceMappingURL=../Animations/babylon.easing.js.map

+ 2 - 1
Babylon/Audio/babylon.analyser.js

@@ -108,4 +108,5 @@ var BABYLON;
     })();
     BABYLON.Analyser = Analyser;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.analyser.js.map
+
+//# sourceMappingURL=../Audio/babylon.analyser.js.map

+ 2 - 1
Babylon/Audio/babylon.audioengine.js

@@ -66,4 +66,5 @@ var BABYLON;
     })();
     BABYLON.AudioEngine = AudioEngine;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.audioengine.js.map
+
+//# sourceMappingURL=../Audio/babylon.audioengine.js.map

+ 2 - 1
Babylon/Audio/babylon.sound.js

@@ -338,4 +338,5 @@ var BABYLON;
     })();
     BABYLON.Sound = Sound;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.sound.js.map
+
+//# sourceMappingURL=../Audio/babylon.sound.js.map

+ 2 - 1
Babylon/Audio/babylon.soundtrack.js

@@ -76,4 +76,5 @@ var BABYLON;
     })();
     BABYLON.SoundTrack = SoundTrack;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.soundtrack.js.map
+
+//# sourceMappingURL=../Audio/babylon.soundtrack.js.map

+ 2 - 1
Babylon/Bones/babylon.bone.js

@@ -71,4 +71,5 @@ var BABYLON;
     })();
     BABYLON.Bone = Bone;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.bone.js.map
+
+//# sourceMappingURL=../Bones/babylon.bone.js.map

+ 2 - 1
Babylon/Bones/babylon.skeleton.js

@@ -67,4 +67,5 @@ var BABYLON;
     })();
     BABYLON.Skeleton = Skeleton;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.skeleton.js.map
+
+//# sourceMappingURL=../Bones/babylon.skeleton.js.map

+ 2 - 1
Babylon/Cameras/VR/babylon.oculusCamera.js

@@ -112,4 +112,5 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     BABYLON.OculusCamera = OculusCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.oculusCamera.js.map
+
+//# sourceMappingURL=../../Cameras/VR/babylon.oculusCamera.js.map

+ 2 - 1
Babylon/Cameras/VR/babylon.oculusGamepadCamera.js

@@ -141,4 +141,5 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     BABYLON.OculusGamepadCamera = OculusGamepadCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.oculusGamepadCamera.js.map
+
+//# sourceMappingURL=../../Cameras/VR/babylon.oculusGamepadCamera.js.map

+ 2 - 1
Babylon/Cameras/VR/babylon.vrDeviceOrientationCamera.js

@@ -33,4 +33,5 @@ var BABYLON;
     })(BABYLON.OculusCamera);
     BABYLON.VRDeviceOrientationCamera = VRDeviceOrientationCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.vrDeviceOrientationCamera.js.map
+
+//# sourceMappingURL=../../Cameras/VR/babylon.vrDeviceOrientationCamera.js.map

+ 2 - 1
Babylon/Cameras/VR/babylon.webVRCamera.js

@@ -67,4 +67,5 @@ var BABYLON;
     })(BABYLON.OculusCamera);
     BABYLON.WebVRCamera = WebVRCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.webVRCamera.js.map
+
+//# sourceMappingURL=../../Cameras/VR/babylon.webVRCamera.js.map

+ 2 - 1
Babylon/Cameras/babylon.anaglyphCamera.js

@@ -79,4 +79,5 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     BABYLON.AnaglyphFreeCamera = AnaglyphFreeCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.anaglyphCamera.js.map
+
+//# sourceMappingURL=../Cameras/babylon.anaglyphCamera.js.map

+ 447 - 446
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -1,446 +1,447 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var eventPrefix = BABYLON.Tools.GetPointerPrefix();
-    var ArcRotateCamera = (function (_super) {
-        __extends(ArcRotateCamera, _super);
-        function ArcRotateCamera(name, alpha, beta, radius, target, scene) {
-            _super.call(this, name, BABYLON.Vector3.Zero(), scene);
-            this.alpha = alpha;
-            this.beta = beta;
-            this.radius = radius;
-            this.target = target;
-            this.inertialAlphaOffset = 0;
-            this.inertialBetaOffset = 0;
-            this.inertialRadiusOffset = 0;
-            this.lowerAlphaLimit = null;
-            this.upperAlphaLimit = null;
-            this.lowerBetaLimit = 0.01;
-            this.upperBetaLimit = Math.PI;
-            this.lowerRadiusLimit = null;
-            this.upperRadiusLimit = null;
-            this.angularSensibility = 1000.0;
-            this.wheelPrecision = 3.0;
-            this.keysUp = [38];
-            this.keysDown = [40];
-            this.keysLeft = [37];
-            this.keysRight = [39];
-            this.zoomOnFactor = 1;
-            this.targetScreenOffset = BABYLON.Vector2.Zero();
-            this._keys = [];
-            this._viewMatrix = new BABYLON.Matrix();
-            this.checkCollisions = false;
-            this.collisionRadius = new BABYLON.Vector3(0.5, 0.5, 0.5);
-            this._collider = new BABYLON.Collider();
-            this._previousPosition = BABYLON.Vector3.Zero();
-            this._collisionVelocity = BABYLON.Vector3.Zero();
-            this._newPosition = BABYLON.Vector3.Zero();
-            // Pinch
-            // value for pinch step scaling
-            // set to 20 by default
-            this.pinchPrecision = 20;
-            this.getViewMatrix();
-        }
-        ArcRotateCamera.prototype._getTargetPosition = function () {
-            return this.target.position || this.target;
-        };
-        // Cache
-        ArcRotateCamera.prototype._initCache = function () {
-            _super.prototype._initCache.call(this);
-            this._cache.target = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
-            this._cache.alpha = undefined;
-            this._cache.beta = undefined;
-            this._cache.radius = undefined;
-            this._cache.targetScreenOffset = undefined;
-        };
-        ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
-            if (!ignoreParentClass) {
-                _super.prototype._updateCache.call(this);
-            }
-            this._cache.target.copyFrom(this._getTargetPosition());
-            this._cache.alpha = this.alpha;
-            this._cache.beta = this.beta;
-            this._cache.radius = this.radius;
-            this._cache.targetScreenOffset = this.targetScreenOffset.clone();
-        };
-        // Synchronized
-        ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
-            if (!_super.prototype._isSynchronizedViewMatrix.call(this))
-                return false;
-            return this._cache.target.equals(this._getTargetPosition()) && this._cache.alpha === this.alpha && this._cache.beta === this.beta && this._cache.radius === this.radius && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
-        };
-        // Methods
-        ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault) {
-            var _this = this;
-            var previousPosition;
-            var pointerId;
-            // to know if pinch started
-            var pinchStarted = false;
-            // two pinch point on X
-            // that will use for find if user action is pinch open or pinch close
-            var pinchPointX1, pinchPointX2;
-            if (this._attachedElement) {
-                return;
-            }
-            this._attachedElement = element;
-            var engine = this.getEngine();
-            if (this._onPointerDown === undefined) {
-                this._onPointerDown = function (evt) {
-                    if (pointerId) {
-                        return;
-                    }
-                    pointerId = evt.pointerId;
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
-                    };
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onPointerUp = function (evt) {
-                    previousPosition = null;
-                    pointerId = null;
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onPointerMove = function (evt) {
-                    if (!previousPosition) {
-                        return;
-                    }
-                    if (pointerId !== evt.pointerId) {
-                        return;
-                    }
-                    // return pinch is started
-                    if (pinchStarted) {
-                        return;
-                    }
-                    var offsetX = evt.clientX - previousPosition.x;
-                    var offsetY = evt.clientY - previousPosition.y;
-                    _this.inertialAlphaOffset -= offsetX / _this.angularSensibility;
-                    _this.inertialBetaOffset -= offsetY / _this.angularSensibility;
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
-                    };
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onMouseMove = function (evt) {
-                    if (!engine.isPointerLock) {
-                        return;
-                    }
-                    // return pinch is started
-                    if (pinchStarted) {
-                        return;
-                    }
-                    var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
-                    var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
-                    _this.inertialAlphaOffset -= offsetX / _this.angularSensibility;
-                    _this.inertialBetaOffset -= offsetY / _this.angularSensibility;
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._wheel = function (event) {
-                    var delta = 0;
-                    if (event.wheelDelta) {
-                        delta = event.wheelDelta / (_this.wheelPrecision * 40);
-                    }
-                    else if (event.detail) {
-                        delta = -event.detail / _this.wheelPrecision;
-                    }
-                    if (delta)
-                        _this.inertialRadiusOffset += delta;
-                    if (event.preventDefault) {
-                        if (!noPreventDefault) {
-                            event.preventDefault();
-                        }
-                    }
-                };
-                this._onKeyDown = function (evt) {
-                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
-                        var index = _this._keys.indexOf(evt.keyCode);
-                        if (index === -1) {
-                            _this._keys.push(evt.keyCode);
-                        }
-                        if (evt.preventDefault) {
-                            if (!noPreventDefault) {
-                                evt.preventDefault();
-                            }
-                        }
-                    }
-                };
-                this._onKeyUp = function (evt) {
-                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
-                        var index = _this._keys.indexOf(evt.keyCode);
-                        if (index >= 0) {
-                            _this._keys.splice(index, 1);
-                        }
-                        if (evt.preventDefault) {
-                            if (!noPreventDefault) {
-                                evt.preventDefault();
-                            }
-                        }
-                    }
-                };
-                this._onLostFocus = function () {
-                    _this._keys = [];
-                    pointerId = null;
-                };
-                this._onGestureStart = function (e) {
-                    if (window.MSGesture === undefined) {
-                        return;
-                    }
-                    if (!_this._MSGestureHandler) {
-                        _this._MSGestureHandler = new MSGesture();
-                        _this._MSGestureHandler.target = element;
-                    }
-                    _this._MSGestureHandler.addPointer(e.pointerId);
-                };
-                this._onGesture = function (e) {
-                    _this.radius *= e.scale;
-                    if (e.preventDefault) {
-                        if (!noPreventDefault) {
-                            e.stopPropagation();
-                            e.preventDefault();
-                        }
-                    }
-                };
-                this._reset = function () {
-                    _this._keys = [];
-                    _this.inertialAlphaOffset = 0;
-                    _this.inertialBetaOffset = 0;
-                    _this.inertialRadiusOffset = 0;
-                    previousPosition = null;
-                    pointerId = null;
-                };
-                this._touchStart = function (event) {
-                    if (event.touches.length === 2) {
-                        //-- start pinch if two fingers on the screen
-                        pinchStarted = true;
-                        _this._pinchStart(event);
-                    }
-                };
-                this._touchMove = function (event) {
-                    if (pinchStarted) {
-                        //-- make scaling
-                        _this._pinchMove(event);
-                    }
-                };
-                this._touchEnd = function (event) {
-                    if (pinchStarted) {
-                        //-- end of pinch
-                        _this._pinchEnd(event);
-                    }
-                };
-                this._pinchStart = function (event) {
-                    // save origin touch point
-                    pinchPointX1 = event.touches[0].clientX;
-                    pinchPointX2 = event.touches[1].clientX;
-                    // block the camera 
-                    // if not it rotate around target during pinch
-                    pinchStarted = true;
-                };
-                this._pinchMove = function (event) {
-                    // variable for new camera's radius
-                    var delta = 0;
-                    // variables to know if pinch open or pinch close
-                    var direction = 1;
-                    var distanceXOrigine, distanceXNow;
-                    if (event.touches.length !== 2)
-                        return;
-                    // calculate absolute distances of the two fingers
-                    distanceXOrigine = Math.abs(pinchPointX1 - pinchPointX2);
-                    distanceXNow = Math.abs(event.touches[0].clientX - event.touches[1].clientX);
-                    // if distanceXNow < distanceXOrigine -> pinch close so direction = -1
-                    if (distanceXNow < distanceXOrigine) {
-                        direction = -1;
-                    }
-                    // calculate new radius
-                    delta = (_this.pinchPrecision / (_this.wheelPrecision * 40)) * direction;
-                    // set new radius
-                    _this.inertialRadiusOffset -= delta;
-                    // save origin touch point
-                    pinchPointX1 = event.touches[0].clientX;
-                    pinchPointX2 = event.touches[1].clientX;
-                };
-                this._pinchEnd = function (event) {
-                    // cancel pinch and deblock camera rotation
-                    pinchStarted = false;
-                };
-            }
-            element.addEventListener(eventPrefix + "down", this._onPointerDown, false);
-            element.addEventListener(eventPrefix + "up", this._onPointerUp, false);
-            element.addEventListener(eventPrefix + "out", this._onPointerUp, false);
-            element.addEventListener(eventPrefix + "move", this._onPointerMove, false);
-            element.addEventListener("mousemove", this._onMouseMove, false);
-            element.addEventListener("MSPointerDown", this._onGestureStart, false);
-            element.addEventListener("MSGestureChange", this._onGesture, false);
-            element.addEventListener('mousewheel', this._wheel, false);
-            element.addEventListener('DOMMouseScroll', this._wheel, false);
-            // pinch
-            element.addEventListener('touchstart', this._touchStart, false);
-            element.addEventListener('touchmove', this._touchMove, false);
-            element.addEventListener('touchend', this._touchEnd, false);
-            BABYLON.Tools.RegisterTopRootEvents([
-                { name: "keydown", handler: this._onKeyDown },
-                { name: "keyup", handler: this._onKeyUp },
-                { name: "blur", handler: this._onLostFocus }
-            ]);
-        };
-        ArcRotateCamera.prototype.detachControl = function (element) {
-            if (this._attachedElement != element) {
-                return;
-            }
-            element.removeEventListener(eventPrefix + "down", this._onPointerDown);
-            element.removeEventListener(eventPrefix + "up", this._onPointerUp);
-            element.removeEventListener(eventPrefix + "out", this._onPointerUp);
-            element.removeEventListener(eventPrefix + "move", this._onPointerMove);
-            element.removeEventListener("mousemove", this._onMouseMove);
-            element.removeEventListener("MSPointerDown", this._onGestureStart);
-            element.removeEventListener("MSGestureChange", this._onGesture);
-            element.removeEventListener('mousewheel', this._wheel);
-            element.removeEventListener('DOMMouseScroll', this._wheel);
-            // pinch
-            element.removeEventListener('touchstart', this._touchStart);
-            element.removeEventListener('touchmove', this._touchMove);
-            element.removeEventListener('touchend', this._touchEnd);
-            BABYLON.Tools.UnregisterTopRootEvents([
-                { name: "keydown", handler: this._onKeyDown },
-                { name: "keyup", handler: this._onKeyUp },
-                { name: "blur", handler: this._onLostFocus }
-            ]);
-            this._MSGestureHandler = null;
-            this._attachedElement = null;
-            if (this._reset) {
-                this._reset();
-            }
-        };
-        ArcRotateCamera.prototype._update = function () {
-            for (var index = 0; index < this._keys.length; index++) {
-                var keyCode = this._keys[index];
-                if (this.keysLeft.indexOf(keyCode) !== -1) {
-                    this.inertialAlphaOffset -= 0.01;
-                }
-                else if (this.keysUp.indexOf(keyCode) !== -1) {
-                    this.inertialBetaOffset -= 0.01;
-                }
-                else if (this.keysRight.indexOf(keyCode) !== -1) {
-                    this.inertialAlphaOffset += 0.01;
-                }
-                else if (this.keysDown.indexOf(keyCode) !== -1) {
-                    this.inertialBetaOffset += 0.01;
-                }
-            }
-            // Inertia
-            if (this.inertialAlphaOffset != 0 || this.inertialBetaOffset != 0 || this.inertialRadiusOffset != 0) {
-                this.alpha += this.inertialAlphaOffset;
-                this.beta += this.inertialBetaOffset;
-                this.radius -= this.inertialRadiusOffset;
-                this.inertialAlphaOffset *= this.inertia;
-                this.inertialBetaOffset *= this.inertia;
-                this.inertialRadiusOffset *= this.inertia;
-                if (Math.abs(this.inertialAlphaOffset) < BABYLON.Engine.Epsilon)
-                    this.inertialAlphaOffset = 0;
-                if (Math.abs(this.inertialBetaOffset) < BABYLON.Engine.Epsilon)
-                    this.inertialBetaOffset = 0;
-                if (Math.abs(this.inertialRadiusOffset) < BABYLON.Engine.Epsilon)
-                    this.inertialRadiusOffset = 0;
-            }
-            // Limits
-            if (this.lowerAlphaLimit && this.alpha < this.lowerAlphaLimit) {
-                this.alpha = this.lowerAlphaLimit;
-            }
-            if (this.upperAlphaLimit && this.alpha > this.upperAlphaLimit) {
-                this.alpha = this.upperAlphaLimit;
-            }
-            if (this.lowerBetaLimit && this.beta < this.lowerBetaLimit) {
-                this.beta = this.lowerBetaLimit;
-            }
-            if (this.upperBetaLimit && this.beta > this.upperBetaLimit) {
-                this.beta = this.upperBetaLimit;
-            }
-            if (this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit) {
-                this.radius = this.lowerRadiusLimit;
-            }
-            if (this.upperRadiusLimit && this.radius > this.upperRadiusLimit) {
-                this.radius = this.upperRadiusLimit;
-            }
-        };
-        ArcRotateCamera.prototype.setPosition = function (position) {
-            var radiusv3 = position.subtract(this._getTargetPosition());
-            this.radius = radiusv3.length();
-            // Alpha
-            this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
-            if (radiusv3.z < 0) {
-                this.alpha = 2 * Math.PI - this.alpha;
-            }
-            // Beta
-            this.beta = Math.acos(radiusv3.y / this.radius);
-        };
-        ArcRotateCamera.prototype._getViewMatrix = function () {
-            // Compute
-            var cosa = Math.cos(this.alpha);
-            var sina = Math.sin(this.alpha);
-            var cosb = Math.cos(this.beta);
-            var sinb = Math.sin(this.beta);
-            var target = this._getTargetPosition();
-            target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this.position);
-            if (this.checkCollisions) {
-                this._collider.radius = this.collisionRadius;
-                this.position.subtractToRef(this._previousPosition, this._collisionVelocity);
-                this.getScene()._getNewPosition(this._previousPosition, this._collisionVelocity, this._collider, 3, this._newPosition);
-                if (!this._newPosition.equalsWithEpsilon(this.position)) {
-                    this.position.copyFrom(this._previousPosition);
-                    this.alpha = this._previousAlpha;
-                    this.beta = this._previousBeta;
-                    this.radius = this._previousRadius;
-                    if (this.onCollide) {
-                        this.onCollide(this._collider.collidedMesh);
-                    }
-                }
-            }
-            BABYLON.Matrix.LookAtLHToRef(this.position, target, this.upVector, this._viewMatrix);
-            this._previousAlpha = this.alpha;
-            this._previousBeta = this.beta;
-            this._previousRadius = this.radius;
-            this._previousPosition.copyFrom(this.position);
-            this._viewMatrix.m[12] += this.targetScreenOffset.x;
-            this._viewMatrix.m[13] += this.targetScreenOffset.y;
-            return this._viewMatrix;
-        };
-        ArcRotateCamera.prototype.zoomOn = function (meshes) {
-            meshes = meshes || this.getScene().meshes;
-            var minMaxVector = BABYLON.Mesh.MinMax(meshes);
-            var distance = BABYLON.Vector3.Distance(minMaxVector.min, minMaxVector.max);
-            this.radius = distance * this.zoomOnFactor;
-            this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance });
-        };
-        ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance) {
-            var meshesOrMinMaxVector;
-            var distance;
-            if (meshesOrMinMaxVectorAndDistance.min === undefined) {
-                meshesOrMinMaxVector = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
-                meshesOrMinMaxVector = BABYLON.Mesh.MinMax(meshesOrMinMaxVector);
-                distance = BABYLON.Vector3.Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
-            }
-            else {
-                meshesOrMinMaxVector = meshesOrMinMaxVectorAndDistance;
-                distance = meshesOrMinMaxVectorAndDistance.distance;
-            }
-            this.target = BABYLON.Mesh.Center(meshesOrMinMaxVector);
-            this.maxZ = distance * 2;
-        };
-        return ArcRotateCamera;
-    })(BABYLON.Camera);
-    BABYLON.ArcRotateCamera = ArcRotateCamera;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.arcRotateCamera.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var eventPrefix = BABYLON.Tools.GetPointerPrefix();
+    var ArcRotateCamera = (function (_super) {
+        __extends(ArcRotateCamera, _super);
+        function ArcRotateCamera(name, alpha, beta, radius, target, scene) {
+            _super.call(this, name, BABYLON.Vector3.Zero(), scene);
+            this.alpha = alpha;
+            this.beta = beta;
+            this.radius = radius;
+            this.target = target;
+            this.inertialAlphaOffset = 0;
+            this.inertialBetaOffset = 0;
+            this.inertialRadiusOffset = 0;
+            this.lowerAlphaLimit = null;
+            this.upperAlphaLimit = null;
+            this.lowerBetaLimit = 0.01;
+            this.upperBetaLimit = Math.PI;
+            this.lowerRadiusLimit = null;
+            this.upperRadiusLimit = null;
+            this.angularSensibility = 1000.0;
+            this.wheelPrecision = 3.0;
+            this.keysUp = [38];
+            this.keysDown = [40];
+            this.keysLeft = [37];
+            this.keysRight = [39];
+            this.zoomOnFactor = 1;
+            this.targetScreenOffset = BABYLON.Vector2.Zero();
+            this._keys = [];
+            this._viewMatrix = new BABYLON.Matrix();
+            this.checkCollisions = false;
+            this.collisionRadius = new BABYLON.Vector3(0.5, 0.5, 0.5);
+            this._collider = new BABYLON.Collider();
+            this._previousPosition = BABYLON.Vector3.Zero();
+            this._collisionVelocity = BABYLON.Vector3.Zero();
+            this._newPosition = BABYLON.Vector3.Zero();
+            // Pinch
+            // value for pinch step scaling
+            // set to 20 by default
+            this.pinchPrecision = 20;
+            this.getViewMatrix();
+        }
+        ArcRotateCamera.prototype._getTargetPosition = function () {
+            return this.target.position || this.target;
+        };
+        // Cache
+        ArcRotateCamera.prototype._initCache = function () {
+            _super.prototype._initCache.call(this);
+            this._cache.target = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cache.alpha = undefined;
+            this._cache.beta = undefined;
+            this._cache.radius = undefined;
+            this._cache.targetScreenOffset = undefined;
+        };
+        ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
+            if (!ignoreParentClass) {
+                _super.prototype._updateCache.call(this);
+            }
+            this._cache.target.copyFrom(this._getTargetPosition());
+            this._cache.alpha = this.alpha;
+            this._cache.beta = this.beta;
+            this._cache.radius = this.radius;
+            this._cache.targetScreenOffset = this.targetScreenOffset.clone();
+        };
+        // Synchronized
+        ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
+            if (!_super.prototype._isSynchronizedViewMatrix.call(this))
+                return false;
+            return this._cache.target.equals(this._getTargetPosition()) && this._cache.alpha === this.alpha && this._cache.beta === this.beta && this._cache.radius === this.radius && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
+        };
+        // Methods
+        ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault) {
+            var _this = this;
+            var previousPosition;
+            var pointerId;
+            // to know if pinch started
+            var pinchStarted = false;
+            // two pinch point on X
+            // that will use for find if user action is pinch open or pinch close
+            var pinchPointX1, pinchPointX2;
+            if (this._attachedElement) {
+                return;
+            }
+            this._attachedElement = element;
+            var engine = this.getEngine();
+            if (this._onPointerDown === undefined) {
+                this._onPointerDown = function (evt) {
+                    if (pointerId) {
+                        return;
+                    }
+                    pointerId = evt.pointerId;
+                    previousPosition = {
+                        x: evt.clientX,
+                        y: evt.clientY
+                    };
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._onPointerUp = function (evt) {
+                    previousPosition = null;
+                    pointerId = null;
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._onPointerMove = function (evt) {
+                    if (!previousPosition) {
+                        return;
+                    }
+                    if (pointerId !== evt.pointerId) {
+                        return;
+                    }
+                    // return pinch is started
+                    if (pinchStarted) {
+                        return;
+                    }
+                    var offsetX = evt.clientX - previousPosition.x;
+                    var offsetY = evt.clientY - previousPosition.y;
+                    _this.inertialAlphaOffset -= offsetX / _this.angularSensibility;
+                    _this.inertialBetaOffset -= offsetY / _this.angularSensibility;
+                    previousPosition = {
+                        x: evt.clientX,
+                        y: evt.clientY
+                    };
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._onMouseMove = function (evt) {
+                    if (!engine.isPointerLock) {
+                        return;
+                    }
+                    // return pinch is started
+                    if (pinchStarted) {
+                        return;
+                    }
+                    var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
+                    var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
+                    _this.inertialAlphaOffset -= offsetX / _this.angularSensibility;
+                    _this.inertialBetaOffset -= offsetY / _this.angularSensibility;
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._wheel = function (event) {
+                    var delta = 0;
+                    if (event.wheelDelta) {
+                        delta = event.wheelDelta / (_this.wheelPrecision * 40);
+                    }
+                    else if (event.detail) {
+                        delta = -event.detail / _this.wheelPrecision;
+                    }
+                    if (delta)
+                        _this.inertialRadiusOffset += delta;
+                    if (event.preventDefault) {
+                        if (!noPreventDefault) {
+                            event.preventDefault();
+                        }
+                    }
+                };
+                this._onKeyDown = function (evt) {
+                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
+                        var index = _this._keys.indexOf(evt.keyCode);
+                        if (index === -1) {
+                            _this._keys.push(evt.keyCode);
+                        }
+                        if (evt.preventDefault) {
+                            if (!noPreventDefault) {
+                                evt.preventDefault();
+                            }
+                        }
+                    }
+                };
+                this._onKeyUp = function (evt) {
+                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
+                        var index = _this._keys.indexOf(evt.keyCode);
+                        if (index >= 0) {
+                            _this._keys.splice(index, 1);
+                        }
+                        if (evt.preventDefault) {
+                            if (!noPreventDefault) {
+                                evt.preventDefault();
+                            }
+                        }
+                    }
+                };
+                this._onLostFocus = function () {
+                    _this._keys = [];
+                    pointerId = null;
+                };
+                this._onGestureStart = function (e) {
+                    if (window.MSGesture === undefined) {
+                        return;
+                    }
+                    if (!_this._MSGestureHandler) {
+                        _this._MSGestureHandler = new MSGesture();
+                        _this._MSGestureHandler.target = element;
+                    }
+                    _this._MSGestureHandler.addPointer(e.pointerId);
+                };
+                this._onGesture = function (e) {
+                    _this.radius *= e.scale;
+                    if (e.preventDefault) {
+                        if (!noPreventDefault) {
+                            e.stopPropagation();
+                            e.preventDefault();
+                        }
+                    }
+                };
+                this._reset = function () {
+                    _this._keys = [];
+                    _this.inertialAlphaOffset = 0;
+                    _this.inertialBetaOffset = 0;
+                    _this.inertialRadiusOffset = 0;
+                    previousPosition = null;
+                    pointerId = null;
+                };
+                this._touchStart = function (event) {
+                    if (event.touches.length === 2) {
+                        //-- start pinch if two fingers on the screen
+                        pinchStarted = true;
+                        _this._pinchStart(event);
+                    }
+                };
+                this._touchMove = function (event) {
+                    if (pinchStarted) {
+                        //-- make scaling
+                        _this._pinchMove(event);
+                    }
+                };
+                this._touchEnd = function (event) {
+                    if (pinchStarted) {
+                        //-- end of pinch
+                        _this._pinchEnd(event);
+                    }
+                };
+                this._pinchStart = function (event) {
+                    // save origin touch point
+                    pinchPointX1 = event.touches[0].clientX;
+                    pinchPointX2 = event.touches[1].clientX;
+                    // block the camera 
+                    // if not it rotate around target during pinch
+                    pinchStarted = true;
+                };
+                this._pinchMove = function (event) {
+                    // variable for new camera's radius
+                    var delta = 0;
+                    // variables to know if pinch open or pinch close
+                    var direction = 1;
+                    var distanceXOrigine, distanceXNow;
+                    if (event.touches.length !== 2)
+                        return;
+                    // calculate absolute distances of the two fingers
+                    distanceXOrigine = Math.abs(pinchPointX1 - pinchPointX2);
+                    distanceXNow = Math.abs(event.touches[0].clientX - event.touches[1].clientX);
+                    // if distanceXNow < distanceXOrigine -> pinch close so direction = -1
+                    if (distanceXNow < distanceXOrigine) {
+                        direction = -1;
+                    }
+                    // calculate new radius
+                    delta = (_this.pinchPrecision / (_this.wheelPrecision * 40)) * direction;
+                    // set new radius
+                    _this.inertialRadiusOffset -= delta;
+                    // save origin touch point
+                    pinchPointX1 = event.touches[0].clientX;
+                    pinchPointX2 = event.touches[1].clientX;
+                };
+                this._pinchEnd = function (event) {
+                    // cancel pinch and deblock camera rotation
+                    pinchStarted = false;
+                };
+            }
+            element.addEventListener(eventPrefix + "down", this._onPointerDown, false);
+            element.addEventListener(eventPrefix + "up", this._onPointerUp, false);
+            element.addEventListener(eventPrefix + "out", this._onPointerUp, false);
+            element.addEventListener(eventPrefix + "move", this._onPointerMove, false);
+            element.addEventListener("mousemove", this._onMouseMove, false);
+            element.addEventListener("MSPointerDown", this._onGestureStart, false);
+            element.addEventListener("MSGestureChange", this._onGesture, false);
+            element.addEventListener('mousewheel', this._wheel, false);
+            element.addEventListener('DOMMouseScroll', this._wheel, false);
+            // pinch
+            element.addEventListener('touchstart', this._touchStart, false);
+            element.addEventListener('touchmove', this._touchMove, false);
+            element.addEventListener('touchend', this._touchEnd, false);
+            BABYLON.Tools.RegisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+        };
+        ArcRotateCamera.prototype.detachControl = function (element) {
+            if (this._attachedElement != element) {
+                return;
+            }
+            element.removeEventListener(eventPrefix + "down", this._onPointerDown);
+            element.removeEventListener(eventPrefix + "up", this._onPointerUp);
+            element.removeEventListener(eventPrefix + "out", this._onPointerUp);
+            element.removeEventListener(eventPrefix + "move", this._onPointerMove);
+            element.removeEventListener("mousemove", this._onMouseMove);
+            element.removeEventListener("MSPointerDown", this._onGestureStart);
+            element.removeEventListener("MSGestureChange", this._onGesture);
+            element.removeEventListener('mousewheel', this._wheel);
+            element.removeEventListener('DOMMouseScroll', this._wheel);
+            // pinch
+            element.removeEventListener('touchstart', this._touchStart);
+            element.removeEventListener('touchmove', this._touchMove);
+            element.removeEventListener('touchend', this._touchEnd);
+            BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+            this._MSGestureHandler = null;
+            this._attachedElement = null;
+            if (this._reset) {
+                this._reset();
+            }
+        };
+        ArcRotateCamera.prototype._update = function () {
+            for (var index = 0; index < this._keys.length; index++) {
+                var keyCode = this._keys[index];
+                if (this.keysLeft.indexOf(keyCode) !== -1) {
+                    this.inertialAlphaOffset -= 0.01;
+                }
+                else if (this.keysUp.indexOf(keyCode) !== -1) {
+                    this.inertialBetaOffset -= 0.01;
+                }
+                else if (this.keysRight.indexOf(keyCode) !== -1) {
+                    this.inertialAlphaOffset += 0.01;
+                }
+                else if (this.keysDown.indexOf(keyCode) !== -1) {
+                    this.inertialBetaOffset += 0.01;
+                }
+            }
+            // Inertia
+            if (this.inertialAlphaOffset != 0 || this.inertialBetaOffset != 0 || this.inertialRadiusOffset != 0) {
+                this.alpha += this.inertialAlphaOffset;
+                this.beta += this.inertialBetaOffset;
+                this.radius -= this.inertialRadiusOffset;
+                this.inertialAlphaOffset *= this.inertia;
+                this.inertialBetaOffset *= this.inertia;
+                this.inertialRadiusOffset *= this.inertia;
+                if (Math.abs(this.inertialAlphaOffset) < BABYLON.Engine.Epsilon)
+                    this.inertialAlphaOffset = 0;
+                if (Math.abs(this.inertialBetaOffset) < BABYLON.Engine.Epsilon)
+                    this.inertialBetaOffset = 0;
+                if (Math.abs(this.inertialRadiusOffset) < BABYLON.Engine.Epsilon)
+                    this.inertialRadiusOffset = 0;
+            }
+            // Limits
+            if (this.lowerAlphaLimit && this.alpha < this.lowerAlphaLimit) {
+                this.alpha = this.lowerAlphaLimit;
+            }
+            if (this.upperAlphaLimit && this.alpha > this.upperAlphaLimit) {
+                this.alpha = this.upperAlphaLimit;
+            }
+            if (this.lowerBetaLimit && this.beta < this.lowerBetaLimit) {
+                this.beta = this.lowerBetaLimit;
+            }
+            if (this.upperBetaLimit && this.beta > this.upperBetaLimit) {
+                this.beta = this.upperBetaLimit;
+            }
+            if (this.lowerRadiusLimit && this.radius < this.lowerRadiusLimit) {
+                this.radius = this.lowerRadiusLimit;
+            }
+            if (this.upperRadiusLimit && this.radius > this.upperRadiusLimit) {
+                this.radius = this.upperRadiusLimit;
+            }
+        };
+        ArcRotateCamera.prototype.setPosition = function (position) {
+            var radiusv3 = position.subtract(this._getTargetPosition());
+            this.radius = radiusv3.length();
+            // Alpha
+            this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
+            if (radiusv3.z < 0) {
+                this.alpha = 2 * Math.PI - this.alpha;
+            }
+            // Beta
+            this.beta = Math.acos(radiusv3.y / this.radius);
+        };
+        ArcRotateCamera.prototype._getViewMatrix = function () {
+            // Compute
+            var cosa = Math.cos(this.alpha);
+            var sina = Math.sin(this.alpha);
+            var cosb = Math.cos(this.beta);
+            var sinb = Math.sin(this.beta);
+            var target = this._getTargetPosition();
+            target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this.position);
+            if (this.checkCollisions) {
+                this._collider.radius = this.collisionRadius;
+                this.position.subtractToRef(this._previousPosition, this._collisionVelocity);
+                this.getScene()._getNewPosition(this._previousPosition, this._collisionVelocity, this._collider, 3, this._newPosition);
+                if (!this._newPosition.equalsWithEpsilon(this.position)) {
+                    this.position.copyFrom(this._previousPosition);
+                    this.alpha = this._previousAlpha;
+                    this.beta = this._previousBeta;
+                    this.radius = this._previousRadius;
+                    if (this.onCollide) {
+                        this.onCollide(this._collider.collidedMesh);
+                    }
+                }
+            }
+            BABYLON.Matrix.LookAtLHToRef(this.position, target, this.upVector, this._viewMatrix);
+            this._previousAlpha = this.alpha;
+            this._previousBeta = this.beta;
+            this._previousRadius = this.radius;
+            this._previousPosition.copyFrom(this.position);
+            this._viewMatrix.m[12] += this.targetScreenOffset.x;
+            this._viewMatrix.m[13] += this.targetScreenOffset.y;
+            return this._viewMatrix;
+        };
+        ArcRotateCamera.prototype.zoomOn = function (meshes) {
+            meshes = meshes || this.getScene().meshes;
+            var minMaxVector = BABYLON.Mesh.MinMax(meshes);
+            var distance = BABYLON.Vector3.Distance(minMaxVector.min, minMaxVector.max);
+            this.radius = distance * this.zoomOnFactor;
+            this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance });
+        };
+        ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance) {
+            var meshesOrMinMaxVector;
+            var distance;
+            if (meshesOrMinMaxVectorAndDistance.min === undefined) {
+                meshesOrMinMaxVector = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
+                meshesOrMinMaxVector = BABYLON.Mesh.MinMax(meshesOrMinMaxVector);
+                distance = BABYLON.Vector3.Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
+            }
+            else {
+                meshesOrMinMaxVector = meshesOrMinMaxVectorAndDistance;
+                distance = meshesOrMinMaxVectorAndDistance.distance;
+            }
+            this.target = BABYLON.Mesh.Center(meshesOrMinMaxVector);
+            this.maxZ = distance * 2;
+        };
+        return ArcRotateCamera;
+    })(BABYLON.Camera);
+    BABYLON.ArcRotateCamera = ArcRotateCamera;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Cameras/babylon.arcRotateCamera.js.map

+ 273 - 272
Babylon/Cameras/babylon.camera.js

@@ -1,272 +1,273 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var Camera = (function (_super) {
-        __extends(Camera, _super);
-        function Camera(name, position, scene) {
-            _super.call(this, name, scene);
-            this.position = position;
-            // Members
-            this.upVector = BABYLON.Vector3.Up();
-            this.orthoLeft = null;
-            this.orthoRight = null;
-            this.orthoBottom = null;
-            this.orthoTop = null;
-            this.fov = 0.8;
-            this.minZ = 1.0;
-            this.maxZ = 10000.0;
-            this.inertia = 0.9;
-            this.mode = Camera.PERSPECTIVE_CAMERA;
-            this.isIntermediate = false;
-            this.viewport = new BABYLON.Viewport(0, 0, 1.0, 1.0);
-            this.subCameras = [];
-            this.layerMask = 0xFFFFFFFF;
-            this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
-            this._computedViewMatrix = BABYLON.Matrix.Identity();
-            this._projectionMatrix = new BABYLON.Matrix();
-            this._postProcesses = new Array();
-            this._postProcessesTakenIndices = [];
-            scene.cameras.push(this);
-            if (!scene.activeCamera) {
-                scene.activeCamera = this;
-            }
-        }
-        Object.defineProperty(Camera, "PERSPECTIVE_CAMERA", {
-            get: function () {
-                return Camera._PERSPECTIVE_CAMERA;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Camera, "ORTHOGRAPHIC_CAMERA", {
-            get: function () {
-                return Camera._ORTHOGRAPHIC_CAMERA;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Camera, "FOVMODE_VERTICAL_FIXED", {
-            get: function () {
-                return Camera._FOVMODE_VERTICAL_FIXED;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Camera, "FOVMODE_HORIZONTAL_FIXED", {
-            get: function () {
-                return Camera._FOVMODE_HORIZONTAL_FIXED;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        //Cache
-        Camera.prototype._initCache = function () {
-            _super.prototype._initCache.call(this);
-            this._cache.position = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
-            this._cache.upVector = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
-            this._cache.mode = undefined;
-            this._cache.minZ = undefined;
-            this._cache.maxZ = undefined;
-            this._cache.fov = undefined;
-            this._cache.aspectRatio = undefined;
-            this._cache.orthoLeft = undefined;
-            this._cache.orthoRight = undefined;
-            this._cache.orthoBottom = undefined;
-            this._cache.orthoTop = undefined;
-            this._cache.renderWidth = undefined;
-            this._cache.renderHeight = undefined;
-        };
-        Camera.prototype._updateCache = function (ignoreParentClass) {
-            if (!ignoreParentClass) {
-                _super.prototype._updateCache.call(this);
-            }
-            var engine = this.getEngine();
-            this._cache.position.copyFrom(this.position);
-            this._cache.upVector.copyFrom(this.upVector);
-            this._cache.mode = this.mode;
-            this._cache.minZ = this.minZ;
-            this._cache.maxZ = this.maxZ;
-            this._cache.fov = this.fov;
-            this._cache.aspectRatio = engine.getAspectRatio(this);
-            this._cache.orthoLeft = this.orthoLeft;
-            this._cache.orthoRight = this.orthoRight;
-            this._cache.orthoBottom = this.orthoBottom;
-            this._cache.orthoTop = this.orthoTop;
-            this._cache.renderWidth = engine.getRenderWidth();
-            this._cache.renderHeight = engine.getRenderHeight();
-        };
-        Camera.prototype._updateFromScene = function () {
-            this.updateCache();
-            this._update();
-        };
-        // Synchronized
-        Camera.prototype._isSynchronized = function () {
-            return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
-        };
-        Camera.prototype._isSynchronizedViewMatrix = function () {
-            if (!_super.prototype._isSynchronized.call(this))
-                return false;
-            return this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent();
-        };
-        Camera.prototype._isSynchronizedProjectionMatrix = function () {
-            var check = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
-            if (!check) {
-                return false;
-            }
-            var engine = this.getEngine();
-            if (this.mode === Camera.PERSPECTIVE_CAMERA) {
-                check = this._cache.fov === this.fov && this._cache.aspectRatio === engine.getAspectRatio(this);
-            }
-            else {
-                check = this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === engine.getRenderWidth() && this._cache.renderHeight === engine.getRenderHeight();
-            }
-            return check;
-        };
-        // Controls
-        Camera.prototype.attachControl = function (element) {
-        };
-        Camera.prototype.detachControl = function (element) {
-        };
-        Camera.prototype._update = function () {
-        };
-        Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
-            if (insertAt === void 0) { insertAt = null; }
-            if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
-                BABYLON.Tools.Error("You're trying to reuse a post process not defined as reusable.");
-                return 0;
-            }
-            if (insertAt == null || insertAt < 0) {
-                this._postProcesses.push(postProcess);
-                this._postProcessesTakenIndices.push(this._postProcesses.length - 1);
-                return this._postProcesses.length - 1;
-            }
-            var add = 0;
-            if (this._postProcesses[insertAt]) {
-                var start = this._postProcesses.length - 1;
-                for (var i = start; i >= insertAt + 1; --i) {
-                    this._postProcesses[i + 1] = this._postProcesses[i];
-                }
-                add = 1;
-            }
-            for (i = 0; i < this._postProcessesTakenIndices.length; ++i) {
-                if (this._postProcessesTakenIndices[i] < insertAt) {
-                    continue;
-                }
-                start = this._postProcessesTakenIndices.length - 1;
-                for (var j = start; j >= i; --j) {
-                    this._postProcessesTakenIndices[j + 1] = this._postProcessesTakenIndices[j] + add;
-                }
-                this._postProcessesTakenIndices[i] = insertAt;
-                break;
-            }
-            if (!add && this._postProcessesTakenIndices.indexOf(insertAt) == -1) {
-                this._postProcessesTakenIndices.push(insertAt);
-            }
-            var result = insertAt + add;
-            this._postProcesses[result] = postProcess;
-            return result;
-        };
-        Camera.prototype.detachPostProcess = function (postProcess, atIndices) {
-            if (atIndices === void 0) { atIndices = null; }
-            var result = [];
-            if (!atIndices) {
-                var length = this._postProcesses.length;
-                for (var i = 0; i < length; i++) {
-                    if (this._postProcesses[i] !== postProcess) {
-                        continue;
-                    }
-                    delete this._postProcesses[i];
-                    var index = this._postProcessesTakenIndices.indexOf(i);
-                    this._postProcessesTakenIndices.splice(index, 1);
-                }
-            }
-            else {
-                atIndices = (atIndices instanceof Array) ? atIndices : [atIndices];
-                for (i = 0; i < atIndices.length; i++) {
-                    var foundPostProcess = this._postProcesses[atIndices[i]];
-                    if (foundPostProcess !== postProcess) {
-                        result.push(i);
-                        continue;
-                    }
-                    delete this._postProcesses[atIndices[i]];
-                    index = this._postProcessesTakenIndices.indexOf(atIndices[i]);
-                    this._postProcessesTakenIndices.splice(index, 1);
-                }
-            }
-            return result;
-        };
-        Camera.prototype.getWorldMatrix = function () {
-            if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
-            }
-            var viewMatrix = this.getViewMatrix();
-            viewMatrix.invertToRef(this._worldMatrix);
-            return this._worldMatrix;
-        };
-        Camera.prototype._getViewMatrix = function () {
-            return BABYLON.Matrix.Identity();
-        };
-        Camera.prototype.getViewMatrix = function () {
-            this._computedViewMatrix = this._computeViewMatrix();
-            if (!this.parent || !this.parent.getWorldMatrix || this.isSynchronized()) {
-                return this._computedViewMatrix;
-            }
-            if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
-            }
-            this._computedViewMatrix.invertToRef(this._worldMatrix);
-            this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._computedViewMatrix);
-            this._computedViewMatrix.invert();
-            this._currentRenderId = this.getScene().getRenderId();
-            return this._computedViewMatrix;
-        };
-        Camera.prototype._computeViewMatrix = function (force) {
-            if (!force && this._isSynchronizedViewMatrix()) {
-                return this._computedViewMatrix;
-            }
-            this._computedViewMatrix = this._getViewMatrix();
-            if (!this.parent || !this.parent.getWorldMatrix) {
-                this._currentRenderId = this.getScene().getRenderId();
-            }
-            return this._computedViewMatrix;
-        };
-        Camera.prototype.getProjectionMatrix = function (force) {
-            if (!force && this._isSynchronizedProjectionMatrix()) {
-                return this._projectionMatrix;
-            }
-            var engine = this.getEngine();
-            if (this.mode === Camera.PERSPECTIVE_CAMERA) {
-                if (this.minZ <= 0) {
-                    this.minZ = 0.1;
-                }
-                BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode);
-                return this._projectionMatrix;
-            }
-            var halfWidth = engine.getRenderWidth() / 2.0;
-            var halfHeight = engine.getRenderHeight() / 2.0;
-            BABYLON.Matrix.OrthoOffCenterLHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
-            return this._projectionMatrix;
-        };
-        Camera.prototype.dispose = function () {
-            // Remove from scene
-            var index = this.getScene().cameras.indexOf(this);
-            this.getScene().cameras.splice(index, 1);
-            for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
-                this._postProcesses[this._postProcessesTakenIndices[i]].dispose(this);
-            }
-        };
-        // Statics
-        Camera._PERSPECTIVE_CAMERA = 0;
-        Camera._ORTHOGRAPHIC_CAMERA = 1;
-        Camera._FOVMODE_VERTICAL_FIXED = 0;
-        Camera._FOVMODE_HORIZONTAL_FIXED = 1;
-        return Camera;
-    })(BABYLON.Node);
-    BABYLON.Camera = Camera;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.camera.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var Camera = (function (_super) {
+        __extends(Camera, _super);
+        function Camera(name, position, scene) {
+            _super.call(this, name, scene);
+            this.position = position;
+            // Members
+            this.upVector = BABYLON.Vector3.Up();
+            this.orthoLeft = null;
+            this.orthoRight = null;
+            this.orthoBottom = null;
+            this.orthoTop = null;
+            this.fov = 0.8;
+            this.minZ = 1.0;
+            this.maxZ = 10000.0;
+            this.inertia = 0.9;
+            this.mode = Camera.PERSPECTIVE_CAMERA;
+            this.isIntermediate = false;
+            this.viewport = new BABYLON.Viewport(0, 0, 1.0, 1.0);
+            this.subCameras = [];
+            this.layerMask = 0xFFFFFFFF;
+            this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
+            this._computedViewMatrix = BABYLON.Matrix.Identity();
+            this._projectionMatrix = new BABYLON.Matrix();
+            this._postProcesses = new Array();
+            this._postProcessesTakenIndices = [];
+            scene.cameras.push(this);
+            if (!scene.activeCamera) {
+                scene.activeCamera = this;
+            }
+        }
+        Object.defineProperty(Camera, "PERSPECTIVE_CAMERA", {
+            get: function () {
+                return Camera._PERSPECTIVE_CAMERA;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "ORTHOGRAPHIC_CAMERA", {
+            get: function () {
+                return Camera._ORTHOGRAPHIC_CAMERA;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "FOVMODE_VERTICAL_FIXED", {
+            get: function () {
+                return Camera._FOVMODE_VERTICAL_FIXED;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "FOVMODE_HORIZONTAL_FIXED", {
+            get: function () {
+                return Camera._FOVMODE_HORIZONTAL_FIXED;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        //Cache
+        Camera.prototype._initCache = function () {
+            _super.prototype._initCache.call(this);
+            this._cache.position = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cache.upVector = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cache.mode = undefined;
+            this._cache.minZ = undefined;
+            this._cache.maxZ = undefined;
+            this._cache.fov = undefined;
+            this._cache.aspectRatio = undefined;
+            this._cache.orthoLeft = undefined;
+            this._cache.orthoRight = undefined;
+            this._cache.orthoBottom = undefined;
+            this._cache.orthoTop = undefined;
+            this._cache.renderWidth = undefined;
+            this._cache.renderHeight = undefined;
+        };
+        Camera.prototype._updateCache = function (ignoreParentClass) {
+            if (!ignoreParentClass) {
+                _super.prototype._updateCache.call(this);
+            }
+            var engine = this.getEngine();
+            this._cache.position.copyFrom(this.position);
+            this._cache.upVector.copyFrom(this.upVector);
+            this._cache.mode = this.mode;
+            this._cache.minZ = this.minZ;
+            this._cache.maxZ = this.maxZ;
+            this._cache.fov = this.fov;
+            this._cache.aspectRatio = engine.getAspectRatio(this);
+            this._cache.orthoLeft = this.orthoLeft;
+            this._cache.orthoRight = this.orthoRight;
+            this._cache.orthoBottom = this.orthoBottom;
+            this._cache.orthoTop = this.orthoTop;
+            this._cache.renderWidth = engine.getRenderWidth();
+            this._cache.renderHeight = engine.getRenderHeight();
+        };
+        Camera.prototype._updateFromScene = function () {
+            this.updateCache();
+            this._update();
+        };
+        // Synchronized
+        Camera.prototype._isSynchronized = function () {
+            return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
+        };
+        Camera.prototype._isSynchronizedViewMatrix = function () {
+            if (!_super.prototype._isSynchronized.call(this))
+                return false;
+            return this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent();
+        };
+        Camera.prototype._isSynchronizedProjectionMatrix = function () {
+            var check = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
+            if (!check) {
+                return false;
+            }
+            var engine = this.getEngine();
+            if (this.mode === Camera.PERSPECTIVE_CAMERA) {
+                check = this._cache.fov === this.fov && this._cache.aspectRatio === engine.getAspectRatio(this);
+            }
+            else {
+                check = this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === engine.getRenderWidth() && this._cache.renderHeight === engine.getRenderHeight();
+            }
+            return check;
+        };
+        // Controls
+        Camera.prototype.attachControl = function (element) {
+        };
+        Camera.prototype.detachControl = function (element) {
+        };
+        Camera.prototype._update = function () {
+        };
+        Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
+            if (insertAt === void 0) { insertAt = null; }
+            if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
+                BABYLON.Tools.Error("You're trying to reuse a post process not defined as reusable.");
+                return 0;
+            }
+            if (insertAt == null || insertAt < 0) {
+                this._postProcesses.push(postProcess);
+                this._postProcessesTakenIndices.push(this._postProcesses.length - 1);
+                return this._postProcesses.length - 1;
+            }
+            var add = 0;
+            if (this._postProcesses[insertAt]) {
+                var start = this._postProcesses.length - 1;
+                for (var i = start; i >= insertAt + 1; --i) {
+                    this._postProcesses[i + 1] = this._postProcesses[i];
+                }
+                add = 1;
+            }
+            for (i = 0; i < this._postProcessesTakenIndices.length; ++i) {
+                if (this._postProcessesTakenIndices[i] < insertAt) {
+                    continue;
+                }
+                start = this._postProcessesTakenIndices.length - 1;
+                for (var j = start; j >= i; --j) {
+                    this._postProcessesTakenIndices[j + 1] = this._postProcessesTakenIndices[j] + add;
+                }
+                this._postProcessesTakenIndices[i] = insertAt;
+                break;
+            }
+            if (!add && this._postProcessesTakenIndices.indexOf(insertAt) == -1) {
+                this._postProcessesTakenIndices.push(insertAt);
+            }
+            var result = insertAt + add;
+            this._postProcesses[result] = postProcess;
+            return result;
+        };
+        Camera.prototype.detachPostProcess = function (postProcess, atIndices) {
+            if (atIndices === void 0) { atIndices = null; }
+            var result = [];
+            if (!atIndices) {
+                var length = this._postProcesses.length;
+                for (var i = 0; i < length; i++) {
+                    if (this._postProcesses[i] !== postProcess) {
+                        continue;
+                    }
+                    delete this._postProcesses[i];
+                    var index = this._postProcessesTakenIndices.indexOf(i);
+                    this._postProcessesTakenIndices.splice(index, 1);
+                }
+            }
+            else {
+                atIndices = (atIndices instanceof Array) ? atIndices : [atIndices];
+                for (i = 0; i < atIndices.length; i++) {
+                    var foundPostProcess = this._postProcesses[atIndices[i]];
+                    if (foundPostProcess !== postProcess) {
+                        result.push(i);
+                        continue;
+                    }
+                    delete this._postProcesses[atIndices[i]];
+                    index = this._postProcessesTakenIndices.indexOf(atIndices[i]);
+                    this._postProcessesTakenIndices.splice(index, 1);
+                }
+            }
+            return result;
+        };
+        Camera.prototype.getWorldMatrix = function () {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            var viewMatrix = this.getViewMatrix();
+            viewMatrix.invertToRef(this._worldMatrix);
+            return this._worldMatrix;
+        };
+        Camera.prototype._getViewMatrix = function () {
+            return BABYLON.Matrix.Identity();
+        };
+        Camera.prototype.getViewMatrix = function () {
+            this._computedViewMatrix = this._computeViewMatrix();
+            if (!this.parent || !this.parent.getWorldMatrix || this.isSynchronized()) {
+                return this._computedViewMatrix;
+            }
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            this._computedViewMatrix.invertToRef(this._worldMatrix);
+            this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._computedViewMatrix);
+            this._computedViewMatrix.invert();
+            this._currentRenderId = this.getScene().getRenderId();
+            return this._computedViewMatrix;
+        };
+        Camera.prototype._computeViewMatrix = function (force) {
+            if (!force && this._isSynchronizedViewMatrix()) {
+                return this._computedViewMatrix;
+            }
+            this._computedViewMatrix = this._getViewMatrix();
+            if (!this.parent || !this.parent.getWorldMatrix) {
+                this._currentRenderId = this.getScene().getRenderId();
+            }
+            return this._computedViewMatrix;
+        };
+        Camera.prototype.getProjectionMatrix = function (force) {
+            if (!force && this._isSynchronizedProjectionMatrix()) {
+                return this._projectionMatrix;
+            }
+            var engine = this.getEngine();
+            if (this.mode === Camera.PERSPECTIVE_CAMERA) {
+                if (this.minZ <= 0) {
+                    this.minZ = 0.1;
+                }
+                BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode);
+                return this._projectionMatrix;
+            }
+            var halfWidth = engine.getRenderWidth() / 2.0;
+            var halfHeight = engine.getRenderHeight() / 2.0;
+            BABYLON.Matrix.OrthoOffCenterLHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
+            return this._projectionMatrix;
+        };
+        Camera.prototype.dispose = function () {
+            // Remove from scene
+            var index = this.getScene().cameras.indexOf(this);
+            this.getScene().cameras.splice(index, 1);
+            for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
+                this._postProcesses[this._postProcessesTakenIndices[i]].dispose(this);
+            }
+        };
+        // Statics
+        Camera._PERSPECTIVE_CAMERA = 0;
+        Camera._ORTHOGRAPHIC_CAMERA = 1;
+        Camera._FOVMODE_VERTICAL_FIXED = 0;
+        Camera._FOVMODE_HORIZONTAL_FIXED = 1;
+        return Camera;
+    })(BABYLON.Node);
+    BABYLON.Camera = Camera;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Cameras/babylon.camera.js.map

+ 2 - 1
Babylon/Cameras/babylon.deviceOrientationCamera.js

@@ -69,4 +69,5 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     BABYLON.DeviceOrientationCamera = DeviceOrientationCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.deviceOrientationCamera.js.map
+
+//# sourceMappingURL=../Cameras/babylon.deviceOrientationCamera.js.map

+ 2 - 1
Babylon/Cameras/babylon.followCamera.js

@@ -51,4 +51,5 @@ var BABYLON;
     })(BABYLON.TargetCamera);
     BABYLON.FollowCamera = FollowCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.followCamera.js.map
+
+//# sourceMappingURL=../Cameras/babylon.followCamera.js.map

+ 213 - 212
Babylon/Cameras/babylon.freeCamera.js

@@ -1,212 +1,213 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var FreeCamera = (function (_super) {
-        __extends(FreeCamera, _super);
-        function FreeCamera(name, position, scene) {
-            _super.call(this, name, position, scene);
-            this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
-            this.keysUp = [38];
-            this.keysDown = [40];
-            this.keysLeft = [37];
-            this.keysRight = [39];
-            this.checkCollisions = false;
-            this.applyGravity = false;
-            this.angularSensibility = 2000.0;
-            this._keys = [];
-            this._collider = new BABYLON.Collider();
-            this._needMoveForGravity = true;
-            this._oldPosition = BABYLON.Vector3.Zero();
-            this._diffPosition = BABYLON.Vector3.Zero();
-            this._newPosition = BABYLON.Vector3.Zero();
-        }
-        // Controls
-        FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
-            var _this = this;
-            var previousPosition;
-            var engine = this.getEngine();
-            if (this._attachedElement) {
-                return;
-            }
-            this._attachedElement = element;
-            if (this._onMouseDown === undefined) {
-                this._onMouseDown = function (evt) {
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
-                    };
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onMouseUp = function (evt) {
-                    previousPosition = null;
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onMouseOut = function (evt) {
-                    previousPosition = null;
-                    _this._keys = [];
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onMouseMove = function (evt) {
-                    if (!previousPosition && !engine.isPointerLock) {
-                        return;
-                    }
-                    var offsetX;
-                    var offsetY;
-                    if (!engine.isPointerLock) {
-                        offsetX = evt.clientX - previousPosition.x;
-                        offsetY = evt.clientY - previousPosition.y;
-                    }
-                    else {
-                        offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
-                        offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
-                    }
-                    _this.cameraRotation.y += offsetX / _this.angularSensibility;
-                    _this.cameraRotation.x += offsetY / _this.angularSensibility;
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
-                    };
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                };
-                this._onKeyDown = function (evt) {
-                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
-                        var index = _this._keys.indexOf(evt.keyCode);
-                        if (index === -1) {
-                            _this._keys.push(evt.keyCode);
-                        }
-                        if (!noPreventDefault) {
-                            evt.preventDefault();
-                        }
-                    }
-                };
-                this._onKeyUp = function (evt) {
-                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
-                        var index = _this._keys.indexOf(evt.keyCode);
-                        if (index >= 0) {
-                            _this._keys.splice(index, 1);
-                        }
-                        if (!noPreventDefault) {
-                            evt.preventDefault();
-                        }
-                    }
-                };
-                this._onLostFocus = function () {
-                    _this._keys = [];
-                };
-                this._reset = function () {
-                    _this._keys = [];
-                    previousPosition = null;
-                    _this.cameraDirection = new BABYLON.Vector3(0, 0, 0);
-                    _this.cameraRotation = new BABYLON.Vector2(0, 0);
-                };
-            }
-            element.addEventListener("mousedown", this._onMouseDown, false);
-            element.addEventListener("mouseup", this._onMouseUp, false);
-            element.addEventListener("mouseout", this._onMouseOut, false);
-            element.addEventListener("mousemove", this._onMouseMove, false);
-            BABYLON.Tools.RegisterTopRootEvents([
-                { name: "keydown", handler: this._onKeyDown },
-                { name: "keyup", handler: this._onKeyUp },
-                { name: "blur", handler: this._onLostFocus }
-            ]);
-        };
-        FreeCamera.prototype.detachControl = function (element) {
-            if (this._attachedElement != element) {
-                return;
-            }
-            element.removeEventListener("mousedown", this._onMouseDown);
-            element.removeEventListener("mouseup", this._onMouseUp);
-            element.removeEventListener("mouseout", this._onMouseOut);
-            element.removeEventListener("mousemove", this._onMouseMove);
-            BABYLON.Tools.UnregisterTopRootEvents([
-                { name: "keydown", handler: this._onKeyDown },
-                { name: "keyup", handler: this._onKeyUp },
-                { name: "blur", handler: this._onLostFocus }
-            ]);
-            this._attachedElement = null;
-            if (this._reset) {
-                this._reset();
-            }
-        };
-        FreeCamera.prototype._collideWithWorld = function (velocity) {
-            var globalPosition;
-            if (this.parent) {
-                globalPosition = BABYLON.Vector3.TransformCoordinates(this.position, this.parent.getWorldMatrix());
-            }
-            else {
-                globalPosition = this.position;
-            }
-            globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
-            this._collider.radius = this.ellipsoid;
-            this.getScene()._getNewPosition(this._oldPosition, velocity, this._collider, 3, this._newPosition);
-            this._newPosition.subtractToRef(this._oldPosition, this._diffPosition);
-            if (this._diffPosition.length() > BABYLON.Engine.CollisionsEpsilon) {
-                this.position.addInPlace(this._diffPosition);
-                if (this.onCollide) {
-                    this.onCollide(this._collider.collidedMesh);
-                }
-            }
-        };
-        FreeCamera.prototype._checkInputs = function () {
-            if (!this._localDirection) {
-                this._localDirection = BABYLON.Vector3.Zero();
-                this._transformedDirection = BABYLON.Vector3.Zero();
-            }
-            for (var index = 0; index < this._keys.length; index++) {
-                var keyCode = this._keys[index];
-                var speed = this._computeLocalCameraSpeed();
-                if (this.keysLeft.indexOf(keyCode) !== -1) {
-                    this._localDirection.copyFromFloats(-speed, 0, 0);
-                }
-                else if (this.keysUp.indexOf(keyCode) !== -1) {
-                    this._localDirection.copyFromFloats(0, 0, speed);
-                }
-                else if (this.keysRight.indexOf(keyCode) !== -1) {
-                    this._localDirection.copyFromFloats(speed, 0, 0);
-                }
-                else if (this.keysDown.indexOf(keyCode) !== -1) {
-                    this._localDirection.copyFromFloats(0, 0, -speed);
-                }
-                this.getViewMatrix().invertToRef(this._cameraTransformMatrix);
-                BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
-                this.cameraDirection.addInPlace(this._transformedDirection);
-            }
-        };
-        FreeCamera.prototype._decideIfNeedsToMove = function () {
-            return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
-        };
-        FreeCamera.prototype._updatePosition = function () {
-            if (this.checkCollisions && this.getScene().collisionsEnabled) {
-                this._collideWithWorld(this.cameraDirection);
-                if (this.applyGravity) {
-                    var oldPosition = this.position;
-                    this._collideWithWorld(this.getScene().gravity);
-                    this._needMoveForGravity = (BABYLON.Vector3.DistanceSquared(oldPosition, this.position) != 0);
-                }
-            }
-            else {
-                this.position.addInPlace(this.cameraDirection);
-            }
-        };
-        FreeCamera.prototype._update = function () {
-            this._checkInputs();
-            _super.prototype._update.call(this);
-        };
-        return FreeCamera;
-    })(BABYLON.TargetCamera);
-    BABYLON.FreeCamera = FreeCamera;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.freeCamera.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var FreeCamera = (function (_super) {
+        __extends(FreeCamera, _super);
+        function FreeCamera(name, position, scene) {
+            _super.call(this, name, position, scene);
+            this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
+            this.keysUp = [38];
+            this.keysDown = [40];
+            this.keysLeft = [37];
+            this.keysRight = [39];
+            this.checkCollisions = false;
+            this.applyGravity = false;
+            this.angularSensibility = 2000.0;
+            this._keys = [];
+            this._collider = new BABYLON.Collider();
+            this._needMoveForGravity = true;
+            this._oldPosition = BABYLON.Vector3.Zero();
+            this._diffPosition = BABYLON.Vector3.Zero();
+            this._newPosition = BABYLON.Vector3.Zero();
+        }
+        // Controls
+        FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
+            var _this = this;
+            var previousPosition;
+            var engine = this.getEngine();
+            if (this._attachedElement) {
+                return;
+            }
+            this._attachedElement = element;
+            if (this._onMouseDown === undefined) {
+                this._onMouseDown = function (evt) {
+                    previousPosition = {
+                        x: evt.clientX,
+                        y: evt.clientY
+                    };
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._onMouseUp = function (evt) {
+                    previousPosition = null;
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._onMouseOut = function (evt) {
+                    previousPosition = null;
+                    _this._keys = [];
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._onMouseMove = function (evt) {
+                    if (!previousPosition && !engine.isPointerLock) {
+                        return;
+                    }
+                    var offsetX;
+                    var offsetY;
+                    if (!engine.isPointerLock) {
+                        offsetX = evt.clientX - previousPosition.x;
+                        offsetY = evt.clientY - previousPosition.y;
+                    }
+                    else {
+                        offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
+                        offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
+                    }
+                    _this.cameraRotation.y += offsetX / _this.angularSensibility;
+                    _this.cameraRotation.x += offsetY / _this.angularSensibility;
+                    previousPosition = {
+                        x: evt.clientX,
+                        y: evt.clientY
+                    };
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                };
+                this._onKeyDown = function (evt) {
+                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
+                        var index = _this._keys.indexOf(evt.keyCode);
+                        if (index === -1) {
+                            _this._keys.push(evt.keyCode);
+                        }
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
+                    }
+                };
+                this._onKeyUp = function (evt) {
+                    if (_this.keysUp.indexOf(evt.keyCode) !== -1 || _this.keysDown.indexOf(evt.keyCode) !== -1 || _this.keysLeft.indexOf(evt.keyCode) !== -1 || _this.keysRight.indexOf(evt.keyCode) !== -1) {
+                        var index = _this._keys.indexOf(evt.keyCode);
+                        if (index >= 0) {
+                            _this._keys.splice(index, 1);
+                        }
+                        if (!noPreventDefault) {
+                            evt.preventDefault();
+                        }
+                    }
+                };
+                this._onLostFocus = function () {
+                    _this._keys = [];
+                };
+                this._reset = function () {
+                    _this._keys = [];
+                    previousPosition = null;
+                    _this.cameraDirection = new BABYLON.Vector3(0, 0, 0);
+                    _this.cameraRotation = new BABYLON.Vector2(0, 0);
+                };
+            }
+            element.addEventListener("mousedown", this._onMouseDown, false);
+            element.addEventListener("mouseup", this._onMouseUp, false);
+            element.addEventListener("mouseout", this._onMouseOut, false);
+            element.addEventListener("mousemove", this._onMouseMove, false);
+            BABYLON.Tools.RegisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+        };
+        FreeCamera.prototype.detachControl = function (element) {
+            if (this._attachedElement != element) {
+                return;
+            }
+            element.removeEventListener("mousedown", this._onMouseDown);
+            element.removeEventListener("mouseup", this._onMouseUp);
+            element.removeEventListener("mouseout", this._onMouseOut);
+            element.removeEventListener("mousemove", this._onMouseMove);
+            BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "keydown", handler: this._onKeyDown },
+                { name: "keyup", handler: this._onKeyUp },
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+            this._attachedElement = null;
+            if (this._reset) {
+                this._reset();
+            }
+        };
+        FreeCamera.prototype._collideWithWorld = function (velocity) {
+            var globalPosition;
+            if (this.parent) {
+                globalPosition = BABYLON.Vector3.TransformCoordinates(this.position, this.parent.getWorldMatrix());
+            }
+            else {
+                globalPosition = this.position;
+            }
+            globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
+            this._collider.radius = this.ellipsoid;
+            this.getScene()._getNewPosition(this._oldPosition, velocity, this._collider, 3, this._newPosition);
+            this._newPosition.subtractToRef(this._oldPosition, this._diffPosition);
+            if (this._diffPosition.length() > BABYLON.Engine.CollisionsEpsilon) {
+                this.position.addInPlace(this._diffPosition);
+                if (this.onCollide) {
+                    this.onCollide(this._collider.collidedMesh);
+                }
+            }
+        };
+        FreeCamera.prototype._checkInputs = function () {
+            if (!this._localDirection) {
+                this._localDirection = BABYLON.Vector3.Zero();
+                this._transformedDirection = BABYLON.Vector3.Zero();
+            }
+            for (var index = 0; index < this._keys.length; index++) {
+                var keyCode = this._keys[index];
+                var speed = this._computeLocalCameraSpeed();
+                if (this.keysLeft.indexOf(keyCode) !== -1) {
+                    this._localDirection.copyFromFloats(-speed, 0, 0);
+                }
+                else if (this.keysUp.indexOf(keyCode) !== -1) {
+                    this._localDirection.copyFromFloats(0, 0, speed);
+                }
+                else if (this.keysRight.indexOf(keyCode) !== -1) {
+                    this._localDirection.copyFromFloats(speed, 0, 0);
+                }
+                else if (this.keysDown.indexOf(keyCode) !== -1) {
+                    this._localDirection.copyFromFloats(0, 0, -speed);
+                }
+                this.getViewMatrix().invertToRef(this._cameraTransformMatrix);
+                BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
+                this.cameraDirection.addInPlace(this._transformedDirection);
+            }
+        };
+        FreeCamera.prototype._decideIfNeedsToMove = function () {
+            return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
+        };
+        FreeCamera.prototype._updatePosition = function () {
+            if (this.checkCollisions && this.getScene().collisionsEnabled) {
+                this._collideWithWorld(this.cameraDirection);
+                if (this.applyGravity) {
+                    var oldPosition = this.position;
+                    this._collideWithWorld(this.getScene().gravity);
+                    this._needMoveForGravity = (BABYLON.Vector3.DistanceSquared(oldPosition, this.position) != 0);
+                }
+            }
+            else {
+                this.position.addInPlace(this.cameraDirection);
+            }
+        };
+        FreeCamera.prototype._update = function () {
+            this._checkInputs();
+            _super.prototype._update.call(this);
+        };
+        return FreeCamera;
+    })(BABYLON.TargetCamera);
+    BABYLON.FreeCamera = FreeCamera;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Cameras/babylon.freeCamera.js.map

+ 2 - 1
Babylon/Cameras/babylon.gamepadCamera.js

@@ -53,4 +53,5 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     BABYLON.GamepadCamera = GamepadCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.gamepadCamera.js.map
+
+//# sourceMappingURL=../Cameras/babylon.gamepadCamera.js.map

+ 2 - 1
Babylon/Cameras/babylon.targetCamera.js

@@ -171,4 +171,5 @@ var BABYLON;
     })(BABYLON.Camera);
     BABYLON.TargetCamera = TargetCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.targetCamera.js.map
+
+//# sourceMappingURL=../Cameras/babylon.targetCamera.js.map

+ 118 - 117
Babylon/Cameras/babylon.touchCamera.js

@@ -1,117 +1,118 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    // We're mainly based on the logic defined into the FreeCamera code
-    var TouchCamera = (function (_super) {
-        __extends(TouchCamera, _super);
-        function TouchCamera(name, position, scene) {
-            _super.call(this, name, position, scene);
-            this._offsetX = null;
-            this._offsetY = null;
-            this._pointerCount = 0;
-            this._pointerPressed = [];
-            this.angularSensibility = 200000.0;
-            this.moveSensibility = 500.0;
-        }
-        TouchCamera.prototype.attachControl = function (canvas, noPreventDefault) {
-            var _this = this;
-            var previousPosition;
-            if (this._attachedCanvas) {
-                return;
-            }
-            this._attachedCanvas = canvas;
-            if (this._onPointerDown === undefined) {
-                this._onPointerDown = function (evt) {
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                    _this._pointerPressed.push(evt.pointerId);
-                    if (_this._pointerPressed.length !== 1) {
-                        return;
-                    }
-                    previousPosition = {
-                        x: evt.clientX,
-                        y: evt.clientY
-                    };
-                };
-                this._onPointerUp = function (evt) {
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                    var index = _this._pointerPressed.indexOf(evt.pointerId);
-                    if (index === -1) {
-                        return;
-                    }
-                    _this._pointerPressed.splice(index, 1);
-                    if (index != 0) {
-                        return;
-                    }
-                    previousPosition = null;
-                    _this._offsetX = null;
-                    _this._offsetY = null;
-                };
-                this._onPointerMove = function (evt) {
-                    if (!noPreventDefault) {
-                        evt.preventDefault();
-                    }
-                    if (!previousPosition) {
-                        return;
-                    }
-                    var index = _this._pointerPressed.indexOf(evt.pointerId);
-                    if (index != 0) {
-                        return;
-                    }
-                    _this._offsetX = evt.clientX - previousPosition.x;
-                    _this._offsetY = -(evt.clientY - previousPosition.y);
-                };
-                this._onLostFocus = function () {
-                    _this._offsetX = null;
-                    _this._offsetY = null;
-                };
-            }
-            canvas.addEventListener("pointerdown", this._onPointerDown);
-            canvas.addEventListener("pointerup", this._onPointerUp);
-            canvas.addEventListener("pointerout", this._onPointerUp);
-            canvas.addEventListener("pointermove", this._onPointerMove);
-            BABYLON.Tools.RegisterTopRootEvents([
-                { name: "blur", handler: this._onLostFocus }
-            ]);
-        };
-        TouchCamera.prototype.detachControl = function (canvas) {
-            if (this._attachedCanvas != canvas) {
-                return;
-            }
-            canvas.removeEventListener("pointerdown", this._onPointerDown);
-            canvas.removeEventListener("pointerup", this._onPointerUp);
-            canvas.removeEventListener("pointerout", this._onPointerUp);
-            canvas.removeEventListener("pointermove", this._onPointerMove);
-            BABYLON.Tools.UnregisterTopRootEvents([
-                { name: "blur", handler: this._onLostFocus }
-            ]);
-            this._attachedCanvas = null;
-        };
-        TouchCamera.prototype._checkInputs = function () {
-            if (!this._offsetX) {
-                return;
-            }
-            this.cameraRotation.y += this._offsetX / this.angularSensibility;
-            if (this._pointerPressed.length > 1) {
-                this.cameraRotation.x += -this._offsetY / this.angularSensibility;
-            }
-            else {
-                var speed = this._computeLocalCameraSpeed();
-                var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
-                BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
-                this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
-            }
-        };
-        return TouchCamera;
-    })(BABYLON.FreeCamera);
-    BABYLON.TouchCamera = TouchCamera;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.touchCamera.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    // We're mainly based on the logic defined into the FreeCamera code
+    var TouchCamera = (function (_super) {
+        __extends(TouchCamera, _super);
+        function TouchCamera(name, position, scene) {
+            _super.call(this, name, position, scene);
+            this._offsetX = null;
+            this._offsetY = null;
+            this._pointerCount = 0;
+            this._pointerPressed = [];
+            this.angularSensibility = 200000.0;
+            this.moveSensibility = 500.0;
+        }
+        TouchCamera.prototype.attachControl = function (canvas, noPreventDefault) {
+            var _this = this;
+            var previousPosition;
+            if (this._attachedCanvas) {
+                return;
+            }
+            this._attachedCanvas = canvas;
+            if (this._onPointerDown === undefined) {
+                this._onPointerDown = function (evt) {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                    _this._pointerPressed.push(evt.pointerId);
+                    if (_this._pointerPressed.length !== 1) {
+                        return;
+                    }
+                    previousPosition = {
+                        x: evt.clientX,
+                        y: evt.clientY
+                    };
+                };
+                this._onPointerUp = function (evt) {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                    var index = _this._pointerPressed.indexOf(evt.pointerId);
+                    if (index === -1) {
+                        return;
+                    }
+                    _this._pointerPressed.splice(index, 1);
+                    if (index != 0) {
+                        return;
+                    }
+                    previousPosition = null;
+                    _this._offsetX = null;
+                    _this._offsetY = null;
+                };
+                this._onPointerMove = function (evt) {
+                    if (!noPreventDefault) {
+                        evt.preventDefault();
+                    }
+                    if (!previousPosition) {
+                        return;
+                    }
+                    var index = _this._pointerPressed.indexOf(evt.pointerId);
+                    if (index != 0) {
+                        return;
+                    }
+                    _this._offsetX = evt.clientX - previousPosition.x;
+                    _this._offsetY = -(evt.clientY - previousPosition.y);
+                };
+                this._onLostFocus = function () {
+                    _this._offsetX = null;
+                    _this._offsetY = null;
+                };
+            }
+            canvas.addEventListener("pointerdown", this._onPointerDown);
+            canvas.addEventListener("pointerup", this._onPointerUp);
+            canvas.addEventListener("pointerout", this._onPointerUp);
+            canvas.addEventListener("pointermove", this._onPointerMove);
+            BABYLON.Tools.RegisterTopRootEvents([
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+        };
+        TouchCamera.prototype.detachControl = function (canvas) {
+            if (this._attachedCanvas != canvas) {
+                return;
+            }
+            canvas.removeEventListener("pointerdown", this._onPointerDown);
+            canvas.removeEventListener("pointerup", this._onPointerUp);
+            canvas.removeEventListener("pointerout", this._onPointerUp);
+            canvas.removeEventListener("pointermove", this._onPointerMove);
+            BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "blur", handler: this._onLostFocus }
+            ]);
+            this._attachedCanvas = null;
+        };
+        TouchCamera.prototype._checkInputs = function () {
+            if (!this._offsetX) {
+                return;
+            }
+            this.cameraRotation.y += this._offsetX / this.angularSensibility;
+            if (this._pointerPressed.length > 1) {
+                this.cameraRotation.x += -this._offsetY / this.angularSensibility;
+            }
+            else {
+                var speed = this._computeLocalCameraSpeed();
+                var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+                BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+                this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
+            }
+        };
+        return TouchCamera;
+    })(BABYLON.FreeCamera);
+    BABYLON.TouchCamera = TouchCamera;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Cameras/babylon.touchCamera.js.map

+ 2 - 1
Babylon/Cameras/babylon.virtualJoysticksCamera.js

@@ -42,4 +42,5 @@ var BABYLON;
     })(BABYLON.FreeCamera);
     BABYLON.VirtualJoysticksCamera = VirtualJoysticksCamera;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.virtualJoysticksCamera.js.map
+
+//# sourceMappingURL=../Cameras/babylon.virtualJoysticksCamera.js.map

+ 274 - 273
Babylon/Collisions/babylon.collider.js

@@ -1,273 +1,274 @@
-var BABYLON;
-(function (BABYLON) {
-    var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
-        if (boxMin.x > sphereCenter.x + sphereRadius)
-            return false;
-        if (sphereCenter.x - sphereRadius > boxMax.x)
-            return false;
-        if (boxMin.y > sphereCenter.y + sphereRadius)
-            return false;
-        if (sphereCenter.y - sphereRadius > boxMax.y)
-            return false;
-        if (boxMin.z > sphereCenter.z + sphereRadius)
-            return false;
-        if (sphereCenter.z - sphereRadius > boxMax.z)
-            return false;
-        return true;
-    };
-    var getLowestRoot = function (a, b, c, maxR) {
-        var determinant = b * b - 4.0 * a * c;
-        var result = { root: 0, found: false };
-        if (determinant < 0)
-            return result;
-        var sqrtD = Math.sqrt(determinant);
-        var r1 = (-b - sqrtD) / (2.0 * a);
-        var r2 = (-b + sqrtD) / (2.0 * a);
-        if (r1 > r2) {
-            var temp = r2;
-            r2 = r1;
-            r1 = temp;
-        }
-        if (r1 > 0 && r1 < maxR) {
-            result.root = r1;
-            result.found = true;
-            return result;
-        }
-        if (r2 > 0 && r2 < maxR) {
-            result.root = r2;
-            result.found = true;
-            return result;
-        }
-        return result;
-    };
-    var Collider = (function () {
-        function Collider() {
-            this.radius = new BABYLON.Vector3(1, 1, 1);
-            this.retry = 0;
-            this.basePointWorld = BABYLON.Vector3.Zero();
-            this.velocityWorld = BABYLON.Vector3.Zero();
-            this.normalizedVelocity = BABYLON.Vector3.Zero();
-            this._collisionPoint = BABYLON.Vector3.Zero();
-            this._planeIntersectionPoint = BABYLON.Vector3.Zero();
-            this._tempVector = BABYLON.Vector3.Zero();
-            this._tempVector2 = BABYLON.Vector3.Zero();
-            this._tempVector3 = BABYLON.Vector3.Zero();
-            this._tempVector4 = BABYLON.Vector3.Zero();
-            this._edge = BABYLON.Vector3.Zero();
-            this._baseToVertex = BABYLON.Vector3.Zero();
-            this._destinationPoint = BABYLON.Vector3.Zero();
-            this._slidePlaneNormal = BABYLON.Vector3.Zero();
-            this._displacementVector = BABYLON.Vector3.Zero();
-        }
-        // Methods
-        Collider.prototype._initialize = function (source, dir, e) {
-            this.velocity = dir;
-            BABYLON.Vector3.NormalizeToRef(dir, this.normalizedVelocity);
-            this.basePoint = source;
-            source.multiplyToRef(this.radius, this.basePointWorld);
-            dir.multiplyToRef(this.radius, this.velocityWorld);
-            this.velocityWorldLength = this.velocityWorld.length();
-            this.epsilon = e;
-            this.collisionFound = false;
-        };
-        Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
-            pa.subtractToRef(point, this._tempVector);
-            pb.subtractToRef(point, this._tempVector2);
-            BABYLON.Vector3.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
-            var d = BABYLON.Vector3.Dot(this._tempVector4, n);
-            if (d < 0)
-                return false;
-            pc.subtractToRef(point, this._tempVector3);
-            BABYLON.Vector3.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
-            d = BABYLON.Vector3.Dot(this._tempVector4, n);
-            if (d < 0)
-                return false;
-            BABYLON.Vector3.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
-            d = BABYLON.Vector3.Dot(this._tempVector4, n);
-            return d >= 0;
-        };
-        Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
-            var distance = BABYLON.Vector3.Distance(this.basePointWorld, sphereCenter);
-            var max = Math.max(this.radius.x, this.radius.y, this.radius.z);
-            if (distance > this.velocityWorldLength + max + sphereRadius) {
-                return false;
-            }
-            if (!intersectBoxAASphere(vecMin, vecMax, this.basePointWorld, this.velocityWorldLength + max))
-                return false;
-            return true;
-        };
-        Collider.prototype._testTriangle = function (faceIndex, subMesh, p1, p2, p3) {
-            var t0;
-            var embeddedInPlane = false;
-            if (!subMesh._trianglePlanes) {
-                subMesh._trianglePlanes = [];
-            }
-            if (!subMesh._trianglePlanes[faceIndex]) {
-                subMesh._trianglePlanes[faceIndex] = new BABYLON.Plane(0, 0, 0, 0);
-                subMesh._trianglePlanes[faceIndex].copyFromPoints(p1, p2, p3);
-            }
-            var trianglePlane = subMesh._trianglePlanes[faceIndex];
-            if ((!subMesh.getMaterial()) && !trianglePlane.isFrontFacingTo(this.normalizedVelocity, 0))
-                return;
-            var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this.basePoint);
-            var normalDotVelocity = BABYLON.Vector3.Dot(trianglePlane.normal, this.velocity);
-            if (normalDotVelocity == 0) {
-                if (Math.abs(signedDistToTrianglePlane) >= 1.0)
-                    return;
-                embeddedInPlane = true;
-                t0 = 0;
-            }
-            else {
-                t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
-                var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
-                if (t0 > t1) {
-                    var temp = t1;
-                    t1 = t0;
-                    t0 = temp;
-                }
-                if (t0 > 1.0 || t1 < 0.0)
-                    return;
-                if (t0 < 0)
-                    t0 = 0;
-                if (t0 > 1.0)
-                    t0 = 1.0;
-            }
-            this._collisionPoint.copyFromFloats(0, 0, 0);
-            var found = false;
-            var t = 1.0;
-            if (!embeddedInPlane) {
-                this.basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
-                this.velocity.scaleToRef(t0, this._tempVector);
-                this._planeIntersectionPoint.addInPlace(this._tempVector);
-                if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
-                    found = true;
-                    t = t0;
-                    this._collisionPoint.copyFrom(this._planeIntersectionPoint);
-                }
-            }
-            if (!found) {
-                var velocitySquaredLength = this.velocity.lengthSquared();
-                var a = velocitySquaredLength;
-                this.basePoint.subtractToRef(p1, this._tempVector);
-                var b = 2.0 * (BABYLON.Vector3.Dot(this.velocity, this._tempVector));
-                var c = this._tempVector.lengthSquared() - 1.0;
-                var lowestRoot = getLowestRoot(a, b, c, t);
-                if (lowestRoot.found) {
-                    t = lowestRoot.root;
-                    found = true;
-                    this._collisionPoint.copyFrom(p1);
-                }
-                this.basePoint.subtractToRef(p2, this._tempVector);
-                b = 2.0 * (BABYLON.Vector3.Dot(this.velocity, this._tempVector));
-                c = this._tempVector.lengthSquared() - 1.0;
-                lowestRoot = getLowestRoot(a, b, c, t);
-                if (lowestRoot.found) {
-                    t = lowestRoot.root;
-                    found = true;
-                    this._collisionPoint.copyFrom(p2);
-                }
-                this.basePoint.subtractToRef(p3, this._tempVector);
-                b = 2.0 * (BABYLON.Vector3.Dot(this.velocity, this._tempVector));
-                c = this._tempVector.lengthSquared() - 1.0;
-                lowestRoot = getLowestRoot(a, b, c, t);
-                if (lowestRoot.found) {
-                    t = lowestRoot.root;
-                    found = true;
-                    this._collisionPoint.copyFrom(p3);
-                }
-                p2.subtractToRef(p1, this._edge);
-                p1.subtractToRef(this.basePoint, this._baseToVertex);
-                var edgeSquaredLength = this._edge.lengthSquared();
-                var edgeDotVelocity = BABYLON.Vector3.Dot(this._edge, this.velocity);
-                var edgeDotBaseToVertex = BABYLON.Vector3.Dot(this._edge, this._baseToVertex);
-                a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
-                b = edgeSquaredLength * (2.0 * BABYLON.Vector3.Dot(this.velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
-                c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
-                lowestRoot = getLowestRoot(a, b, c, t);
-                if (lowestRoot.found) {
-                    var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
-                    if (f >= 0.0 && f <= 1.0) {
-                        t = lowestRoot.root;
-                        found = true;
-                        this._edge.scaleInPlace(f);
-                        p1.addToRef(this._edge, this._collisionPoint);
-                    }
-                }
-                p3.subtractToRef(p2, this._edge);
-                p2.subtractToRef(this.basePoint, this._baseToVertex);
-                edgeSquaredLength = this._edge.lengthSquared();
-                edgeDotVelocity = BABYLON.Vector3.Dot(this._edge, this.velocity);
-                edgeDotBaseToVertex = BABYLON.Vector3.Dot(this._edge, this._baseToVertex);
-                a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
-                b = edgeSquaredLength * (2.0 * BABYLON.Vector3.Dot(this.velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
-                c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
-                lowestRoot = getLowestRoot(a, b, c, t);
-                if (lowestRoot.found) {
-                    f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
-                    if (f >= 0.0 && f <= 1.0) {
-                        t = lowestRoot.root;
-                        found = true;
-                        this._edge.scaleInPlace(f);
-                        p2.addToRef(this._edge, this._collisionPoint);
-                    }
-                }
-                p1.subtractToRef(p3, this._edge);
-                p3.subtractToRef(this.basePoint, this._baseToVertex);
-                edgeSquaredLength = this._edge.lengthSquared();
-                edgeDotVelocity = BABYLON.Vector3.Dot(this._edge, this.velocity);
-                edgeDotBaseToVertex = BABYLON.Vector3.Dot(this._edge, this._baseToVertex);
-                a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
-                b = edgeSquaredLength * (2.0 * BABYLON.Vector3.Dot(this.velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
-                c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
-                lowestRoot = getLowestRoot(a, b, c, t);
-                if (lowestRoot.found) {
-                    f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
-                    if (f >= 0.0 && f <= 1.0) {
-                        t = lowestRoot.root;
-                        found = true;
-                        this._edge.scaleInPlace(f);
-                        p3.addToRef(this._edge, this._collisionPoint);
-                    }
-                }
-            }
-            if (found) {
-                var distToCollision = t * this.velocity.length();
-                if (!this.collisionFound || distToCollision < this.nearestDistance) {
-                    if (!this.intersectionPoint) {
-                        this.intersectionPoint = this._collisionPoint.clone();
-                    }
-                    else {
-                        this.intersectionPoint.copyFrom(this._collisionPoint);
-                    }
-                    this.nearestDistance = distToCollision;
-                    this.collisionFound = true;
-                    this.collidedMesh = subMesh.getMesh();
-                }
-            }
-        };
-        Collider.prototype._collide = function (subMesh, pts, indices, indexStart, indexEnd, decal) {
-            for (var i = indexStart; i < indexEnd; i += 3) {
-                var p1 = pts[indices[i] - decal];
-                var p2 = pts[indices[i + 1] - decal];
-                var p3 = pts[indices[i + 2] - decal];
-                this._testTriangle(i, subMesh, p3, p2, p1);
-            }
-        };
-        Collider.prototype._getResponse = function (pos, vel) {
-            pos.addToRef(vel, this._destinationPoint);
-            vel.scaleInPlace((this.nearestDistance / vel.length()));
-            this.basePoint.addToRef(vel, pos);
-            pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
-            this._slidePlaneNormal.normalize();
-            this._slidePlaneNormal.scaleToRef(this.epsilon, this._displacementVector);
-            pos.addInPlace(this._displacementVector);
-            this.intersectionPoint.addInPlace(this._displacementVector);
-            this._slidePlaneNormal.scaleInPlace(BABYLON.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
-            this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
-            this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
-        };
-        return Collider;
-    })();
-    BABYLON.Collider = Collider;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.collider.js.map
+var BABYLON;
+(function (BABYLON) {
+    var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
+        if (boxMin.x > sphereCenter.x + sphereRadius)
+            return false;
+        if (sphereCenter.x - sphereRadius > boxMax.x)
+            return false;
+        if (boxMin.y > sphereCenter.y + sphereRadius)
+            return false;
+        if (sphereCenter.y - sphereRadius > boxMax.y)
+            return false;
+        if (boxMin.z > sphereCenter.z + sphereRadius)
+            return false;
+        if (sphereCenter.z - sphereRadius > boxMax.z)
+            return false;
+        return true;
+    };
+    var getLowestRoot = function (a, b, c, maxR) {
+        var determinant = b * b - 4.0 * a * c;
+        var result = { root: 0, found: false };
+        if (determinant < 0)
+            return result;
+        var sqrtD = Math.sqrt(determinant);
+        var r1 = (-b - sqrtD) / (2.0 * a);
+        var r2 = (-b + sqrtD) / (2.0 * a);
+        if (r1 > r2) {
+            var temp = r2;
+            r2 = r1;
+            r1 = temp;
+        }
+        if (r1 > 0 && r1 < maxR) {
+            result.root = r1;
+            result.found = true;
+            return result;
+        }
+        if (r2 > 0 && r2 < maxR) {
+            result.root = r2;
+            result.found = true;
+            return result;
+        }
+        return result;
+    };
+    var Collider = (function () {
+        function Collider() {
+            this.radius = new BABYLON.Vector3(1, 1, 1);
+            this.retry = 0;
+            this.basePointWorld = BABYLON.Vector3.Zero();
+            this.velocityWorld = BABYLON.Vector3.Zero();
+            this.normalizedVelocity = BABYLON.Vector3.Zero();
+            this._collisionPoint = BABYLON.Vector3.Zero();
+            this._planeIntersectionPoint = BABYLON.Vector3.Zero();
+            this._tempVector = BABYLON.Vector3.Zero();
+            this._tempVector2 = BABYLON.Vector3.Zero();
+            this._tempVector3 = BABYLON.Vector3.Zero();
+            this._tempVector4 = BABYLON.Vector3.Zero();
+            this._edge = BABYLON.Vector3.Zero();
+            this._baseToVertex = BABYLON.Vector3.Zero();
+            this._destinationPoint = BABYLON.Vector3.Zero();
+            this._slidePlaneNormal = BABYLON.Vector3.Zero();
+            this._displacementVector = BABYLON.Vector3.Zero();
+        }
+        // Methods
+        Collider.prototype._initialize = function (source, dir, e) {
+            this.velocity = dir;
+            BABYLON.Vector3.NormalizeToRef(dir, this.normalizedVelocity);
+            this.basePoint = source;
+            source.multiplyToRef(this.radius, this.basePointWorld);
+            dir.multiplyToRef(this.radius, this.velocityWorld);
+            this.velocityWorldLength = this.velocityWorld.length();
+            this.epsilon = e;
+            this.collisionFound = false;
+        };
+        Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
+            pa.subtractToRef(point, this._tempVector);
+            pb.subtractToRef(point, this._tempVector2);
+            BABYLON.Vector3.CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
+            var d = BABYLON.Vector3.Dot(this._tempVector4, n);
+            if (d < 0)
+                return false;
+            pc.subtractToRef(point, this._tempVector3);
+            BABYLON.Vector3.CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
+            d = BABYLON.Vector3.Dot(this._tempVector4, n);
+            if (d < 0)
+                return false;
+            BABYLON.Vector3.CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
+            d = BABYLON.Vector3.Dot(this._tempVector4, n);
+            return d >= 0;
+        };
+        Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
+            var distance = BABYLON.Vector3.Distance(this.basePointWorld, sphereCenter);
+            var max = Math.max(this.radius.x, this.radius.y, this.radius.z);
+            if (distance > this.velocityWorldLength + max + sphereRadius) {
+                return false;
+            }
+            if (!intersectBoxAASphere(vecMin, vecMax, this.basePointWorld, this.velocityWorldLength + max))
+                return false;
+            return true;
+        };
+        Collider.prototype._testTriangle = function (faceIndex, subMesh, p1, p2, p3) {
+            var t0;
+            var embeddedInPlane = false;
+            if (!subMesh._trianglePlanes) {
+                subMesh._trianglePlanes = [];
+            }
+            if (!subMesh._trianglePlanes[faceIndex]) {
+                subMesh._trianglePlanes[faceIndex] = new BABYLON.Plane(0, 0, 0, 0);
+                subMesh._trianglePlanes[faceIndex].copyFromPoints(p1, p2, p3);
+            }
+            var trianglePlane = subMesh._trianglePlanes[faceIndex];
+            if ((!subMesh.getMaterial()) && !trianglePlane.isFrontFacingTo(this.normalizedVelocity, 0))
+                return;
+            var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this.basePoint);
+            var normalDotVelocity = BABYLON.Vector3.Dot(trianglePlane.normal, this.velocity);
+            if (normalDotVelocity == 0) {
+                if (Math.abs(signedDistToTrianglePlane) >= 1.0)
+                    return;
+                embeddedInPlane = true;
+                t0 = 0;
+            }
+            else {
+                t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
+                var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
+                if (t0 > t1) {
+                    var temp = t1;
+                    t1 = t0;
+                    t0 = temp;
+                }
+                if (t0 > 1.0 || t1 < 0.0)
+                    return;
+                if (t0 < 0)
+                    t0 = 0;
+                if (t0 > 1.0)
+                    t0 = 1.0;
+            }
+            this._collisionPoint.copyFromFloats(0, 0, 0);
+            var found = false;
+            var t = 1.0;
+            if (!embeddedInPlane) {
+                this.basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
+                this.velocity.scaleToRef(t0, this._tempVector);
+                this._planeIntersectionPoint.addInPlace(this._tempVector);
+                if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
+                    found = true;
+                    t = t0;
+                    this._collisionPoint.copyFrom(this._planeIntersectionPoint);
+                }
+            }
+            if (!found) {
+                var velocitySquaredLength = this.velocity.lengthSquared();
+                var a = velocitySquaredLength;
+                this.basePoint.subtractToRef(p1, this._tempVector);
+                var b = 2.0 * (BABYLON.Vector3.Dot(this.velocity, this._tempVector));
+                var c = this._tempVector.lengthSquared() - 1.0;
+                var lowestRoot = getLowestRoot(a, b, c, t);
+                if (lowestRoot.found) {
+                    t = lowestRoot.root;
+                    found = true;
+                    this._collisionPoint.copyFrom(p1);
+                }
+                this.basePoint.subtractToRef(p2, this._tempVector);
+                b = 2.0 * (BABYLON.Vector3.Dot(this.velocity, this._tempVector));
+                c = this._tempVector.lengthSquared() - 1.0;
+                lowestRoot = getLowestRoot(a, b, c, t);
+                if (lowestRoot.found) {
+                    t = lowestRoot.root;
+                    found = true;
+                    this._collisionPoint.copyFrom(p2);
+                }
+                this.basePoint.subtractToRef(p3, this._tempVector);
+                b = 2.0 * (BABYLON.Vector3.Dot(this.velocity, this._tempVector));
+                c = this._tempVector.lengthSquared() - 1.0;
+                lowestRoot = getLowestRoot(a, b, c, t);
+                if (lowestRoot.found) {
+                    t = lowestRoot.root;
+                    found = true;
+                    this._collisionPoint.copyFrom(p3);
+                }
+                p2.subtractToRef(p1, this._edge);
+                p1.subtractToRef(this.basePoint, this._baseToVertex);
+                var edgeSquaredLength = this._edge.lengthSquared();
+                var edgeDotVelocity = BABYLON.Vector3.Dot(this._edge, this.velocity);
+                var edgeDotBaseToVertex = BABYLON.Vector3.Dot(this._edge, this._baseToVertex);
+                a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
+                b = edgeSquaredLength * (2.0 * BABYLON.Vector3.Dot(this.velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
+                c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
+                lowestRoot = getLowestRoot(a, b, c, t);
+                if (lowestRoot.found) {
+                    var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
+                    if (f >= 0.0 && f <= 1.0) {
+                        t = lowestRoot.root;
+                        found = true;
+                        this._edge.scaleInPlace(f);
+                        p1.addToRef(this._edge, this._collisionPoint);
+                    }
+                }
+                p3.subtractToRef(p2, this._edge);
+                p2.subtractToRef(this.basePoint, this._baseToVertex);
+                edgeSquaredLength = this._edge.lengthSquared();
+                edgeDotVelocity = BABYLON.Vector3.Dot(this._edge, this.velocity);
+                edgeDotBaseToVertex = BABYLON.Vector3.Dot(this._edge, this._baseToVertex);
+                a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
+                b = edgeSquaredLength * (2.0 * BABYLON.Vector3.Dot(this.velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
+                c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
+                lowestRoot = getLowestRoot(a, b, c, t);
+                if (lowestRoot.found) {
+                    f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
+                    if (f >= 0.0 && f <= 1.0) {
+                        t = lowestRoot.root;
+                        found = true;
+                        this._edge.scaleInPlace(f);
+                        p2.addToRef(this._edge, this._collisionPoint);
+                    }
+                }
+                p1.subtractToRef(p3, this._edge);
+                p3.subtractToRef(this.basePoint, this._baseToVertex);
+                edgeSquaredLength = this._edge.lengthSquared();
+                edgeDotVelocity = BABYLON.Vector3.Dot(this._edge, this.velocity);
+                edgeDotBaseToVertex = BABYLON.Vector3.Dot(this._edge, this._baseToVertex);
+                a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
+                b = edgeSquaredLength * (2.0 * BABYLON.Vector3.Dot(this.velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
+                c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
+                lowestRoot = getLowestRoot(a, b, c, t);
+                if (lowestRoot.found) {
+                    f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
+                    if (f >= 0.0 && f <= 1.0) {
+                        t = lowestRoot.root;
+                        found = true;
+                        this._edge.scaleInPlace(f);
+                        p3.addToRef(this._edge, this._collisionPoint);
+                    }
+                }
+            }
+            if (found) {
+                var distToCollision = t * this.velocity.length();
+                if (!this.collisionFound || distToCollision < this.nearestDistance) {
+                    if (!this.intersectionPoint) {
+                        this.intersectionPoint = this._collisionPoint.clone();
+                    }
+                    else {
+                        this.intersectionPoint.copyFrom(this._collisionPoint);
+                    }
+                    this.nearestDistance = distToCollision;
+                    this.collisionFound = true;
+                    this.collidedMesh = subMesh.getMesh();
+                }
+            }
+        };
+        Collider.prototype._collide = function (subMesh, pts, indices, indexStart, indexEnd, decal) {
+            for (var i = indexStart; i < indexEnd; i += 3) {
+                var p1 = pts[indices[i] - decal];
+                var p2 = pts[indices[i + 1] - decal];
+                var p3 = pts[indices[i + 2] - decal];
+                this._testTriangle(i, subMesh, p3, p2, p1);
+            }
+        };
+        Collider.prototype._getResponse = function (pos, vel) {
+            pos.addToRef(vel, this._destinationPoint);
+            vel.scaleInPlace((this.nearestDistance / vel.length()));
+            this.basePoint.addToRef(vel, pos);
+            pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
+            this._slidePlaneNormal.normalize();
+            this._slidePlaneNormal.scaleToRef(this.epsilon, this._displacementVector);
+            pos.addInPlace(this._displacementVector);
+            this.intersectionPoint.addInPlace(this._displacementVector);
+            this._slidePlaneNormal.scaleInPlace(BABYLON.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
+            this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
+            this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
+        };
+        return Collider;
+    })();
+    BABYLON.Collider = Collider;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Collisions/babylon.collider.js.map

+ 2 - 1
Babylon/Collisions/babylon.pickingInfo.js

@@ -55,4 +55,5 @@ var BABYLON;
     })();
     BABYLON.PickingInfo = PickingInfo;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.pickingInfo.js.map
+
+//# sourceMappingURL=../Collisions/babylon.pickingInfo.js.map

+ 2 - 1
Babylon/Culling/Octrees/babylon.octree.js

@@ -85,4 +85,5 @@ var BABYLON;
     })();
     BABYLON.Octree = Octree;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.octree.js.map
+
+//# sourceMappingURL=../../Culling/Octrees/babylon.octree.js.map

+ 2 - 1
Babylon/Culling/Octrees/babylon.octreeBlock.js

@@ -120,4 +120,5 @@ var BABYLON;
     })();
     BABYLON.OctreeBlock = OctreeBlock;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.octreeBlock.js.map
+
+//# sourceMappingURL=../../Culling/Octrees/babylon.octreeBlock.js.map

+ 107 - 106
Babylon/Culling/babylon.boundingInfo.js

@@ -1,106 +1,107 @@
-var BABYLON;
-(function (BABYLON) {
-    var computeBoxExtents = function (axis, box) {
-        var p = BABYLON.Vector3.Dot(box.center, axis);
-        var r0 = Math.abs(BABYLON.Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;
-        var r1 = Math.abs(BABYLON.Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;
-        var r2 = Math.abs(BABYLON.Vector3.Dot(box.directions[2], axis)) * box.extendSize.z;
-        var r = r0 + r1 + r2;
-        return {
-            min: p - r,
-            max: p + r
-        };
-    };
-    var extentsOverlap = function (min0, max0, min1, max1) { return !(min0 > max1 || min1 > max0); };
-    var axisOverlap = function (axis, box0, box1) {
-        var result0 = computeBoxExtents(axis, box0);
-        var result1 = computeBoxExtents(axis, box1);
-        return extentsOverlap(result0.min, result0.max, result1.min, result1.max);
-    };
-    var BoundingInfo = (function () {
-        function BoundingInfo(minimum, maximum) {
-            this.minimum = minimum;
-            this.maximum = maximum;
-            this.boundingBox = new BABYLON.BoundingBox(minimum, maximum);
-            this.boundingSphere = new BABYLON.BoundingSphere(minimum, maximum);
-        }
-        // Methods
-        BoundingInfo.prototype._update = function (world) {
-            this.boundingBox._update(world);
-            this.boundingSphere._update(world);
-        };
-        BoundingInfo.prototype.isInFrustum = function (frustumPlanes) {
-            if (!this.boundingSphere.isInFrustum(frustumPlanes))
-                return false;
-            return this.boundingBox.isInFrustum(frustumPlanes);
-        };
-        BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
-            return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
-        };
-        BoundingInfo.prototype._checkCollision = function (collider) {
-            return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
-        };
-        BoundingInfo.prototype.intersectsPoint = function (point) {
-            if (!this.boundingSphere.centerWorld) {
-                return false;
-            }
-            if (!this.boundingSphere.intersectsPoint(point)) {
-                return false;
-            }
-            if (!this.boundingBox.intersectsPoint(point)) {
-                return false;
-            }
-            return true;
-        };
-        BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
-            if (!this.boundingSphere.centerWorld || !boundingInfo.boundingSphere.centerWorld) {
-                return false;
-            }
-            if (!BABYLON.BoundingSphere.Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
-                return false;
-            }
-            if (!BABYLON.BoundingBox.Intersects(this.boundingBox, boundingInfo.boundingBox)) {
-                return false;
-            }
-            if (!precise) {
-                return true;
-            }
-            var box0 = this.boundingBox;
-            var box1 = boundingInfo.boundingBox;
-            if (!axisOverlap(box0.directions[0], box0, box1))
-                return false;
-            if (!axisOverlap(box0.directions[1], box0, box1))
-                return false;
-            if (!axisOverlap(box0.directions[2], box0, box1))
-                return false;
-            if (!axisOverlap(box1.directions[0], box0, box1))
-                return false;
-            if (!axisOverlap(box1.directions[1], box0, box1))
-                return false;
-            if (!axisOverlap(box1.directions[2], box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[0], box1.directions[0]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[0], box1.directions[1]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[0], box1.directions[2]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[1], box1.directions[0]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[1], box1.directions[1]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[1], box1.directions[2]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[2], box1.directions[0]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[2], box1.directions[1]), box0, box1))
-                return false;
-            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[2], box1.directions[2]), box0, box1))
-                return false;
-            return true;
-        };
-        return BoundingInfo;
-    })();
-    BABYLON.BoundingInfo = BoundingInfo;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.boundingInfo.js.map
+var BABYLON;
+(function (BABYLON) {
+    var computeBoxExtents = function (axis, box) {
+        var p = BABYLON.Vector3.Dot(box.center, axis);
+        var r0 = Math.abs(BABYLON.Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;
+        var r1 = Math.abs(BABYLON.Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;
+        var r2 = Math.abs(BABYLON.Vector3.Dot(box.directions[2], axis)) * box.extendSize.z;
+        var r = r0 + r1 + r2;
+        return {
+            min: p - r,
+            max: p + r
+        };
+    };
+    var extentsOverlap = function (min0, max0, min1, max1) { return !(min0 > max1 || min1 > max0); };
+    var axisOverlap = function (axis, box0, box1) {
+        var result0 = computeBoxExtents(axis, box0);
+        var result1 = computeBoxExtents(axis, box1);
+        return extentsOverlap(result0.min, result0.max, result1.min, result1.max);
+    };
+    var BoundingInfo = (function () {
+        function BoundingInfo(minimum, maximum) {
+            this.minimum = minimum;
+            this.maximum = maximum;
+            this.boundingBox = new BABYLON.BoundingBox(minimum, maximum);
+            this.boundingSphere = new BABYLON.BoundingSphere(minimum, maximum);
+        }
+        // Methods
+        BoundingInfo.prototype._update = function (world) {
+            this.boundingBox._update(world);
+            this.boundingSphere._update(world);
+        };
+        BoundingInfo.prototype.isInFrustum = function (frustumPlanes) {
+            if (!this.boundingSphere.isInFrustum(frustumPlanes))
+                return false;
+            return this.boundingBox.isInFrustum(frustumPlanes);
+        };
+        BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
+            return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
+        };
+        BoundingInfo.prototype._checkCollision = function (collider) {
+            return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
+        };
+        BoundingInfo.prototype.intersectsPoint = function (point) {
+            if (!this.boundingSphere.centerWorld) {
+                return false;
+            }
+            if (!this.boundingSphere.intersectsPoint(point)) {
+                return false;
+            }
+            if (!this.boundingBox.intersectsPoint(point)) {
+                return false;
+            }
+            return true;
+        };
+        BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
+            if (!this.boundingSphere.centerWorld || !boundingInfo.boundingSphere.centerWorld) {
+                return false;
+            }
+            if (!BABYLON.BoundingSphere.Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
+                return false;
+            }
+            if (!BABYLON.BoundingBox.Intersects(this.boundingBox, boundingInfo.boundingBox)) {
+                return false;
+            }
+            if (!precise) {
+                return true;
+            }
+            var box0 = this.boundingBox;
+            var box1 = boundingInfo.boundingBox;
+            if (!axisOverlap(box0.directions[0], box0, box1))
+                return false;
+            if (!axisOverlap(box0.directions[1], box0, box1))
+                return false;
+            if (!axisOverlap(box0.directions[2], box0, box1))
+                return false;
+            if (!axisOverlap(box1.directions[0], box0, box1))
+                return false;
+            if (!axisOverlap(box1.directions[1], box0, box1))
+                return false;
+            if (!axisOverlap(box1.directions[2], box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[0], box1.directions[0]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[0], box1.directions[1]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[0], box1.directions[2]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[1], box1.directions[0]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[1], box1.directions[1]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[1], box1.directions[2]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[2], box1.directions[0]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[2], box1.directions[1]), box0, box1))
+                return false;
+            if (!axisOverlap(BABYLON.Vector3.Cross(box0.directions[2], box1.directions[2]), box0, box1))
+                return false;
+            return true;
+        };
+        return BoundingInfo;
+    })();
+    BABYLON.BoundingInfo = BoundingInfo;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Culling/babylon.boundingInfo.js.map

+ 51 - 50
Babylon/Culling/babylon.boundingSphere.js

@@ -1,50 +1,51 @@
-var BABYLON;
-(function (BABYLON) {
-    var BoundingSphere = (function () {
-        function BoundingSphere(minimum, maximum) {
-            this.minimum = minimum;
-            this.maximum = maximum;
-            this._tempRadiusVector = BABYLON.Vector3.Zero();
-            var distance = BABYLON.Vector3.Distance(minimum, maximum);
-            this.center = BABYLON.Vector3.Lerp(minimum, maximum, 0.5);
-            this.radius = distance * 0.5;
-            this.centerWorld = BABYLON.Vector3.Zero();
-            this._update(BABYLON.Matrix.Identity());
-        }
-        // Methods
-        BoundingSphere.prototype._update = function (world) {
-            BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
-            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, this._tempRadiusVector);
-            this.radiusWorld = Math.max(Math.abs(this._tempRadiusVector.x), Math.abs(this._tempRadiusVector.y), Math.abs(this._tempRadiusVector.z)) * this.radius;
-        };
-        BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
-            for (var i = 0; i < 6; i++) {
-                if (frustumPlanes[i].dotCoordinate(this.centerWorld) <= -this.radiusWorld)
-                    return false;
-            }
-            return true;
-        };
-        BoundingSphere.prototype.intersectsPoint = function (point) {
-            var x = this.centerWorld.x - point.x;
-            var y = this.centerWorld.y - point.y;
-            var z = this.centerWorld.z - point.z;
-            var distance = Math.sqrt((x * x) + (y * y) + (z * z));
-            if (Math.abs(this.radiusWorld - distance) < BABYLON.Engine.Epsilon)
-                return false;
-            return true;
-        };
-        // Statics
-        BoundingSphere.Intersects = function (sphere0, sphere1) {
-            var x = sphere0.centerWorld.x - sphere1.centerWorld.x;
-            var y = sphere0.centerWorld.y - sphere1.centerWorld.y;
-            var z = sphere0.centerWorld.z - sphere1.centerWorld.z;
-            var distance = Math.sqrt((x * x) + (y * y) + (z * z));
-            if (sphere0.radiusWorld + sphere1.radiusWorld < distance)
-                return false;
-            return true;
-        };
-        return BoundingSphere;
-    })();
-    BABYLON.BoundingSphere = BoundingSphere;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.boundingSphere.js.map
+var BABYLON;
+(function (BABYLON) {
+    var BoundingSphere = (function () {
+        function BoundingSphere(minimum, maximum) {
+            this.minimum = minimum;
+            this.maximum = maximum;
+            this._tempRadiusVector = BABYLON.Vector3.Zero();
+            var distance = BABYLON.Vector3.Distance(minimum, maximum);
+            this.center = BABYLON.Vector3.Lerp(minimum, maximum, 0.5);
+            this.radius = distance * 0.5;
+            this.centerWorld = BABYLON.Vector3.Zero();
+            this._update(BABYLON.Matrix.Identity());
+        }
+        // Methods
+        BoundingSphere.prototype._update = function (world) {
+            BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
+            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, this._tempRadiusVector);
+            this.radiusWorld = Math.max(Math.abs(this._tempRadiusVector.x), Math.abs(this._tempRadiusVector.y), Math.abs(this._tempRadiusVector.z)) * this.radius;
+        };
+        BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
+            for (var i = 0; i < 6; i++) {
+                if (frustumPlanes[i].dotCoordinate(this.centerWorld) <= -this.radiusWorld)
+                    return false;
+            }
+            return true;
+        };
+        BoundingSphere.prototype.intersectsPoint = function (point) {
+            var x = this.centerWorld.x - point.x;
+            var y = this.centerWorld.y - point.y;
+            var z = this.centerWorld.z - point.z;
+            var distance = Math.sqrt((x * x) + (y * y) + (z * z));
+            if (Math.abs(this.radiusWorld - distance) < BABYLON.Engine.Epsilon)
+                return false;
+            return true;
+        };
+        // Statics
+        BoundingSphere.Intersects = function (sphere0, sphere1) {
+            var x = sphere0.centerWorld.x - sphere1.centerWorld.x;
+            var y = sphere0.centerWorld.y - sphere1.centerWorld.y;
+            var z = sphere0.centerWorld.z - sphere1.centerWorld.z;
+            var distance = Math.sqrt((x * x) + (y * y) + (z * z));
+            if (sphere0.radiusWorld + sphere1.radiusWorld < distance)
+                return false;
+            return true;
+        };
+        return BoundingSphere;
+    })();
+    BABYLON.BoundingSphere = BoundingSphere;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Culling/babylon.boundingSphere.js.map

+ 2 - 1
Babylon/Debug/babylon.debugLayer.js

@@ -567,4 +567,5 @@ var BABYLON;
     })();
     BABYLON.DebugLayer = DebugLayer;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.debugLayer.js.map
+
+//# sourceMappingURL=../Debug/babylon.debugLayer.js.map

文件差异内容过多而无法显示
+ 1 - 1
Babylon/Debug/babylon.debugLayer.js.map


+ 78 - 77
Babylon/Layer/babylon.layer.js

@@ -1,77 +1,78 @@
-var BABYLON;
-(function (BABYLON) {
-    var Layer = (function () {
-        function Layer(name, imgUrl, scene, isBackground, color) {
-            this.name = name;
-            this._vertexDeclaration = [2];
-            this._vertexStrideSize = 2 * 4;
-            this.texture = imgUrl ? new BABYLON.Texture(imgUrl, scene, true) : null;
-            this.isBackground = isBackground === undefined ? true : isBackground;
-            this.color = color === undefined ? new BABYLON.Color4(1, 1, 1, 1) : color;
-            this._scene = scene;
-            this._scene.layers.push(this);
-            // VBO
-            var vertices = [];
-            vertices.push(1, 1);
-            vertices.push(-1, 1);
-            vertices.push(-1, -1);
-            vertices.push(1, -1);
-            this._vertexBuffer = scene.getEngine().createVertexBuffer(vertices);
-            // Indices
-            var indices = [];
-            indices.push(0);
-            indices.push(1);
-            indices.push(2);
-            indices.push(0);
-            indices.push(2);
-            indices.push(3);
-            this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
-            // Effects
-            this._effect = this._scene.getEngine().createEffect("layer", ["position"], ["textureMatrix", "color"], ["textureSampler"], "");
-        }
-        Layer.prototype.render = function () {
-            // Check
-            if (!this._effect.isReady() || !this.texture || !this.texture.isReady())
-                return;
-            var engine = this._scene.getEngine();
-            // Render
-            engine.enableEffect(this._effect);
-            engine.setState(false);
-            // Texture
-            this._effect.setTexture("textureSampler", this.texture);
-            this._effect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
-            // Color
-            this._effect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
-            // VBOs
-            engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, this._effect);
-            // Draw order
-            engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.draw(true, 0, 6);
-            engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
-        };
-        Layer.prototype.dispose = function () {
-            if (this._vertexBuffer) {
-                this._scene.getEngine()._releaseBuffer(this._vertexBuffer);
-                this._vertexBuffer = null;
-            }
-            if (this._indexBuffer) {
-                this._scene.getEngine()._releaseBuffer(this._indexBuffer);
-                this._indexBuffer = null;
-            }
-            if (this.texture) {
-                this.texture.dispose();
-                this.texture = null;
-            }
-            // Remove from scene
-            var index = this._scene.layers.indexOf(this);
-            this._scene.layers.splice(index, 1);
-            // Callback
-            if (this.onDispose) {
-                this.onDispose();
-            }
-        };
-        return Layer;
-    })();
-    BABYLON.Layer = Layer;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.layer.js.map
+var BABYLON;
+(function (BABYLON) {
+    var Layer = (function () {
+        function Layer(name, imgUrl, scene, isBackground, color) {
+            this.name = name;
+            this._vertexDeclaration = [2];
+            this._vertexStrideSize = 2 * 4;
+            this.texture = imgUrl ? new BABYLON.Texture(imgUrl, scene, true) : null;
+            this.isBackground = isBackground === undefined ? true : isBackground;
+            this.color = color === undefined ? new BABYLON.Color4(1, 1, 1, 1) : color;
+            this._scene = scene;
+            this._scene.layers.push(this);
+            // VBO
+            var vertices = [];
+            vertices.push(1, 1);
+            vertices.push(-1, 1);
+            vertices.push(-1, -1);
+            vertices.push(1, -1);
+            this._vertexBuffer = scene.getEngine().createVertexBuffer(vertices);
+            // Indices
+            var indices = [];
+            indices.push(0);
+            indices.push(1);
+            indices.push(2);
+            indices.push(0);
+            indices.push(2);
+            indices.push(3);
+            this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
+            // Effects
+            this._effect = this._scene.getEngine().createEffect("layer", ["position"], ["textureMatrix", "color"], ["textureSampler"], "");
+        }
+        Layer.prototype.render = function () {
+            // Check
+            if (!this._effect.isReady() || !this.texture || !this.texture.isReady())
+                return;
+            var engine = this._scene.getEngine();
+            // Render
+            engine.enableEffect(this._effect);
+            engine.setState(false);
+            // Texture
+            this._effect.setTexture("textureSampler", this.texture);
+            this._effect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
+            // Color
+            this._effect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
+            // VBOs
+            engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, this._effect);
+            // Draw order
+            engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            engine.draw(true, 0, 6);
+            engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
+        };
+        Layer.prototype.dispose = function () {
+            if (this._vertexBuffer) {
+                this._scene.getEngine()._releaseBuffer(this._vertexBuffer);
+                this._vertexBuffer = null;
+            }
+            if (this._indexBuffer) {
+                this._scene.getEngine()._releaseBuffer(this._indexBuffer);
+                this._indexBuffer = null;
+            }
+            if (this.texture) {
+                this.texture.dispose();
+                this.texture = null;
+            }
+            // Remove from scene
+            var index = this._scene.layers.indexOf(this);
+            this._scene.layers.splice(index, 1);
+            // Callback
+            if (this.onDispose) {
+                this.onDispose();
+            }
+        };
+        return Layer;
+    })();
+    BABYLON.Layer = Layer;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Layer/babylon.layer.js.map

+ 2 - 1
Babylon/LensFlare/babylon.lensFlare.js

@@ -21,4 +21,5 @@ var BABYLON;
     })();
     BABYLON.LensFlare = LensFlare;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.lensFlare.js.map
+
+//# sourceMappingURL=../LensFlare/babylon.lensFlare.js.map

+ 2 - 1
Babylon/LensFlare/babylon.lensFlareSystem.js

@@ -175,4 +175,5 @@ var BABYLON;
     })();
     BABYLON.LensFlareSystem = LensFlareSystem;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.lensFlareSystem.js.map
+
+//# sourceMappingURL=../LensFlare/babylon.lensFlareSystem.js.map

+ 2 - 1
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -202,4 +202,5 @@ var BABYLON;
     })();
     BABYLON.ShadowGenerator = ShadowGenerator;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.shadowGenerator.js.map
+
+//# sourceMappingURL=../../Lights/Shadows/babylon.shadowGenerator.js.map

+ 56 - 55
Babylon/Lights/babylon.directionalLight.js

@@ -1,55 +1,56 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var DirectionalLight = (function (_super) {
-        __extends(DirectionalLight, _super);
-        function DirectionalLight(name, direction, scene) {
-            _super.call(this, name, scene);
-            this.direction = direction;
-            this.position = direction.scale(-1);
-        }
-        DirectionalLight.prototype.getAbsolutePosition = function () {
-            return this.transformedPosition ? this.transformedPosition : this.position;
-        };
-        DirectionalLight.prototype.setDirectionToTarget = function (target) {
-            this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position));
-            return this.direction;
-        };
-        DirectionalLight.prototype.computeTransformedPosition = function () {
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this.transformedPosition) {
-                    this.transformedPosition = BABYLON.Vector3.Zero();
-                }
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
-                return true;
-            }
-            return false;
-        };
-        DirectionalLight.prototype.transferToEffect = function (effect, directionUniformName) {
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._transformedDirection) {
-                    this._transformedDirection = BABYLON.Vector3.Zero();
-                }
-                BABYLON.Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
-                effect.setFloat4(directionUniformName, this._transformedDirection.x, this._transformedDirection.y, this._transformedDirection.z, 1);
-                return;
-            }
-            effect.setFloat4(directionUniformName, this.direction.x, this.direction.y, this.direction.z, 1);
-        };
-        DirectionalLight.prototype._getWorldMatrix = function () {
-            if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
-            }
-            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
-            return this._worldMatrix;
-        };
-        return DirectionalLight;
-    })(BABYLON.Light);
-    BABYLON.DirectionalLight = DirectionalLight;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.directionalLight.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var DirectionalLight = (function (_super) {
+        __extends(DirectionalLight, _super);
+        function DirectionalLight(name, direction, scene) {
+            _super.call(this, name, scene);
+            this.direction = direction;
+            this.position = direction.scale(-1);
+        }
+        DirectionalLight.prototype.getAbsolutePosition = function () {
+            return this.transformedPosition ? this.transformedPosition : this.position;
+        };
+        DirectionalLight.prototype.setDirectionToTarget = function (target) {
+            this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position));
+            return this.direction;
+        };
+        DirectionalLight.prototype.computeTransformedPosition = function () {
+            if (this.parent && this.parent.getWorldMatrix) {
+                if (!this.transformedPosition) {
+                    this.transformedPosition = BABYLON.Vector3.Zero();
+                }
+                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
+                return true;
+            }
+            return false;
+        };
+        DirectionalLight.prototype.transferToEffect = function (effect, directionUniformName) {
+            if (this.parent && this.parent.getWorldMatrix) {
+                if (!this._transformedDirection) {
+                    this._transformedDirection = BABYLON.Vector3.Zero();
+                }
+                BABYLON.Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
+                effect.setFloat4(directionUniformName, this._transformedDirection.x, this._transformedDirection.y, this._transformedDirection.z, 1);
+                return;
+            }
+            effect.setFloat4(directionUniformName, this.direction.x, this.direction.y, this.direction.z, 1);
+        };
+        DirectionalLight.prototype._getWorldMatrix = function () {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            return this._worldMatrix;
+        };
+        return DirectionalLight;
+    })(BABYLON.Light);
+    BABYLON.DirectionalLight = DirectionalLight;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Lights/babylon.directionalLight.js.map

+ 39 - 38
Babylon/Lights/babylon.hemisphericLight.js

@@ -1,38 +1,39 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var HemisphericLight = (function (_super) {
-        __extends(HemisphericLight, _super);
-        function HemisphericLight(name, direction, scene) {
-            _super.call(this, name, scene);
-            this.direction = direction;
-            this.groundColor = new BABYLON.Color3(0.0, 0.0, 0.0);
-        }
-        HemisphericLight.prototype.setDirectionToTarget = function (target) {
-            this.direction = BABYLON.Vector3.Normalize(target.subtract(BABYLON.Vector3.Zero()));
-            return this.direction;
-        };
-        HemisphericLight.prototype.getShadowGenerator = function () {
-            return null;
-        };
-        HemisphericLight.prototype.transferToEffect = function (effect, directionUniformName, groundColorUniformName) {
-            var normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
-            effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
-            effect.setColor3(groundColorUniformName, this.groundColor.scale(this.intensity));
-        };
-        HemisphericLight.prototype._getWorldMatrix = function () {
-            if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
-            }
-            return this._worldMatrix;
-        };
-        return HemisphericLight;
-    })(BABYLON.Light);
-    BABYLON.HemisphericLight = HemisphericLight;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.hemisphericLight.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var HemisphericLight = (function (_super) {
+        __extends(HemisphericLight, _super);
+        function HemisphericLight(name, direction, scene) {
+            _super.call(this, name, scene);
+            this.direction = direction;
+            this.groundColor = new BABYLON.Color3(0.0, 0.0, 0.0);
+        }
+        HemisphericLight.prototype.setDirectionToTarget = function (target) {
+            this.direction = BABYLON.Vector3.Normalize(target.subtract(BABYLON.Vector3.Zero()));
+            return this.direction;
+        };
+        HemisphericLight.prototype.getShadowGenerator = function () {
+            return null;
+        };
+        HemisphericLight.prototype.transferToEffect = function (effect, directionUniformName, groundColorUniformName) {
+            var normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
+            effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
+            effect.setColor3(groundColorUniformName, this.groundColor.scale(this.intensity));
+        };
+        HemisphericLight.prototype._getWorldMatrix = function () {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            return this._worldMatrix;
+        };
+        return HemisphericLight;
+    })(BABYLON.Light);
+    BABYLON.HemisphericLight = HemisphericLight;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Lights/babylon.hemisphericLight.js.map

+ 72 - 71
Babylon/Lights/babylon.light.js

@@ -1,71 +1,72 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var Light = (function (_super) {
-        __extends(Light, _super);
-        function Light(name, scene) {
-            _super.call(this, name, scene);
-            this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
-            this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
-            this.intensity = 1.0;
-            this.range = Number.MAX_VALUE;
-            this.includedOnlyMeshes = new Array();
-            this.excludedMeshes = new Array();
-            this._excludedMeshesIds = new Array();
-            this._includedOnlyMeshesIds = new Array();
-            scene.lights.push(this);
-        }
-        Light.prototype.getShadowGenerator = function () {
-            return this._shadowGenerator;
-        };
-        Light.prototype.getAbsolutePosition = function () {
-            return BABYLON.Vector3.Zero();
-        };
-        Light.prototype.transferToEffect = function (effect, uniformName0, uniformName1) {
-        };
-        Light.prototype._getWorldMatrix = function () {
-            return BABYLON.Matrix.Identity();
-        };
-        Light.prototype.canAffectMesh = function (mesh) {
-            if (!mesh) {
-                return true;
-            }
-            if (this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
-                return false;
-            }
-            if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
-                return false;
-            }
-            return true;
-        };
-        Light.prototype.getWorldMatrix = function () {
-            this._currentRenderId = this.getScene().getRenderId();
-            var worldMatrix = this._getWorldMatrix();
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._parentedWorldMatrix) {
-                    this._parentedWorldMatrix = BABYLON.Matrix.Identity();
-                }
-                worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
-                return this._parentedWorldMatrix;
-            }
-            return worldMatrix;
-        };
-        Light.prototype.dispose = function () {
-            if (this._shadowGenerator) {
-                this._shadowGenerator.dispose();
-                this._shadowGenerator = null;
-            }
-            // Remove from scene
-            var index = this.getScene().lights.indexOf(this);
-            this.getScene().lights.splice(index, 1);
-        };
-        return Light;
-    })(BABYLON.Node);
-    BABYLON.Light = Light;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.light.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var Light = (function (_super) {
+        __extends(Light, _super);
+        function Light(name, scene) {
+            _super.call(this, name, scene);
+            this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
+            this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
+            this.intensity = 1.0;
+            this.range = Number.MAX_VALUE;
+            this.includedOnlyMeshes = new Array();
+            this.excludedMeshes = new Array();
+            this._excludedMeshesIds = new Array();
+            this._includedOnlyMeshesIds = new Array();
+            scene.lights.push(this);
+        }
+        Light.prototype.getShadowGenerator = function () {
+            return this._shadowGenerator;
+        };
+        Light.prototype.getAbsolutePosition = function () {
+            return BABYLON.Vector3.Zero();
+        };
+        Light.prototype.transferToEffect = function (effect, uniformName0, uniformName1) {
+        };
+        Light.prototype._getWorldMatrix = function () {
+            return BABYLON.Matrix.Identity();
+        };
+        Light.prototype.canAffectMesh = function (mesh) {
+            if (!mesh) {
+                return true;
+            }
+            if (this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
+                return false;
+            }
+            if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
+                return false;
+            }
+            return true;
+        };
+        Light.prototype.getWorldMatrix = function () {
+            this._currentRenderId = this.getScene().getRenderId();
+            var worldMatrix = this._getWorldMatrix();
+            if (this.parent && this.parent.getWorldMatrix) {
+                if (!this._parentedWorldMatrix) {
+                    this._parentedWorldMatrix = BABYLON.Matrix.Identity();
+                }
+                worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
+                return this._parentedWorldMatrix;
+            }
+            return worldMatrix;
+        };
+        Light.prototype.dispose = function () {
+            if (this._shadowGenerator) {
+                this._shadowGenerator.dispose();
+                this._shadowGenerator = null;
+            }
+            // Remove from scene
+            var index = this.getScene().lights.indexOf(this);
+            this.getScene().lights.splice(index, 1);
+        };
+        return Light;
+    })(BABYLON.Node);
+    BABYLON.Light = Light;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Lights/babylon.light.js.map

+ 44 - 43
Babylon/Lights/babylon.pointLight.js

@@ -1,43 +1,44 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var PointLight = (function (_super) {
-        __extends(PointLight, _super);
-        function PointLight(name, position, scene) {
-            _super.call(this, name, scene);
-            this.position = position;
-        }
-        PointLight.prototype.getAbsolutePosition = function () {
-            return this._transformedPosition ? this._transformedPosition : this.position;
-        };
-        PointLight.prototype.transferToEffect = function (effect, positionUniformName) {
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._transformedPosition) {
-                    this._transformedPosition = BABYLON.Vector3.Zero();
-                }
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
-                effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, 0);
-                return;
-            }
-            effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, 0);
-        };
-        PointLight.prototype.getShadowGenerator = function () {
-            return null;
-        };
-        PointLight.prototype._getWorldMatrix = function () {
-            if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
-            }
-            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
-            return this._worldMatrix;
-        };
-        return PointLight;
-    })(BABYLON.Light);
-    BABYLON.PointLight = PointLight;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.pointLight.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var PointLight = (function (_super) {
+        __extends(PointLight, _super);
+        function PointLight(name, position, scene) {
+            _super.call(this, name, scene);
+            this.position = position;
+        }
+        PointLight.prototype.getAbsolutePosition = function () {
+            return this._transformedPosition ? this._transformedPosition : this.position;
+        };
+        PointLight.prototype.transferToEffect = function (effect, positionUniformName) {
+            if (this.parent && this.parent.getWorldMatrix) {
+                if (!this._transformedPosition) {
+                    this._transformedPosition = BABYLON.Vector3.Zero();
+                }
+                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
+                effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, 0);
+                return;
+            }
+            effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, 0);
+        };
+        PointLight.prototype.getShadowGenerator = function () {
+            return null;
+        };
+        PointLight.prototype._getWorldMatrix = function () {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            return this._worldMatrix;
+        };
+        return PointLight;
+    })(BABYLON.Light);
+    BABYLON.PointLight = PointLight;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Lights/babylon.pointLight.js.map

+ 64 - 63
Babylon/Lights/babylon.spotLight.js

@@ -1,63 +1,64 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var SpotLight = (function (_super) {
-        __extends(SpotLight, _super);
-        function SpotLight(name, position, direction, angle, exponent, scene) {
-            _super.call(this, name, scene);
-            this.position = position;
-            this.direction = direction;
-            this.angle = angle;
-            this.exponent = exponent;
-        }
-        SpotLight.prototype.getAbsolutePosition = function () {
-            return this.transformedPosition ? this.transformedPosition : this.position;
-        };
-        SpotLight.prototype.setDirectionToTarget = function (target) {
-            this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position));
-            return this.direction;
-        };
-        SpotLight.prototype.computeTransformedPosition = function () {
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this.transformedPosition) {
-                    this.transformedPosition = BABYLON.Vector3.Zero();
-                }
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
-                return true;
-            }
-            return false;
-        };
-        SpotLight.prototype.transferToEffect = function (effect, positionUniformName, directionUniformName) {
-            var normalizeDirection;
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._transformedDirection) {
-                    this._transformedDirection = BABYLON.Vector3.Zero();
-                }
-                this.computeTransformedPosition();
-                BABYLON.Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
-                effect.setFloat4(positionUniformName, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent);
-                normalizeDirection = BABYLON.Vector3.Normalize(this._transformedDirection);
-            }
-            else {
-                effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, this.exponent);
-                normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
-            }
-            effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(this.angle * 0.5));
-        };
-        SpotLight.prototype._getWorldMatrix = function () {
-            if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
-            }
-            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
-            return this._worldMatrix;
-        };
-        return SpotLight;
-    })(BABYLON.Light);
-    BABYLON.SpotLight = SpotLight;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.spotLight.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var SpotLight = (function (_super) {
+        __extends(SpotLight, _super);
+        function SpotLight(name, position, direction, angle, exponent, scene) {
+            _super.call(this, name, scene);
+            this.position = position;
+            this.direction = direction;
+            this.angle = angle;
+            this.exponent = exponent;
+        }
+        SpotLight.prototype.getAbsolutePosition = function () {
+            return this.transformedPosition ? this.transformedPosition : this.position;
+        };
+        SpotLight.prototype.setDirectionToTarget = function (target) {
+            this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position));
+            return this.direction;
+        };
+        SpotLight.prototype.computeTransformedPosition = function () {
+            if (this.parent && this.parent.getWorldMatrix) {
+                if (!this.transformedPosition) {
+                    this.transformedPosition = BABYLON.Vector3.Zero();
+                }
+                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
+                return true;
+            }
+            return false;
+        };
+        SpotLight.prototype.transferToEffect = function (effect, positionUniformName, directionUniformName) {
+            var normalizeDirection;
+            if (this.parent && this.parent.getWorldMatrix) {
+                if (!this._transformedDirection) {
+                    this._transformedDirection = BABYLON.Vector3.Zero();
+                }
+                this.computeTransformedPosition();
+                BABYLON.Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
+                effect.setFloat4(positionUniformName, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent);
+                normalizeDirection = BABYLON.Vector3.Normalize(this._transformedDirection);
+            }
+            else {
+                effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, this.exponent);
+                normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
+            }
+            effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(this.angle * 0.5));
+        };
+        SpotLight.prototype._getWorldMatrix = function () {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            return this._worldMatrix;
+        };
+        return SpotLight;
+    })(BABYLON.Light);
+    BABYLON.SpotLight = SpotLight;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Lights/babylon.spotLight.js.map

+ 2 - 1
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -1218,4 +1218,5 @@ var BABYLON;
         });
     })(Internals = BABYLON.Internals || (BABYLON.Internals = {}));
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.babylonFileLoader.js.map
+
+//# sourceMappingURL=../../Loading/Plugins/babylon.babylonFileLoader.js.map

+ 2 - 1
Babylon/Loading/babylon.sceneLoader.js

@@ -144,4 +144,5 @@ var BABYLON;
     BABYLON.SceneLoader = SceneLoader;
     ;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.sceneLoader.js.map
+
+//# sourceMappingURL=../Loading/babylon.sceneLoader.js.map

+ 2 - 1
Babylon/Materials/Textures/Procedurals/babylon.customProceduralTexture.js

@@ -123,4 +123,5 @@ var BABYLON;
     })(BABYLON.ProceduralTexture);
     BABYLON.CustomProceduralTexture = CustomProceduralTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.customProceduralTexture.js.map
+
+//# sourceMappingURL=../../../Materials/Textures/Procedurals/babylon.customProceduralTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/Procedurals/babylon.proceduralTexture.js

@@ -239,4 +239,5 @@ var BABYLON;
     })(BABYLON.Texture);
     BABYLON.ProceduralTexture = ProceduralTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.proceduralTexture.js.map
+
+//# sourceMappingURL=../../../Materials/Textures/Procedurals/babylon.proceduralTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/Procedurals/babylon.standardProceduralTexture.js

@@ -435,4 +435,5 @@ var BABYLON;
     })(BABYLON.ProceduralTexture);
     BABYLON.MarbleProceduralTexture = MarbleProceduralTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.standardProceduralTexture.js.map
+
+//# sourceMappingURL=../../../Materials/Textures/Procedurals/babylon.standardProceduralTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.baseTexture.js

@@ -125,4 +125,5 @@ var BABYLON;
     })();
     BABYLON.BaseTexture = BaseTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.baseTexture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.baseTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.cubeTexture.js

@@ -59,4 +59,5 @@ var BABYLON;
     })(BABYLON.BaseTexture);
     BABYLON.CubeTexture = CubeTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.cubeTexture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.cubeTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.dynamicTexture.js

@@ -92,4 +92,5 @@ var BABYLON;
     })(BABYLON.Texture);
     BABYLON.DynamicTexture = DynamicTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.dynamicTexture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.dynamicTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.mirrorTexture.js

@@ -43,4 +43,5 @@ var BABYLON;
     })(BABYLON.RenderTargetTexture);
     BABYLON.MirrorTexture = MirrorTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.mirrorTexture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.mirrorTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.rawTexture.js

@@ -52,4 +52,5 @@ var BABYLON;
     })(BABYLON.Texture);
     BABYLON.RawTexture = RawTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.rawTexture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.rawTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.renderTargetTexture.js

@@ -153,4 +153,5 @@ var BABYLON;
     })(BABYLON.Texture);
     BABYLON.RenderTargetTexture = RenderTargetTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.renderTargetTexture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.renderTargetTexture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.texture.js

@@ -189,4 +189,5 @@ var BABYLON;
     })(BABYLON.BaseTexture);
     BABYLON.Texture = Texture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.texture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.texture.js.map

+ 2 - 1
Babylon/Materials/Textures/babylon.videoTexture.js

@@ -55,4 +55,5 @@ var BABYLON;
     })(BABYLON.Texture);
     BABYLON.VideoTexture = VideoTexture;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.videoTexture.js.map
+
+//# sourceMappingURL=../../Materials/Textures/babylon.videoTexture.js.map

+ 344 - 343
Babylon/Materials/babylon.effect.js

@@ -1,343 +1,344 @@
-var BABYLON;
-(function (BABYLON) {
-    var EffectFallbacks = (function () {
-        function EffectFallbacks() {
-            this._defines = {};
-            this._currentRank = 32;
-            this._maxRank = -1;
-        }
-        EffectFallbacks.prototype.addFallback = function (rank, define) {
-            if (!this._defines[rank]) {
-                if (rank < this._currentRank) {
-                    this._currentRank = rank;
-                }
-                if (rank > this._maxRank) {
-                    this._maxRank = rank;
-                }
-                this._defines[rank] = new Array();
-            }
-            this._defines[rank].push(define);
-        };
-        Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
-            get: function () {
-                return this._currentRank <= this._maxRank;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        EffectFallbacks.prototype.reduce = function (currentDefines) {
-            var currentFallbacks = this._defines[this._currentRank];
-            for (var index = 0; index < currentFallbacks.length; index++) {
-                currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
-            }
-            this._currentRank++;
-            return currentDefines;
-        };
-        return EffectFallbacks;
-    })();
-    BABYLON.EffectFallbacks = EffectFallbacks;
-    var Effect = (function () {
-        function Effect(baseName, attributesNames, uniformsNames, samplers, engine, defines, fallbacks, onCompiled, onError) {
-            var _this = this;
-            this._isReady = false;
-            this._compilationError = "";
-            this._valueCache = [];
-            this._engine = engine;
-            this.name = baseName;
-            this.defines = defines;
-            this._uniformsNames = uniformsNames.concat(samplers);
-            this._samplers = samplers;
-            this._attributesNames = attributesNames;
-            this.onError = onError;
-            this.onCompiled = onCompiled;
-            var vertexSource;
-            var fragmentSource;
-            if (baseName.vertexElement) {
-                vertexSource = document.getElementById(baseName.vertexElement);
-                if (!vertexSource) {
-                    vertexSource = baseName.vertexElement;
-                }
-            }
-            else {
-                vertexSource = baseName.vertex || baseName;
-            }
-            if (baseName.fragmentElement) {
-                fragmentSource = document.getElementById(baseName.fragmentElement);
-                if (!fragmentSource) {
-                    fragmentSource = baseName.fragmentElement;
-                }
-            }
-            else {
-                fragmentSource = baseName.fragment || baseName;
-            }
-            this._loadVertexShader(vertexSource, function (vertexCode) {
-                _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
-                    _this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, fallbacks);
-                });
-            });
-        }
-        // Properties
-        Effect.prototype.isReady = function () {
-            return this._isReady;
-        };
-        Effect.prototype.getProgram = function () {
-            return this._program;
-        };
-        Effect.prototype.getAttributesNames = function () {
-            return this._attributesNames;
-        };
-        Effect.prototype.getAttributeLocation = function (index) {
-            return this._attributes[index];
-        };
-        Effect.prototype.getAttributeLocationByName = function (name) {
-            var index = this._attributesNames.indexOf(name);
-            return this._attributes[index];
-        };
-        Effect.prototype.getAttributesCount = function () {
-            return this._attributes.length;
-        };
-        Effect.prototype.getUniformIndex = function (uniformName) {
-            return this._uniformsNames.indexOf(uniformName);
-        };
-        Effect.prototype.getUniform = function (uniformName) {
-            return this._uniforms[this._uniformsNames.indexOf(uniformName)];
-        };
-        Effect.prototype.getSamplers = function () {
-            return this._samplers;
-        };
-        Effect.prototype.getCompilationError = function () {
-            return this._compilationError;
-        };
-        // Methods
-        Effect.prototype._loadVertexShader = function (vertex, callback) {
-            // DOM element ?
-            if (vertex instanceof HTMLElement) {
-                var vertexCode = BABYLON.Tools.GetDOMTextContent(vertex);
-                callback(vertexCode);
-                return;
-            }
-            // Is in local store ?
-            if (Effect.ShadersStore[vertex + "VertexShader"]) {
-                callback(Effect.ShadersStore[vertex + "VertexShader"]);
-                return;
-            }
-            var vertexShaderUrl;
-            if (vertex[0] === ".") {
-                vertexShaderUrl = vertex;
-            }
-            else {
-                vertexShaderUrl = BABYLON.Engine.ShadersRepository + vertex;
-            }
-            // Vertex shader
-            BABYLON.Tools.LoadFile(vertexShaderUrl + ".vertex.fx", callback);
-        };
-        Effect.prototype._loadFragmentShader = function (fragment, callback) {
-            // DOM element ?
-            if (fragment instanceof HTMLElement) {
-                var fragmentCode = BABYLON.Tools.GetDOMTextContent(fragment);
-                callback(fragmentCode);
-                return;
-            }
-            // Is in local store ?
-            if (Effect.ShadersStore[fragment + "PixelShader"]) {
-                callback(Effect.ShadersStore[fragment + "PixelShader"]);
-                return;
-            }
-            if (Effect.ShadersStore[fragment + "FragmentShader"]) {
-                callback(Effect.ShadersStore[fragment + "FragmentShader"]);
-                return;
-            }
-            var fragmentShaderUrl;
-            if (fragment[0] === ".") {
-                fragmentShaderUrl = fragment;
-            }
-            else {
-                fragmentShaderUrl = BABYLON.Engine.ShadersRepository + fragment;
-            }
-            // Fragment shader
-            BABYLON.Tools.LoadFile(fragmentShaderUrl + ".fragment.fx", callback);
-        };
-        Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks) {
-            try {
-                var engine = this._engine;
-                this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
-                this._uniforms = engine.getUniforms(this._program, this._uniformsNames);
-                this._attributes = engine.getAttributes(this._program, attributesNames);
-                for (var index = 0; index < this._samplers.length; index++) {
-                    var sampler = this.getUniform(this._samplers[index]);
-                    if (sampler == null) {
-                        this._samplers.splice(index, 1);
-                        index--;
-                    }
-                }
-                engine.bindSamplers(this);
-                this._isReady = true;
-                if (this.onCompiled) {
-                    this.onCompiled(this);
-                }
-            }
-            catch (e) {
-                // Is it a problem with precision?
-                if (e.message.indexOf("highp") !== -1) {
-                    vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
-                    fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
-                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
-                    return;
-                }
-                // Let's go through fallbacks then
-                if (fallbacks && fallbacks.isMoreFallbacks) {
-                    defines = fallbacks.reduce(defines);
-                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
-                }
-                else {
-                    BABYLON.Tools.Error("Unable to compile effect: " + this.name);
-                    BABYLON.Tools.Error("Defines: " + defines);
-                    BABYLON.Tools.Error("Error: " + e.message);
-                    this._compilationError = e.message;
-                    if (this.onError) {
-                        this.onError(this, this._compilationError);
-                    }
-                }
-            }
-        };
-        Effect.prototype._bindTexture = function (channel, texture) {
-            this._engine._bindTexture(this._samplers.indexOf(channel), texture);
-        };
-        Effect.prototype.setTexture = function (channel, texture) {
-            this._engine.setTexture(this._samplers.indexOf(channel), texture);
-        };
-        Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
-            this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
-        };
-        //public _cacheMatrix(uniformName, matrix) {
-        //    if (!this._valueCache[uniformName]) {
-        //        this._valueCache[uniformName] = new BABYLON.Matrix();
-        //    }
-        //    for (var index = 0; index < 16; index++) {
-        //        this._valueCache[uniformName].m[index] = matrix.m[index];
-        //    }
-        //};
-        Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
-            if (!this._valueCache[uniformName]) {
-                this._valueCache[uniformName] = [x, y];
-                return;
-            }
-            this._valueCache[uniformName][0] = x;
-            this._valueCache[uniformName][1] = y;
-        };
-        Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
-            if (!this._valueCache[uniformName]) {
-                this._valueCache[uniformName] = [x, y, z];
-                return;
-            }
-            this._valueCache[uniformName][0] = x;
-            this._valueCache[uniformName][1] = y;
-            this._valueCache[uniformName][2] = z;
-        };
-        Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
-            if (!this._valueCache[uniformName]) {
-                this._valueCache[uniformName] = [x, y, z, w];
-                return;
-            }
-            this._valueCache[uniformName][0] = x;
-            this._valueCache[uniformName][1] = y;
-            this._valueCache[uniformName][2] = z;
-            this._valueCache[uniformName][3] = w;
-        };
-        Effect.prototype.setArray = function (uniformName, array) {
-            this._engine.setArray(this.getUniform(uniformName), array);
-            return this;
-        };
-        Effect.prototype.setArray2 = function (uniformName, array) {
-            this._engine.setArray2(this.getUniform(uniformName), array);
-            return this;
-        };
-        Effect.prototype.setArray3 = function (uniformName, array) {
-            this._engine.setArray3(this.getUniform(uniformName), array);
-            return this;
-        };
-        Effect.prototype.setArray4 = function (uniformName, array) {
-            this._engine.setArray4(this.getUniform(uniformName), array);
-            return this;
-        };
-        Effect.prototype.setMatrices = function (uniformName, matrices) {
-            this._engine.setMatrices(this.getUniform(uniformName), matrices);
-            return this;
-        };
-        Effect.prototype.setMatrix = function (uniformName, matrix) {
-            //if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
-            //    return;
-            //this._cacheMatrix(uniformName, matrix);
-            this._engine.setMatrix(this.getUniform(uniformName), matrix);
-            return this;
-        };
-        Effect.prototype.setFloat = function (uniformName, value) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName] === value)
-                return this;
-            this._valueCache[uniformName] = value;
-            this._engine.setFloat(this.getUniform(uniformName), value);
-            return this;
-        };
-        Effect.prototype.setBool = function (uniformName, bool) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName] === bool)
-                return this;
-            this._valueCache[uniformName] = bool;
-            this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
-            return this;
-        };
-        Effect.prototype.setVector2 = function (uniformName, vector2) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector2.x && this._valueCache[uniformName][1] === vector2.y)
-                return this;
-            this._cacheFloat2(uniformName, vector2.x, vector2.y);
-            this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
-            return this;
-        };
-        Effect.prototype.setFloat2 = function (uniformName, x, y) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y)
-                return this;
-            this._cacheFloat2(uniformName, x, y);
-            this._engine.setFloat2(this.getUniform(uniformName), x, y);
-            return this;
-        };
-        Effect.prototype.setVector3 = function (uniformName, vector3) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector3.x && this._valueCache[uniformName][1] === vector3.y && this._valueCache[uniformName][2] === vector3.z)
-                return this;
-            this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z);
-            this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
-            return this;
-        };
-        Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z)
-                return this;
-            this._cacheFloat3(uniformName, x, y, z);
-            this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
-            return this;
-        };
-        Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z && this._valueCache[uniformName][3] === w)
-                return this;
-            this._cacheFloat4(uniformName, x, y, z, w);
-            this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
-            return this;
-        };
-        Effect.prototype.setColor3 = function (uniformName, color3) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b)
-                return this;
-            this._cacheFloat3(uniformName, color3.r, color3.g, color3.b);
-            this._engine.setColor3(this.getUniform(uniformName), color3);
-            return this;
-        };
-        Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
-            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b && this._valueCache[uniformName][3] === alpha)
-                return this;
-            this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha);
-            this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
-            return this;
-        };
-        // Statics
-        Effect.ShadersStore = {};
-        return Effect;
-    })();
-    BABYLON.Effect = Effect;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.effect.js.map
+var BABYLON;
+(function (BABYLON) {
+    var EffectFallbacks = (function () {
+        function EffectFallbacks() {
+            this._defines = {};
+            this._currentRank = 32;
+            this._maxRank = -1;
+        }
+        EffectFallbacks.prototype.addFallback = function (rank, define) {
+            if (!this._defines[rank]) {
+                if (rank < this._currentRank) {
+                    this._currentRank = rank;
+                }
+                if (rank > this._maxRank) {
+                    this._maxRank = rank;
+                }
+                this._defines[rank] = new Array();
+            }
+            this._defines[rank].push(define);
+        };
+        Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
+            get: function () {
+                return this._currentRank <= this._maxRank;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        EffectFallbacks.prototype.reduce = function (currentDefines) {
+            var currentFallbacks = this._defines[this._currentRank];
+            for (var index = 0; index < currentFallbacks.length; index++) {
+                currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
+            }
+            this._currentRank++;
+            return currentDefines;
+        };
+        return EffectFallbacks;
+    })();
+    BABYLON.EffectFallbacks = EffectFallbacks;
+    var Effect = (function () {
+        function Effect(baseName, attributesNames, uniformsNames, samplers, engine, defines, fallbacks, onCompiled, onError) {
+            var _this = this;
+            this._isReady = false;
+            this._compilationError = "";
+            this._valueCache = [];
+            this._engine = engine;
+            this.name = baseName;
+            this.defines = defines;
+            this._uniformsNames = uniformsNames.concat(samplers);
+            this._samplers = samplers;
+            this._attributesNames = attributesNames;
+            this.onError = onError;
+            this.onCompiled = onCompiled;
+            var vertexSource;
+            var fragmentSource;
+            if (baseName.vertexElement) {
+                vertexSource = document.getElementById(baseName.vertexElement);
+                if (!vertexSource) {
+                    vertexSource = baseName.vertexElement;
+                }
+            }
+            else {
+                vertexSource = baseName.vertex || baseName;
+            }
+            if (baseName.fragmentElement) {
+                fragmentSource = document.getElementById(baseName.fragmentElement);
+                if (!fragmentSource) {
+                    fragmentSource = baseName.fragmentElement;
+                }
+            }
+            else {
+                fragmentSource = baseName.fragment || baseName;
+            }
+            this._loadVertexShader(vertexSource, function (vertexCode) {
+                _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
+                    _this._prepareEffect(vertexCode, fragmentCode, attributesNames, defines, fallbacks);
+                });
+            });
+        }
+        // Properties
+        Effect.prototype.isReady = function () {
+            return this._isReady;
+        };
+        Effect.prototype.getProgram = function () {
+            return this._program;
+        };
+        Effect.prototype.getAttributesNames = function () {
+            return this._attributesNames;
+        };
+        Effect.prototype.getAttributeLocation = function (index) {
+            return this._attributes[index];
+        };
+        Effect.prototype.getAttributeLocationByName = function (name) {
+            var index = this._attributesNames.indexOf(name);
+            return this._attributes[index];
+        };
+        Effect.prototype.getAttributesCount = function () {
+            return this._attributes.length;
+        };
+        Effect.prototype.getUniformIndex = function (uniformName) {
+            return this._uniformsNames.indexOf(uniformName);
+        };
+        Effect.prototype.getUniform = function (uniformName) {
+            return this._uniforms[this._uniformsNames.indexOf(uniformName)];
+        };
+        Effect.prototype.getSamplers = function () {
+            return this._samplers;
+        };
+        Effect.prototype.getCompilationError = function () {
+            return this._compilationError;
+        };
+        // Methods
+        Effect.prototype._loadVertexShader = function (vertex, callback) {
+            // DOM element ?
+            if (vertex instanceof HTMLElement) {
+                var vertexCode = BABYLON.Tools.GetDOMTextContent(vertex);
+                callback(vertexCode);
+                return;
+            }
+            // Is in local store ?
+            if (Effect.ShadersStore[vertex + "VertexShader"]) {
+                callback(Effect.ShadersStore[vertex + "VertexShader"]);
+                return;
+            }
+            var vertexShaderUrl;
+            if (vertex[0] === ".") {
+                vertexShaderUrl = vertex;
+            }
+            else {
+                vertexShaderUrl = BABYLON.Engine.ShadersRepository + vertex;
+            }
+            // Vertex shader
+            BABYLON.Tools.LoadFile(vertexShaderUrl + ".vertex.fx", callback);
+        };
+        Effect.prototype._loadFragmentShader = function (fragment, callback) {
+            // DOM element ?
+            if (fragment instanceof HTMLElement) {
+                var fragmentCode = BABYLON.Tools.GetDOMTextContent(fragment);
+                callback(fragmentCode);
+                return;
+            }
+            // Is in local store ?
+            if (Effect.ShadersStore[fragment + "PixelShader"]) {
+                callback(Effect.ShadersStore[fragment + "PixelShader"]);
+                return;
+            }
+            if (Effect.ShadersStore[fragment + "FragmentShader"]) {
+                callback(Effect.ShadersStore[fragment + "FragmentShader"]);
+                return;
+            }
+            var fragmentShaderUrl;
+            if (fragment[0] === ".") {
+                fragmentShaderUrl = fragment;
+            }
+            else {
+                fragmentShaderUrl = BABYLON.Engine.ShadersRepository + fragment;
+            }
+            // Fragment shader
+            BABYLON.Tools.LoadFile(fragmentShaderUrl + ".fragment.fx", callback);
+        };
+        Effect.prototype._prepareEffect = function (vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks) {
+            try {
+                var engine = this._engine;
+                this._program = engine.createShaderProgram(vertexSourceCode, fragmentSourceCode, defines);
+                this._uniforms = engine.getUniforms(this._program, this._uniformsNames);
+                this._attributes = engine.getAttributes(this._program, attributesNames);
+                for (var index = 0; index < this._samplers.length; index++) {
+                    var sampler = this.getUniform(this._samplers[index]);
+                    if (sampler == null) {
+                        this._samplers.splice(index, 1);
+                        index--;
+                    }
+                }
+                engine.bindSamplers(this);
+                this._isReady = true;
+                if (this.onCompiled) {
+                    this.onCompiled(this);
+                }
+            }
+            catch (e) {
+                // Is it a problem with precision?
+                if (e.message.indexOf("highp") !== -1) {
+                    vertexSourceCode = vertexSourceCode.replace("precision highp float", "precision mediump float");
+                    fragmentSourceCode = fragmentSourceCode.replace("precision highp float", "precision mediump float");
+                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
+                    return;
+                }
+                // Let's go through fallbacks then
+                if (fallbacks && fallbacks.isMoreFallbacks) {
+                    defines = fallbacks.reduce(defines);
+                    this._prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks);
+                }
+                else {
+                    BABYLON.Tools.Error("Unable to compile effect: " + this.name);
+                    BABYLON.Tools.Error("Defines: " + defines);
+                    BABYLON.Tools.Error("Error: " + e.message);
+                    this._compilationError = e.message;
+                    if (this.onError) {
+                        this.onError(this, this._compilationError);
+                    }
+                }
+            }
+        };
+        Effect.prototype._bindTexture = function (channel, texture) {
+            this._engine._bindTexture(this._samplers.indexOf(channel), texture);
+        };
+        Effect.prototype.setTexture = function (channel, texture) {
+            this._engine.setTexture(this._samplers.indexOf(channel), texture);
+        };
+        Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
+            this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
+        };
+        //public _cacheMatrix(uniformName, matrix) {
+        //    if (!this._valueCache[uniformName]) {
+        //        this._valueCache[uniformName] = new BABYLON.Matrix();
+        //    }
+        //    for (var index = 0; index < 16; index++) {
+        //        this._valueCache[uniformName].m[index] = matrix.m[index];
+        //    }
+        //};
+        Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
+            if (!this._valueCache[uniformName]) {
+                this._valueCache[uniformName] = [x, y];
+                return;
+            }
+            this._valueCache[uniformName][0] = x;
+            this._valueCache[uniformName][1] = y;
+        };
+        Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
+            if (!this._valueCache[uniformName]) {
+                this._valueCache[uniformName] = [x, y, z];
+                return;
+            }
+            this._valueCache[uniformName][0] = x;
+            this._valueCache[uniformName][1] = y;
+            this._valueCache[uniformName][2] = z;
+        };
+        Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
+            if (!this._valueCache[uniformName]) {
+                this._valueCache[uniformName] = [x, y, z, w];
+                return;
+            }
+            this._valueCache[uniformName][0] = x;
+            this._valueCache[uniformName][1] = y;
+            this._valueCache[uniformName][2] = z;
+            this._valueCache[uniformName][3] = w;
+        };
+        Effect.prototype.setArray = function (uniformName, array) {
+            this._engine.setArray(this.getUniform(uniformName), array);
+            return this;
+        };
+        Effect.prototype.setArray2 = function (uniformName, array) {
+            this._engine.setArray2(this.getUniform(uniformName), array);
+            return this;
+        };
+        Effect.prototype.setArray3 = function (uniformName, array) {
+            this._engine.setArray3(this.getUniform(uniformName), array);
+            return this;
+        };
+        Effect.prototype.setArray4 = function (uniformName, array) {
+            this._engine.setArray4(this.getUniform(uniformName), array);
+            return this;
+        };
+        Effect.prototype.setMatrices = function (uniformName, matrices) {
+            this._engine.setMatrices(this.getUniform(uniformName), matrices);
+            return this;
+        };
+        Effect.prototype.setMatrix = function (uniformName, matrix) {
+            //if (this._valueCache[uniformName] && this._valueCache[uniformName].equals(matrix))
+            //    return;
+            //this._cacheMatrix(uniformName, matrix);
+            this._engine.setMatrix(this.getUniform(uniformName), matrix);
+            return this;
+        };
+        Effect.prototype.setFloat = function (uniformName, value) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName] === value)
+                return this;
+            this._valueCache[uniformName] = value;
+            this._engine.setFloat(this.getUniform(uniformName), value);
+            return this;
+        };
+        Effect.prototype.setBool = function (uniformName, bool) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName] === bool)
+                return this;
+            this._valueCache[uniformName] = bool;
+            this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
+            return this;
+        };
+        Effect.prototype.setVector2 = function (uniformName, vector2) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector2.x && this._valueCache[uniformName][1] === vector2.y)
+                return this;
+            this._cacheFloat2(uniformName, vector2.x, vector2.y);
+            this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
+            return this;
+        };
+        Effect.prototype.setFloat2 = function (uniformName, x, y) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y)
+                return this;
+            this._cacheFloat2(uniformName, x, y);
+            this._engine.setFloat2(this.getUniform(uniformName), x, y);
+            return this;
+        };
+        Effect.prototype.setVector3 = function (uniformName, vector3) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === vector3.x && this._valueCache[uniformName][1] === vector3.y && this._valueCache[uniformName][2] === vector3.z)
+                return this;
+            this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z);
+            this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
+            return this;
+        };
+        Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z)
+                return this;
+            this._cacheFloat3(uniformName, x, y, z);
+            this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
+            return this;
+        };
+        Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === x && this._valueCache[uniformName][1] === y && this._valueCache[uniformName][2] === z && this._valueCache[uniformName][3] === w)
+                return this;
+            this._cacheFloat4(uniformName, x, y, z, w);
+            this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
+            return this;
+        };
+        Effect.prototype.setColor3 = function (uniformName, color3) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b)
+                return this;
+            this._cacheFloat3(uniformName, color3.r, color3.g, color3.b);
+            this._engine.setColor3(this.getUniform(uniformName), color3);
+            return this;
+        };
+        Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
+            if (this._valueCache[uniformName] && this._valueCache[uniformName][0] === color3.r && this._valueCache[uniformName][1] === color3.g && this._valueCache[uniformName][2] === color3.b && this._valueCache[uniformName][3] === alpha)
+                return this;
+            this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha);
+            this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
+            return this;
+        };
+        // Statics
+        Effect.ShadersStore = {};
+        return Effect;
+    })();
+    BABYLON.Effect = Effect;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Materials/babylon.effect.js.map

+ 128 - 127
Babylon/Materials/babylon.material.js

@@ -1,127 +1,128 @@
-var BABYLON;
-(function (BABYLON) {
-    var Material = (function () {
-        function Material(name, scene, doNotAdd) {
-            this.name = name;
-            this.checkReadyOnEveryCall = true;
-            this.checkReadyOnlyOnce = false;
-            this.state = "";
-            this.alpha = 1.0;
-            this.backFaceCulling = true;
-            this._wasPreviouslyReady = false;
-            this._fillMode = Material.TriangleFillMode;
-            this.pointSize = 1.0;
-            this.id = name;
-            this._scene = scene;
-            if (!doNotAdd) {
-                scene.materials.push(this);
-            }
-        }
-        Object.defineProperty(Material, "TriangleFillMode", {
-            get: function () {
-                return Material._TriangleFillMode;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Material, "WireFrameFillMode", {
-            get: function () {
-                return Material._WireFrameFillMode;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Material, "PointFillMode", {
-            get: function () {
-                return Material._PointFillMode;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Material.prototype, "wireframe", {
-            get: function () {
-                return this._fillMode === Material.WireFrameFillMode;
-            },
-            set: function (value) {
-                this._fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Material.prototype, "pointsCloud", {
-            get: function () {
-                return this._fillMode === Material.PointFillMode;
-            },
-            set: function (value) {
-                this._fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Object.defineProperty(Material.prototype, "fillMode", {
-            get: function () {
-                return this._fillMode;
-            },
-            set: function (value) {
-                this._fillMode = value;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        Material.prototype.isReady = function (mesh, useInstances) {
-            return true;
-        };
-        Material.prototype.getEffect = function () {
-            return this._effect;
-        };
-        Material.prototype.getScene = function () {
-            return this._scene;
-        };
-        Material.prototype.needAlphaBlending = function () {
-            return (this.alpha < 1.0);
-        };
-        Material.prototype.needAlphaTesting = function () {
-            return false;
-        };
-        Material.prototype.getAlphaTestTexture = function () {
-            return null;
-        };
-        Material.prototype.trackCreation = function (onCompiled, onError) {
-        };
-        Material.prototype._preBind = function () {
-            var engine = this._scene.getEngine();
-            engine.enableEffect(this._effect);
-            engine.setState(this.backFaceCulling);
-        };
-        Material.prototype.bind = function (world, mesh) {
-            this._scene._cachedMaterial = this;
-            if (this.onBind) {
-                this.onBind(this);
-            }
-        };
-        Material.prototype.bindOnlyWorldMatrix = function (world) {
-        };
-        Material.prototype.unbind = function () {
-        };
-        Material.prototype.dispose = function (forceDisposeEffect) {
-            // Remove from scene
-            var index = this._scene.materials.indexOf(this);
-            this._scene.materials.splice(index, 1);
-            // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
-            if (forceDisposeEffect && this._effect) {
-                this._scene.getEngine()._releaseEffect(this._effect);
-                this._effect = null;
-            }
-            // Callback
-            if (this.onDispose) {
-                this.onDispose();
-            }
-        };
-        Material._TriangleFillMode = 0;
-        Material._WireFrameFillMode = 1;
-        Material._PointFillMode = 2;
-        return Material;
-    })();
-    BABYLON.Material = Material;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.material.js.map
+var BABYLON;
+(function (BABYLON) {
+    var Material = (function () {
+        function Material(name, scene, doNotAdd) {
+            this.name = name;
+            this.checkReadyOnEveryCall = true;
+            this.checkReadyOnlyOnce = false;
+            this.state = "";
+            this.alpha = 1.0;
+            this.backFaceCulling = true;
+            this._wasPreviouslyReady = false;
+            this._fillMode = Material.TriangleFillMode;
+            this.pointSize = 1.0;
+            this.id = name;
+            this._scene = scene;
+            if (!doNotAdd) {
+                scene.materials.push(this);
+            }
+        }
+        Object.defineProperty(Material, "TriangleFillMode", {
+            get: function () {
+                return Material._TriangleFillMode;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Material, "WireFrameFillMode", {
+            get: function () {
+                return Material._WireFrameFillMode;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Material, "PointFillMode", {
+            get: function () {
+                return Material._PointFillMode;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Material.prototype, "wireframe", {
+            get: function () {
+                return this._fillMode === Material.WireFrameFillMode;
+            },
+            set: function (value) {
+                this._fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Material.prototype, "pointsCloud", {
+            get: function () {
+                return this._fillMode === Material.PointFillMode;
+            },
+            set: function (value) {
+                this._fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Material.prototype, "fillMode", {
+            get: function () {
+                return this._fillMode;
+            },
+            set: function (value) {
+                this._fillMode = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Material.prototype.isReady = function (mesh, useInstances) {
+            return true;
+        };
+        Material.prototype.getEffect = function () {
+            return this._effect;
+        };
+        Material.prototype.getScene = function () {
+            return this._scene;
+        };
+        Material.prototype.needAlphaBlending = function () {
+            return (this.alpha < 1.0);
+        };
+        Material.prototype.needAlphaTesting = function () {
+            return false;
+        };
+        Material.prototype.getAlphaTestTexture = function () {
+            return null;
+        };
+        Material.prototype.trackCreation = function (onCompiled, onError) {
+        };
+        Material.prototype._preBind = function () {
+            var engine = this._scene.getEngine();
+            engine.enableEffect(this._effect);
+            engine.setState(this.backFaceCulling);
+        };
+        Material.prototype.bind = function (world, mesh) {
+            this._scene._cachedMaterial = this;
+            if (this.onBind) {
+                this.onBind(this);
+            }
+        };
+        Material.prototype.bindOnlyWorldMatrix = function (world) {
+        };
+        Material.prototype.unbind = function () {
+        };
+        Material.prototype.dispose = function (forceDisposeEffect) {
+            // Remove from scene
+            var index = this._scene.materials.indexOf(this);
+            this._scene.materials.splice(index, 1);
+            // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
+            if (forceDisposeEffect && this._effect) {
+                this._scene.getEngine()._releaseEffect(this._effect);
+                this._effect = null;
+            }
+            // Callback
+            if (this.onDispose) {
+                this.onDispose();
+            }
+        };
+        Material._TriangleFillMode = 0;
+        Material._WireFrameFillMode = 1;
+        Material._PointFillMode = 2;
+        return Material;
+    })();
+    BABYLON.Material = Material;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Materials/babylon.material.js.map

+ 40 - 39
Babylon/Materials/babylon.multiMaterial.js

@@ -1,39 +1,40 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var MultiMaterial = (function (_super) {
-        __extends(MultiMaterial, _super);
-        function MultiMaterial(name, scene) {
-            _super.call(this, name, scene, true);
-            this.subMaterials = new Array();
-            scene.multiMaterials.push(this);
-        }
-        // Properties
-        MultiMaterial.prototype.getSubMaterial = function (index) {
-            if (index < 0 || index >= this.subMaterials.length) {
-                return this.getScene().defaultMaterial;
-            }
-            return this.subMaterials[index];
-        };
-        // Methods
-        MultiMaterial.prototype.isReady = function (mesh) {
-            for (var index = 0; index < this.subMaterials.length; index++) {
-                var subMaterial = this.subMaterials[index];
-                if (subMaterial) {
-                    if (!this.subMaterials[index].isReady(mesh)) {
-                        return false;
-                    }
-                }
-            }
-            return true;
-        };
-        return MultiMaterial;
-    })(BABYLON.Material);
-    BABYLON.MultiMaterial = MultiMaterial;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.multiMaterial.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var MultiMaterial = (function (_super) {
+        __extends(MultiMaterial, _super);
+        function MultiMaterial(name, scene) {
+            _super.call(this, name, scene, true);
+            this.subMaterials = new Array();
+            scene.multiMaterials.push(this);
+        }
+        // Properties
+        MultiMaterial.prototype.getSubMaterial = function (index) {
+            if (index < 0 || index >= this.subMaterials.length) {
+                return this.getScene().defaultMaterial;
+            }
+            return this.subMaterials[index];
+        };
+        // Methods
+        MultiMaterial.prototype.isReady = function (mesh) {
+            for (var index = 0; index < this.subMaterials.length; index++) {
+                var subMaterial = this.subMaterials[index];
+                if (subMaterial) {
+                    if (!this.subMaterials[index].isReady(mesh)) {
+                        return false;
+                    }
+                }
+            }
+            return true;
+        };
+        return MultiMaterial;
+    })(BABYLON.Material);
+    BABYLON.MultiMaterial = MultiMaterial;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Materials/babylon.multiMaterial.js.map

+ 2 - 1
Babylon/Materials/babylon.shaderMaterial.js

@@ -164,4 +164,5 @@ var BABYLON;
     })(BABYLON.Material);
     BABYLON.ShaderMaterial = ShaderMaterial;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.shaderMaterial.js.map
+
+//# sourceMappingURL=../Materials/babylon.shaderMaterial.js.map

文件差异内容过多而无法显示
+ 581 - 580
Babylon/Materials/babylon.standardMaterial.js


文件差异内容过多而无法显示
+ 2406 - 2405
Babylon/Math/babylon.math.js


+ 2 - 1
Babylon/Mesh/babylon.InstancedMesh.js

@@ -150,4 +150,5 @@ var BABYLON;
     })(BABYLON.AbstractMesh);
     BABYLON.InstancedMesh = InstancedMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.instancedMesh.js.map
+
+//# sourceMappingURL=../Mesh/babylon.InstancedMesh.js.map

+ 2 - 1
Babylon/Mesh/babylon.abstractMesh.js

@@ -798,4 +798,5 @@ var BABYLON;
     })(BABYLON.Node);
     BABYLON.AbstractMesh = AbstractMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.abstractMesh.js.map
+
+//# sourceMappingURL=../Mesh/babylon.abstractMesh.js.map

+ 2 - 1
Babylon/Mesh/babylon.csg.js

@@ -497,4 +497,5 @@ var BABYLON;
     })();
     BABYLON.CSG = CSG;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.csg.js.map
+
+//# sourceMappingURL=../Mesh/babylon.csg.js.map

+ 2 - 1
Babylon/Mesh/babylon.geometry.js

@@ -539,4 +539,5 @@ var BABYLON;
         })(Primitives = Geometry.Primitives || (Geometry.Primitives = {}));
     })(Geometry = BABYLON.Geometry || (BABYLON.Geometry = {}));
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.geometry.js.map
+
+//# sourceMappingURL=../Mesh/babylon.geometry.js.map

+ 2 - 1
Babylon/Mesh/babylon.groundMesh.js

@@ -38,4 +38,5 @@ var BABYLON;
     })(BABYLON.Mesh);
     BABYLON.GroundMesh = GroundMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.groundMesh.js.map
+
+//# sourceMappingURL=../Mesh/babylon.groundMesh.js.map

+ 2 - 1
Babylon/Mesh/babylon.linesMesh.js

@@ -68,4 +68,5 @@ var BABYLON;
     })(BABYLON.Mesh);
     BABYLON.LinesMesh = LinesMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.linesMesh.js.map
+
+//# sourceMappingURL=../Mesh/babylon.linesMesh.js.map

文件差异内容过多而无法显示
+ 1062 - 1055
Babylon/Mesh/babylon.mesh.js


+ 133 - 1
Babylon/Mesh/babylon.mesh.vertexData.js

@@ -215,6 +215,137 @@ var BABYLON;
             result.indices = meshOrGeometry.getIndices();
             return result;
         };
+        VertexData.CreateRibbon = function (pathArray, closeArray, closePath, offset) {
+            closeArray = closeArray || false;
+            closePath = closePath || false;
+            var defaultOffset = Math.floor(pathArray[0].length / 2);
+            offset = offset || defaultOffset;
+            offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
+            var positions = [];
+            var indices = [];
+            var normals = [];
+            var uvs = [];
+            var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
+            var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
+            var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
+            var vTotalDistance = []; //  vTotalDistance[i] : total distance between points i of first and last path from pathArray
+            var minlg; // minimal length among all paths from pathArray
+            var lg = []; // array of path lengths : nb of vertex per path
+            var idx = []; // array of path indexes : index of each path (first vertex) in positions array
+            // if single path in pathArray
+            if (pathArray.length < 2) {
+                var ar1 = [];
+                var ar2 = [];
+                for (var i = 0; i < pathArray[0].length - offset; i++) {
+                    ar1.push(pathArray[0][i]);
+                    ar2.push(pathArray[0][i + offset]);
+                }
+                pathArray = [ar1, ar2];
+            }
+            // positions and horizontal distances (u)
+            var idc = 0;
+            minlg = pathArray[0].length;
+            for (var p = 0; p < pathArray.length; p++) {
+                uTotalDistance[p] = 0;
+                us[p] = [0];
+                var path = pathArray[p];
+                var l = path.length;
+                minlg = (minlg < l) ? minlg : l;
+                lg[p] = l;
+                idx[p] = idc;
+                var j = 0;
+                while (j < l) {
+                    positions.push(path[j].x, path[j].y, path[j].z);
+                    if (j > 0) {
+                        var vectlg = path[j].subtract(path[j - 1]).length();
+                        var dist = vectlg + uTotalDistance[p];
+                        us[p].push(dist);
+                        uTotalDistance[p] = dist;
+                    }
+                    j++;
+                }
+                if (closePath) {
+                    var vectlg = path[0].subtract(path[j - 1]).length();
+                    var dist = vectlg + uTotalDistance[p];
+                    uTotalDistance[p] = dist;
+                }
+                idc += l;
+            }
+            for (var i = 0; i < minlg; i++) {
+                vTotalDistance[i] = 0;
+                vs[i] = [0];
+                for (var p = 0; p < pathArray.length - 1; p++) {
+                    var path1 = pathArray[p];
+                    var path2 = pathArray[p + 1];
+                    var vectlg = path2[i].subtract(path1[i]).length();
+                    var dist = vectlg + vTotalDistance[i];
+                    vs[i].push(dist);
+                    vTotalDistance[i] = dist;
+                }
+                if (closeArray) {
+                    var path1 = pathArray[p];
+                    var path2 = pathArray[0];
+                    var vectlg = path2[i].subtract(path1[i]).length();
+                    var dist = vectlg + vTotalDistance[i];
+                    vTotalDistance[i] = dist;
+                }
+            }
+            for (var p = 0; p < pathArray.length; p++) {
+                for (var i = 0; i < minlg; i++) {
+                    var u = us[p][i] / uTotalDistance[p];
+                    var v = vs[i][p] / vTotalDistance[i];
+                    uvs.push(u, v);
+                }
+            }
+            // indices
+            var p = 0; // path index
+            var i = 0; // positions array index
+            var l1 = lg[p] - 1; // path1 length
+            var l2 = lg[p + 1] - 1; // path2 length
+            var min = (l1 < l2) ? l1 : l2; // current path stop index
+            var shft = idx[1] - idx[0]; // shift 
+            var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate	
+            while (i <= min && p < path1nb) {
+                // draw two triangles between path1 (p1) and path2 (p2) : (p1.i, p2.i, p1.i+1) and (p2.i+1, p1.i+1, p2.i) clockwise
+                var t1 = i;
+                var t2 = i + shft;
+                var t3 = i + 1;
+                var t4 = i + shft + 1;
+                indices.push(i, i + shft, i + 1);
+                indices.push(i + shft + 1, i + 1, i + shft);
+                i += 1;
+                if (i == min) {
+                    if (closePath) {
+                        indices.push(i, i + shft, idx[p]);
+                        indices.push(idx[p] + shft, idx[p], i + shft);
+                        t3 = idx[p];
+                        t4 = idx[p] + shft;
+                    }
+                    p++;
+                    if (p == lg.length - 1) {
+                        shft = idx[0] - idx[p];
+                        l1 = lg[p] - 1;
+                        l2 = lg[0] - 1;
+                    }
+                    else {
+                        shft = idx[p + 1] - idx[p];
+                        l1 = lg[p] - 1;
+                        l2 = lg[p + 1] - 1;
+                    }
+                    i = idx[p];
+                    min = (l1 < l2) ? l1 + i : l2 + i;
+                }
+            }
+            // normals
+            BABYLON.VertexData.ComputeNormals(positions, indices, normals);
+            // Result
+            var vertexData = new BABYLON.VertexData();
+            vertexData.indices = indices;
+            vertexData.positions = positions;
+            vertexData.normals = normals;
+            vertexData.uvs = uvs;
+            return vertexData;
+        };
         VertexData.CreateBox = function (size) {
             var normalsSource = [
                 new BABYLON.Vector3(0, 0, 1),
@@ -761,4 +892,5 @@ var BABYLON;
     })();
     BABYLON.VertexData = VertexData;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.mesh.vertexData.js.map
+
+//# sourceMappingURL=../Mesh/babylon.mesh.vertexData.js.map

+ 2 - 1
Babylon/Mesh/babylon.meshLODLevel.js

@@ -12,4 +12,5 @@ var BABYLON;
         Internals.MeshLODLevel = MeshLODLevel;
     })(Internals = BABYLON.Internals || (BABYLON.Internals = {}));
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.meshLODLevel.js.map
+
+//# sourceMappingURL=../Mesh/babylon.meshLODLevel.js.map

+ 2 - 1
Babylon/Mesh/babylon.meshSimplification.js

@@ -550,4 +550,5 @@ var BABYLON;
     })();
     BABYLON.QuadraticErrorSimplification = QuadraticErrorSimplification;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.meshSimplification.js.map
+
+//# sourceMappingURL=../Mesh/babylon.meshSimplification.js.map

+ 2 - 1
Babylon/Mesh/babylon.polygonmesh.js

@@ -146,4 +146,5 @@ var BABYLON;
     })();
     BABYLON.PolygonMeshBuilder = PolygonMeshBuilder;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.polygonMesh.js.map
+
+//# sourceMappingURL=../Mesh/babylon.polygonmesh.js.map

+ 144 - 143
Babylon/Mesh/babylon.subMesh.js

@@ -1,143 +1,144 @@
-var BABYLON;
-(function (BABYLON) {
-    var SubMesh = (function () {
-        function SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
-            if (createBoundingBox === void 0) { createBoundingBox = true; }
-            this.materialIndex = materialIndex;
-            this.verticesStart = verticesStart;
-            this.verticesCount = verticesCount;
-            this.indexStart = indexStart;
-            this.indexCount = indexCount;
-            this._renderId = 0;
-            this._mesh = mesh;
-            this._renderingMesh = renderingMesh || mesh;
-            mesh.subMeshes.push(this);
-            this._id = mesh.subMeshes.length - 1;
-            if (createBoundingBox) {
-                this.refreshBoundingInfo();
-            }
-        }
-        SubMesh.prototype.getBoundingInfo = function () {
-            return this._boundingInfo;
-        };
-        SubMesh.prototype.getMesh = function () {
-            return this._mesh;
-        };
-        SubMesh.prototype.getRenderingMesh = function () {
-            return this._renderingMesh;
-        };
-        SubMesh.prototype.getMaterial = function () {
-            var rootMaterial = this._renderingMesh.material;
-            if (rootMaterial && rootMaterial instanceof BABYLON.MultiMaterial) {
-                var multiMaterial = rootMaterial;
-                return multiMaterial.getSubMaterial(this.materialIndex);
-            }
-            if (!rootMaterial) {
-                return this._mesh.getScene().defaultMaterial;
-            }
-            return rootMaterial;
-        };
-        // Methods
-        SubMesh.prototype.refreshBoundingInfo = function () {
-            var data = this._renderingMesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
-            if (!data) {
-                this._boundingInfo = this._mesh._boundingInfo;
-                return;
-            }
-            var indices = this._renderingMesh.getIndices();
-            var extend;
-            if (this.indexStart === 0 && this.indexCount === indices.length) {
-                extend = BABYLON.Tools.ExtractMinAndMax(data, this.verticesStart, this.verticesCount);
-            }
-            else {
-                extend = BABYLON.Tools.ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount);
-            }
-            this._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
-        };
-        SubMesh.prototype._checkCollision = function (collider) {
-            return this._boundingInfo._checkCollision(collider);
-        };
-        SubMesh.prototype.updateBoundingInfo = function (world) {
-            if (!this._boundingInfo) {
-                this.refreshBoundingInfo();
-            }
-            this._boundingInfo._update(world);
-        };
-        SubMesh.prototype.isInFrustum = function (frustumPlanes) {
-            return this._boundingInfo.isInFrustum(frustumPlanes);
-        };
-        SubMesh.prototype.render = function () {
-            this._renderingMesh.render(this);
-        };
-        SubMesh.prototype.getLinesIndexBuffer = function (indices, engine) {
-            if (!this._linesIndexBuffer) {
-                var linesIndices = [];
-                for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
-                    linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
-                }
-                this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
-                this.linesIndexCount = linesIndices.length;
-            }
-            return this._linesIndexBuffer;
-        };
-        SubMesh.prototype.canIntersects = function (ray) {
-            return ray.intersectsBox(this._boundingInfo.boundingBox);
-        };
-        SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
-            var intersectInfo = null;
-            for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
-                var p0 = positions[indices[index]];
-                var p1 = positions[indices[index + 1]];
-                var p2 = positions[indices[index + 2]];
-                var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
-                if (currentIntersectInfo) {
-                    if (currentIntersectInfo.distance < 0) {
-                        continue;
-                    }
-                    if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
-                        intersectInfo = currentIntersectInfo;
-                        intersectInfo.faceId = index / 3;
-                        if (fastCheck) {
-                            break;
-                        }
-                    }
-                }
-            }
-            return intersectInfo;
-        };
-        // Clone    
-        SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
-            var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
-            result._boundingInfo = new BABYLON.BoundingInfo(this._boundingInfo.minimum, this._boundingInfo.maximum);
-            return result;
-        };
-        // Dispose
-        SubMesh.prototype.dispose = function () {
-            if (this._linesIndexBuffer) {
-                this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
-                this._linesIndexBuffer = null;
-            }
-            // Remove from mesh
-            var index = this._mesh.subMeshes.indexOf(this);
-            this._mesh.subMeshes.splice(index, 1);
-        };
-        // Statics
-        SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
-            var minVertexIndex = Number.MAX_VALUE;
-            var maxVertexIndex = -Number.MAX_VALUE;
-            renderingMesh = renderingMesh || mesh;
-            var indices = renderingMesh.getIndices();
-            for (var index = startIndex; index < startIndex + indexCount; index++) {
-                var vertexIndex = indices[index];
-                if (vertexIndex < minVertexIndex)
-                    minVertexIndex = vertexIndex;
-                if (vertexIndex > maxVertexIndex)
-                    maxVertexIndex = vertexIndex;
-            }
-            return new BABYLON.SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
-        };
-        return SubMesh;
-    })();
-    BABYLON.SubMesh = SubMesh;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.subMesh.js.map
+var BABYLON;
+(function (BABYLON) {
+    var SubMesh = (function () {
+        function SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
+            if (createBoundingBox === void 0) { createBoundingBox = true; }
+            this.materialIndex = materialIndex;
+            this.verticesStart = verticesStart;
+            this.verticesCount = verticesCount;
+            this.indexStart = indexStart;
+            this.indexCount = indexCount;
+            this._renderId = 0;
+            this._mesh = mesh;
+            this._renderingMesh = renderingMesh || mesh;
+            mesh.subMeshes.push(this);
+            this._id = mesh.subMeshes.length - 1;
+            if (createBoundingBox) {
+                this.refreshBoundingInfo();
+            }
+        }
+        SubMesh.prototype.getBoundingInfo = function () {
+            return this._boundingInfo;
+        };
+        SubMesh.prototype.getMesh = function () {
+            return this._mesh;
+        };
+        SubMesh.prototype.getRenderingMesh = function () {
+            return this._renderingMesh;
+        };
+        SubMesh.prototype.getMaterial = function () {
+            var rootMaterial = this._renderingMesh.material;
+            if (rootMaterial && rootMaterial instanceof BABYLON.MultiMaterial) {
+                var multiMaterial = rootMaterial;
+                return multiMaterial.getSubMaterial(this.materialIndex);
+            }
+            if (!rootMaterial) {
+                return this._mesh.getScene().defaultMaterial;
+            }
+            return rootMaterial;
+        };
+        // Methods
+        SubMesh.prototype.refreshBoundingInfo = function () {
+            var data = this._renderingMesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);
+            if (!data) {
+                this._boundingInfo = this._mesh._boundingInfo;
+                return;
+            }
+            var indices = this._renderingMesh.getIndices();
+            var extend;
+            if (this.indexStart === 0 && this.indexCount === indices.length) {
+                extend = BABYLON.Tools.ExtractMinAndMax(data, this.verticesStart, this.verticesCount);
+            }
+            else {
+                extend = BABYLON.Tools.ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount);
+            }
+            this._boundingInfo = new BABYLON.BoundingInfo(extend.minimum, extend.maximum);
+        };
+        SubMesh.prototype._checkCollision = function (collider) {
+            return this._boundingInfo._checkCollision(collider);
+        };
+        SubMesh.prototype.updateBoundingInfo = function (world) {
+            if (!this._boundingInfo) {
+                this.refreshBoundingInfo();
+            }
+            this._boundingInfo._update(world);
+        };
+        SubMesh.prototype.isInFrustum = function (frustumPlanes) {
+            return this._boundingInfo.isInFrustum(frustumPlanes);
+        };
+        SubMesh.prototype.render = function () {
+            this._renderingMesh.render(this);
+        };
+        SubMesh.prototype.getLinesIndexBuffer = function (indices, engine) {
+            if (!this._linesIndexBuffer) {
+                var linesIndices = [];
+                for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
+                    linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
+                }
+                this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
+                this.linesIndexCount = linesIndices.length;
+            }
+            return this._linesIndexBuffer;
+        };
+        SubMesh.prototype.canIntersects = function (ray) {
+            return ray.intersectsBox(this._boundingInfo.boundingBox);
+        };
+        SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
+            var intersectInfo = null;
+            for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
+                var p0 = positions[indices[index]];
+                var p1 = positions[indices[index + 1]];
+                var p2 = positions[indices[index + 2]];
+                var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
+                if (currentIntersectInfo) {
+                    if (currentIntersectInfo.distance < 0) {
+                        continue;
+                    }
+                    if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
+                        intersectInfo = currentIntersectInfo;
+                        intersectInfo.faceId = index / 3;
+                        if (fastCheck) {
+                            break;
+                        }
+                    }
+                }
+            }
+            return intersectInfo;
+        };
+        // Clone    
+        SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
+            var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
+            result._boundingInfo = new BABYLON.BoundingInfo(this._boundingInfo.minimum, this._boundingInfo.maximum);
+            return result;
+        };
+        // Dispose
+        SubMesh.prototype.dispose = function () {
+            if (this._linesIndexBuffer) {
+                this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
+                this._linesIndexBuffer = null;
+            }
+            // Remove from mesh
+            var index = this._mesh.subMeshes.indexOf(this);
+            this._mesh.subMeshes.splice(index, 1);
+        };
+        // Statics
+        SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
+            var minVertexIndex = Number.MAX_VALUE;
+            var maxVertexIndex = -Number.MAX_VALUE;
+            renderingMesh = renderingMesh || mesh;
+            var indices = renderingMesh.getIndices();
+            for (var index = startIndex; index < startIndex + indexCount; index++) {
+                var vertexIndex = indices[index];
+                if (vertexIndex < minVertexIndex)
+                    minVertexIndex = vertexIndex;
+                if (vertexIndex > maxVertexIndex)
+                    maxVertexIndex = vertexIndex;
+            }
+            return new BABYLON.SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
+        };
+        return SubMesh;
+    })();
+    BABYLON.SubMesh = SubMesh;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Mesh/babylon.subMesh.js.map

+ 2 - 1
Babylon/Mesh/babylon.vertexBuffer.js

@@ -155,4 +155,5 @@ var BABYLON;
     })();
     BABYLON.VertexBuffer = VertexBuffer;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.vertexBuffer.js.map
+
+//# sourceMappingURL=../Mesh/babylon.vertexBuffer.js.map

+ 31 - 30
Babylon/Particles/babylon.particle.js

@@ -1,30 +1,31 @@
-var BABYLON;
-(function (BABYLON) {
-    var Particle = (function () {
-        function Particle() {
-            this.position = BABYLON.Vector3.Zero();
-            this.direction = BABYLON.Vector3.Zero();
-            this.color = new BABYLON.Color4(0, 0, 0, 0);
-            this.colorStep = new BABYLON.Color4(0, 0, 0, 0);
-            this.lifeTime = 1.0;
-            this.age = 0;
-            this.size = 0;
-            this.angle = 0;
-            this.angularSpeed = 0;
-        }
-        Particle.prototype.copyTo = function (other) {
-            other.position.copyFrom(this.position);
-            other.direction.copyFrom(this.direction);
-            other.color.copyFrom(this.color);
-            other.colorStep.copyFrom(this.colorStep);
-            other.lifeTime = this.lifeTime;
-            other.age = this.age;
-            other.size = this.size;
-            other.angle = this.angle;
-            other.angularSpeed = this.angularSpeed;
-        };
-        return Particle;
-    })();
-    BABYLON.Particle = Particle;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.particle.js.map
+var BABYLON;
+(function (BABYLON) {
+    var Particle = (function () {
+        function Particle() {
+            this.position = BABYLON.Vector3.Zero();
+            this.direction = BABYLON.Vector3.Zero();
+            this.color = new BABYLON.Color4(0, 0, 0, 0);
+            this.colorStep = new BABYLON.Color4(0, 0, 0, 0);
+            this.lifeTime = 1.0;
+            this.age = 0;
+            this.size = 0;
+            this.angle = 0;
+            this.angularSpeed = 0;
+        }
+        Particle.prototype.copyTo = function (other) {
+            other.position.copyFrom(this.position);
+            other.direction.copyFrom(this.direction);
+            other.color.copyFrom(this.color);
+            other.colorStep.copyFrom(this.colorStep);
+            other.lifeTime = this.lifeTime;
+            other.age = this.age;
+            other.size = this.size;
+            other.angle = this.angle;
+            other.angularSpeed = this.angularSpeed;
+        };
+        return Particle;
+    })();
+    BABYLON.Particle = Particle;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Particles/babylon.particle.js.map

+ 338 - 337
Babylon/Particles/babylon.particleSystem.js

@@ -1,337 +1,338 @@
-var BABYLON;
-(function (BABYLON) {
-    var randomNumber = function (min, max) {
-        if (min === max) {
-            return (min);
-        }
-        var random = Math.random();
-        return ((random * (max - min)) + min);
-    };
-    var ParticleSystem = (function () {
-        function ParticleSystem(name, capacity, scene, customEffect) {
-            var _this = this;
-            this.name = name;
-            this.renderingGroupId = 0;
-            this.emitter = null;
-            this.emitRate = 10;
-            this.manualEmitCount = -1;
-            this.updateSpeed = 0.01;
-            this.targetStopDuration = 0;
-            this.disposeOnStop = false;
-            this.minEmitPower = 1;
-            this.maxEmitPower = 1;
-            this.minLifeTime = 1;
-            this.maxLifeTime = 1;
-            this.minSize = 1;
-            this.maxSize = 1;
-            this.minAngularSpeed = 0;
-            this.maxAngularSpeed = 0;
-            this.blendMode = ParticleSystem.BLENDMODE_ONEONE;
-            this.forceDepthWrite = false;
-            this.gravity = BABYLON.Vector3.Zero();
-            this.direction1 = new BABYLON.Vector3(0, 1.0, 0);
-            this.direction2 = new BABYLON.Vector3(0, 1.0, 0);
-            this.minEmitBox = new BABYLON.Vector3(-0.5, -0.5, -0.5);
-            this.maxEmitBox = new BABYLON.Vector3(0.5, 0.5, 0.5);
-            this.color1 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
-            this.color2 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
-            this.colorDead = new BABYLON.Color4(0, 0, 0, 1.0);
-            this.textureMask = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
-            this.particles = new Array();
-            this._vertexDeclaration = [3, 4, 4];
-            this._vertexStrideSize = 11 * 4; // 11 floats per particle (x, y, z, r, g, b, a, angle, size, offsetX, offsetY)
-            this._stockParticles = new Array();
-            this._newPartsExcess = 0;
-            this._scaledColorStep = new BABYLON.Color4(0, 0, 0, 0);
-            this._colorDiff = new BABYLON.Color4(0, 0, 0, 0);
-            this._scaledDirection = BABYLON.Vector3.Zero();
-            this._scaledGravity = BABYLON.Vector3.Zero();
-            this._currentRenderId = -1;
-            this._started = false;
-            this._stopped = false;
-            this._actualFrame = 0;
-            this.id = name;
-            this._capacity = capacity;
-            this._scene = scene;
-            this._customEffect = customEffect;
-            scene.particleSystems.push(this);
-            // VBO
-            this._vertexBuffer = scene.getEngine().createDynamicVertexBuffer(capacity * this._vertexStrideSize * 4);
-            var indices = [];
-            var index = 0;
-            for (var count = 0; count < capacity; count++) {
-                indices.push(index);
-                indices.push(index + 1);
-                indices.push(index + 2);
-                indices.push(index);
-                indices.push(index + 2);
-                indices.push(index + 3);
-                index += 4;
-            }
-            this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
-            this._vertices = new Float32Array(capacity * this._vertexStrideSize);
-            // Default behaviors
-            this.startDirectionFunction = function (emitPower, worldMatrix, directionToUpdate) {
-                var randX = randomNumber(_this.direction1.x, _this.direction2.x);
-                var randY = randomNumber(_this.direction1.y, _this.direction2.y);
-                var randZ = randomNumber(_this.direction1.z, _this.direction2.z);
-                BABYLON.Vector3.TransformNormalFromFloatsToRef(randX * emitPower, randY * emitPower, randZ * emitPower, worldMatrix, directionToUpdate);
-            };
-            this.startPositionFunction = function (worldMatrix, positionToUpdate) {
-                var randX = randomNumber(_this.minEmitBox.x, _this.maxEmitBox.x);
-                var randY = randomNumber(_this.minEmitBox.y, _this.maxEmitBox.y);
-                var randZ = randomNumber(_this.minEmitBox.z, _this.maxEmitBox.z);
-                BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
-            };
-            this.updateFunction = function (particles) {
-                for (var index = 0; index < particles.length; index++) {
-                    var particle = particles[index];
-                    particle.age += _this._scaledUpdateSpeed;
-                    if (particle.age >= particle.lifeTime) {
-                        _this.recycleParticle(particle);
-                        index--;
-                        continue;
-                    }
-                    else {
-                        particle.colorStep.scaleToRef(_this._scaledUpdateSpeed, _this._scaledColorStep);
-                        particle.color.addInPlace(_this._scaledColorStep);
-                        if (particle.color.a < 0)
-                            particle.color.a = 0;
-                        particle.angle += particle.angularSpeed * _this._scaledUpdateSpeed;
-                        particle.direction.scaleToRef(_this._scaledUpdateSpeed, _this._scaledDirection);
-                        particle.position.addInPlace(_this._scaledDirection);
-                        _this.gravity.scaleToRef(_this._scaledUpdateSpeed, _this._scaledGravity);
-                        particle.direction.addInPlace(_this._scaledGravity);
-                    }
-                }
-            };
-        }
-        ParticleSystem.prototype.recycleParticle = function (particle) {
-            var lastParticle = this.particles.pop();
-            if (lastParticle !== particle) {
-                lastParticle.copyTo(particle);
-                this._stockParticles.push(lastParticle);
-            }
-        };
-        ParticleSystem.prototype.getCapacity = function () {
-            return this._capacity;
-        };
-        ParticleSystem.prototype.isAlive = function () {
-            return this._alive;
-        };
-        ParticleSystem.prototype.isStarted = function () {
-            return this._started;
-        };
-        ParticleSystem.prototype.start = function () {
-            this._started = true;
-            this._stopped = false;
-            this._actualFrame = 0;
-        };
-        ParticleSystem.prototype.stop = function () {
-            this._stopped = true;
-        };
-        ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
-            var offset = index * 11;
-            this._vertices[offset] = particle.position.x;
-            this._vertices[offset + 1] = particle.position.y;
-            this._vertices[offset + 2] = particle.position.z;
-            this._vertices[offset + 3] = particle.color.r;
-            this._vertices[offset + 4] = particle.color.g;
-            this._vertices[offset + 5] = particle.color.b;
-            this._vertices[offset + 6] = particle.color.a;
-            this._vertices[offset + 7] = particle.angle;
-            this._vertices[offset + 8] = particle.size;
-            this._vertices[offset + 9] = offsetX;
-            this._vertices[offset + 10] = offsetY;
-        };
-        ParticleSystem.prototype._update = function (newParticles) {
-            // Update current
-            this._alive = this.particles.length > 0;
-            this.updateFunction(this.particles);
-            // Add new ones
-            var worldMatrix;
-            if (this.emitter.position) {
-                worldMatrix = this.emitter.getWorldMatrix();
-            }
-            else {
-                worldMatrix = BABYLON.Matrix.Translation(this.emitter.x, this.emitter.y, this.emitter.z);
-            }
-            for (var index = 0; index < newParticles; index++) {
-                if (this.particles.length === this._capacity) {
-                    break;
-                }
-                if (this._stockParticles.length !== 0) {
-                    var particle = this._stockParticles.pop();
-                    particle.age = 0;
-                }
-                else {
-                    particle = new BABYLON.Particle();
-                }
-                this.particles.push(particle);
-                var emitPower = randomNumber(this.minEmitPower, this.maxEmitPower);
-                this.startDirectionFunction(emitPower, worldMatrix, particle.direction);
-                particle.lifeTime = randomNumber(this.minLifeTime, this.maxLifeTime);
-                particle.size = randomNumber(this.minSize, this.maxSize);
-                particle.angularSpeed = randomNumber(this.minAngularSpeed, this.maxAngularSpeed);
-                this.startPositionFunction(worldMatrix, particle.position);
-                var step = randomNumber(0, 1.0);
-                BABYLON.Color4.LerpToRef(this.color1, this.color2, step, particle.color);
-                this.colorDead.subtractToRef(particle.color, this._colorDiff);
-                this._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
-            }
-        };
-        ParticleSystem.prototype._getEffect = function () {
-            if (this._customEffect) {
-                return this._customEffect;
-            }
-            ;
-            var defines = [];
-            if (this._scene.clipPlane) {
-                defines.push("#define CLIPPLANE");
-            }
-            // Effect
-            var join = defines.join("\n");
-            if (this._cachedDefines !== join) {
-                this._cachedDefines = join;
-                this._effect = this._scene.getEngine().createEffect("particles", ["position", "color", "options"], ["invView", "view", "projection", "vClipPlane", "textureMask"], ["diffuseSampler"], join);
-            }
-            return this._effect;
-        };
-        ParticleSystem.prototype.animate = function () {
-            if (!this._started)
-                return;
-            var effect = this._getEffect();
-            // Check
-            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady())
-                return;
-            if (this._currentRenderId === this._scene.getRenderId()) {
-                return;
-            }
-            this._currentRenderId = this._scene.getRenderId();
-            this._scaledUpdateSpeed = this.updateSpeed * this._scene.getAnimationRatio();
-            // determine the number of particles we need to create   
-            var emitCout;
-            if (this.manualEmitCount > -1) {
-                emitCout = this.manualEmitCount;
-                this.manualEmitCount = 0;
-            }
-            else {
-                emitCout = this.emitRate;
-            }
-            var newParticles = ((emitCout * this._scaledUpdateSpeed) >> 0);
-            this._newPartsExcess += emitCout * this._scaledUpdateSpeed - newParticles;
-            if (this._newPartsExcess > 1.0) {
-                newParticles += this._newPartsExcess >> 0;
-                this._newPartsExcess -= this._newPartsExcess >> 0;
-            }
-            this._alive = false;
-            if (!this._stopped) {
-                this._actualFrame += this._scaledUpdateSpeed;
-                if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration)
-                    this.stop();
-            }
-            else {
-                newParticles = 0;
-            }
-            this._update(newParticles);
-            // Stopped?
-            if (this._stopped) {
-                if (!this._alive) {
-                    this._started = false;
-                    if (this.disposeOnStop) {
-                        this._scene._toBeDisposed.push(this);
-                    }
-                }
-            }
-            // Update VBO
-            var offset = 0;
-            for (var index = 0; index < this.particles.length; index++) {
-                var particle = this.particles[index];
-                this._appendParticleVertex(offset++, particle, 0, 0);
-                this._appendParticleVertex(offset++, particle, 1, 0);
-                this._appendParticleVertex(offset++, particle, 1, 1);
-                this._appendParticleVertex(offset++, particle, 0, 1);
-            }
-            var engine = this._scene.getEngine();
-            engine.updateDynamicVertexBuffer(this._vertexBuffer, this._vertices);
-        };
-        ParticleSystem.prototype.render = function () {
-            var effect = this._getEffect();
-            // Check
-            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this.particles.length)
-                return 0;
-            var engine = this._scene.getEngine();
-            // Render
-            engine.enableEffect(effect);
-            engine.setState(false);
-            var viewMatrix = this._scene.getViewMatrix();
-            effect.setTexture("diffuseSampler", this.particleTexture);
-            effect.setMatrix("view", viewMatrix);
-            effect.setMatrix("projection", this._scene.getProjectionMatrix());
-            effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
-            if (this._scene.clipPlane) {
-                var clipPlane = this._scene.clipPlane;
-                var invView = viewMatrix.clone();
-                invView.invert();
-                effect.setMatrix("invView", invView);
-                effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
-            }
-            // VBOs
-            engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
-            // Draw order
-            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
-            }
-            else {
-                engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            }
-            if (this.forceDepthWrite) {
-                engine.setDepthWrite(true);
-            }
-            engine.draw(true, 0, this.particles.length * 6);
-            engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
-            return this.particles.length;
-        };
-        ParticleSystem.prototype.dispose = function () {
-            if (this._vertexBuffer) {
-                this._scene.getEngine()._releaseBuffer(this._vertexBuffer);
-                this._vertexBuffer = null;
-            }
-            if (this._indexBuffer) {
-                this._scene.getEngine()._releaseBuffer(this._indexBuffer);
-                this._indexBuffer = null;
-            }
-            if (this.particleTexture) {
-                this.particleTexture.dispose();
-                this.particleTexture = null;
-            }
-            // Remove from scene
-            var index = this._scene.particleSystems.indexOf(this);
-            this._scene.particleSystems.splice(index, 1);
-            // Callback
-            if (this.onDispose) {
-                this.onDispose();
-            }
-        };
-        // Clone
-        ParticleSystem.prototype.clone = function (name, newEmitter) {
-            var result = new ParticleSystem(name, this._capacity, this._scene);
-            BABYLON.Tools.DeepCopy(this, result, ["particles"], ["_vertexDeclaration", "_vertexStrideSize"]);
-            if (newEmitter === undefined) {
-                newEmitter = this.emitter;
-            }
-            result.emitter = newEmitter;
-            if (this.particleTexture) {
-                result.particleTexture = new BABYLON.Texture(this.particleTexture.url, this._scene);
-            }
-            result.start();
-            return result;
-        };
-        // Statics
-        ParticleSystem.BLENDMODE_ONEONE = 0;
-        ParticleSystem.BLENDMODE_STANDARD = 1;
-        return ParticleSystem;
-    })();
-    BABYLON.ParticleSystem = ParticleSystem;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.particleSystem.js.map
+var BABYLON;
+(function (BABYLON) {
+    var randomNumber = function (min, max) {
+        if (min === max) {
+            return (min);
+        }
+        var random = Math.random();
+        return ((random * (max - min)) + min);
+    };
+    var ParticleSystem = (function () {
+        function ParticleSystem(name, capacity, scene, customEffect) {
+            var _this = this;
+            this.name = name;
+            this.renderingGroupId = 0;
+            this.emitter = null;
+            this.emitRate = 10;
+            this.manualEmitCount = -1;
+            this.updateSpeed = 0.01;
+            this.targetStopDuration = 0;
+            this.disposeOnStop = false;
+            this.minEmitPower = 1;
+            this.maxEmitPower = 1;
+            this.minLifeTime = 1;
+            this.maxLifeTime = 1;
+            this.minSize = 1;
+            this.maxSize = 1;
+            this.minAngularSpeed = 0;
+            this.maxAngularSpeed = 0;
+            this.blendMode = ParticleSystem.BLENDMODE_ONEONE;
+            this.forceDepthWrite = false;
+            this.gravity = BABYLON.Vector3.Zero();
+            this.direction1 = new BABYLON.Vector3(0, 1.0, 0);
+            this.direction2 = new BABYLON.Vector3(0, 1.0, 0);
+            this.minEmitBox = new BABYLON.Vector3(-0.5, -0.5, -0.5);
+            this.maxEmitBox = new BABYLON.Vector3(0.5, 0.5, 0.5);
+            this.color1 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
+            this.color2 = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
+            this.colorDead = new BABYLON.Color4(0, 0, 0, 1.0);
+            this.textureMask = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
+            this.particles = new Array();
+            this._vertexDeclaration = [3, 4, 4];
+            this._vertexStrideSize = 11 * 4; // 11 floats per particle (x, y, z, r, g, b, a, angle, size, offsetX, offsetY)
+            this._stockParticles = new Array();
+            this._newPartsExcess = 0;
+            this._scaledColorStep = new BABYLON.Color4(0, 0, 0, 0);
+            this._colorDiff = new BABYLON.Color4(0, 0, 0, 0);
+            this._scaledDirection = BABYLON.Vector3.Zero();
+            this._scaledGravity = BABYLON.Vector3.Zero();
+            this._currentRenderId = -1;
+            this._started = false;
+            this._stopped = false;
+            this._actualFrame = 0;
+            this.id = name;
+            this._capacity = capacity;
+            this._scene = scene;
+            this._customEffect = customEffect;
+            scene.particleSystems.push(this);
+            // VBO
+            this._vertexBuffer = scene.getEngine().createDynamicVertexBuffer(capacity * this._vertexStrideSize * 4);
+            var indices = [];
+            var index = 0;
+            for (var count = 0; count < capacity; count++) {
+                indices.push(index);
+                indices.push(index + 1);
+                indices.push(index + 2);
+                indices.push(index);
+                indices.push(index + 2);
+                indices.push(index + 3);
+                index += 4;
+            }
+            this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
+            this._vertices = new Float32Array(capacity * this._vertexStrideSize);
+            // Default behaviors
+            this.startDirectionFunction = function (emitPower, worldMatrix, directionToUpdate) {
+                var randX = randomNumber(_this.direction1.x, _this.direction2.x);
+                var randY = randomNumber(_this.direction1.y, _this.direction2.y);
+                var randZ = randomNumber(_this.direction1.z, _this.direction2.z);
+                BABYLON.Vector3.TransformNormalFromFloatsToRef(randX * emitPower, randY * emitPower, randZ * emitPower, worldMatrix, directionToUpdate);
+            };
+            this.startPositionFunction = function (worldMatrix, positionToUpdate) {
+                var randX = randomNumber(_this.minEmitBox.x, _this.maxEmitBox.x);
+                var randY = randomNumber(_this.minEmitBox.y, _this.maxEmitBox.y);
+                var randZ = randomNumber(_this.minEmitBox.z, _this.maxEmitBox.z);
+                BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
+            };
+            this.updateFunction = function (particles) {
+                for (var index = 0; index < particles.length; index++) {
+                    var particle = particles[index];
+                    particle.age += _this._scaledUpdateSpeed;
+                    if (particle.age >= particle.lifeTime) {
+                        _this.recycleParticle(particle);
+                        index--;
+                        continue;
+                    }
+                    else {
+                        particle.colorStep.scaleToRef(_this._scaledUpdateSpeed, _this._scaledColorStep);
+                        particle.color.addInPlace(_this._scaledColorStep);
+                        if (particle.color.a < 0)
+                            particle.color.a = 0;
+                        particle.angle += particle.angularSpeed * _this._scaledUpdateSpeed;
+                        particle.direction.scaleToRef(_this._scaledUpdateSpeed, _this._scaledDirection);
+                        particle.position.addInPlace(_this._scaledDirection);
+                        _this.gravity.scaleToRef(_this._scaledUpdateSpeed, _this._scaledGravity);
+                        particle.direction.addInPlace(_this._scaledGravity);
+                    }
+                }
+            };
+        }
+        ParticleSystem.prototype.recycleParticle = function (particle) {
+            var lastParticle = this.particles.pop();
+            if (lastParticle !== particle) {
+                lastParticle.copyTo(particle);
+                this._stockParticles.push(lastParticle);
+            }
+        };
+        ParticleSystem.prototype.getCapacity = function () {
+            return this._capacity;
+        };
+        ParticleSystem.prototype.isAlive = function () {
+            return this._alive;
+        };
+        ParticleSystem.prototype.isStarted = function () {
+            return this._started;
+        };
+        ParticleSystem.prototype.start = function () {
+            this._started = true;
+            this._stopped = false;
+            this._actualFrame = 0;
+        };
+        ParticleSystem.prototype.stop = function () {
+            this._stopped = true;
+        };
+        ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
+            var offset = index * 11;
+            this._vertices[offset] = particle.position.x;
+            this._vertices[offset + 1] = particle.position.y;
+            this._vertices[offset + 2] = particle.position.z;
+            this._vertices[offset + 3] = particle.color.r;
+            this._vertices[offset + 4] = particle.color.g;
+            this._vertices[offset + 5] = particle.color.b;
+            this._vertices[offset + 6] = particle.color.a;
+            this._vertices[offset + 7] = particle.angle;
+            this._vertices[offset + 8] = particle.size;
+            this._vertices[offset + 9] = offsetX;
+            this._vertices[offset + 10] = offsetY;
+        };
+        ParticleSystem.prototype._update = function (newParticles) {
+            // Update current
+            this._alive = this.particles.length > 0;
+            this.updateFunction(this.particles);
+            // Add new ones
+            var worldMatrix;
+            if (this.emitter.position) {
+                worldMatrix = this.emitter.getWorldMatrix();
+            }
+            else {
+                worldMatrix = BABYLON.Matrix.Translation(this.emitter.x, this.emitter.y, this.emitter.z);
+            }
+            for (var index = 0; index < newParticles; index++) {
+                if (this.particles.length === this._capacity) {
+                    break;
+                }
+                if (this._stockParticles.length !== 0) {
+                    var particle = this._stockParticles.pop();
+                    particle.age = 0;
+                }
+                else {
+                    particle = new BABYLON.Particle();
+                }
+                this.particles.push(particle);
+                var emitPower = randomNumber(this.minEmitPower, this.maxEmitPower);
+                this.startDirectionFunction(emitPower, worldMatrix, particle.direction);
+                particle.lifeTime = randomNumber(this.minLifeTime, this.maxLifeTime);
+                particle.size = randomNumber(this.minSize, this.maxSize);
+                particle.angularSpeed = randomNumber(this.minAngularSpeed, this.maxAngularSpeed);
+                this.startPositionFunction(worldMatrix, particle.position);
+                var step = randomNumber(0, 1.0);
+                BABYLON.Color4.LerpToRef(this.color1, this.color2, step, particle.color);
+                this.colorDead.subtractToRef(particle.color, this._colorDiff);
+                this._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
+            }
+        };
+        ParticleSystem.prototype._getEffect = function () {
+            if (this._customEffect) {
+                return this._customEffect;
+            }
+            ;
+            var defines = [];
+            if (this._scene.clipPlane) {
+                defines.push("#define CLIPPLANE");
+            }
+            // Effect
+            var join = defines.join("\n");
+            if (this._cachedDefines !== join) {
+                this._cachedDefines = join;
+                this._effect = this._scene.getEngine().createEffect("particles", ["position", "color", "options"], ["invView", "view", "projection", "vClipPlane", "textureMask"], ["diffuseSampler"], join);
+            }
+            return this._effect;
+        };
+        ParticleSystem.prototype.animate = function () {
+            if (!this._started)
+                return;
+            var effect = this._getEffect();
+            // Check
+            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady())
+                return;
+            if (this._currentRenderId === this._scene.getRenderId()) {
+                return;
+            }
+            this._currentRenderId = this._scene.getRenderId();
+            this._scaledUpdateSpeed = this.updateSpeed * this._scene.getAnimationRatio();
+            // determine the number of particles we need to create   
+            var emitCout;
+            if (this.manualEmitCount > -1) {
+                emitCout = this.manualEmitCount;
+                this.manualEmitCount = 0;
+            }
+            else {
+                emitCout = this.emitRate;
+            }
+            var newParticles = ((emitCout * this._scaledUpdateSpeed) >> 0);
+            this._newPartsExcess += emitCout * this._scaledUpdateSpeed - newParticles;
+            if (this._newPartsExcess > 1.0) {
+                newParticles += this._newPartsExcess >> 0;
+                this._newPartsExcess -= this._newPartsExcess >> 0;
+            }
+            this._alive = false;
+            if (!this._stopped) {
+                this._actualFrame += this._scaledUpdateSpeed;
+                if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration)
+                    this.stop();
+            }
+            else {
+                newParticles = 0;
+            }
+            this._update(newParticles);
+            // Stopped?
+            if (this._stopped) {
+                if (!this._alive) {
+                    this._started = false;
+                    if (this.disposeOnStop) {
+                        this._scene._toBeDisposed.push(this);
+                    }
+                }
+            }
+            // Update VBO
+            var offset = 0;
+            for (var index = 0; index < this.particles.length; index++) {
+                var particle = this.particles[index];
+                this._appendParticleVertex(offset++, particle, 0, 0);
+                this._appendParticleVertex(offset++, particle, 1, 0);
+                this._appendParticleVertex(offset++, particle, 1, 1);
+                this._appendParticleVertex(offset++, particle, 0, 1);
+            }
+            var engine = this._scene.getEngine();
+            engine.updateDynamicVertexBuffer(this._vertexBuffer, this._vertices);
+        };
+        ParticleSystem.prototype.render = function () {
+            var effect = this._getEffect();
+            // Check
+            if (!this.emitter || !effect.isReady() || !this.particleTexture || !this.particleTexture.isReady() || !this.particles.length)
+                return 0;
+            var engine = this._scene.getEngine();
+            // Render
+            engine.enableEffect(effect);
+            engine.setState(false);
+            var viewMatrix = this._scene.getViewMatrix();
+            effect.setTexture("diffuseSampler", this.particleTexture);
+            effect.setMatrix("view", viewMatrix);
+            effect.setMatrix("projection", this._scene.getProjectionMatrix());
+            effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
+            if (this._scene.clipPlane) {
+                var clipPlane = this._scene.clipPlane;
+                var invView = viewMatrix.clone();
+                invView.invert();
+                effect.setMatrix("invView", invView);
+                effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
+            }
+            // VBOs
+            engine.bindBuffers(this._vertexBuffer, this._indexBuffer, this._vertexDeclaration, this._vertexStrideSize, effect);
+            // Draw order
+            if (this.blendMode === ParticleSystem.BLENDMODE_ONEONE) {
+                engine.setAlphaMode(BABYLON.Engine.ALPHA_ADD);
+            }
+            else {
+                engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
+            }
+            if (this.forceDepthWrite) {
+                engine.setDepthWrite(true);
+            }
+            engine.draw(true, 0, this.particles.length * 6);
+            engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
+            return this.particles.length;
+        };
+        ParticleSystem.prototype.dispose = function () {
+            if (this._vertexBuffer) {
+                this._scene.getEngine()._releaseBuffer(this._vertexBuffer);
+                this._vertexBuffer = null;
+            }
+            if (this._indexBuffer) {
+                this._scene.getEngine()._releaseBuffer(this._indexBuffer);
+                this._indexBuffer = null;
+            }
+            if (this.particleTexture) {
+                this.particleTexture.dispose();
+                this.particleTexture = null;
+            }
+            // Remove from scene
+            var index = this._scene.particleSystems.indexOf(this);
+            this._scene.particleSystems.splice(index, 1);
+            // Callback
+            if (this.onDispose) {
+                this.onDispose();
+            }
+        };
+        // Clone
+        ParticleSystem.prototype.clone = function (name, newEmitter) {
+            var result = new ParticleSystem(name, this._capacity, this._scene);
+            BABYLON.Tools.DeepCopy(this, result, ["particles"], ["_vertexDeclaration", "_vertexStrideSize"]);
+            if (newEmitter === undefined) {
+                newEmitter = this.emitter;
+            }
+            result.emitter = newEmitter;
+            if (this.particleTexture) {
+                result.particleTexture = new BABYLON.Texture(this.particleTexture.url, this._scene);
+            }
+            result.start();
+            return result;
+        };
+        // Statics
+        ParticleSystem.BLENDMODE_ONEONE = 0;
+        ParticleSystem.BLENDMODE_STANDARD = 1;
+        return ParticleSystem;
+    })();
+    BABYLON.ParticleSystem = ParticleSystem;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../Particles/babylon.particleSystem.js.map

+ 2 - 1
Babylon/Physics/Plugins/babylon.cannonJSPlugin.js

@@ -249,4 +249,5 @@ var BABYLON;
     })();
     BABYLON.CannonJSPlugin = CannonJSPlugin;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.cannonJSPlugin.js.map
+
+//# sourceMappingURL=../../Physics/Plugins/babylon.cannonJSPlugin.js.map

+ 2 - 1
Babylon/Physics/Plugins/babylon.oimoJSPlugin.js

@@ -328,4 +328,5 @@ var BABYLON;
     })();
     BABYLON.OimoJSPlugin = OimoJSPlugin;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.oimoJSPlugin.js.map
+
+//# sourceMappingURL=../../Physics/Plugins/babylon.oimoJSPlugin.js.map

+ 2 - 1
Babylon/Physics/babylon.physicsEngine.js

@@ -60,4 +60,5 @@ var BABYLON;
     })();
     BABYLON.PhysicsEngine = PhysicsEngine;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.physicsEngine.js.map
+
+//# sourceMappingURL=../Physics/babylon.physicsEngine.js.map

+ 2 - 1
Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderEffect.js

@@ -138,4 +138,5 @@ var BABYLON;
     })();
     BABYLON.PostProcessRenderEffect = PostProcessRenderEffect;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.postProcessRenderEffect.js.map
+
+//# sourceMappingURL=../../PostProcess/RenderPipeline/babylon.postProcessRenderEffect.js.map

+ 2 - 1
Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPass.js

@@ -40,4 +40,5 @@ var BABYLON;
     })();
     BABYLON.PostProcessRenderPass = PostProcessRenderPass;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.postProcessRenderPass.js.map
+
+//# sourceMappingURL=../../PostProcess/RenderPipeline/babylon.postProcessRenderPass.js.map

+ 2 - 1
Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.js

@@ -114,4 +114,5 @@ var BABYLON;
     })();
     BABYLON.PostProcessRenderPipeline = PostProcessRenderPipeline;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.postProcessRenderPipeline.js.map
+
+//# sourceMappingURL=../../PostProcess/RenderPipeline/babylon.postProcessRenderPipeline.js.map

+ 2 - 1
Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPipelineManager.js

@@ -58,4 +58,5 @@ var BABYLON;
     })();
     BABYLON.PostProcessRenderPipelineManager = PostProcessRenderPipelineManager;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.postProcessRenderPipelineManager.js.map
+
+//# sourceMappingURL=../../PostProcess/RenderPipeline/babylon.postProcessRenderPipelineManager.js.map

+ 2 - 1
Babylon/PostProcess/babylon.anaglyphPostProcess.js

@@ -15,4 +15,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.AnaglyphPostProcess = AnaglyphPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.anaglyphPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.anaglyphPostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.blackAndWhitePostProcess.js

@@ -15,4 +15,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.BlackAndWhitePostProcess = BlackAndWhitePostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.blackAndWhitePostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.blackAndWhitePostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.blurPostProcess.js

@@ -24,4 +24,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.BlurPostProcess = BlurPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.blurPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.blurPostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.convolutionPostProcess.js

@@ -29,4 +29,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.ConvolutionPostProcess = ConvolutionPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.convolutionPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.convolutionPostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.displayPassPostProcess.js

@@ -15,4 +15,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.DisplayPassPostProcess = DisplayPassPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.displayPassPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.displayPassPostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.filterPostProcess.js

@@ -20,4 +20,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.FilterPostProcess = FilterPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.filterPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.filterPostProcess.js.map

+ 27 - 26
Babylon/PostProcess/babylon.fxaaPostProcess.js

@@ -1,26 +1,27 @@
-var __extends = this.__extends || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    __.prototype = b.prototype;
-    d.prototype = new __();
-};
-var BABYLON;
-(function (BABYLON) {
-    var FxaaPostProcess = (function (_super) {
-        __extends(FxaaPostProcess, _super);
-        function FxaaPostProcess(name, ratio, camera, samplingMode, engine, reusable) {
-            var _this = this;
-            _super.call(this, name, "fxaa", ["texelSize"], null, ratio, camera, samplingMode, engine, reusable);
-            this.onSizeChanged = function () {
-                _this.texelWidth = 1.0 / _this.width;
-                _this.texelHeight = 1.0 / _this.height;
-            };
-            this.onApply = function (effect) {
-                effect.setFloat2("texelSize", _this.texelWidth, _this.texelHeight);
-            };
-        }
-        return FxaaPostProcess;
-    })(BABYLON.PostProcess);
-    BABYLON.FxaaPostProcess = FxaaPostProcess;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.fxaaPostProcess.js.map
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var FxaaPostProcess = (function (_super) {
+        __extends(FxaaPostProcess, _super);
+        function FxaaPostProcess(name, ratio, camera, samplingMode, engine, reusable) {
+            var _this = this;
+            _super.call(this, name, "fxaa", ["texelSize"], null, ratio, camera, samplingMode, engine, reusable);
+            this.onSizeChanged = function () {
+                _this.texelWidth = 1.0 / _this.width;
+                _this.texelHeight = 1.0 / _this.height;
+            };
+            this.onApply = function (effect) {
+                effect.setFloat2("texelSize", _this.texelWidth, _this.texelHeight);
+            };
+        }
+        return FxaaPostProcess;
+    })(BABYLON.PostProcess);
+    BABYLON.FxaaPostProcess = FxaaPostProcess;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../PostProcess/babylon.fxaaPostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.oculusDistortionCorrectionPostProcess.js

@@ -38,4 +38,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.OculusDistortionCorrectionPostProcess = OculusDistortionCorrectionPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.oculusDistortionCorrectionPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.oculusDistortionCorrectionPostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.passPostProcess.js

@@ -15,4 +15,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.PassPostProcess = PassPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.passPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.passPostProcess.js.map

+ 102 - 101
Babylon/PostProcess/babylon.postProcess.js

@@ -1,101 +1,102 @@
-var BABYLON;
-(function (BABYLON) {
-    var PostProcess = (function () {
-        function PostProcess(name, fragmentUrl, parameters, samplers, ratio, camera, samplingMode, engine, reusable, defines) {
-            this.name = name;
-            this.width = -1;
-            this.height = -1;
-            this._reusable = false;
-            this._textures = new BABYLON.SmartArray(2);
-            this._currentRenderTextureInd = 0;
-            if (camera != null) {
-                this._camera = camera;
-                this._scene = camera.getScene();
-                camera.attachPostProcess(this);
-                this._engine = this._scene.getEngine();
-            }
-            else {
-                this._engine = engine;
-            }
-            this._renderRatio = ratio;
-            this.renderTargetSamplingMode = samplingMode ? samplingMode : BABYLON.Texture.NEAREST_SAMPLINGMODE;
-            this._reusable = reusable || false;
-            samplers = samplers || [];
-            samplers.push("textureSampler");
-            this._effect = this._engine.createEffect({ vertex: "postprocess", fragment: fragmentUrl }, ["position"], parameters || [], samplers, defines !== undefined ? defines : "");
-        }
-        PostProcess.prototype.isReusable = function () {
-            return this._reusable;
-        };
-        PostProcess.prototype.activate = function (camera, sourceTexture) {
-            camera = camera || this._camera;
-            var scene = camera.getScene();
-            var maxSize = camera.getEngine().getCaps().maxTextureSize;
-            var desiredWidth = ((sourceTexture ? sourceTexture._width : this._engine.getRenderingCanvas().width) * this._renderRatio) | 0;
-            var desiredHeight = ((sourceTexture ? sourceTexture._height : this._engine.getRenderingCanvas().height) * this._renderRatio) | 0;
-            desiredWidth = BABYLON.Tools.GetExponantOfTwo(desiredWidth, maxSize);
-            desiredHeight = BABYLON.Tools.GetExponantOfTwo(desiredHeight, maxSize);
-            if (this.width !== desiredWidth || this.height !== desiredHeight) {
-                if (this._textures.length > 0) {
-                    for (var i = 0; i < this._textures.length; i++) {
-                        this._engine._releaseTexture(this._textures.data[i]);
-                    }
-                    this._textures.reset();
-                }
-                this.width = desiredWidth;
-                this.height = desiredHeight;
-                this._textures.push(this._engine.createRenderTargetTexture({ width: this.width, height: this.height }, { generateMipMaps: false, generateDepthBuffer: camera._postProcesses.indexOf(this) === camera._postProcessesTakenIndices[0], samplingMode: this.renderTargetSamplingMode }));
-                if (this._reusable) {
-                    this._textures.push(this._engine.createRenderTargetTexture({ width: this.width, height: this.height }, { generateMipMaps: false, generateDepthBuffer: camera._postProcesses.indexOf(this) === camera._postProcessesTakenIndices[0], samplingMode: this.renderTargetSamplingMode }));
-                }
-                if (this.onSizeChanged) {
-                    this.onSizeChanged();
-                }
-            }
-            this._engine.bindFramebuffer(this._textures.data[this._currentRenderTextureInd]);
-            if (this.onActivate) {
-                this.onActivate(camera);
-            }
-            // Clear
-            this._engine.clear(scene.clearColor, scene.autoClear || scene.forceWireframe, true);
-            if (this._reusable) {
-                this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
-            }
-        };
-        PostProcess.prototype.apply = function () {
-            // Check
-            if (!this._effect.isReady())
-                return null;
-            // States
-            this._engine.enableEffect(this._effect);
-            this._engine.setState(false);
-            this._engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
-            this._engine.setDepthBuffer(false);
-            this._engine.setDepthWrite(false);
-            // Texture
-            this._effect._bindTexture("textureSampler", this._textures.data[this._currentRenderTextureInd]);
-            // Parameters
-            if (this.onApply) {
-                this.onApply(this._effect);
-            }
-            return this._effect;
-        };
-        PostProcess.prototype.dispose = function (camera) {
-            camera = camera || this._camera;
-            if (this._textures.length > 0) {
-                for (var i = 0; i < this._textures.length; i++) {
-                    this._engine._releaseTexture(this._textures.data[i]);
-                }
-                this._textures.reset();
-            }
-            camera.detachPostProcess(this);
-            var index = camera._postProcesses.indexOf(this);
-            if (index === camera._postProcessesTakenIndices[0] && camera._postProcessesTakenIndices.length > 0) {
-                this._camera._postProcesses[camera._postProcessesTakenIndices[0]].width = -1; // invalidate frameBuffer to hint the postprocess to create a depth buffer
-            }
-        };
-        return PostProcess;
-    })();
-    BABYLON.PostProcess = PostProcess;
-})(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.postProcess.js.map
+var BABYLON;
+(function (BABYLON) {
+    var PostProcess = (function () {
+        function PostProcess(name, fragmentUrl, parameters, samplers, ratio, camera, samplingMode, engine, reusable, defines) {
+            this.name = name;
+            this.width = -1;
+            this.height = -1;
+            this._reusable = false;
+            this._textures = new BABYLON.SmartArray(2);
+            this._currentRenderTextureInd = 0;
+            if (camera != null) {
+                this._camera = camera;
+                this._scene = camera.getScene();
+                camera.attachPostProcess(this);
+                this._engine = this._scene.getEngine();
+            }
+            else {
+                this._engine = engine;
+            }
+            this._renderRatio = ratio;
+            this.renderTargetSamplingMode = samplingMode ? samplingMode : BABYLON.Texture.NEAREST_SAMPLINGMODE;
+            this._reusable = reusable || false;
+            samplers = samplers || [];
+            samplers.push("textureSampler");
+            this._effect = this._engine.createEffect({ vertex: "postprocess", fragment: fragmentUrl }, ["position"], parameters || [], samplers, defines !== undefined ? defines : "");
+        }
+        PostProcess.prototype.isReusable = function () {
+            return this._reusable;
+        };
+        PostProcess.prototype.activate = function (camera, sourceTexture) {
+            camera = camera || this._camera;
+            var scene = camera.getScene();
+            var maxSize = camera.getEngine().getCaps().maxTextureSize;
+            var desiredWidth = ((sourceTexture ? sourceTexture._width : this._engine.getRenderingCanvas().width) * this._renderRatio) | 0;
+            var desiredHeight = ((sourceTexture ? sourceTexture._height : this._engine.getRenderingCanvas().height) * this._renderRatio) | 0;
+            desiredWidth = BABYLON.Tools.GetExponantOfTwo(desiredWidth, maxSize);
+            desiredHeight = BABYLON.Tools.GetExponantOfTwo(desiredHeight, maxSize);
+            if (this.width !== desiredWidth || this.height !== desiredHeight) {
+                if (this._textures.length > 0) {
+                    for (var i = 0; i < this._textures.length; i++) {
+                        this._engine._releaseTexture(this._textures.data[i]);
+                    }
+                    this._textures.reset();
+                }
+                this.width = desiredWidth;
+                this.height = desiredHeight;
+                this._textures.push(this._engine.createRenderTargetTexture({ width: this.width, height: this.height }, { generateMipMaps: false, generateDepthBuffer: camera._postProcesses.indexOf(this) === camera._postProcessesTakenIndices[0], samplingMode: this.renderTargetSamplingMode }));
+                if (this._reusable) {
+                    this._textures.push(this._engine.createRenderTargetTexture({ width: this.width, height: this.height }, { generateMipMaps: false, generateDepthBuffer: camera._postProcesses.indexOf(this) === camera._postProcessesTakenIndices[0], samplingMode: this.renderTargetSamplingMode }));
+                }
+                if (this.onSizeChanged) {
+                    this.onSizeChanged();
+                }
+            }
+            this._engine.bindFramebuffer(this._textures.data[this._currentRenderTextureInd]);
+            if (this.onActivate) {
+                this.onActivate(camera);
+            }
+            // Clear
+            this._engine.clear(scene.clearColor, scene.autoClear || scene.forceWireframe, true);
+            if (this._reusable) {
+                this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
+            }
+        };
+        PostProcess.prototype.apply = function () {
+            // Check
+            if (!this._effect.isReady())
+                return null;
+            // States
+            this._engine.enableEffect(this._effect);
+            this._engine.setState(false);
+            this._engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
+            this._engine.setDepthBuffer(false);
+            this._engine.setDepthWrite(false);
+            // Texture
+            this._effect._bindTexture("textureSampler", this._textures.data[this._currentRenderTextureInd]);
+            // Parameters
+            if (this.onApply) {
+                this.onApply(this._effect);
+            }
+            return this._effect;
+        };
+        PostProcess.prototype.dispose = function (camera) {
+            camera = camera || this._camera;
+            if (this._textures.length > 0) {
+                for (var i = 0; i < this._textures.length; i++) {
+                    this._engine._releaseTexture(this._textures.data[i]);
+                }
+                this._textures.reset();
+            }
+            camera.detachPostProcess(this);
+            var index = camera._postProcesses.indexOf(this);
+            if (index === camera._postProcessesTakenIndices[0] && camera._postProcessesTakenIndices.length > 0) {
+                this._camera._postProcesses[camera._postProcessesTakenIndices[0]].width = -1; // invalidate frameBuffer to hint the postprocess to create a depth buffer
+            }
+        };
+        return PostProcess;
+    })();
+    BABYLON.PostProcess = PostProcess;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=../PostProcess/babylon.postProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.postProcessManager.js

@@ -84,4 +84,5 @@ var BABYLON;
     })();
     BABYLON.PostProcessManager = PostProcessManager;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.postProcessManager.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.postProcessManager.js.map

+ 2 - 1
Babylon/PostProcess/babylon.refractionPostProcess.js

@@ -35,4 +35,5 @@ var BABYLON;
     })(BABYLON.PostProcess);
     BABYLON.RefractionPostProcess = RefractionPostProcess;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.refractionPostProcess.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.refractionPostProcess.js.map

+ 2 - 1
Babylon/PostProcess/babylon.ssaoRenderingPipeline.js

@@ -205,4 +205,5 @@ var BABYLON;
     })(BABYLON.PostProcessRenderPipeline);
     BABYLON.SSAORenderingPipeline = SSAORenderingPipeline;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.ssaoRenderingPipeline.js.map
+
+//# sourceMappingURL=../PostProcess/babylon.ssaoRenderingPipeline.js.map

+ 0 - 0
Babylon/PostProcess/babylon.volumetricLightScatteringPostProcess.js


部分文件因为文件数量过多而无法显示