David Catuhe 8 years ago
parent
commit
a12e33ff5b

+ 3 - 0
Playground/index-local.html

@@ -16,6 +16,9 @@
     <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
     <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
     <script src="node_modules/monaco-editor/min/vs/loader.js"></script>
     <script src="node_modules/monaco-editor/min/vs/loader.js"></script>
     <!-- Babylon.js -->    
     <!-- Babylon.js -->    
+    
+    <script src="https://babylonjs.azurewebsites.net/cannon.js"></script>
+    <script src="https://babylonjs.azurewebsites.net/Oimo.js"></script>
 	<script src="../tools/DevLoader/BabylonLoader.js"></script>
 	<script src="../tools/DevLoader/BabylonLoader.js"></script>
     <link href="index.css" rel="stylesheet" />
     <link href="index.css" rel="stylesheet" />
 </head>
 </head>

File diff suppressed because it is too large
+ 25 - 25
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 1642 - 1570
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 38 - 38
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 476 - 203
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 1642 - 1570
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 38 - 38
dist/preview release/babylon.noworker.js


+ 25 - 25
dist/preview release/canvas2D/babylon.canvas2d.js

@@ -3844,14 +3844,14 @@ var BABYLON;
     var RowDefinition = (function (_super) {
     var RowDefinition = (function (_super) {
         __extends(RowDefinition, _super);
         __extends(RowDefinition, _super);
         function RowDefinition() {
         function RowDefinition() {
-            return _super !== null && _super.apply(this, arguments) || this;
+            return _super.apply(this, arguments) || this;
         }
         }
         return RowDefinition;
         return RowDefinition;
     }(GridDimensionDefinition));
     }(GridDimensionDefinition));
     var ColumnDefinition = (function (_super) {
     var ColumnDefinition = (function (_super) {
         __extends(ColumnDefinition, _super);
         __extends(ColumnDefinition, _super);
         function ColumnDefinition() {
         function ColumnDefinition() {
-            return _super !== null && _super.apply(this, arguments) || this;
+            return _super.apply(this, arguments) || this;
         }
         }
         return ColumnDefinition;
         return ColumnDefinition;
     }(GridDimensionDefinition));
     }(GridDimensionDefinition));
