Browse Source

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

Conflicts:
	Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.js
	Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.ts
	Babylon/Math/babylon.math.ts
	Babylon/Shaders/brick.fragment.fx
	babylon.2.0-alpha.debug.js
	babylon.2.0-alpha.js
	babylon.2.0.d.ts
David Catuhe 10 years ago
parent
commit
edd037afc5
32 changed files with 3390 additions and 2403 deletions
  1. 13 0
      Babylon/Loading/Plugins/babylon.babylonFileLoader.js
  2. 13 0
      Babylon/Loading/Plugins/babylon.babylonFileLoader.ts
  3. 124 0
      Babylon/Materials/textures/Procedurals/babylon.customProceduralTexture.js
  4. 122 0
      Babylon/Materials/textures/Procedurals/babylon.customProceduralTexture.ts
  5. 4 0
      Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.js
  6. 5 0
      Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.ts
  7. 51 0
      Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.js
  8. 43 1
      Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.ts
  9. 8 0
      Babylon/Materials/textures/babylon.texture.js
  10. 5 0
      Babylon/Materials/textures/babylon.texture.ts
  11. 27 3
      Babylon/Math/babylon.math.js
  12. 2346 2325
      Babylon/Math/babylon.math.ts
  13. 16 0
      Babylon/Mesh/babylon.abstractMesh.js
  14. 16 0
      Babylon/Mesh/babylon.abstractMesh.ts
  15. 3 3
      Babylon/Mesh/babylon.geometry.js
  16. 3 3
      Babylon/Mesh/babylon.geometry.ts
  17. 2 2
      Babylon/Mesh/babylon.mesh.js
  18. 2 2
      Babylon/Mesh/babylon.mesh.ts
  19. 6 1
      Babylon/Mesh/babylon.vertexBuffer.js
  20. 7 1
      Babylon/Mesh/babylon.vertexBuffer.ts
  21. 2 0
      Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPass.js
  22. 2 1
      Babylon/PostProcess/RenderPipeline/babylon.postProcessRenderPass.ts
  23. 2 1
      Babylon/Shaders/brick.fragment.fx
  24. 8 0
      Babylon/Shaders/empty.fragment.fx
  25. 11 24
      Babylon/Shaders/grass.fragment.fx
  26. 104 0
      Babylon/Shaders/marble.fragment.fx
  27. 28 3
      Babylon/babylon.engine.js
  28. 30 3
      Babylon/babylon.engine.ts
  29. 1 0
      Babylon/babylon.mixins.ts
  30. 287 14
      babylon.2.0-alpha.debug.js
  31. 12 12
      babylon.2.0-alpha.js
  32. 87 4
      babylon.2.0.d.ts

+ 13 - 0
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -335,6 +335,11 @@
                 light._excludedMeshesIds = parsedLight.excludedMeshesIds;
             }
 
+            // Parent
+            if (parsedLight.parentId) {
+                light._waitingParentId = parsedLight.parentId;
+            }
+
             if (parsedLight.includedOnlyMeshesIds) {
                 light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
             }
@@ -1196,6 +1201,14 @@
                     }
                 }
 
+                for (index = 0; index < scene.lights.length; index++) {
+                    var light = scene.lights[index];
+                    if (light._waitingParentId) {
+                        light.parent = scene.getLastEntryByID(light._waitingParentId);
+                        light._waitingParentId = undefined;
+                    }
+                }
+
                 for (index = 0; index < scene.meshes.length; index++) {
                     var mesh = scene.meshes[index];
                     if (mesh._waitingParentId) {

+ 13 - 0
Babylon/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -334,6 +334,11 @@
             light._excludedMeshesIds = parsedLight.excludedMeshesIds;
         }
 
+        // Parent
+        if (parsedLight.parentId) {
+            light._waitingParentId = parsedLight.parentId;
+        }
+
         if (parsedLight.includedOnlyMeshesIds) {
             light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
         }
@@ -1213,6 +1218,14 @@
                 }
             }
 
