浏览代码

SpotLights can now cast shadows

David Catuhe 10 年之前
父节点
当前提交
e6ef918a6b

+ 3 - 3
Babylon/Bones/babylon.bone.ts

@@ -6,9 +6,9 @@
         private _skeleton: Skeleton;
         private _matrix: Matrix;
         private _baseMatrix: Matrix;
-        private _worldTransform = new BABYLON.Matrix();
-        private _absoluteTransform = new BABYLON.Matrix();
-        private _invertedAbsoluteTransform = new BABYLON.Matrix();
+        private _worldTransform = new Matrix();
+        private _absoluteTransform = new Matrix();
+        private _invertedAbsoluteTransform = new Matrix();
         private _parent: Bone;
 
         constructor(public name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix) {

+ 3 - 3
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -268,7 +268,7 @@ var BABYLON;
                 };
 
                 this._touchStart = function (event) {
-                    if (event.touches.length == 2) {
+                    if (event.touches.length === 2) {
                         //-- start pinch if two fingers on the screen
                         pinchStarted = true;
                         _this._pinchStart(event);
@@ -304,7 +304,7 @@ var BABYLON;
                     var direction = 1;
                     var distanceXOrigine, distanceXNow;
 
-                    if (event.touches.length != 2)
+                    if (event.touches.length !== 2)
                         return;
 
                     // calculate absolute distances of the two fingers
@@ -320,7 +320,7 @@ var BABYLON;
                     delta = (_this.pinchPrecision / (_this.wheelPrecision * 40)) * direction;
 
                     // set new radius
-                    _this.inertialRadiusOffset += delta;
+                    _this.inertialRadiusOffset -= delta;
 
                     // save origin touch point
                     pinchPointX1 = event.touches[0].clientX;

+ 3 - 3
Babylon/Cameras/babylon.arcRotateCamera.ts

@@ -299,7 +299,7 @@
                 };
 
                 this._touchStart = event => {
-                    if (event.touches.length == 2) {
+                    if (event.touches.length === 2) {
                         //-- start pinch if two fingers on the screen
                         pinchStarted = true;
                         this._pinchStart(event);
@@ -333,7 +333,7 @@
                     var direction = 1;
                     var distanceXOrigine, distanceXNow;
 
-                    if (event.touches.length != 2)
+                    if (event.touches.length !== 2)
                         return;
                     // calculate absolute distances of the two fingers
                     distanceXOrigine = Math.abs(pinchPointX1 - pinchPointX2);
@@ -346,7 +346,7 @@
                     // calculate new radius
                     delta = (this.pinchPrecision / (this.wheelPrecision * 40)) * direction;
                     // set new radius
-                    this.inertialRadiusOffset += delta;
+                    this.inertialRadiusOffset -= delta;
                     // save origin touch point
                     pinchPointX1 = event.touches[0].clientX;
                     pinchPointX2 = event.touches[1].clientX;

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


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


+ 59 - 29
Babylon/Debug/babylon.debugLayer.ts

@@ -37,19 +37,21 @@
 
         public accentColor = "orange";
 
+        public customStatsFunction: () => string;
+
         constructor(scene: Scene) {
             this._scene = scene;
 
             this._syncPositions = (): void => {
                 var engine = this._scene.getEngine();
                 var canvasRect = engine.getRenderingCanvasClientRect();
-                
+
                 if (this._showUI) {
-                    this._statsDiv.style.left = (canvasRect.width - 310) + "px";
-                    this._statsDiv.style.top = (canvasRect.height - 370) + "px";
-                    this._statsDiv.style.width = "300px";
-                    this._statsDiv.style.height = "360px";
-                    this._statsSubsetDiv.style.maxHeight = (canvasRect.height - 60) + "px";
+                    this._statsDiv.style.left = (canvasRect.width - 410) + "px";
+                    this._statsDiv.style.top = (canvasRect.height - 290) + "px";
+                    this._statsDiv.style.width = "400px";
+                    this._statsDiv.style.height = "auto";
+                    this._statsSubsetDiv.style.maxHeight = "240px";
 
                     this._optionsDiv.style.left = "0px";
                     this._optionsDiv.style.top = "10px";
@@ -66,7 +68,7 @@
                     this._treeDiv.style.top = "10px";
                     this._treeDiv.style.width = "300px";
                     this._treeDiv.style.height = "auto";
-                    this._treeSubsetDiv.style.maxHeight = (canvasRect.height - 430) + "px";
+                    this._treeSubsetDiv.style.maxHeight = (canvasRect.height - 340) + "px";
                 }
 
                 this._globalDiv.style.left = canvasRect.left + "px";
@@ -187,10 +189,10 @@
 
                             if (!this.shouldDisplayLabel || this.shouldDisplayLabel(light)) {
                                 this._renderLabel(light.name, projectedPosition, -20,
-                                () => {
-                                    light.setEnabled(!light.isEnabled());
-                                },
-                                () => { return light.isEnabled() ? "orange" : "gray"; });
+                                    () => {
+                                        light.setEnabled(!light.isEnabled());
+                                    },
+                                    () => { return light.isEnabled() ? "orange" : "gray"; });
                             }
 
                         }
@@ -227,7 +229,7 @@
                 this._generateAdvancedCheckBox(this._treeSubsetDiv, mesh.name, mesh.getTotalVertices() + " verts", mesh.isVisible, (element, m) => {
                     m.isVisible = element.checked;
                 }, mesh);
-            } 
+            }
         }
 
         private _renderSingleAxis(zero: Vector3, unit: Vector3, unitText: Vector3, label: string, color: string) {
@@ -505,12 +507,11 @@
                 this._statsDiv.style.position = "absolute";
                 this._statsDiv.style.background = background;
                 this._statsDiv.style.padding = "0px 0px 0px 5px";
-                this._statsDiv.style.pointerEvents = "none";
-                this._statsDiv.style.overflowY = "auto";
                 this._generateheader(this._statsDiv, "STATISTICS");
                 this._statsSubsetDiv = document.createElement("div");
                 this._statsSubsetDiv.style.paddingTop = "5px";
                 this._statsSubsetDiv.style.paddingBottom = "5px";
+                this._statsSubsetDiv.style.overflowY = "auto";
                 this._statsDiv.appendChild(this._statsSubsetDiv);
 
                 // Tree
@@ -567,13 +568,15 @@
                 this._optionsSubsetDiv.style.maxHeight = "200px";
                 this._optionsDiv.appendChild(this._optionsSubsetDiv);
 
-                this._generateTexBox(this._optionsSubsetDiv, "<b>General:</b>", this.accentColor);
+                this._generateTexBox(this._optionsSubsetDiv, "<b>Windows:</b>", this.accentColor);
                 this._generateCheckBox(this._optionsSubsetDiv, "Statistics", this._displayStatistics, (element) => { this._displayStatistics = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Logs", this._displayLogs, (element) => { this._displayLogs = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Meshes tree", this._displayTree, (element) => {
                     this._displayTree = element.checked;
                     this._needToRefreshMeshesTree = true;
                 });
+                this._optionsSubsetDiv.appendChild(document.createElement("br"));
+                this._generateTexBox(this._optionsSubsetDiv, "<b>General:</b>", this.accentColor);
                 this._generateCheckBox(this._optionsSubsetDiv, "Bounding boxes", this._scene.forceShowBoundingBoxes, (element) => { this._scene.forceShowBoundingBoxes = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Clickable labels", this._labelsEnabled, (element) => {
                     this._labelsEnabled = element.checked;
@@ -581,7 +584,7 @@
                         this._clearLabels();
                     }
                 });
-                this._generateCheckBox(this._optionsSubsetDiv, "Generate user marks", Tools.PerformanceLogLevel === Tools.PerformanceUserMarkLogLevel,
+                this._generateCheckBox(this._optionsSubsetDiv, "Generate user marks (F12)", Tools.PerformanceLogLevel === Tools.PerformanceUserMarkLogLevel,
                     (element) => {
                         if (element.checked) {
                             Tools.PerformanceLogLevel = Tools.PerformanceUserMarkLogLevel;
@@ -645,21 +648,48 @@
         private _displayStats() {
             var scene = this._scene;
             var engine = scene.getEngine();
+            var glInfo = engine.getGlInfo();
 
             this._statsSubsetDiv.innerHTML = "Babylon.js v" + Engine.Version + " - <b>" + Tools.Format(engine.getFps(), 0) + " fps</b><br><br>"
-            + "Total meshes: " + scene.meshes.length + "<br>"
-            + "Total vertices: " + scene.getTotalVertices() + "<br>"
-            + "Active meshes: " + scene.getActiveMeshes().length + "<br>"
-            + "Active vertices: " + scene.getActiveVertices() + "<br>"
-            + "Active bones: " + scene.getActiveBones() + "<br>"
-            + "Active particles: " + scene.getActiveParticles() + "<br><br>"
-            + "Frame duration: " + Tools.Format(scene.getLastFrameDuration()) + " ms<br>"
-            + "<b>Draw calls: " + engine.drawCalls + "</b><br><br>"
-            + "<i>Evaluate Active Meshes duration:</i> " + Tools.Format(scene.getEvaluateActiveMeshesDuration()) + " ms<br>"
-            + "<i>Render Targets duration:</i> " + Tools.Format(scene.getRenderTargetsDuration()) + " ms<br>"
-            + "<i>Particles duration:</i> " + Tools.Format(scene.getParticlesDuration()) + " ms<br>"
-            + "<i>Sprites duration:</i> " + Tools.Format(scene.getSpritesDuration()) + " ms<br>"
-            + "<i>Render duration:</i> <b>" + Tools.Format(scene.getRenderDuration()) + " ms</b>";
+                + "<div style='column-count: 2;-moz-column-count:2;-webkit-column-count:2'>"
+                + "<b>Count</b><br>"
+                + "Total meshes: " + scene.meshes.length + "<br>"
+                + "Total vertices: " + scene.getTotalVertices() + "<br>"
+                + "Total materials: " + scene.materials.length + "<br>"
+                + "Total textures: " + scene.textures.length + "<br>"
+                + "Active meshes: " + scene.getActiveMeshes().length + "<br>"
+                + "Active vertices: " + scene.getActiveVertices() + "<br>"
+                + "Active bones: " + scene.getActiveBones() + "<br>"
+                + "Active particles: " + scene.getActiveParticles() + "<br>"
+                + "<b>Draw calls: " + engine.drawCalls + "</b><br><br>"
+                + "<b>Duration</b><br>"
+                + "Meshes selection:</i> " + Tools.Format(scene.getEvaluateActiveMeshesDuration()) + " ms<br>"
+                + "Render Targets: " + Tools.Format(scene.getRenderTargetsDuration()) + " ms<br>"
+                + "Particles: " + Tools.Format(scene.getParticlesDuration()) + " ms<br>"
+                + "Sprites: " + Tools.Format(scene.getSpritesDuration()) + " ms<br><br>"
+                + "Render: <b>" + Tools.Format(scene.getRenderDuration()) + " ms</b><br>"
+                + "Frame: " + Tools.Format(scene.getLastFrameDuration()) + " ms<br>"
+                + "Potential FPS: " + Tools.Format(1000.0 / scene.getLastFrameDuration(), 0) + "<br><br>"
+                + "</div>"
+                + "<div style='column-count: 2;-moz-column-count:2;-webkit-column-count:2'>"
+                + "<b>Extensions</b><br>"
+                + "Std derivatives: " + (engine.getCaps().standardDerivatives ? "Yes" : "No") + "<br>"
+                + "Compressed textures: " + (engine.getCaps().s3tc ? "Yes" : "No") + "<br>"
+                + "Hardware instances: " + (engine.getCaps().instancedArrays ? "Yes" : "No") + "<br>"
+                + "Texture float: " + (engine.getCaps().textureFloat ? "Yes" : "No") + "<br>"
+                + "32bits indices: " + (engine.getCaps().uintIndices ? "Yes" : "No") + "<br>"
+                + "<b>Caps.</b><br>"
+                + "Max textures units: " + engine.getCaps().maxTexturesImageUnits + "<br>"
+                + "Max textures size: " + engine.getCaps().maxTextureSize + "<br>"
+                + "Max anisotropy: " + engine.getCaps().maxAnisotropy + "<br><br><br>"
+                + "</div><br>"
+                + "<b>Info</b><br>"
+                + glInfo.version + "<br>"
+                + glInfo.renderer + "<br>";
+
+            if (this.customStatsFunction) {
+                this._statsSubsetDiv.innerHTML += this._statsSubsetDiv.innerHTML;
+            }
         }
     }
 }

+ 3 - 3
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -198,7 +198,7 @@
 
             // Get correct effect
             var join = defines.join("\n");
-            if (this._cachedDefines != join) {
+            if (this._cachedDefines !== join) {
                 this._cachedDefines = join;
                 this._effect = this._scene.getEngine().createEffect("shadowMap", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
             }
@@ -219,8 +219,8 @@
             var lightPosition = this._light.position;
             var lightDirection = this._light.direction;
 
-            if (this._light._computeTransformedPosition()) {
-                lightPosition = this._light._transformedPosition;
+            if (this._light.computeTransformedPosition()) {
+                lightPosition = this._light.transformedPosition;
             }
 
             if (!this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !lightDirection.equals(this._cachedDirection)) {

+ 24 - 24
Babylon/Lights/Shadows/babylon.shadowGenerator.ts

@@ -34,31 +34,31 @@
             this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
         }
 
-        private _light: DirectionalLight;
+        private _light: IShadowLight;
         private _scene: Scene;
         private _shadowMap: RenderTargetTexture;
         private _darkness = 0;
         private _transparencyShadow = false;
         private _effect: Effect;
 
-        private _viewMatrix = BABYLON.Matrix.Zero();
-        private _projectionMatrix = BABYLON.Matrix.Zero();
-        private _transformMatrix = BABYLON.Matrix.Zero();
-        private _worldViewProjection = BABYLON.Matrix.Zero();
+        private _viewMatrix = Matrix.Zero();
+        private _projectionMatrix = Matrix.Zero();
+        private _transformMatrix = Matrix.Zero();
+        private _worldViewProjection = Matrix.Zero();
         private _cachedPosition: Vector3;
         private _cachedDirection: Vector3;
         private _cachedDefines: string;
 
-        constructor(mapSize: number, light: DirectionalLight) {
+        constructor(mapSize: number, light: IShadowLight) {
             this._light = light;
             this._scene = light.getScene();
 
             light._shadowGenerator = this;
 
             // Render target
-            this._shadowMap = new BABYLON.RenderTargetTexture(light.name + "_shadowMap", mapSize, this._scene, false);
-            this._shadowMap.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
-            this._shadowMap.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
+            this._shadowMap = new RenderTargetTexture(light.name + "_shadowMap", mapSize, this._scene, false);
+            this._shadowMap.wrapU = Texture.CLAMP_ADDRESSMODE;
+            this._shadowMap.wrapV = Texture.CLAMP_ADDRESSMODE;
             this._shadowMap.renderParticles = false;
 
             // Custom render function
@@ -94,7 +94,7 @@
                     }
 
                     // Bones
-                    var useBones = mesh.skeleton && scene.skeletonsEnabled && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind);
+                    var useBones = mesh.skeleton && scene.skeletonsEnabled && mesh.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind);
 
                     if (useBones) {
                         this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
@@ -154,7 +154,7 @@
                 defines.push("#define VSM");
             }
 
-            var attribs = [BABYLON.VertexBuffer.PositionKind];
+            var attribs = [VertexBuffer.PositionKind];
 
             var mesh = subMesh.getMesh();
             var scene = mesh.getScene();
@@ -163,20 +163,20 @@
             // Alpha test
             if (material && material.needAlphaTesting()) {
                 defines.push("#define ALPHATEST");
-                if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
-                    attribs.push(BABYLON.VertexBuffer.UVKind);
+                if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
+                    attribs.push(VertexBuffer.UVKind);
                     defines.push("#define UV1");
                 }
-                if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
-                    attribs.push(BABYLON.VertexBuffer.UV2Kind);
+                if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
+                    attribs.push(VertexBuffer.UV2Kind);
                     defines.push("#define UV2");
                 }
             }
 
             // Bones
-            if (mesh.skeleton && scene.skeletonsEnabled && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
-                attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);
-                attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);
+            if (mesh.skeleton && scene.skeletonsEnabled && mesh.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)) {
+                attribs.push(VertexBuffer.MatricesIndicesKind);
+                attribs.push(VertexBuffer.MatricesWeightsKind);
                 defines.push("#define BONES");
                 defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
             }
@@ -192,7 +192,7 @@
 
             // Get correct effect      
             var join = defines.join("\n");
-            if (this._cachedDefines != join) {
+            if (this._cachedDefines !== join) {
                 this._cachedDefines = join;
                 this._effect = this._scene.getEngine().createEffect("shadowMap",
                     attribs,
@@ -207,7 +207,7 @@
             return this._shadowMap;
         }
 
-        public getLight(): DirectionalLight {
+        public getLight(): IShadowLight {
             return this._light;
         }
 
@@ -216,8 +216,8 @@
             var lightPosition = this._light.position;
             var lightDirection = this._light.direction;
 
-            if (this._light._computeTransformedPosition()) {
-                lightPosition = this._light._transformedPosition;
+            if (this._light.computeTransformedPosition()) {
+                lightPosition = this._light.transformedPosition;
             }
 
             if (!this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !lightDirection.equals(this._cachedDirection)) {
@@ -227,8 +227,8 @@
 
                 var activeCamera = this._scene.activeCamera;
 
-                BABYLON.Matrix.LookAtLHToRef(lightPosition, this._light.position.add(lightDirection), BABYLON.Vector3.Up(), this._viewMatrix);
-                BABYLON.Matrix.PerspectiveFovLHToRef(Math.PI / 2.0, 1.0, activeCamera.minZ, activeCamera.maxZ, this._projectionMatrix);
+                Matrix.LookAtLHToRef(lightPosition, this._light.position.add(lightDirection), Vector3.Up(), this._viewMatrix);
+                Matrix.PerspectiveFovLHToRef(Math.PI / 2.0, 1.0, activeCamera.minZ, activeCamera.maxZ, this._projectionMatrix);
 
                 this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
             }

+ 5 - 5
Babylon/Lights/babylon.directionalLight.js

@@ -15,7 +15,7 @@ var BABYLON;
             this.position = direction.scale(-1);
         }
         DirectionalLight.prototype.getAbsolutePosition = function () {
-            return this._transformedPosition ? this._transformedPosition : this.position;
+            return this.transformedPosition ? this.transformedPosition : this.position;
         };
 
         DirectionalLight.prototype.setDirectionToTarget = function (target) {
@@ -23,13 +23,13 @@ var BABYLON;
             return this.direction;
         };
 
-        DirectionalLight.prototype._computeTransformedPosition = function () {
+        DirectionalLight.prototype.computeTransformedPosition = function () {
             if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._transformedPosition) {
-                    this._transformedPosition = BABYLON.Vector3.Zero();
+                if (!this.transformedPosition) {
+                    this.transformedPosition = BABYLON.Vector3.Zero();
                 }
 
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
+                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
                 return true;
             }
 

+ 12 - 12
Babylon/Lights/babylon.directionalLight.ts

@@ -1,9 +1,9 @@
 module BABYLON {
-    export class DirectionalLight extends Light {
+    export class DirectionalLight extends Light implements IShadowLight {
         public position: Vector3;
 
         private _transformedDirection: Vector3;
-        public _transformedPosition: Vector3;
+        public transformedPosition: Vector3;
         private _worldMatrix: Matrix;
 
         constructor(name: string, public direction: Vector3, scene: Scene) {
@@ -13,21 +13,21 @@
         }
 
         public getAbsolutePosition(): Vector3 {
-            return this._transformedPosition ? this._transformedPosition : this.position;
+            return this.transformedPosition ? this.transformedPosition : this.position;
         }
 
         public setDirectionToTarget(target: Vector3): Vector3 {
-            this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position));
+            this.direction = Vector3.Normalize(target.subtract(this.position));
             return this.direction;
         }
 
-        public _computeTransformedPosition(): boolean {
+        public computeTransformedPosition(): boolean {
             if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._transformedPosition) {
-                    this._transformedPosition = BABYLON.Vector3.Zero();
+                if (!this.transformedPosition) {
+                    this.transformedPosition = Vector3.Zero();
                 }
 
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
+                Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
                 return true;
             }
 
@@ -37,10 +37,10 @@
         public transferToEffect(effect: Effect, directionUniformName: string): void {
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this._transformedDirection) {
-                    this._transformedDirection = BABYLON.Vector3.Zero();
+                    this._transformedDirection = Vector3.Zero();
                 }
 
-                BABYLON.Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
+                Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
                 effect.setFloat4(directionUniformName, this._transformedDirection.x, this._transformedDirection.y, this._transformedDirection.z, 1);
 
                 return;
@@ -51,10 +51,10 @@
 
         public _getWorldMatrix(): Matrix {
             if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
+                this._worldMatrix = Matrix.Identity();
             }
 
-            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
 
             return this._worldMatrix;
         }

+ 13 - 0
Babylon/Lights/babylon.light.ts

@@ -1,4 +1,17 @@
 module BABYLON {
+
+    export interface IShadowLight {
+        position: Vector3;
+        direction: Vector3;
+        transformedPosition: Vector3;
+        name: string;
+
+        computeTransformedPosition(): boolean;
+        getScene(): Scene;
+
+        _shadowGenerator: ShadowGenerator;
+    }
+
     export class Light extends Node {
         public diffuse = new Color3(1.0, 1.0, 1.0);
         public specular = new Color3(1.0, 1.0, 1.0);

+ 3 - 3
Babylon/Lights/babylon.pointLight.ts

@@ -14,10 +14,10 @@
         public transferToEffect(effect: Effect, positionUniformName: string): void {
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this._transformedPosition) {
-                    this._transformedPosition = BABYLON.Vector3.Zero();
+                    this._transformedPosition = Vector3.Zero();
                 }
 
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
+                Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
                 effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, 0);
 
                 return;
@@ -32,7 +32,7 @@
 
         public _getWorldMatrix(): Matrix {
             if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
+                this._worldMatrix = Matrix.Identity();
             }
 
             Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);

+ 17 - 9
Babylon/Lights/babylon.spotLight.js

@@ -16,7 +16,7 @@ var BABYLON;
             this.exponent = exponent;
         }
         SpotLight.prototype.getAbsolutePosition = function () {
-            return this._transformedPosition ? this._transformedPosition : this.position;
+            return this.transformedPosition ? this.transformedPosition : this.position;
         };
 
         SpotLight.prototype.setDirectionToTarget = function (target) {
@@ -24,6 +24,19 @@ var BABYLON;
             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;
 
@@ -32,16 +45,11 @@ var BABYLON;
                     this._transformedDirection = BABYLON.Vector3.Zero();
                 }
 
-                if (!this._transformedPosition) {
-                    this._transformedPosition = BABYLON.Vector3.Zero();
-                }
-
-                var parentWorldMatrix = this.parent.getWorldMatrix();
+                this.computeTransformedPosition();
 
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, parentWorldMatrix, this._transformedPosition);
-                BABYLON.Vector3.TransformNormalToRef(this.direction, parentWorldMatrix, this._transformedDirection);
+                BABYLON.Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this._transformedDirection);
 
-                effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, this.exponent);
+                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);

+ 27 - 18
Babylon/Lights/babylon.spotLight.ts

@@ -1,8 +1,9 @@
 module BABYLON {
-    export class SpotLight extends Light {
+    export class SpotLight extends Light implements IShadowLight {
+
+        public transformedPosition: Vector3;
 
         private _transformedDirection: Vector3;
-        private _transformedPosition: Vector3;
         private _worldMatrix: Matrix;
 
         constructor(name: string, public position: Vector3, public direction: Vector3, public angle: number, public exponent: number, scene: Scene) {
@@ -10,36 +11,44 @@
         }
 
         public getAbsolutePosition(): Vector3 {
-            return this._transformedPosition ? this._transformedPosition : this.position;
+            return this.transformedPosition ? this.transformedPosition : this.position;
         }
 
         public setDirectionToTarget(target: Vector3): Vector3 {
-            this.direction = BABYLON.Vector3.Normalize(target.subtract(this.position));
+            this.direction = Vector3.Normalize(target.subtract(this.position));
             return this.direction;
         }
 
+        public computeTransformedPosition(): boolean {
+            if (this.parent && this.parent.getWorldMatrix) {
+                if (!this.transformedPosition) {
+                    this.transformedPosition = Vector3.Zero();
+                }
+
+                Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
+                return true;
+            }
+
+            return false;
+        }
+
         public transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void {
             var normalizeDirection;
 
             if (this.parent && this.parent.getWorldMatrix) {
                 if (!this._transformedDirection) {
-                    this._transformedDirection = BABYLON.Vector3.Zero();
+                    this._transformedDirection = Vector3.Zero();
                 }
 
-                if (!this._transformedPosition) {
-                    this._transformedPosition = BABYLON.Vector3.Zero();
-                }
-
-                var parentWorldMatrix = this.parent.getWorldMatrix();
-
-                BABYLON.Vector3.TransformCoordinatesToRef(this.position, parentWorldMatrix, this._transformedPosition);
-                BABYLON.Vector3.TransformNormalToRef(this.direction, parentWorldMatrix, this._transformedDirection);
+                this.computeTransformedPosition();
+                
+                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);
+                effect.setFloat4(positionUniformName, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent);
+                normalizeDirection = 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);
+                normalizeDirection = Vector3.Normalize(this.direction);
             }
 
             effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, Math.cos(this.angle * 0.5));
@@ -47,10 +56,10 @@
 
         public _getWorldMatrix(): Matrix {
             if (!this._worldMatrix) {
-                this._worldMatrix = BABYLON.Matrix.Identity();
+                this._worldMatrix = Matrix.Identity();
             }
 
-            BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
 
             return this._worldMatrix;
         }

+ 1 - 1
Babylon/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -1240,7 +1240,7 @@
                 scene.setActiveCameraByID(parsedData.activeCameraID);
             }
 
-            // Connecting parents
+            // Browsing all the graph to connect the dots
             for (index = 0; index < scene.cameras.length; index++) {
                 var camera = scene.cameras[index];
                 if (camera._waitingParentId) {

+ 11 - 3
Babylon/Materials/Textures/babylon.dynamicTexture.js

@@ -64,11 +64,17 @@ var BABYLON;
             return this._context;
         };
 
+        DynamicTexture.prototype.clear = function () {
+            var size = this.getSize();
+            this._context.fillRect(0, 0, size.width, size.height);
+        };
+
         DynamicTexture.prototype.update = function (invertY) {
             this.getScene().getEngine().updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY);
         };
 
-        DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY) {
+        DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
+            if (typeof update === "undefined") { update = true; }
             var size = this.getSize();
             if (clearColor) {
                 this._context.fillStyle = clearColor;
@@ -84,12 +90,14 @@ var BABYLON;
             this._context.fillStyle = color;
             this._context.fillText(text, x, y);
 
-            this.update(invertY);
+            if (update) {
+                this.update(invertY);
+            }
         };
 
         DynamicTexture.prototype.clone = function () {
             var textureSize = this.getSize();
-            var newTexture = new BABYLON.DynamicTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
+            var newTexture = new DynamicTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
 
             // Base texture
             newTexture.hasAlpha = this.hasAlpha;

+ 12 - 5
Babylon/Materials/Textures/babylon.dynamicTexture.ts

@@ -9,8 +9,8 @@
 
             this.name = name;
 
-            this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
-            this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
+            this.wrapU = Texture.CLAMP_ADDRESSMODE;
+            this.wrapV = Texture.CLAMP_ADDRESSMODE;
 
             this._generateMipMaps = generateMipMaps;
 
@@ -56,11 +56,16 @@
             return this._context;
         }
 
+        public clear(): void {
+            var size = this.getSize();
+            this._context.fillRect(0, 0, size.width, size.height);
+        }
+
         public update(invertY?: boolean): void {
             this.getScene().getEngine().updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY);
         }
 
-        public drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean) {
+        public drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update = true) {
             var size = this.getSize();
             if (clearColor) {
                 this._context.fillStyle = clearColor;
@@ -76,12 +81,14 @@
             this._context.fillStyle = color;
             this._context.fillText(text, x, y);
 
-            this.update(invertY);
+            if (update) {
+                this.update(invertY);
+            }
         }
 
         public clone(): DynamicTexture {
             var textureSize = this.getSize();
-            var newTexture = new BABYLON.DynamicTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
+            var newTexture = new DynamicTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
 
             // Base texture
             newTexture.hasAlpha = this.hasAlpha;

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

@@ -56,6 +56,13 @@ var BABYLON;
 
             switch (impostor) {
                 case BABYLON.PhysicsEngine.SphereImpostor:
+                    var initialRotation = null;
+                    if (mesh.rotationQuaternion) {
+                        initialRotation = mesh.rotationQuaternion.clone();
+                        mesh.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
+                        mesh.computeWorldMatrix(true);
+                    }
+
                     var bbox = mesh.getBoundingInfo().boundingBox;
                     var radiusX = bbox.maximumWorld.x - bbox.minimumWorld.x;
                     var radiusY = bbox.maximumWorld.y - bbox.minimumWorld.y;
@@ -66,6 +73,13 @@ var BABYLON;
                     // The delta between the mesh position and the mesh bounding box center
                     var deltaPosition = mesh.position.subtract(bbox.center);
 
+                    // Transform delta position with the rotation
+                    if (initialRotation) {
+                        var m = new BABYLON.Matrix();
+                        initialRotation.toRotationMatrix(m);
+                        deltaPosition = BABYLON.Vector3.TransformCoordinates(deltaPosition, m);
+                    }
+
                     body = new OIMO.Body({
                         type: 'sphere',
                         size: [size],
@@ -75,6 +89,12 @@ var BABYLON;
                         config: [options.mass, options.friction, options.restitution],
                         world: this._world
                     });
+
+                    // Restore rotation
+                    if (initialRotation) {
+                        body.setQuaternion(initialRotation);
+                    }
+
                     this._registeredMeshes.push({
                         mesh: mesh,
                         body: body,
@@ -84,6 +104,13 @@ var BABYLON;
 
                 case BABYLON.PhysicsEngine.PlaneImpostor:
                 case BABYLON.PhysicsEngine.BoxImpostor:
+                    initialRotation = null;
+                    if (mesh.rotationQuaternion) {
+                        initialRotation = mesh.rotationQuaternion.clone();
+                        mesh.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
+                        mesh.computeWorldMatrix(true);
+                    }
+
                     bbox = mesh.getBoundingInfo().boundingBox;
                     var min = bbox.minimumWorld;
                     var max = bbox.maximumWorld;
@@ -93,7 +120,14 @@ var BABYLON;
                     var sizeZ = this._checkWithEpsilon(box.z);
 
                     // The delta between the mesh position and the mesh boudning box center
-                    var deltaPosition = mesh.position.subtract(bbox.center);
+                    deltaPosition = mesh.position.subtract(bbox.center);
+
+                    // Transform delta position with the rotation
+                    if (initialRotation) {
+                        m = new BABYLON.Matrix();
+                        initialRotation.toRotationMatrix(m);
+                        deltaPosition = BABYLON.Vector3.TransformCoordinates(deltaPosition, m);
+                    }
 
                     body = new OIMO.Body({
                         type: 'box',
@@ -105,6 +139,10 @@ var BABYLON;
                         world: this._world
                     });
 
+                    if (initialRotation) {
+                        body.setQuaternion(initialRotation);
+                    }
+
                     this._registeredMeshes.push({
                         mesh: mesh,
                         body: body,

+ 41 - 1
Babylon/Physics/Plugins/babylon.oimoJSPlugin.ts

@@ -26,6 +26,14 @@ module BABYLON {
             // register mesh
             switch (impostor) {
                 case BABYLON.PhysicsEngine.SphereImpostor:
+
+                    var initialRotation = null;
+                    if (mesh.rotationQuaternion) {
+                        initialRotation = mesh.rotationQuaternion.clone();
+                        mesh.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
+                        mesh.computeWorldMatrix(true);
+                    }
+
                     var bbox = mesh.getBoundingInfo().boundingBox;
                     var radiusX = bbox.maximumWorld.x - bbox.minimumWorld.x;
                     var radiusY = bbox.maximumWorld.y - bbox.minimumWorld.y;
@@ -39,6 +47,13 @@ module BABYLON {
                     // The delta between the mesh position and the mesh bounding box center
                     var deltaPosition = mesh.position.subtract(bbox.center);
 
+                    // Transform delta position with the rotation
+                    if (initialRotation) {
+                        var m = new BABYLON.Matrix();
+                        initialRotation.toRotationMatrix(m);
+                        deltaPosition = BABYLON.Vector3.TransformCoordinates(deltaPosition, m);
+                    }
+
                     body = new OIMO.Body({
                         type: 'sphere',
                         size: [size],
@@ -48,6 +63,12 @@ module BABYLON {
                         config: [options.mass, options.friction, options.restitution],
                         world: this._world
                     });
+
+                    // Restore rotation
+                    if (initialRotation) {
+                        body.setQuaternion(initialRotation);
+                    }
+
                     this._registeredMeshes.push({
                         mesh: mesh,
                         body: body,
@@ -57,6 +78,14 @@ module BABYLON {
 
                 case BABYLON.PhysicsEngine.PlaneImpostor:
                 case BABYLON.PhysicsEngine.BoxImpostor:
+
+                    initialRotation = null;
+                    if (mesh.rotationQuaternion) {
+                        initialRotation = mesh.rotationQuaternion.clone();
+                        mesh.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 1);
+                        mesh.computeWorldMatrix(true);
+                    }
+
                     bbox = mesh.getBoundingInfo().boundingBox;
                     var min = bbox.minimumWorld;
                     var max = bbox.maximumWorld;
@@ -66,7 +95,14 @@ module BABYLON {
                     var sizeZ = this._checkWithEpsilon(box.z);
 
                     // The delta between the mesh position and the mesh boudning box center
-                    var deltaPosition = mesh.position.subtract(bbox.center);
+                    deltaPosition = mesh.position.subtract(bbox.center);
+
+                    // Transform delta position with the rotation
+                    if (initialRotation) {
+                        m = new BABYLON.Matrix();
+                        initialRotation.toRotationMatrix(m);
+                        deltaPosition = BABYLON.Vector3.TransformCoordinates(deltaPosition, m);
+                    }
 
                     body = new OIMO.Body({
                         type: 'box',
@@ -78,6 +114,10 @@ module BABYLON {
                         world: this._world
                     });
 
+                    if (initialRotation) {
+                        body.setQuaternion(initialRotation);
+                    }
+
                     this._registeredMeshes.push({
                         mesh: mesh,
                         body: body,

+ 41 - 18
Babylon/babylon.engine.js

@@ -122,9 +122,9 @@
 
             // Cull
             if (this._isCullDirty) {
-                if (this.cull === true) {
+                if (this.cull) {
                     gl.enable(gl.CULL_FACE);
-                } else if (this.cull === false) {
+                } else {
                     gl.disable(gl.CULL_FACE);
                 }
 
@@ -145,9 +145,9 @@
 
             // Depth test
             if (this._isDepthTestDirty) {
-                if (this.depthTest === true) {
+                if (this.depthTest) {
                     gl.enable(gl.DEPTH_TEST);
-                } else if (this.depthTest === false) {
+                } else {
                     gl.disable(gl.DEPTH_TEST);
                 }
                 this._isDepthTestDirty = false;
@@ -226,9 +226,9 @@
 
             // Alpha blend
             if (this._isAlphaBlendDirty) {
-                if (this._alphaBlend === true) {
+                if (this._alphaBlend) {
                     gl.enable(gl.BLEND);
-                } else if (this._alphaBlend === false) {
+                } else {
                     gl.disable(gl.BLEND);
                 }
 
@@ -322,15 +322,13 @@
     };
 
     var partialLoad = function (url, index, loadedImages, scene, onfinish) {
-        var img;
-
         var onload = function () {
             loadedImages[index] = img;
             loadedImages._internalCount++;
 
             scene._removePendingData(img);
 
-            if (loadedImages._internalCount == 6) {
+            if (loadedImages._internalCount === 6) {
                 onfinish(loadedImages);
             }
         };
@@ -339,7 +337,7 @@
             scene._removePendingData(img);
         };
 
-        img = BABYLON.Tools.LoadImage(url, onload, onerror, scene.database);
+        var img = BABYLON.Tools.LoadImage(url, onload, onerror, scene.database);
         scene._addPendingData(img);
     };
 
@@ -429,6 +427,23 @@
             this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
             this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
 
+            // Infos
+            this._glVersion = this._gl.getParameter(this._gl.VERSION);
+
+            var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
+            if (rendererInfo != null) {
+                this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
+                this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
+            }
+
+            if (!this._glVendor) {
+                this._glVendor = "Unknown vendor";
+            }
+
+            if (!this._glRenderer) {
+                this._glRenderer = "Unknown renderer";
+            }
+
             // Extensions
             this._caps.standardDerivatives = (this._gl.getExtension('OES_standard_derivatives') !== null);
             this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc');
@@ -588,6 +603,14 @@
             configurable: true
         });
 
+        Engine.prototype.getGlInfo = function () {
+            return {
+                vendor: this._glVendor,
+                renderer: this._glRenderer,
+                version: this._glVersion
+            };
+        };
+
         Engine.prototype.getAudioEngine = function () {
             return this._audioEngine;
         };
@@ -1256,16 +1279,16 @@
 
         Engine.prototype.setAlphaMode = function (mode) {
             switch (mode) {
-                case BABYLON.Engine.ALPHA_DISABLE:
+                case Engine.ALPHA_DISABLE:
                     this.setDepthWrite(true);
                     this._alphaState.alphaBlend = false;
                     break;
-                case BABYLON.Engine.ALPHA_COMBINE:
+                case Engine.ALPHA_COMBINE:
                     this.setDepthWrite(false);
                     this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
                     this._alphaState.alphaBlend = true;
                     break;
-                case BABYLON.Engine.ALPHA_ADD:
+                case Engine.ALPHA_ADD:
                     this.setDepthWrite(false);
                     this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
                     this._alphaState.alphaBlend = true;
@@ -1389,7 +1412,7 @@
                 callback = function (data) {
                     var info = BABYLON.Internals.DDSTools.GetDDSInfo(data);
 
-                    var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) == 1);
+                    var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) === 1);
                     prepareWebGLTexture(texture, _this._gl, scene, info.width, info.height, invertY, !loadMipmap, info.isFourCC, function () {
                         BABYLON.Internals.DDSTools.UploadDDSLevels(_this._gl, _this.getCaps().s3tc, data, info, loadMipmap, 1);
 
@@ -1408,7 +1431,7 @@
             } else {
                 var onload = function (img) {
                     prepareWebGLTexture(texture, _this._gl, scene, img.width, img.height, invertY, noMipmap, false, function (potWidth, potHeight) {
-                        var isPot = (img.width == potWidth && img.height == potHeight);
+                        var isPot = (img.width === potWidth && img.height === potHeight);
                         if (!isPot) {
                             _this._workingCanvas.width = potWidth;
                             _this._workingCanvas.height = potHeight;
@@ -1649,7 +1672,7 @@
 
                     BABYLON.Internals.DDSTools.UploadDDSLevels(_this._gl, _this.getCaps().s3tc, data, info, loadMipmap, 6);
 
-                    if (!noMipmap && !info.isFourCC && info.mipmapCount == 1) {
+                    if (!noMipmap && !info.isFourCC && info.mipmapCount === 1) {
                         gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
                     }
 
@@ -1777,12 +1800,12 @@
                 if (texture.update()) {
                     this._activeTexturesCache[channel] = null;
                 }
-            } else if (texture.delayLoadState == BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
+            } else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) {
                 texture.delayLoad();
                 return;
             }
 
-            if (this._activeTexturesCache[channel] == texture) {
+            if (this._activeTexturesCache[channel] === texture) {
                 return;
             }
             this._activeTexturesCache[channel] = texture;

+ 75 - 48
Babylon/babylon.engine.ts

@@ -103,9 +103,9 @@
 
             // Cull
             if (this._isCullDirty) {
-                if (this.cull === true) {
+                if (this.cull) {
                     gl.enable(gl.CULL_FACE);
-                } else if (this.cull === false) {
+                } else {
                     gl.disable(gl.CULL_FACE);
                 }
 
@@ -126,9 +126,9 @@
 
             // Depth test
             if (this._isDepthTestDirty) {
-                if (this.depthTest === true) {
+                if (this.depthTest) {
                     gl.enable(gl.DEPTH_TEST);
-                } else if (this.depthTest === false) {
+                } else {
                     gl.disable(gl.DEPTH_TEST);
                 }
                 this._isDepthTestDirty = false;
@@ -202,9 +202,9 @@
 
             // Alpha blend
             if (this._isAlphaBlendDirty) {
-                if (this._alphaBlend === true) {
+                if (this._alphaBlend) {
                     gl.enable(gl.BLEND);
-                } else if (this._alphaBlend === false) {
+                } else {
                     gl.disable(gl.BLEND);
                 }
 
@@ -234,21 +234,21 @@
     var getSamplingParameters = (samplingMode: number, generateMipMaps: boolean, gl: WebGLRenderingContext): { min: number; mag: number } => {
         var magFilter = gl.NEAREST;
         var minFilter = gl.NEAREST;
-        if (samplingMode === BABYLON.Texture.BILINEAR_SAMPLINGMODE) {
+        if (samplingMode === Texture.BILINEAR_SAMPLINGMODE) {
             magFilter = gl.LINEAR;
             if (generateMipMaps) {
                 minFilter = gl.LINEAR_MIPMAP_NEAREST;
             } else {
                 minFilter = gl.LINEAR;
             }
-        } else if (samplingMode === BABYLON.Texture.TRILINEAR_SAMPLINGMODE) {
+        } else if (samplingMode === Texture.TRILINEAR_SAMPLINGMODE) {
             magFilter = gl.LINEAR;
             if (generateMipMaps) {
                 minFilter = gl.LINEAR_MIPMAP_LINEAR;
             } else {
                 minFilter = gl.LINEAR;
             }
-        } else if (samplingMode === BABYLON.Texture.NEAREST_SAMPLINGMODE) {
+        } else if (samplingMode === Texture.NEAREST_SAMPLINGMODE) {
             magFilter = gl.NEAREST;
             if (generateMipMaps) {
                 minFilter = gl.NEAREST_MIPMAP_LINEAR;
@@ -298,15 +298,13 @@
     var partialLoad = (url: string, index: number, loadedImages: any, scene,
         onfinish: (images: HTMLImageElement[]) => void) => {
 
-        var img: HTMLImageElement;
-
         var onload = () => {
             loadedImages[index] = img;
             loadedImages._internalCount++;
 
             scene._removePendingData(img);
 
-            if (loadedImages._internalCount == 6) {
+            if (loadedImages._internalCount === 6) {
                 onfinish(loadedImages);
             }
         };
@@ -315,7 +313,7 @@
             scene._removePendingData(img);
         };
 
-        img = BABYLON.Tools.LoadImage(url, onload, onerror, scene.database);
+        var img = Tools.LoadImage(url, onload, onerror, scene.database);
         scene._addPendingData(img);
     }
 
@@ -426,11 +424,11 @@
         public scenes = new Array<Scene>();
 
         // Private Members
-        private _gl: WebGLRenderingContext;
+        public _gl: WebGLRenderingContext;
         private _renderingCanvas: HTMLCanvasElement;
         private _windowIsBackground = false;
 
-        private _audioEngine: BABYLON.AudioEngine;
+        private _audioEngine: AudioEngine;
 
         private _onBlur: () => void;
         private _onFocus: () => void;
@@ -449,6 +447,10 @@
 
         private _drawCalls = 0;
 
+        private _glVersion: string;
+        private _glRenderer: string;
+        private _glVendor: string;
+
         private _renderingQueueLaunched = false;
         private _activeRenderLoops = [];
 
@@ -525,6 +527,23 @@
             this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
             this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
 
+            // Infos
+            this._glVersion = this._gl.getParameter(this._gl.VERSION);
+
+            var rendererInfo: any = this._gl.getExtension("WEBGL_debug_renderer_info");
+            if (rendererInfo != null) {
+                this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
+                this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
+            }
+
+            if (!this._glVendor) {
+                this._glVendor = "Unknown vendor";
+            }
+
+            if (!this._glRenderer) {
+                this._glRenderer = "Unknown renderer";
+            }
+
             // Extensions
             this._caps.standardDerivatives = (this._gl.getExtension('OES_standard_derivatives') !== null);
             this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc');
@@ -583,11 +602,19 @@
             document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
             document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
 
-            this._audioEngine = new BABYLON.AudioEngine();
+            this._audioEngine = new AudioEngine();
 
             Tools.Log("Babylon.js engine (v" + Engine.Version + ") launched");
         }
 
+        public getGlInfo() {
+            return {
+                vendor: this._glVendor,
+                renderer: this._glRenderer,
+                version: this._glVersion
+            }
+        }
+
         public getAudioEngine(): AudioEngine {
             return this._audioEngine;
         }
@@ -698,7 +725,7 @@
 
             if (this._activeRenderLoops.length > 0) {
                 // Register new frame
-                BABYLON.Tools.QueueNewFrame(() => {
+                Tools.QueueNewFrame(() => {
                     this._renderLoop();
                 });
             } else {
@@ -715,7 +742,7 @@
 
             if (!this._renderingQueueLaunched) {
                 this._renderingQueueLaunched = true;
-                BABYLON.Tools.QueueNewFrame(() => {
+                Tools.QueueNewFrame(() => {
                     this._renderLoop();
                 });
             }
@@ -723,10 +750,10 @@
 
         public switchFullscreen(requestPointerLock: boolean): void {
             if (this.isFullscreen) {
-                BABYLON.Tools.ExitFullscreen();
+                Tools.ExitFullscreen();
             } else {
                 this._pointerLockRequested = requestPointerLock;
-                BABYLON.Tools.RequestFullscreen(this._renderingCanvas);
+                Tools.RequestFullscreen(this._renderingCanvas);
             }
         }
 
@@ -1047,7 +1074,7 @@
                 return this._compiledEffects[name];
             }
 
-            var effect = new BABYLON.Effect(baseName, attributesNames, uniformsNames, samplers, this, defines, fallbacks, onCompiled, onError);
+            var effect = new Effect(baseName, attributesNames, uniformsNames, samplers, this, defines, fallbacks, onCompiled, onError);
             effect._key = name;
             this._compiledEffects[name] = effect;
 
@@ -1256,16 +1283,16 @@
 
         public setAlphaMode(mode: number): void {
             switch (mode) {
-                case BABYLON.Engine.ALPHA_DISABLE:
+                case Engine.ALPHA_DISABLE:
                     this.setDepthWrite(true);
                     this._alphaState.alphaBlend = false;
                     break;
-                case BABYLON.Engine.ALPHA_COMBINE:
+                case Engine.ALPHA_COMBINE:
                     this.setDepthWrite(false);
                     this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
                     this._alphaState.alphaBlend = true;
                     break;
-                case BABYLON.Engine.ALPHA_ADD:
+                case Engine.ALPHA_ADD:
                     this.setDepthWrite(false);
                     this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
                     this._alphaState.alphaBlend = true;
@@ -1308,10 +1335,10 @@
             var magFilter = gl.NEAREST;
             var minFilter = gl.NEAREST;
 
-            if (samplingMode === BABYLON.Texture.BILINEAR_SAMPLINGMODE) {
+            if (samplingMode === Texture.BILINEAR_SAMPLINGMODE) {
                 magFilter = gl.LINEAR;
                 minFilter = gl.LINEAR;
-            } else if (samplingMode === BABYLON.Texture.TRILINEAR_SAMPLINGMODE) {
+            } else if (samplingMode === Texture.TRILINEAR_SAMPLINGMODE) {
                 magFilter = gl.LINEAR;
                 minFilter = gl.LINEAR_MIPMAP_LINEAR;
             }
@@ -1364,7 +1391,7 @@
                 var callback = (arrayBuffer) => {
                     var data = new Uint8Array(arrayBuffer);
 
-                    var header = BABYLON.Internals.TGATools.GetTGAHeader(data);
+                    var header = Internals.TGATools.GetTGAHeader(data);
 
                     prepareWebGLTexture(texture, this._gl, scene, header.width, header.height, invertY, noMipmap, false, () => {
                         Internals.TGATools.UploadContent(this._gl, data);
@@ -1376,7 +1403,7 @@
                 };
 
                 if (!(fromData instanceof Array))
-                    BABYLON.Tools.LoadFile(url, arrayBuffer => {
+                    Tools.LoadFile(url, arrayBuffer => {
                         callback(arrayBuffer);
                     }, onerror, scene.database, true);
                 else
@@ -1384,9 +1411,9 @@
 
             } else if (isDDS) {
                 callback = (data) => {
-                    var info = BABYLON.Internals.DDSTools.GetDDSInfo(data);
+                    var info = Internals.DDSTools.GetDDSInfo(data);
 
-                    var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) == 1);
+                    var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) === 1);
                     prepareWebGLTexture(texture, this._gl, scene, info.width, info.height, invertY, !loadMipmap, info.isFourCC, () => {
 
                         Internals.DDSTools.UploadDDSLevels(this._gl, this.getCaps().s3tc, data, info, loadMipmap, 1);
@@ -1398,7 +1425,7 @@
                 };
 
                 if (!(fromData instanceof Array))
-                    BABYLON.Tools.LoadFile(url, data => {
+                    Tools.LoadFile(url, data => {
                         callback(data);
                     }, onerror, scene.database, true);
                 else
@@ -1407,7 +1434,7 @@
             } else {
                 var onload = (img) => {
                     prepareWebGLTexture(texture, this._gl, scene, img.width, img.height, invertY, noMipmap, false, (potWidth, potHeight) => {
-                        var isPot = (img.width == potWidth && img.height == potHeight);
+                        var isPot = (img.width === potWidth && img.height === potHeight);
                         if (!isPot) {
                             this._workingCanvas.width = potWidth;
                             this._workingCanvas.height = potHeight;
@@ -1425,9 +1452,9 @@
 
 
                 if (!(fromData instanceof Array))
-                    BABYLON.Tools.LoadImage(url, onload, onerror, scene.database);
+                    Tools.LoadImage(url, onload, onerror, scene.database);
                 else
-                    BABYLON.Tools.LoadImage(buffer, onload, onerror, scene.database);
+                    Tools.LoadImage(buffer, onload, onerror, scene.database);
             }
 
             return texture;
@@ -1563,7 +1590,7 @@
             // in the same way, generateDepthBuffer is defaulted to true
             var generateMipMaps = false;
             var generateDepthBuffer = true;
-            var samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
+            var samplingMode = Texture.TRILINEAR_SAMPLINGMODE;
             if (options !== undefined) {
                 generateMipMaps = options.generateMipMaps === undefined ? options : options.generateMipmaps;
                 generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
@@ -1637,8 +1664,8 @@
             var isDDS = this.getCaps().s3tc && (extension === ".dds");
 
             if (isDDS) {
-                BABYLON.Tools.LoadFile(rootUrl, data => {
-                    var info = BABYLON.Internals.DDSTools.GetDDSInfo(data);
+                Tools.LoadFile(rootUrl, data => {
+                    var info = Internals.DDSTools.GetDDSInfo(data);
 
                     var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap;
 
@@ -1647,7 +1674,7 @@
 
                     Internals.DDSTools.UploadDDSLevels(this._gl, this.getCaps().s3tc, data, info, loadMipmap, 6);
 
-                    if (!noMipmap && !info.isFourCC && info.mipmapCount == 1) {
+                    if (!noMipmap && !info.isFourCC && info.mipmapCount === 1) {
                         gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
                     }
 
@@ -1772,16 +1799,16 @@
             }
 
             // Video
-            if (texture instanceof BABYLON.VideoTexture) {
+            if (texture instanceof VideoTexture) {
                 if ((<VideoTexture>texture).update()) {
                     this._activeTexturesCache[channel] = null;
                 }
-            } else if (texture.delayLoadState == BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
+            } else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
                 texture.delayLoad();
                 return;
             }
 
-            if (this._activeTexturesCache[channel] == texture) {
+            if (this._activeTexturesCache[channel] === texture) {
                 return;
             }
             this._activeTexturesCache[channel] = texture;
@@ -1795,7 +1822,7 @@
                 if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
                     internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
                     // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE.  All other modes use REPEAT.
-                    var textureWrapMode = (texture.coordinatesMode !== BABYLON.Texture.CUBIC_MODE && texture.coordinatesMode !== BABYLON.Texture.SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
+                    var textureWrapMode = (texture.coordinatesMode !== Texture.CUBIC_MODE && texture.coordinatesMode !== Texture.SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
                     this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode);
                     this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
                 }
@@ -1808,13 +1835,13 @@
                     internalTexture._cachedWrapU = texture.wrapU;
 
                     switch (texture.wrapU) {
-                        case BABYLON.Texture.WRAP_ADDRESSMODE:
+                        case Texture.WRAP_ADDRESSMODE:
                             this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.REPEAT);
                             break;
-                        case BABYLON.Texture.CLAMP_ADDRESSMODE:
+                        case Texture.CLAMP_ADDRESSMODE:
                             this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE);
                             break;
-                        case BABYLON.Texture.MIRROR_ADDRESSMODE:
+                        case Texture.MIRROR_ADDRESSMODE:
                             this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.MIRRORED_REPEAT);
                             break;
                     }
@@ -1823,13 +1850,13 @@
                 if (internalTexture._cachedWrapV !== texture.wrapV) {
                     internalTexture._cachedWrapV = texture.wrapV;
                     switch (texture.wrapV) {
-                        case BABYLON.Texture.WRAP_ADDRESSMODE:
+                        case Texture.WRAP_ADDRESSMODE:
                             this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.REPEAT);
                             break;
-                        case BABYLON.Texture.CLAMP_ADDRESSMODE:
+                        case Texture.CLAMP_ADDRESSMODE:
                             this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
                             break;
-                        case BABYLON.Texture.MIRROR_ADDRESSMODE:
+                        case Texture.MIRROR_ADDRESSMODE:
                             this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.MIRRORED_REPEAT);
                             break;
                     }

文件差异内容过多而无法显示
+ 3716 - 2423
Oimo.js


文件差异内容过多而无法显示
+ 136 - 53
babylon.2.0-alpha.debug.js


文件差异内容过多而无法显示
+ 16 - 16
babylon.2.0-alpha.js


+ 185 - 54
babylon.2.0.d.ts

@@ -51,6 +51,11 @@ declare module BABYLON {
         private static _DELAYLOADSTATE_LOADED;
         private static _DELAYLOADSTATE_LOADING;
         private static _DELAYLOADSTATE_NOTLOADED;
+        private static _TEXTUREFORMAT_ALPHA;
+        private static _TEXTUREFORMAT_LUMINANCE;
+        private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
+        private static _TEXTUREFORMAT_RGB;
+        private static _TEXTUREFORMAT_RGBA;
         static ALPHA_DISABLE : number;
         static ALPHA_ADD : number;
         static ALPHA_COMBINE : number;
@@ -58,6 +63,11 @@ declare module BABYLON {
         static DELAYLOADSTATE_LOADED : number;
         static DELAYLOADSTATE_LOADING : number;
         static DELAYLOADSTATE_NOTLOADED : number;
+        static TEXTUREFORMAT_ALPHA : number;
+        static TEXTUREFORMAT_LUMINANCE : number;
+        static TEXTUREFORMAT_LUMINANCE_ALPHA : number;
+        static TEXTUREFORMAT_RGB : number;
+        static TEXTUREFORMAT_RGBA : number;
         static Version : string;
         static Epsilon: number;
         static CollisionsEpsilon: number;
@@ -67,7 +77,7 @@ declare module BABYLON {
         public cullBackFaces: boolean;
         public renderEvenInBackground: boolean;
         public scenes: Scene[];
-        private _gl;
+        public _gl: WebGLRenderingContext;
         private _renderingCanvas;
         private _windowIsBackground;
         private _audioEngine;
@@ -84,6 +94,9 @@ declare module BABYLON {
         private _loadingTextDiv;
         private _loadingDivBackgroundColor;
         private _drawCalls;
+        private _glVersion;
+        private _glRenderer;
+        private _glVendor;
         private _renderingQueueLaunched;
         private _activeRenderLoops;
         private fpsRange;
@@ -108,6 +121,11 @@ declare module BABYLON {
         private _workingCanvas;
         private _workingContext;
         constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?: any);
+        public getGlInfo(): {
+            vendor: string;
+            renderer: string;
+            version: string;
+        };
         public getAudioEngine(): AudioEngine;
         public getAspectRatio(camera: Camera): number;
         public getRenderWidth(): number;
@@ -184,6 +202,7 @@ declare module BABYLON {
         public wipeCaches(): void;
         public setSamplingMode(texture: WebGLTexture, samplingMode: number): void;
         public createTexture(url: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any): WebGLTexture;
+        public createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number): WebGLTexture;
         public createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): WebGLTexture;
         public updateDynamicTexture(texture: WebGLTexture, canvas: HTMLCanvasElement, invertY: boolean): void;
         public updateVideoTexture(texture: WebGLTexture, video: HTMLVideoElement, invertY: boolean): void;
@@ -252,6 +271,7 @@ interface WebGLTexture {
     isCube: boolean;
     url: string;
     noMipmap: boolean;
+    samplingMode: number;
     references: number;
     generateMipMaps: boolean;
     _size: number;
@@ -787,6 +807,7 @@ declare module BABYLON {
         public color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
         public clone(): Animation;
         public setKeys(values: any[]): void;
+        private _getKeyValue(value);
         private _interpolate(currentFrame, repeatCount, loopMode, offsetValue?, highLimitValue?);
         public animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number): boolean;
         private static _ANIMATIONTYPE_FLOAT;
@@ -892,11 +913,18 @@ declare module BABYLON {
 }
 declare module BABYLON {
     class Sound {
-        public maxDistance: number;
         public autoplay: boolean;
         public loop: boolean;
-        public useBabylonJSAttenuation: boolean;
+        public useCustomAttenuation: boolean;
         public soundTrackId: number;
+        public spatialSound: boolean;
+        public refDistance: number;
+        public rolloffFactor: number;
+        public maxDistance: number;
+        public distanceModel: string;
+        public panningModel: string;
+        private startTime;
+        private startOffset;
         private _position;
         private _localDirection;
         private _volume;
@@ -910,20 +938,24 @@ declare module BABYLON {
         private _soundSource;
         private _soundPanner;
         private _soundGain;
+        private _audioNode;
         private _coneInnerAngle;
         private _coneOuterAngle;
         private _coneOuterGain;
         private _scene;
         private _name;
         private _connectedMesh;
+        private _customAttenuationFunction;
         /**
         * Create a sound and attach it to a scene
         * @param name Name of your sound
-        * @param url Url to the sound to load async
+        * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
         * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
-        * @param options Objects to provide with the current available options: autoplay, loop, distanceMax
+        * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel
         */
-        constructor(name: string, url: string, scene: Scene, readyToPlayCallback?: () => void, options?: any);
+        constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any);
+        public updateOptions(options: any): void;
+        private _createSpatialParameters();
         public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
         /**
         * Transform this sound into a directional source
@@ -936,6 +968,7 @@ declare module BABYLON {
         public setLocalDirectionToMesh(newLocalDirection: Vector3): void;
         private _updateDirection();
         public updateDistanceFromListener(): void;
+        public setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
         /**
         * Play the sound
         * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
@@ -1227,41 +1260,6 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
-    class OculusCamera extends FreeCamera {
-        private _leftCamera;
-        private _rightCamera;
-        private _offsetOrientation;
-        private _deviceOrientationHandler;
-        constructor(name: string, position: Vector3, scene: Scene);
-        public _update(): void;
-        public _updateCamera(camera: FreeCamera): void;
-        public _onOrientationEvent(evt: DeviceOrientationEvent): void;
-        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
-        public detachControl(element: HTMLElement): void;
-    }
-}
-declare module BABYLON {
-    class OculusGamepadCamera extends FreeCamera {
-        private _leftCamera;
-        private _rightCamera;
-        private _offsetOrientation;
-        private _deviceOrientationHandler;
-        private _gamepad;
-        private _gamepads;
-        public angularSensibility: number;
-        public moveSensibility: number;
-        constructor(name: string, position: Vector3, scene: Scene);
-        private _onNewGameConnected(gamepad);
-        public _update(): void;
-        public _checkInputs(): void;
-        public _updateCamera(camera: FreeCamera): void;
-        public _onOrientationEvent(evt: DeviceOrientationEvent): void;
-        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
-        public detachControl(element: HTMLElement): void;
-        public dispose(): void;
-    }
-}
-declare module BABYLON {
     class TargetCamera extends Camera {
         public cameraDirection: Vector3;
         public cameraRotation: Vector2;
@@ -1322,6 +1320,41 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
+    class OculusCamera extends FreeCamera {
+        private _leftCamera;
+        private _rightCamera;
+        private _offsetOrientation;
+        private _deviceOrientationHandler;
+        constructor(name: string, position: Vector3, scene: Scene);
+        public _update(): void;
+        public _updateCamera(camera: FreeCamera): void;
+        public _onOrientationEvent(evt: DeviceOrientationEvent): void;
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
+        public detachControl(element: HTMLElement): void;
+    }
+}
+declare module BABYLON {
+    class OculusGamepadCamera extends FreeCamera {
+        private _leftCamera;
+        private _rightCamera;
+        private _offsetOrientation;
+        private _deviceOrientationHandler;
+        private _gamepad;
+        private _gamepads;
+        public angularSensibility: number;
+        public moveSensibility: number;
+        constructor(name: string, position: Vector3, scene: Scene);
+        private _onNewGameConnected(gamepad);
+        public _update(): void;
+        public _checkInputs(): void;
+        public _updateCamera(camera: FreeCamera): void;
+        public _onOrientationEvent(evt: DeviceOrientationEvent): void;
+        public attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
+        public detachControl(element: HTMLElement): void;
+        public dispose(): void;
+    }
+}
+declare module BABYLON {
     class VRDeviceOrientationCamera extends OculusCamera {
         public _alpha: number;
         public _beta: number;
@@ -1535,6 +1568,8 @@ declare module BABYLON {
         public shouldDisplayLabel: (node: Node) => boolean;
         public shouldDisplayAxis: (mesh: Mesh) => boolean;
         public axisRatio: number;
+        public accentColor: string;
+        public customStatsFunction: () => string;
         constructor(scene: Scene);
         private _refreshMeshesTreeContent();
         private _renderSingleAxis(zero, unit, unitText, label, color);
@@ -1546,7 +1581,7 @@ declare module BABYLON {
         public show(showUI?: boolean): void;
         private _clearLabels();
         private _generateheader(root, text);
-        private _generateTexBox(root, title);
+        private _generateTexBox(root, title, color);
         private _generateAdvancedCheckBox(root, leftTitle, rightTitle, initialState, task, tag?);
         private _generateCheckBox(root, title, initialState, task, tag?);
         private _generateRadio(root, title, name, initialState, task, tag?);
@@ -1611,16 +1646,16 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
-    class DirectionalLight extends Light {
+    class DirectionalLight extends Light implements IShadowLight {
         public direction: Vector3;
         public position: Vector3;
         private _transformedDirection;
-        public _transformedPosition: Vector3;
+        public transformedPosition: Vector3;
         private _worldMatrix;
         constructor(name: string, direction: Vector3, scene: Scene);
         public getAbsolutePosition(): Vector3;
         public setDirectionToTarget(target: Vector3): Vector3;
-        public _computeTransformedPosition(): boolean;
+        public computeTransformedPosition(): boolean;
         public transferToEffect(effect: Effect, directionUniformName: string): void;
         public _getWorldMatrix(): Matrix;
     }
@@ -1638,6 +1673,15 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
+    interface IShadowLight {
+        position: Vector3;
+        direction: Vector3;
+        transformedPosition: Vector3;
+        name: string;
+        computeTransformedPosition(): boolean;
+        getScene(): Scene;
+        _shadowGenerator: ShadowGenerator;
+    }
     class Light extends Node {
         public diffuse: Color3;
         public specular: Color3;
@@ -1672,17 +1716,18 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
-    class SpotLight extends Light {
+    class SpotLight extends Light implements IShadowLight {
         public position: Vector3;
         public direction: Vector3;
         public angle: number;
         public exponent: number;
+        public transformedPosition: Vector3;
         private _transformedDirection;
-        private _transformedPosition;
         private _worldMatrix;
         constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
         public getAbsolutePosition(): Vector3;
         public setDirectionToTarget(target: Vector3): Vector3;
+        public computeTransformedPosition(): boolean;
         public transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void;
         public _getWorldMatrix(): Matrix;
     }
@@ -1711,10 +1756,10 @@ declare module BABYLON {
         private _cachedPosition;
         private _cachedDirection;
         private _cachedDefines;
-        constructor(mapSize: number, light: DirectionalLight);
+        constructor(mapSize: number, light: IShadowLight);
         public isReady(subMesh: SubMesh, useInstances: boolean): boolean;
         public getShadowMap(): RenderTargetTexture;
-        public getLight(): DirectionalLight;
+        public getLight(): IShadowLight;
         public getTransformMatrix(): Matrix;
         public getDarkness(): number;
         public setDarkness(darkness: number): void;
@@ -1986,7 +2031,7 @@ declare module BABYLON {
         public scale(ratio: number): void;
         public canRescale : boolean;
         public _removeFromCache(url: string, noMipmap: boolean): void;
-        public _getFromCache(url: string, noMipmap: boolean): WebGLTexture;
+        public _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture;
         public delayLoad(): void;
         public releaseInternalTexture(): void;
         public clone(): BaseTexture;
@@ -2015,8 +2060,9 @@ declare module BABYLON {
         public canRescale : boolean;
         public scale(ratio: number): void;
         public getContext(): CanvasRenderingContext2D;
+        public clear(): void;
         public update(invertY?: boolean): void;
-        public drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean): void;
+        public drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
         public clone(): DynamicTexture;
     }
 }
@@ -2032,7 +2078,12 @@ declare module BABYLON {
 }
 declare module BABYLON {
     class RawTexture extends Texture {
-        constructor(scene: Scene, samplingMode?: number);
+        constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
+        static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
+        static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
+        static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
+        static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
+        static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
     }
 }
 declare module BABYLON {
@@ -2635,6 +2686,58 @@ declare module BABYLON {
     class BezierCurve {
         static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
     }
+    enum Orientation {
+        CW = 0,
+        CCW = 1,
+    }
+    class Angle {
+        private _radians;
+        constructor(radians: number);
+        public degrees: () => number;
+        public radians: () => number;
+        static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
+        static FromRadians(radians: number): Angle;
+        static FromDegrees(degrees: number): Angle;
+    }
+    class Arc2 {
+        public startPoint: Vector2;
+        public midPoint: Vector2;
+        public endPoint: Vector2;
+        public centerPoint: Vector2;
+        public radius: number;
+        public angle: Angle;
+        public startAngle: Angle;
+        public orientation: Orientation;
+        constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
+    }
+    class PathCursor {
+        private path;
+        private _onchange;
+        public value: number;
+        public animations: Animation[];
+        constructor(path: Path2);
+        public getPoint(): Vector3;
+        public moveAhead(step?: number): void;
+        public moveBack(step?: number): void;
+        public move(step: number): void;
+        private ensureLimits();
+        private markAsDirty(propertyName);
+        private raiseOnChange();
+        public onchange(f: (cursor: PathCursor) => void): void;
+    }
+    class Path2 {
+        private _points;
+        private _length;
+        public closed: boolean;
+        constructor(x: number, y: number);
+        public addLineTo(x: number, y: number): Path2;
+        public addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
+        public close(): Path2;
+        public length(): number;
+        public getPoints(): Vector2[];
+        public getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
+        static StartingAt(x: number, y: number): Path2;
+    }
 }
 declare module BABYLON {
     class AbstractMesh extends Node implements IDisposable {
@@ -3018,7 +3121,17 @@ declare module BABYLON {
         private _instancesBufferSize;
         public _shouldGenerateFlatShading: boolean;
         private _preActivateId;
-        constructor(name: string, scene: Scene);
+        /**
+        * @param {string} name - The value used by scene.getMeshByName() to do a lookup.
+        * @param {BABYLON.Scene} scene - The scene to add this mesh to.
+        * @param {BABYLON.Node} parent - The parent of this mesh, if it has one
+        * @param {BABYLON.Mesh} source - An optional Mesh from which geometry is shared, cloned.
+        * @param {boolean} doNotCloneChildren - When cloning, skip cloning child meshes of source, default False.
+        *                  When false, achieved by calling a clone(), also passing False.
+        *                  This will make creation of children, recursive.
+        */
+        constructor(name: string, scene: Scene, parent?: Node, source?: Mesh, doNotCloneChildren?: boolean);
+        private _clone();
         public hasLODLevels : boolean;
         private _sortLODLevels();
         public addLODLevel(distance: number, mesh: Mesh): Mesh;
@@ -3152,6 +3265,24 @@ declare module BABYLON.Internals {
     }
 }
 declare module BABYLON {
+    class Polygon {
+        static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
+        static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
+        static Parse(input: string): Vector2[];
+        static StartingAt(x: number, y: number): Path2;
+    }
+    class PolygonMeshBuilder {
+        private _swctx;
+        private _points;
+        private _name;
+        private _scene;
+        constructor(name: string, contours: Path2, scene: Scene);
+        constructor(name: string, contours: Vector2[], scene: Scene);
+        public addHole(hole: Vector2[]): PolygonMeshBuilder;
+        public build(updatable?: boolean): Mesh;
+    }
+}
+declare module BABYLON {
     class SubMesh {
         public materialIndex: number;
         public verticesStart: number;
@@ -4120,7 +4251,7 @@ declare module BABYLON {
         static Clamp(value: number, min?: number, max?: number): number;
         static Format(value: number, decimals?: number): string;
         static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
-        static WithinEpsilon(a: number, b: number): boolean;
+        static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
         static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
         static IsEmpty(obj: any): boolean;
         static RegisterTopRootEvents(events: {