@@ -6897,7 +6897,7 @@ var BABYLON;
     var Prim2DBase = Prim2DBase_1 = (function (_super) {
     var Prim2DBase = Prim2DBase_1 = (function (_super) {
         __extends(Prim2DBase, _super);
         __extends(Prim2DBase, _super);
         function Prim2DBase(settings) {
         function Prim2DBase(settings) {
-            var _this = this;
+            var _this;
             // Avoid checking every time if the object exists
             // Avoid checking every time if the object exists
             if (settings == null) {
             if (settings == null) {
                 settings = {};
                 settings = {};
@@ -11025,7 +11025,7 @@ var BABYLON;
     var Shape2DInstanceData = (function (_super) {
     var Shape2DInstanceData = (function (_super) {
         __extends(Shape2DInstanceData, _super);
         __extends(Shape2DInstanceData, _super);
         function Shape2DInstanceData() {
         function Shape2DInstanceData() {
-            return _super !== null && _super.apply(this, arguments) || this;
+            return _super.apply(this, arguments) || this;
         }
         }
         Object.defineProperty(Shape2DInstanceData.prototype, "fillSolidColor", {
         Object.defineProperty(Shape2DInstanceData.prototype, "fillSolidColor", {
             // FILL ATTRIBUTES
             // FILL ATTRIBUTES
@@ -11200,7 +11200,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          */
          */
         function Group2D(settings) {
         function Group2D(settings) {
-            var _this = this;
+            var _this;
             if (settings == null) {
             if (settings == null) {
                 settings = {};
                 settings = {};
             }
             }
@@ -12139,7 +12139,7 @@ var BABYLON;
     var WireFrame2DRenderCache = (function (_super) {
     var WireFrame2DRenderCache = (function (_super) {
         __extends(WireFrame2DRenderCache, _super);
         __extends(WireFrame2DRenderCache, _super);
         function WireFrame2DRenderCache() {
         function WireFrame2DRenderCache() {
-            var _this = _super !== null && _super.apply(this, arguments) || this;
+            var _this = _super.apply(this, arguments) || this;
             _this.effectsReady = false;
             _this.effectsReady = false;
             _this.vb = null;
             _this.vb = null;
             _this.vtxCount = 0;
             _this.vtxCount = 0;
@@ -12365,7 +12365,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          */
          */
         function WireFrame2D(wireFrameGroups, settings) {
         function WireFrame2D(wireFrameGroups, settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -12745,7 +12745,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          */
          */
         function Rectangle2D(settings) {
         function Rectangle2D(settings) {
-            var _this = this;
+            var _this;
             // Avoid checking every time if the object exists
             // Avoid checking every time if the object exists
             if (settings == null) {
             if (settings == null) {
                 settings = {};
                 settings = {};
@@ -13260,7 +13260,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          */
          */
         function Ellipse2D(settings) {
         function Ellipse2D(settings) {
-            var _this = this;
+            var _this;
             // Avoid checking every time if the object exists
             // Avoid checking every time if the object exists
             if (settings == null) {
             if (settings == null) {
                 settings = {};
                 settings = {};
@@ -13444,7 +13444,7 @@ var BABYLON;
     var Sprite2DRenderCache = (function (_super) {
     var Sprite2DRenderCache = (function (_super) {
         __extends(Sprite2DRenderCache, _super);
         __extends(Sprite2DRenderCache, _super);
         function Sprite2DRenderCache() {
         function Sprite2DRenderCache() {
-            var _this = _super !== null && _super.apply(this, arguments) || this;
+            var _this = _super.apply(this, arguments) || this;
             _this.effectsReady = false;
             _this.effectsReady = false;
             _this.vb = null;
             _this.vb = null;
             _this.ib = null;
             _this.ib = null;
@@ -13564,7 +13564,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          */
          */
         function Sprite2D(texture, settings) {
         function Sprite2D(texture, settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -14202,7 +14202,7 @@ var BABYLON;
     var Text2DRenderCache = (function (_super) {
     var Text2DRenderCache = (function (_super) {
         __extends(Text2DRenderCache, _super);
         __extends(Text2DRenderCache, _super);
         function Text2DRenderCache() {
         function Text2DRenderCache() {
-            var _this = _super !== null && _super.apply(this, arguments) || this;
+            var _this = _super.apply(this, arguments) || this;
             _this.effectsReady = false;
             _this.effectsReady = false;
             _this.vb = null;
             _this.vb = null;
             _this.ib = null;
             _this.ib = null;
@@ -14400,7 +14400,7 @@ var BABYLON;
          * - wordWrap: if true the text will wrap inside content area
          * - wordWrap: if true the text will wrap inside content area
          */
          */
         function Text2D(text, settings) {
         function Text2D(text, settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -15237,7 +15237,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          */
          */
         function Lines2D(points, settings) {
         function Lines2D(points, settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -17891,7 +17891,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
          */
          */
         function WorldSpaceCanvas2D(scene, size, settings) {
         function WorldSpaceCanvas2D(scene, size, settings) {
-            var _this = this;
+            var _this;
             BABYLON.Prim2DBase._isCanvasInit = true;
             BABYLON.Prim2DBase._isCanvasInit = true;
             var s = settings;
             var s = settings;
             s.isScreenSpace = false;
             s.isScreenSpace = false;
@@ -18053,7 +18053,7 @@ var BABYLON;
          * - padding: top, left, right and bottom padding formatted as a single string (see BABYLON.PrimitiveThickness.fromString)
          * - padding: top, left, right and bottom padding formatted as a single string (see BABYLON.PrimitiveThickness.fromString)
          */
          */
         function ScreenSpaceCanvas2D(scene, settings) {
         function ScreenSpaceCanvas2D(scene, settings) {
-            var _this = this;
+            var _this;
             BABYLON.Prim2DBase._isCanvasInit = true;
             BABYLON.Prim2DBase._isCanvasInit = true;
             _this = _super.call(this, scene, settings) || this;
             _this = _super.call(this, scene, settings) || this;
             return _this;
             return _this;
@@ -19037,7 +19037,7 @@ var BABYLON;
     var StackPanel = StackPanel_1 = (function (_super) {
     var StackPanel = StackPanel_1 = (function (_super) {
         __extends(StackPanel, _super);
         __extends(StackPanel, _super);
         function StackPanel(settings) {
         function StackPanel(settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -19100,7 +19100,7 @@ var BABYLON;
     var DefaultStackPanelRenderingTemplate = DefaultStackPanelRenderingTemplate_1 = (function (_super) {
     var DefaultStackPanelRenderingTemplate = DefaultStackPanelRenderingTemplate_1 = (function (_super) {
         __extends(DefaultStackPanelRenderingTemplate, _super);
         __extends(DefaultStackPanelRenderingTemplate, _super);
         function DefaultStackPanelRenderingTemplate() {
         function DefaultStackPanelRenderingTemplate() {
-            return _super !== null && _super.apply(this, arguments) || this;
+            return _super.apply(this, arguments) || this;
         }
         }
         DefaultStackPanelRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
         DefaultStackPanelRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
             return { root: visualPlaceholder, contentPlaceholder: visualPlaceholder };
             return { root: visualPlaceholder, contentPlaceholder: visualPlaceholder };
@@ -19229,7 +19229,7 @@ var BABYLON;
     var ContentControl = ContentControl_1 = (function (_super) {
     var ContentControl = ContentControl_1 = (function (_super) {
         __extends(ContentControl, _super);
         __extends(ContentControl, _super);
         function ContentControl(settings) {
         function ContentControl(settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -19384,7 +19384,7 @@ var BABYLON;
     var Window = Window_1 = (function (_super) {
     var Window = Window_1 = (function (_super) {
         __extends(Window, _super);
         __extends(Window, _super);
         function Window(scene, settings) {
         function Window(scene, settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -19569,7 +19569,7 @@ var BABYLON;
     var DefaultWindowRenderingTemplate = DefaultWindowRenderingTemplate_1 = (function (_super) {
     var DefaultWindowRenderingTemplate = DefaultWindowRenderingTemplate_1 = (function (_super) {
         __extends(DefaultWindowRenderingTemplate, _super);
         __extends(DefaultWindowRenderingTemplate, _super);
         function DefaultWindowRenderingTemplate() {
         function DefaultWindowRenderingTemplate() {
-            return _super !== null && _super.apply(this, arguments) || this;
+            return _super.apply(this, arguments) || this;
         }
         }
         DefaultWindowRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
         DefaultWindowRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
             var r = new BABYLON.Rectangle2D({ parent: visualPlaceholder, fill: "#808080FF" });
             var r = new BABYLON.Rectangle2D({ parent: visualPlaceholder, fill: "#808080FF" });
@@ -19600,7 +19600,7 @@ var BABYLON;
     var Label = Label_1 = (function (_super) {
     var Label = Label_1 = (function (_super) {
         __extends(Label, _super);
         __extends(Label, _super);
         function Label(settings) {
         function Label(settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -19647,7 +19647,7 @@ var BABYLON;
     var DefaultLabelRenderingTemplate = DefaultLabelRenderingTemplate_1 = (function (_super) {
     var DefaultLabelRenderingTemplate = DefaultLabelRenderingTemplate_1 = (function (_super) {
         __extends(DefaultLabelRenderingTemplate, _super);
         __extends(DefaultLabelRenderingTemplate, _super);
         function DefaultLabelRenderingTemplate() {
         function DefaultLabelRenderingTemplate() {
-            return _super !== null && _super.apply(this, arguments) || this;
+            return _super.apply(this, arguments) || this;
         }
         }
         DefaultLabelRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
         DefaultLabelRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
             var r = new BABYLON.Text2D("", { parent: visualPlaceholder });
             var r = new BABYLON.Text2D("", { parent: visualPlaceholder });
@@ -19680,7 +19680,7 @@ var BABYLON;
     var Button = Button_1 = (function (_super) {
     var Button = Button_1 = (function (_super) {
         __extends(Button, _super);
         __extends(Button, _super);
         function Button(settings) {
         function Button(settings) {
-            var _this = this;
+            var _this;
             if (!settings) {
             if (!settings) {
                 settings = {};
                 settings = {};
             }
             }
@@ -19834,7 +19834,7 @@ var BABYLON;
     var DefaultButtonRenderingTemplate = DefaultButtonRenderingTemplate_1 = (function (_super) {
     var DefaultButtonRenderingTemplate = DefaultButtonRenderingTemplate_1 = (function (_super) {
         __extends(DefaultButtonRenderingTemplate, _super);
         __extends(DefaultButtonRenderingTemplate, _super);
         function DefaultButtonRenderingTemplate() {
         function DefaultButtonRenderingTemplate() {
-            return _super !== null && _super.apply(this, arguments) || this;
+            return _super.apply(this, arguments) || this;
         }
         }
         DefaultButtonRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
         DefaultButtonRenderingTemplate.prototype.createVisualTree = function (owner, visualPlaceholder) {
             this._rect = new BABYLON.Rectangle2D({ parent: visualPlaceholder, fill: "#FF8080FF", border: "#FF8080FF", roundRadius: 10, borderThickness: 2 });
             this._rect = new BABYLON.Rectangle2D({ parent: visualPlaceholder, fill: "#FF8080FF", border: "#FF8080FF", roundRadius: 10, borderThickness: 2 });

File diff suppressed because it is too large
+ 9 - 9
dist/preview release/canvas2D/babylon.canvas2d.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/inspector/babylon.inspector.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.furMaterial.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.furMaterial.min.js


+ 11 - 0
dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.d.ts

@@ -0,0 +1,11 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts" />
+declare module BABYLON {
+    class NormalMapProceduralTexture extends ProceduralTexture {
+        private _baseTexture;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        render(useCameraPostProcess?: boolean): void;
+        resize(size: any, generateMipMaps: any): void;
+        baseTexture: Texture;
+    }
+}

File diff suppressed because it is too large
+ 46 - 0
dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.js


File diff suppressed because it is too large
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.min.js


+ 1 - 0
dist/preview release/what's new.md

@@ -15,6 +15,7 @@
  - Multi-platform Compressed Textures for Desktops & Mobile Devices with fall back.  Batch (dos) scripts to convert entire directories of .jpg's & .png's ([jcpalmer](https://github.com/Palmer-JC))
  - Multi-platform Compressed Textures for Desktops & Mobile Devices with fall back.  Batch (dos) scripts to convert entire directories of .jpg's & .png's ([jcpalmer](https://github.com/Palmer-JC))
 
 
 ### Updates
 ### Updates
+- Added `Light.customProjectionMatrixBuilder` to allow developers to define their own projection matrix for shadows ([deltakosh](https://github.com/deltakosh))
 - Added `set()` function to all basic types ([deltakosh](https://github.com/deltakosh))
 - Added `set()` function to all basic types ([deltakosh](https://github.com/deltakosh))
 - Added `HDRCubeTextureAssetTask` to AssetManager ([deltakosh](https://github.com/deltakosh))
 - Added `HDRCubeTextureAssetTask` to AssetManager ([deltakosh](https://github.com/deltakosh))
 - Engine now uses range based fog ([deltakosh](https://github.com/deltakosh))
 - Engine now uses range based fog ([deltakosh](https://github.com/deltakosh))

+ 1 - 1
src/Bones/babylon.skeleton.ts

@@ -361,7 +361,7 @@
                 var serializedBone: any = {
                 var serializedBone: any = {
                     parentBoneIndex: bone.getParent() ? this.bones.indexOf(bone.getParent()) : -1,
                     parentBoneIndex: bone.getParent() ? this.bones.indexOf(bone.getParent()) : -1,
                     name: bone.name,
                     name: bone.name,
-                    matrix: bone.getLocalMatrix().toArray(),
+                    matrix: bone.getBaseMatrix().toArray(),
                     rest: bone.getRestPose().toArray()
                     rest: bone.getRestPose().toArray()
                 };
                 };
 
 

+ 40 - 35
src/Lights/babylon.directionalLight.ts

@@ -17,6 +17,8 @@ module BABYLON {
 
 
         @serialize()
         @serialize()
         public autoUpdateExtends = true;
         public autoUpdateExtends = true;
+        
+        public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
 
 
         // Cache
         // Cache
         private _orthoLeft = Number.MAX_VALUE;
         private _orthoLeft = Number.MAX_VALUE;
@@ -60,55 +62,58 @@ module BABYLON {
          * Returns the DirectionalLight.  
          * Returns the DirectionalLight.  
          */
          */
         public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): DirectionalLight {
         public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): DirectionalLight {
-            var activeCamera = this.getScene().activeCamera;
+            if (this.customProjectionMatrixBuilder) {
+                this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
+            } else {
+                var activeCamera = this.getScene().activeCamera;
 
 
-            // Check extends
-            if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
-                var tempVector3 = Vector3.Zero();
+                // Check extends
+                if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
+                    var tempVector3 = Vector3.Zero();
 
 
-                this._orthoLeft = Number.MAX_VALUE;
-                this._orthoRight = Number.MIN_VALUE;
-                this._orthoTop = Number.MIN_VALUE;
-                this._orthoBottom = Number.MAX_VALUE;
+                    this._orthoLeft = Number.MAX_VALUE;
+                    this._orthoRight = Number.MIN_VALUE;
+                    this._orthoTop = Number.MIN_VALUE;
+                    this._orthoBottom = Number.MAX_VALUE;
 
 
-                for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
-                    var mesh = renderList[meshIndex];
+                    for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
+                        var mesh = renderList[meshIndex];
 
 
-                    if (!mesh) {
-                        continue;
-                    }
+                        if (!mesh) {
+                            continue;
+                        }
 
 
-                    var boundingInfo = mesh.getBoundingInfo();
+                        var boundingInfo = mesh.getBoundingInfo();
 
 
-                    if (!boundingInfo) {
-                        continue;
-                    }
+                        if (!boundingInfo) {
+                            continue;
+                        }
 
 
-                    var boundingBox = boundingInfo.boundingBox;
+                        var boundingBox = boundingInfo.boundingBox;
 
 
-                    for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
-                        Vector3.TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
+                        for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
+                            Vector3.TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
 
 
-                        if (tempVector3.x < this._orthoLeft)
-                            this._orthoLeft = tempVector3.x;
-                        if (tempVector3.y < this._orthoBottom)
-                            this._orthoBottom = tempVector3.y;
+                            if (tempVector3.x < this._orthoLeft)
+                                this._orthoLeft = tempVector3.x;
+                            if (tempVector3.y < this._orthoBottom)
+                                this._orthoBottom = tempVector3.y;
 
 
-                        if (tempVector3.x > this._orthoRight)
-                            this._orthoRight = tempVector3.x;
-                        if (tempVector3.y > this._orthoTop)
-                            this._orthoTop = tempVector3.y;
+                            if (tempVector3.x > this._orthoRight)
+                                this._orthoRight = tempVector3.x;
+                            if (tempVector3.y > this._orthoTop)
+                                this._orthoTop = tempVector3.y;
+                        }
                     }
                     }
                 }
                 }
-            }
 
 
-            var xOffset = this._orthoRight - this._orthoLeft;
-            var yOffset = this._orthoTop - this._orthoBottom;
-
-            Matrix.OrthoOffCenterLHToRef(this._orthoLeft - xOffset * this.shadowOrthoScale, this._orthoRight + xOffset * this.shadowOrthoScale,
-                this._orthoBottom - yOffset * this.shadowOrthoScale, this._orthoTop + yOffset * this.shadowOrthoScale,
-                -activeCamera.maxZ, activeCamera.maxZ, matrix);
+                var xOffset = this._orthoRight - this._orthoLeft;
+                var yOffset = this._orthoTop - this._orthoBottom;
 
 
+                Matrix.OrthoOffCenterLHToRef(this._orthoLeft - xOffset * this.shadowOrthoScale, this._orthoRight + xOffset * this.shadowOrthoScale,
+                    this._orthoBottom - yOffset * this.shadowOrthoScale, this._orthoTop + yOffset * this.shadowOrthoScale,
+                    -activeCamera.maxZ, activeCamera.maxZ, matrix);
+            }
             return this;
             return this;
         }
         }
 
 

+ 2 - 0
src/Lights/babylon.light.ts

@@ -9,6 +9,8 @@
         computeTransformedPosition(): boolean;
         computeTransformedPosition(): boolean;
         getScene(): Scene;
         getScene(): Scene;
 
 
+
+        customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
         setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
         setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
 
 
         supportsVSM(): boolean;
         supportsVSM(): boolean;

+ 8 - 2
src/Lights/babylon.pointLight.ts

@@ -5,6 +5,8 @@
 
 
         @serializeAsVector3()
         @serializeAsVector3()
         public position: Vector3;
         public position: Vector3;
+        
+        public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
 
 
         /**
         /**
          * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.  
          * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.  
@@ -117,8 +119,12 @@
          * Returns the PointLight.  
          * Returns the PointLight.  
          */
          */
         public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): PointLight {
         public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): PointLight {
-            var activeCamera = this.getScene().activeCamera;
-            Matrix.PerspectiveFovLHToRef(Math.PI / 2, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+            if (this.customProjectionMatrixBuilder) {
+                this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
+            } else {
+                var activeCamera = this.getScene().activeCamera;
+                Matrix.PerspectiveFovLHToRef(Math.PI / 2, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+            }
             return this;
             return this;
         }
         }
 
 

+ 8 - 2
src/Lights/babylon.spotLight.ts

@@ -14,6 +14,8 @@
 
 
         public transformedPosition: Vector3;
         public transformedPosition: Vector3;
 
 
+        public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
+
         private _transformedDirection: Vector3;
         private _transformedDirection: Vector3;
         private _worldMatrix: Matrix;
         private _worldMatrix: Matrix;
 
 
@@ -52,8 +54,12 @@
          * Returns the SpotLight.  
          * Returns the SpotLight.  
          */
          */
         public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): SpotLight {
         public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): SpotLight {
-            var activeCamera = this.getScene().activeCamera;
-            Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+            if (this.customProjectionMatrixBuilder) {
+                this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
+            } else {
+                var activeCamera = this.getScene().activeCamera;
+                Matrix.PerspectiveFovLHToRef(this.angle, 1.0, activeCamera.minZ, activeCamera.maxZ, matrix);
+            }
             return this;
             return this;
         }
         }
         /**
         /**

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

@@ -298,7 +298,7 @@
             }
             }
         }
         }
 
 
-        public static SetCorsBehavior(url: string, img: HTMLImageElement): string {
+        public static SetCorsBehavior(url: string, img: HTMLImageElement): void {
             if (Tools.CorsBehavior) {
             if (Tools.CorsBehavior) {
                 switch (typeof (Tools.CorsBehavior)) {
                 switch (typeof (Tools.CorsBehavior)) {
                     case "function":
                     case "function":