+            for (index = 0; index < scene.lights.length; index++) {
+                var light = scene.lights[index];
+                if (light._waitingParentId) {
+                    light.parent = scene.getLastEntryByID(light._waitingParentId);
+                    light._waitingParentId = undefined;
+                }
+            }
+
             for (index = 0; index < scene.meshes.length; index++) {
                 var mesh = scene.meshes[index];
                 if (mesh._waitingParentId) {

+ 124 - 0
Babylon/Materials/textures/Procedurals/babylon.customProceduralTexture.js

@@ -0,0 +1,124 @@
+var __extends = this.__extends || function (d, b) {
+    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
+    function __() { this.constructor = d; }
+    __.prototype = b.prototype;
+    d.prototype = new __();
+};
+var BABYLON;
+(function (BABYLON) {
+    var CustomProceduralTexture = (function (_super) {
+        __extends(CustomProceduralTexture, _super);
+        function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "empty", scene, fallbackTexture, generateMipMaps);
+            this._generateTime = true;
+            this._time = 0;
+            this._shaderLoaded = false;
+
+            this._texturePath = texturePath;
+
+            //readJson
+            this.loadJson(texturePath);
+
+            // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
+            this.refreshRate = 0;
+        }
+        CustomProceduralTexture.prototype.loadJson = function (jsonUrl) {
+            var _this = this;
+            function noConfigFile() {
+                BABYLON.Tools.Log("No config file found in " + jsonUrl);
+            }
+
+            var that = this;
+            var configFileUrl = jsonUrl + "/config.json";
+
+            var xhr = new XMLHttpRequest();
+
+            xhr.open("GET", configFileUrl, true);
+            xhr.addEventListener("load", function () {
+                if (xhr.status === 200 || BABYLON.Tools.ValidateXHRData(xhr, 1)) {
+                    try  {
+                        that._config = JSON.parse(xhr.response);
+                        that.updateShaderUniforms();
+                        that.setFragment(jsonUrl + "/custom");
+                        that._generateTime = that._config.generateTime;
+                        if (that._generateTime)
+                            _this.refreshRate = 1;
+                        that._shaderLoaded = true;
+                        that.render();
+                    } catch (ex) {
+                        noConfigFile();
+                    }
+                } else {
+                    noConfigFile();
+                }
+            }, false);
+
+            xhr.addEventListener("error", function (event) {
+                noConfigFile();
+            }, false);
+
+            try  {
+                xhr.send();
+            } catch (ex) {
+                BABYLON.Tools.Error("Error on XHR send request.");
+            }
+        };
+
+        CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
+            //if config and shader not loaded, do not render
+            if (!this._shaderLoaded)
+                return;
+
+            if (this._generateTime) {
+                this._time += this.getScene().getAnimationRatio() * 0.03;
+                this.updateShaderUniforms();
+            }
+
+            _super.prototype.render.call(this, useCameraPostProcess);
+        };
+
+        CustomProceduralTexture.prototype.updateShaderUniforms = function () {
+            for (var i = 0; i < this._config.texture2Ds.length; i++) {
+                this.setTexture(this._config.texture2Ds[i].textureName, new BABYLON.Texture(this._texturePath + "/" + this._config.texture2Ds[i].textureRelativeUrl, this.getScene()));
+            }
+
+            for (var j = 0; j < this._config.uniforms.length; j++) {
+                var uniform = this._config.uniforms[j];
+
+                switch (uniform.type) {
+                    case "float":
+                        this.setFloat(uniform.name, uniform.value);
+                        break;
+                    case "color3":
+                        this.setColor3(uniform.name, new BABYLON.Color3(uniform.r, uniform.g, uniform.b));
+                        break;
+                    case "color4":
+                        this.setColor4(uniform.name, new BABYLON.Color4(uniform.r, uniform.g, uniform.b, uniform.a));
+                        break;
+                    case "vector2":
+                        this.setVector2(uniform.name, new BABYLON.Vector2(uniform.x, uniform.y));
+                        break;
+                    case "vector3":
+                        this.setVector3(uniform.name, new BABYLON.Vector3(uniform.x, uniform.y, uniform.z));
+                        break;
+                }
+            }
+        };
+
+        Object.defineProperty(CustomProceduralTexture.prototype, "generateTime", {
+            get: function () {
+                return this.generateTime;
+            },
+            set: function (value) {
+                this.generateTime = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        return CustomProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.CustomProceduralTexture = CustomProceduralTexture;
+})(BABYLON || (BABYLON = {}));
+//# sourceMappingURL=babylon.customProceduralTexture.js.map

+ 122 - 0
Babylon/Materials/textures/Procedurals/babylon.customProceduralTexture.ts

@@ -0,0 +1,122 @@
+module BABYLON {
+    export class CustomProceduralTexture extends ProceduralTexture {
+
+        private _generateTime: boolean = true;
+        private _time: number = 0;
+        private _shaderLoaded: boolean = false;
+        private _config: any;
+        private _texturePath: string;
+
+        constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
+            super(name, size, "empty", scene, fallbackTexture, generateMipMaps);
+
+            this._texturePath = texturePath;
+
+            //readJson
+            this.loadJson(texturePath);
+
+            // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
+            this.refreshRate = 0;
+
+        }
+
+        private loadJson(jsonUrl: string) {
+
+            function noConfigFile() {
+                BABYLON.Tools.Log("No config file found in " + jsonUrl);
+            }
+
+            var that = this;
+            var configFileUrl = jsonUrl + "/config.json";
+
+            var xhr: XMLHttpRequest = new XMLHttpRequest();
+
+            xhr.open("GET", configFileUrl, true);
+            xhr.addEventListener("load", () => {
+                if (xhr.status === 200 || BABYLON.Tools.ValidateXHRData(xhr, 1)) {
+                    try {
+                        that._config = JSON.parse(xhr.response);
+                        that.updateShaderUniforms();
+                        that.setFragment(jsonUrl + "/custom");
+                        that._generateTime = that._config.generateTime;
+                        if (that._generateTime)
+                            this.refreshRate = 1;
+                        that._shaderLoaded = true;
+                        that.render();
+                    }
+                    catch (ex) {
+                        noConfigFile();
+                    }
+                }
+                else {
+                    noConfigFile();
+                }
+            }, false);
+
+            xhr.addEventListener("error", event => {
+                noConfigFile();
+            }, false);
+
+            try {
+                xhr.send();
+            }
+            catch (ex) {
+                BABYLON.Tools.Error("Error on XHR send request.");
+            }
+        }
+
+        public render(useCameraPostProcess?: boolean) {
+
+            //if config and shader not loaded, do not render
+            if (!this._shaderLoaded)
+                return;
+
+
+            if (this._generateTime) {
+                this._time += this.getScene().getAnimationRatio() * 0.03;
+                this.updateShaderUniforms();
+            }
+
+            super.render(useCameraPostProcess);
+        }
+
+        public updateShaderUniforms() {
+
+            for (var i = 0; i < this._config.texture2Ds.length; i++) {
+                this.setTexture(this._config.texture2Ds[i].textureName, new BABYLON.Texture(this._texturePath + "/" + this._config.texture2Ds[i].textureRelativeUrl, this.getScene()));
+            }
+
+            for (var j = 0; j < this._config.uniforms.length; j++) {
+                var uniform = this._config.uniforms[j];
+
+                switch (uniform.type) {
+                    case "float":
+                        this.setFloat(uniform.name, uniform.value);
+                        break;
+                    case "color3":
+                        this.setColor3(uniform.name, new BABYLON.Color3(uniform.r, uniform.g, uniform.b));
+                        break;
+                    case "color4":
+                        this.setColor4(uniform.name, new BABYLON.Color4(uniform.r, uniform.g, uniform.b, uniform.a));
+                        break;
+                    case "vector2":
+                        this.setVector2(uniform.name, new BABYLON.Vector2(uniform.x, uniform.y));
+                        break;
+                    case "vector3":
+                        this.setVector3(uniform.name, new BABYLON.Vector3(uniform.x, uniform.y, uniform.z));
+                        break;
+                }
+            }
+        }
+
+        public get generateTime(): boolean {
+            return this.generateTime;
+        }
+
+        public set generateTime(value: boolean) {
+            this.generateTime = value;
+            this.updateShaderUniforms();
+        }
+
+    }
+}

+ 4 - 0
Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.js

@@ -77,6 +77,10 @@ var BABYLON;
             this._currentRefreshId = -1;
         };
 
+        ProceduralTexture.prototype.setFragment = function (fragment) {
+            this._fragment = fragment;
+        };
+
         Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
             get: function () {
                 return this._refreshRate;

+ 5 - 0
Babylon/Materials/textures/Procedurals/babylon.proceduralTexture.ts

@@ -66,6 +66,7 @@
             this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
         }
 
+      
         public isReady(): boolean {
             var engine = this.getScene().getEngine();
 
@@ -87,6 +88,10 @@
             this._currentRefreshId = -1;
         }
 
+        public setFragment(fragment: any) {
+            this._fragment = fragment;
+        }
+
         public get refreshRate(): number {
             return this._refreshRate;
         }

+ 51 - 0
Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.js

@@ -230,6 +230,7 @@ var BABYLON;
 
             // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
             this.refreshRate = 0;
+            // https://www.shadertoy.com/view/XsjSRt
         }
         CloudProceduralTexture.prototype.updateShaderUniforms = function () {
             this.setColor3("skyColor", this._skyColor);
@@ -350,5 +351,55 @@ var BABYLON;
         return BrickProceduralTexture;
     })(BABYLON.ProceduralTexture);
     BABYLON.BrickProceduralTexture = BrickProceduralTexture;
+
+    var MarbleProceduralTexture = (function (_super) {
+        __extends(MarbleProceduralTexture, _super);
+        function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
+            _super.call(this, name, size, "marble", scene, fallbackTexture, generateMipMaps);
+            this._numberOfBricksHeight = 3;
+            this._numberOfBricksWidth = 3;
+
+            this.updateShaderUniforms();
+
+            // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
+            this.refreshRate = 0;
+        }
+        MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
+            this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
+            this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
+        };
+
+        Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfBricksHeight", {
+            get: function () {
+                return this._numberOfBricksHeight;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(MarbleProceduralTexture.prototype, "cloudColor", {
+            set: function (value) {
+                this._numberOfBricksHeight = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfBricksWidth", {
+            get: function () {
+                return this._numberOfBricksWidth;
+            },
+            set: function (value) {
+                this._numberOfBricksHeight = value;
+                this.updateShaderUniforms();
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        return MarbleProceduralTexture;
+    })(BABYLON.ProceduralTexture);
+    BABYLON.MarbleProceduralTexture = MarbleProceduralTexture;
 })(BABYLON || (BABYLON = {}));
 //# sourceMappingURL=babylon.standardProceduralTexture.js.map

+ 43 - 1
Babylon/Materials/textures/Procedurals/babylon.standardProceduralTexture.ts

@@ -190,7 +190,7 @@
 
             // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
             this.refreshRate = 0;
-
+            // https://www.shadertoy.com/view/XsjSRt
         }
 
         public updateShaderUniforms() {
@@ -294,4 +294,46 @@
         }
     }
 
+
+    export class MarbleProceduralTexture extends ProceduralTexture {
+
+        private _numberOfBricksHeight: number = 3;
+        private _numberOfBricksWidth: number = 3;
+
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
+            super(name, size, "marble", scene, fallbackTexture, generateMipMaps);
+
+            this.updateShaderUniforms();
+
+            // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
+            this.refreshRate = 0;
+
+        }
+
+        public updateShaderUniforms() {
+
+            this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
+            this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
+        }
+
+        public get numberOfBricksHeight(): number {
+            return this._numberOfBricksHeight;
+        }
+
+        public set cloudColor(value: number) {
+            this._numberOfBricksHeight = value;
+            this.updateShaderUniforms();
+        }
+
+        public get numberOfBricksWidth(): number {
+            return this._numberOfBricksWidth;
+        }
+
+        public set numberOfBricksWidth(value: number) {
+            this._numberOfBricksHeight = value;
+            this.updateShaderUniforms();
+        }
+
+    }
+
 }

+ 8 - 0
Babylon/Materials/textures/babylon.texture.js

@@ -190,6 +190,14 @@ var BABYLON;
 
             return newTexture;
         };
+
+        // Statics
+        Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError) {
+            if (typeof samplingMode === "undefined") { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
+            if (typeof onLoad === "undefined") { onLoad = null; }
+            if (typeof onError === "undefined") { onError = null; }
+            return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data);
+        };
         Texture.NEAREST_SAMPLINGMODE = 1;
         Texture.BILINEAR_SAMPLINGMODE = 2;
         Texture.TRILINEAR_SAMPLINGMODE = 3;

+ 5 - 0
Babylon/Materials/textures/babylon.texture.ts

@@ -224,5 +224,10 @@
 
             return newTexture;
         }
+
+        // Statics
+        public static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, onLoad: () => void = null, onError: () => void = null): Texture {
+            return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data);
+        }
     }
 } 

+ 27 - 3
Babylon/Math/babylon.math.js

@@ -2281,9 +2281,11 @@
     BABYLON.Frustum = Frustum;
 
     var Ray = (function () {
-        function Ray(origin, direction) {
+        function Ray(origin, direction, length) {
+            if (typeof length === "undefined") { length = Number.MAX_VALUE; }
             this.origin = origin;
             this.direction = direction;
+            this.length = length;
         }
         // Methods
         Ray.prototype.intersectsBoxMinMax = function (minimum, maximum) {
@@ -2422,7 +2424,13 @@
                 return null;
             }
 
-            return new BABYLON.IntersectionInfo(bu, bv, Vector3.Dot(this._edge2, this._qvec) * invdet);
+            //check if the distance is longer than the predefined length.
+            var distance = Vector3.Dot(this._edge2, this._qvec) * invdet;
+            if (distance > this.length) {
+                return null;
+            }
+
+            return new BABYLON.IntersectionInfo(bu, bv, distance);
         };
 
         // Statics
@@ -2436,11 +2444,27 @@
             return new Ray(start, direction);
         };
 
+        /**
+        * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
+        * transformed to the given world matrix.
+        * @param origin The origin point
+        * @param end The end point
+        * @param world a matrix to transform the ray to. Default is the identity matrix.
+        */
+        Ray.CreateNewFromTo = function (origin, end, world) {
+            if (typeof world === "undefined") { world = BABYLON.Matrix.Identity(); }
+            var direction = end.subtract(origin);
+            var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
+            direction.normalize();
+
+            return Ray.Transform(new Ray(origin, direction, length), world);
+        };
+
         Ray.Transform = function (ray, matrix) {
             var newOrigin = BABYLON.Vector3.TransformCoordinates(ray.origin, matrix);
             var newDirection = BABYLON.Vector3.TransformNormal(ray.direction, matrix);
 
-            return new Ray(newOrigin, newDirection);
+            return new Ray(newOrigin, newDirection, ray.length);
         };
         return Ray;
     })();

File diff suppressed because it is too large
+ 2346 - 2325
Babylon/Math/babylon.math.ts


+ 16 - 0
Babylon/Mesh/babylon.abstractMesh.js

@@ -547,6 +547,22 @@ var BABYLON;
             return this._physicRestitution;
         };
 
+        AbstractMesh.prototype.getPositionInCameraSpace = function (camera) {
+            if (!camera) {
+                camera = this.getScene().activeCamera;
+            }
+
+            return BABYLON.Vector3.TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
+        };
+
+        AbstractMesh.prototype.getDistanceToCamera = function (camera) {
+            if (!camera) {
+                camera = this.getScene().activeCamera;
+            }
+
+            return this.absolutePosition.subtract(camera.position);
+        };
+
         AbstractMesh.prototype.applyImpulse = function (force, contactPoint) {
             if (!this._physicImpostor) {
                 return;

+ 16 - 0
Babylon/Mesh/babylon.abstractMesh.ts

@@ -540,6 +540,22 @@
             return this._physicRestitution;
         }
 
+        public getPositionInCameraSpace(camera?: Camera): Vector3 {
+            if (!camera) {
+                camera = this.getScene().activeCamera;
+            }
+
+            return Vector3.TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
+        }
+
+        public getDistanceToCamera(camera?: Camera): Vector3 {
+            if (!camera) {
+                camera = this.getScene().activeCamera;
+            }
+
+            return this.absolutePosition.subtract(camera.position);
+        }
+
         public applyImpulse(force: Vector3, contactPoint: Vector3): void {
             if (!this._physicImpostor) {
                 return;

+ 3 - 3
Babylon/Mesh/babylon.geometry.js

@@ -45,17 +45,17 @@ var BABYLON;
             vertexData.applyToGeometry(this, updatable);
         };
 
-        Geometry.prototype.setVerticesData = function (kind, data, updatable) {
+        Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
             this._vertexBuffers = this._vertexBuffers || {};
 
             if (this._vertexBuffers[kind]) {
                 this._vertexBuffers[kind].dispose();
             }
 
-            this._vertexBuffers[kind] = new BABYLON.VertexBuffer(this._engine, data, kind, updatable, this._meshes.length === 0);
+            this._vertexBuffers[kind] = new BABYLON.VertexBuffer(this._engine, data, kind, updatable, this._meshes.length === 0, stride);
 
             if (kind === BABYLON.VertexBuffer.PositionKind) {
-                var stride = this._vertexBuffers[kind].getStrideSize();
+                stride = this._vertexBuffers[kind].getStrideSize();
 
                 this._totalVertices = data.length / stride;
 

+ 3 - 3
Babylon/Mesh/babylon.geometry.ts

@@ -54,17 +54,17 @@
             vertexData.applyToGeometry(this, updatable);
         }
 
-        public setVerticesData(kind: string, data: number[], updatable?: boolean): void {
+        public setVerticesData(kind: string, data: number[], updatable?: boolean, stride?: number): void {
             this._vertexBuffers = this._vertexBuffers || {};
 
             if (this._vertexBuffers[kind]) {
                 this._vertexBuffers[kind].dispose();
             }
 
-            this._vertexBuffers[kind] = new VertexBuffer(this._engine, data, kind, updatable, this._meshes.length === 0);
+            this._vertexBuffers[kind] = new VertexBuffer(this._engine, data, kind, updatable, this._meshes.length === 0, stride);
 
             if (kind === BABYLON.VertexBuffer.PositionKind) {
-                var stride = this._vertexBuffers[kind].getStrideSize();
+                stride = this._vertexBuffers[kind].getStrideSize();
 
                 this._totalVertices = data.length / stride;
 

+ 2 - 2
Babylon/Mesh/babylon.mesh.js

@@ -274,7 +274,7 @@ var BABYLON;
             this.synchronizeInstances();
         };
 
-        Mesh.prototype.setVerticesData = function (kind, data, updatable) {
+        Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
             if (kind instanceof Array) {
                 var temp = data;
                 data = kind;
@@ -291,7 +291,7 @@ var BABYLON;
 
                 new BABYLON.Geometry(BABYLON.Geometry.RandomId(), scene, vertexData, updatable, this);
             } else {
-                this._geometry.setVerticesData(kind, data, updatable);
+                this._geometry.setVerticesData(kind, data, updatable, stride);
             }
         };
 

+ 2 - 2
Babylon/Mesh/babylon.mesh.ts

@@ -269,7 +269,7 @@
             this.synchronizeInstances();
         }
 
-        public setVerticesData(kind: any, data: any, updatable?: boolean): void {
+        public setVerticesData(kind: any, data: any, updatable?: boolean, stride?: number): void {
             if (kind instanceof Array) {
                 var temp = data;
                 data = kind;
@@ -287,7 +287,7 @@
                 new BABYLON.Geometry(Geometry.RandomId(), scene, vertexData, updatable, this);
             }
             else {
-                this._geometry.setVerticesData(kind, data, updatable);
+                this._geometry.setVerticesData(kind, data, updatable, stride);
             }
         }
 

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

@@ -1,7 +1,7 @@
 var BABYLON;
 (function (BABYLON) {
     var VertexBuffer = (function () {
-        function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation) {
+        function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride) {
             if (engine instanceof BABYLON.Mesh) {
                 this._engine = engine.getScene().getEngine();
             } else {
@@ -18,6 +18,11 @@
 
             this._kind = kind;
 
+            if (stride) {
+                this._strideSize = stride;
+                return;
+            }
+
             switch (kind) {
                 case VertexBuffer.PositionKind:
                     this._strideSize = 3;

+ 7 - 1
Babylon/Mesh/babylon.vertexBuffer.ts

@@ -8,7 +8,7 @@
         private _kind: string;
         private _strideSize: number;
 
-        constructor(engine: any, data: number[], kind: string, updatable: boolean, postponeInternalCreation?: boolean) {
+        constructor(engine: any, data: number[], kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number) {
             if (engine instanceof Mesh) { // old versions of BABYLON.VertexBuffer accepted 'mesh' instead of 'engine'
                 this._engine = engine.getScene().getEngine();
             }
@@ -26,6 +26,12 @@
 
             this._kind = kind;
 
+            if (stride) {
+                this._strideSize = stride;
+                return;
+            }
+
+            // Deduce stride from kind
             switch (kind) {
                 case VertexBuffer.PositionKind:
                     this._strideSize = 3;

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

@@ -13,6 +13,8 @@
             this._renderTexture.onAfterRender = afterRender;
 
             this._scene = scene;
+
+            this._renderList = renderList;
         }
         // private
         PostProcessRenderPass.prototype._incRefCount = function () {

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

@@ -19,10 +19,11 @@
             this._renderTexture.onAfterRender = afterRender;
 
             this._scene = scene;
+
+            this._renderList = renderList;
         }
 
         // private
-
         public _incRefCount(): number {
             if (this._refCount === 0) {
                 this._scene.customRenderTargets.push(this._renderTexture);

+ 2 - 1
Babylon/Shaders/brick.fragment.fx

@@ -56,6 +56,7 @@ void main(void)
 
 	float nxi = round(xi);
 
+	vec2 brickvUV = vec2((xi - floor(xi)) / brickH, (yi - floor(yi)) /  brickW);
 
 
 	if (yi < nyi + jointHPercentage && yi > nyi - jointHPercentage){
@@ -73,7 +74,7 @@ void main(void)
 			color = mix(color, vec3(0.11, 0.11, 0.11), 0.3);
 
 
-		//color = mix(color, vec3(0.1, 0.1, 0.1), fbm(vUV * 64.0));
+		//color = mix(momo, vec3(0.53, 0.2, 0.0), fbm(brickvUV * 2.0));
 	}
 
 

+ 8 - 0
Babylon/Shaders/empty.fragment.fx

@@ -0,0 +1,8 @@
+#ifdef GL_ES
+precision highp float;
+#endif
+
+void main(void)
+{
+	
+}

+ 11 - 24
Babylon/Shaders/grass.fragment.fx

@@ -5,11 +5,6 @@ precision highp float;
 varying vec2 vPosition;
 varying vec2 vUV;
 
-uniform float ampScale;
-uniform float ringScale;
-uniform vec3 woodColor1;
-uniform vec3 woodColor2;
-
 
 float rand(vec2 n) {
 	return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
@@ -33,25 +28,17 @@ float fbm(vec2 n) {
 
 void main(void) {
 
-	float herbwidth = 8.0;
-
-	vec3 dirt = vec3(0.32, 0.17, 0.09);
-	vec3 herb = vec3(0.0, 0.39, 0.09);
-	vec3 ground = dirt;
-
-	herbwidth = floor(herbwidth - noise(vUV * 8.0 ));
-
-	float ratioy = mod(floor(gl_FragCoord.y), herbwidth);
-	float ratiox = mod(floor(gl_FragCoord.x), herbwidth);
-
-	/*herb = herb * ratiox;
-	dirt = dirt * ratioy;*/
-
-	if (ratioy >= 0.0 && ratioy < herbwidth / fbm(vUV * 2.0))
-		ground = herb;
-
-	if (ratiox >= 0.0 && ratiox < herbwidth / 2.0)
-		ground = herb;
+	vec3 herb1 = vec3(0.29, 0.38, 0.02);
+	vec3 herb2 = vec3(0.36, 0.49, 0.09);
+	vec3 herb3 = vec3(0.51, 0.6, 0.28);
+	vec3 dirt = vec3(0.6, 0.46, 0.13);
+
+	vec3 ground = vec3(1,1,1);
+	
+	ground = mix(ground, herb1, rand(gl_FragCoord.xy * 4.0));
+	ground = mix(ground, herb2, rand(gl_FragCoord.xy * 8.0));
+	ground = mix(ground, herb3, rand(gl_FragCoord.xy));
+	ground = mix(ground, herb1, fbm(gl_FragCoord.xy * 16.0));
 
 	gl_FragColor = vec4(ground, 1.0);
 }

+ 104 - 0
Babylon/Shaders/marble.fragment.fx

@@ -0,0 +1,104 @@
+#ifdef GL_ES
+precision highp float;
+#endif
+
+varying vec2 vPosition;
+varying vec2 vUV;
+
+
+uniform float numberOfBricksHeight;
+uniform float numberOfBricksWidth ;
+
+const vec3 tileSize = vec3(1.1, 1.0, 1.1);
+const vec3 tilePct = vec3(0.98, 1.0, 0.98);
+
+
+float rand(vec2 n) {
+	return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
+}
+
+float noise(vec2 n) {
+	const vec2 d = vec2(0.0, 1.0);
+	vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
+	return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
+}
+
+float turbulence(vec2 P)
+{
+	float val = 0.0;
+	float freq = 1.0;
+	for (int i = 0; i < 4; i++)
+	{
+		val += abs(noise(P*freq) / freq);
+		freq *= 2.07;
+	}
+	return val;
+}
+
+float round(float number){
+	return sign(number)*floor(abs(number) + 0.5);
+}
+
+
+vec3 marble_color(float x)
+{
+	vec3 col;
+	x = 0.5*(x + 1.);
+	x = sqrt(x);             
+	x = sqrt(x);
+	x = sqrt(x);
+	col = vec3(.2 + .75*x);  
+	col.b *= 0.95;           
+	return col;
+}
+void main()
+{
+
+	vec3 brick = vec3(0.77, 0.47, 0.40);
+	vec3 joint = vec3(0.72, 0.72, 0.72);
+
+	float brickW = 1.0 / numberOfBricksWidth;
+	float brickH = 1.0 / numberOfBricksHeight;
+	float jointWPercentage = 0.01;
+	float jointHPercentage = 0.01;
+
+	vec3 color = brick;
+
+
+	float yi = vUV.y / brickH;
+	float nyi = round(yi);
+
+	float xi = vUV.x / brickW;
+
+	if (mod(floor(yi), 2.0) == 0.0){
+		xi = xi - 0.5;
+	}
+
+	float nxi = round(xi);
+
+	vec2 brickvUV = vec2((xi - floor(xi)) / brickH, (yi - floor(yi)) / brickW);
+
+
+	if (yi < nyi + jointHPercentage && yi > nyi - jointHPercentage){
+		color = mix(joint, vec3(0.37, 0.25, 0.25), (yi - nyi) / jointHPercentage + 0.2);
+	}
+	else if (xi < nxi + jointWPercentage && xi > nxi - jointWPercentage){
+		color = mix(joint, vec3(0.44, 0.44, 0.44), (xi - nxi) / jointWPercentage + 0.2);
+	}
+	else {
+
+		float amplitude = 9.0;
+
+		float t = 6.28 * brickvUV.x / (tileSize.x + noise(vec2(vUV)*6.0));
+		t += amplitude * turbulence(brickvUV.xy);
+
+		t = sin(t);
+		color = marble_color(t);
+
+
+	}
+
+	gl_FragColor = vec4(color, 0.0);
+
+	
+}

+ 28 - 3
Babylon/babylon.engine.js

@@ -378,6 +378,7 @@
             this._loadedTexturesCache = new Array();
             this._activeTexturesCache = new Array();
             this._compiledEffects = {};
+            this._uintIndicesCurrentlySet = false;
             this._renderingCanvas = canvas;
             this._canvasClientRect = this._renderingCanvas.getBoundingClientRect();
 
@@ -427,6 +428,7 @@
             this._caps.textureAnisotropicFilterExtension = this._gl.getExtension('EXT_texture_filter_anisotropic') || this._gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') || this._gl.getExtension('MOZ_EXT_texture_filter_anisotropic');
             this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
             this._caps.instancedArrays = this._gl.getExtension('ANGLE_instanced_arrays');
+            this._caps.uintIndices = this._gl.getExtension('OES_element_index_uint') !== null;
 
             // Depth buffer
             this.setDepthBuffer(true);
@@ -730,6 +732,7 @@
         };
 
         Engine.prototype.restoreDefaultFramebuffer = function () {
+            this._currentRenderTarget = null;
             this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, null);
 
             this.setViewport(this._cachedViewport);
@@ -785,9 +788,28 @@
         Engine.prototype.createIndexBuffer = function (indices) {
             var vbo = this._gl.createBuffer();
             this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, vbo);
-            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), this._gl.STATIC_DRAW);
+
+            // Check for 32 bits indices
+            var arrayBuffer;
+            var need32Bits = false;
+
+            if (this._caps.uintIndices) {
+                for (var index = 0; index < indices.length; index++) {
+                    if (indices[index] > 65535) {
+                        need32Bits = true;
+                        break;
+                    }
+                }
+
+                arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
+            } else {
+                arrayBuffer = new Uint16Array(indices);
+            }
+
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.STATIC_DRAW);
             this._resetIndexBufferBinding();
             vbo.references = 1;
+            vbo.is32Bits = need32Bits;
             return vbo;
         };
 
@@ -812,6 +834,7 @@
             if (this._cachedIndexBuffer !== indexBuffer) {
                 this._cachedIndexBuffer = indexBuffer;
                 this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+                this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
             }
         };
 
@@ -840,6 +863,7 @@
             if (indexBuffer != null && this._cachedIndexBuffer !== indexBuffer) {
                 this._cachedIndexBuffer = indexBuffer;
                 this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+                this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
             }
         };
 
@@ -899,12 +923,13 @@
             this.applyStates();
 
             // Render
+            var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
             if (instancesCount) {
-                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2, instancesCount);
+                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2, instancesCount);
                 return;
             }
 
-            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
+            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2);
         };
 
         Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {

+ 30 - 3
Babylon/babylon.engine.ts

@@ -341,6 +341,7 @@
         public textureAnisotropicFilterExtension;
         public maxAnisotropy: number;
         public instancedArrays;
+        public uintIndices: boolean;
     }
 
     export class Engine {
@@ -439,6 +440,7 @@
         private _cachedEffectForVertexBuffers: Effect;
         private _currentRenderTarget: WebGLTexture;
         private _canvasClientRect: ClientRect;
+        private _uintIndicesCurrentlySet = false;
 
         private _workingCanvas: HTMLCanvasElement;
         private _workingContext: CanvasRenderingContext2D;
@@ -495,6 +497,7 @@
             this._caps.textureAnisotropicFilterExtension = this._gl.getExtension('EXT_texture_filter_anisotropic') || this._gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic') || this._gl.getExtension('MOZ_EXT_texture_filter_anisotropic');
             this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
             this._caps.instancedArrays = this._gl.getExtension('ANGLE_instanced_arrays');
+            this._caps.uintIndices = this._gl.getExtension('OES_element_index_uint') !== null;
 
             // Depth buffer
             this.setDepthBuffer(true);
@@ -740,6 +743,7 @@
         }
 
         public restoreDefaultFramebuffer(): void {
+            this._currentRenderTarget = null;
             this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, null);
 
             this.setViewport(this._cachedViewport);
@@ -794,9 +798,29 @@
         public createIndexBuffer(indices: number[]): WebGLBuffer {
             var vbo = this._gl.createBuffer();
             this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, vbo);
-            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), this._gl.STATIC_DRAW);
+
+            // Check for 32 bits indices
+            var arrayBuffer;
+            var need32Bits = false;
+
+            if (this._caps.uintIndices) {
+                
+                for (var index = 0; index < indices.length; index++) {
+                    if (indices[index] > 65535) {
+                        need32Bits = true;
+                        break;
+                    }
+                }
+
+                arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
+            } else {
+                arrayBuffer = new Uint16Array(indices);
+            }
+
+            this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.STATIC_DRAW);
             this._resetIndexBufferBinding();
             vbo.references = 1;
+            vbo.is32Bits = need32Bits;
             return vbo;
         }
 
@@ -821,6 +845,7 @@
             if (this._cachedIndexBuffer !== indexBuffer) {
                 this._cachedIndexBuffer = indexBuffer;
                 this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+                this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
             }
         }
 
@@ -849,6 +874,7 @@
             if (indexBuffer!= null && this._cachedIndexBuffer !== indexBuffer) {
                 this._cachedIndexBuffer = indexBuffer;
                 this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+                this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
             }
         }
 
@@ -909,12 +935,13 @@
             this.applyStates();
 
             // Render
+            var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
             if (instancesCount) {
-                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2, instancesCount);
+                this._caps.instancedArrays.drawElementsInstancedANGLE(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2, instancesCount);
                 return;
             }
 
-            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, this._gl.UNSIGNED_SHORT, indexStart * 2);
+            this._gl.drawElements(useTriangles ? this._gl.TRIANGLES : this._gl.LINES, indexCount, indexFormat, indexStart * 2);
         }
 
         public drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void {

+ 1 - 0
Babylon/babylon.mixins.ts

@@ -67,6 +67,7 @@ interface WebGLTexture {
 interface WebGLBuffer {
     references: number;
     capacity: number;
+    is32Bits: boolean;
 }
 
 interface MouseEvent {

File diff suppressed because it is too large
+ 287 - 14
babylon.2.0-alpha.debug.js


File diff suppressed because it is too large
+ 12 - 12
babylon.2.0-alpha.js


+ 87 - 4
babylon.2.0.d.ts

@@ -41,6 +41,7 @@ declare module BABYLON {
         public textureAnisotropicFilterExtension: any;
         public maxAnisotropy: number;
         public instancedArrays: any;
+        public uintIndices: boolean;
     }
     class Engine {
         private static _ALPHA_DISABLE;
@@ -97,6 +98,7 @@ declare module BABYLON {
         private _cachedEffectForVertexBuffers;
         private _currentRenderTarget;
         private _canvasClientRect;
+        private _uintIndicesCurrentlySet;
         private _workingCanvas;
         private _workingContext;
         constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?: any);
@@ -255,6 +257,7 @@ interface WebGLTexture {
 interface WebGLBuffer {
     references: number;
     capacity: number;
+    is32Bits: boolean;
 }
 interface MouseEvent {
     movementX: number;
@@ -1776,6 +1779,50 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
+    class ProceduralTexture extends Texture {
+        private _size;
+        public _generateMipMaps: boolean;
+        private _doNotChangeAspectRatio;
+        private _currentRefreshId;
+        private _refreshRate;
+        private _vertexBuffer;
+        private _indexBuffer;
+        private _effect;
+        private _vertexDeclaration;
+        private _vertexStrideSize;
+        private _uniforms;
+        private _samplers;
+        private _fragment;
+        private _textures;
+        private _floats;
+        private _floatsArrays;
+        private _colors3;
+        private _colors4;
+        private _vectors2;
+        private _vectors3;
+        private _matrices;
+        constructor(name: string, size: any, fragment: any, scene: Scene, generateMipMaps?: boolean);
+        public isReady(): boolean;
+        public resetRefreshCounter(): void;
+        public refreshRate : number;
+        public _shouldRender(): boolean;
+        public getRenderSize(): number;
+        public resize(size: any, generateMipMaps: any): void;
+        private _checkUniform(uniformName);
+        public setTexture(name: string, texture: Texture): ProceduralTexture;
+        public setFloat(name: string, value: number): ProceduralTexture;
+        public setFloats(name: string, value: number[]): ProceduralTexture;
+        public setColor3(name: string, value: Color3): ProceduralTexture;
+        public setColor4(name: string, value: Color4): ProceduralTexture;
+        public setVector2(name: string, value: Vector2): ProceduralTexture;
+        public setVector3(name: string, value: Vector3): ProceduralTexture;
+        public setMatrix(name: string, value: Matrix): ProceduralTexture;
+        public render(useCameraPostProcess?: boolean): void;
+        public clone(): ProceduralTexture;
+        public dispose(): void;
+    }
+}
+declare module BABYLON {
     class RenderTargetTexture extends Texture {
         public renderList: AbstractMesh[];
         public renderParticles: boolean;
@@ -1852,6 +1899,7 @@ declare module BABYLON {
         public getTextureMatrix(): Matrix;
         public getReflectionTextureMatrix(): Matrix;
         public clone(): Texture;
+        static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void): Texture;
     }
 }
 declare module BABYLON {
@@ -1864,6 +1912,20 @@ declare module BABYLON {
     }
 }
 declare module BABYLON {
+    class CustomProceduralTexture extends ProceduralTexture {
+        private _generateTime;
+        private _time;
+        private _shaderLoaded;
+        private _config;
+        private _texturePath;
+        constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        private loadJson(jsonUrl);
+        public render(useCameraPostProcess?: boolean): void;
+        public updateShaderUniforms(): void;
+        public generateTime : boolean;
+    }
+}
+declare module BABYLON {
     class ProceduralTexture extends Texture {
         private _size;
         public _generateMipMaps: boolean;
@@ -1890,6 +1952,7 @@ declare module BABYLON {
         constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
         public isReady(): boolean;
         public resetRefreshCounter(): void;
+        public setFragment(fragment: any): void;
         public refreshRate : number;
         public _shouldRender(): boolean;
         public getRenderSize(): number;
@@ -1963,6 +2026,15 @@ declare module BABYLON {
         public cloudColor : number;
         public numberOfBricksWidth : number;
     }
+    class MarbleProceduralTexture extends ProceduralTexture {
+        private _numberOfBricksHeight;
+        private _numberOfBricksWidth;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        public updateShaderUniforms(): void;
+        public numberOfBricksHeight : number;
+        public cloudColor : number;
+        public numberOfBricksWidth : number;
+    }
 }
 declare module BABYLON {
     class Color3 {
@@ -2295,17 +2367,26 @@ declare module BABYLON {
     class Ray {
         public origin: Vector3;
         public direction: Vector3;
+        public length: number;
         private _edge1;
         private _edge2;
         private _pvec;
         private _tvec;
         private _qvec;
-        constructor(origin: Vector3, direction: Vector3);
+        constructor(origin: Vector3, direction: Vector3, length?: number);
         public intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
         public intersectsBox(box: BoundingBox): boolean;
         public intersectsSphere(sphere: any): boolean;
         public intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo;
         static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
+        /**
+        * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
+        * transformed to the given world matrix.
+        * @param origin The origin point
+        * @param end The end point
+        * @param world a matrix to transform the ray to. Default is the identity matrix.
+        */
+        static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
         static Transform(ray: Ray, matrix: Matrix): Ray;
     }
     enum Space {
@@ -2424,6 +2505,8 @@ declare module BABYLON {
         public getPhysicsMass(): number;
         public getPhysicsFriction(): number;
         public getPhysicsRestitution(): number;
+        public getPositionInCameraSpace(camera?: Camera): Vector3;
+        public getDistanceToCamera(camera?: Camera): Vector3;
         public applyImpulse(force: Vector3, contactPoint: Vector3): void;
         public setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void;
         public updatePhysicsBodyPosition(): void;
@@ -2487,7 +2570,7 @@ declare module BABYLON {
         public getEngine(): Engine;
         public isReady(): boolean;
         public setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
-        public setVerticesData(kind: string, data: number[], updatable?: boolean): void;
+        public setVerticesData(kind: string, data: number[], updatable?: boolean, stride?: number): void;
         public updateVerticesDataDirectly(kind: string, data: Float32Array): void;
         public updateVerticesData(kind: string, data: number[], updateExtends?: boolean): void;
         public getTotalVertices(): number;
@@ -2702,7 +2785,7 @@ declare module BABYLON {
         public refreshBoundingInfo(): void;
         public _createGlobalSubMesh(): SubMesh;
         public subdivide(count: number): void;
-        public setVerticesData(kind: any, data: any, updatable?: boolean): void;
+        public setVerticesData(kind: any, data: any, updatable?: boolean, stride?: number): void;
         public updateVerticesData(kind: string, data: number[], updateExtends?: boolean, makeItUnique?: boolean): void;
         public updateVerticesDataDirectly(kind: string, data: Float32Array, makeItUnique?: boolean): void;
         public makeGeometryUnique(): void;
@@ -2857,7 +2940,7 @@ declare module BABYLON {
         private _updatable;
         private _kind;
         private _strideSize;
-        constructor(engine: any, data: number[], kind: string, updatable: boolean, postponeInternalCreation?: boolean);
+        constructor(engine: any, data: number[], kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number);
         public isUpdatable(): boolean;
         public getData(): number[];
         public getBuffer(): WebGLBuffer;