Przeglądaj źródła

Merge remote-tracking branch 'upstream/master' into fix.CreateXXX_with_options

jbousquie 10 lat temu
rodzic
commit
7f3fa9b705

+ 2 - 1
Tools/Gulp/config.json

@@ -147,7 +147,8 @@
       "../../src/Rendering/babylon.edgesRenderer.js",
       "../../src/PostProcess/babylon.tonemapPostProcess.js",
 	    "../../src/Tools/babylon.loadingScreen.js",
-      "../../src/Materials/babylon.pbrMaterial.js"
+      "../../src/Materials/babylon.pbrMaterial.js",
+      "../../src/Probes/babylon.reflectionProbe.js"
     ]
   },
   "shadersDirectories": [

Plik diff jest za duży
+ 907 - 852
dist/preview release/babylon.d.ts


Plik diff jest za duży
+ 21 - 22
dist/preview release/babylon.js


Plik diff jest za duży
+ 237 - 79
dist/preview release/babylon.max.js


Plik diff jest za duży
+ 21 - 22
dist/preview release/babylon.noworker.js


+ 8 - 6
dist/preview release/what's new.md

@@ -14,9 +14,11 @@
   - **Breaking changes**
     - `VertexData.CreateCylinder()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
     - `VertexData.CreateRibbon()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
-      - `VertexData.CreateBox()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
-      - `VertexData.CreateSphere)` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
-        - `VertexData.CreateTorus()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
-        - `VertexData.CreateTorusKnot()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
-      - `VertexData.CreatePlane()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
-
+    - `VertexData.CreateBox()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateSphere)` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateTorus()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateTorusKnot()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreatePlane()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateDisc()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateLines()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))
+    - `VertexData.CreateDashedLines()` now supports only the single _options_ parameter ([jerome](https://github.com/jbousquie))

+ 3 - 2
src/Actions/babylon.interpolateValueAction.js

@@ -7,13 +7,14 @@ var BABYLON;
 (function (BABYLON) {
     var InterpolateValueAction = (function (_super) {
         __extends(InterpolateValueAction, _super);
-        function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations) {
+        function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
             if (duration === void 0) { duration = 1000; }
             _super.call(this, triggerOptions, condition);
             this.propertyPath = propertyPath;
             this.value = value;
             this.duration = duration;
             this.stopOtherAnimations = stopOtherAnimations;
+            this.onInterpolationDone = onInterpolationDone;
             this._target = target;
         }
         InterpolateValueAction.prototype._prepare = function () {
@@ -56,7 +57,7 @@ var BABYLON;
             if (this.stopOtherAnimations) {
                 scene.stopAnimation(this._target);
             }
-            scene.beginDirectAnimation(this._target, [animation], 0, 100);
+            scene.beginDirectAnimation(this._target, [animation], 0, 100, false, 1, this.onInterpolationDone);
         };
         return InterpolateValueAction;
     })(BABYLON.Action);

+ 2 - 2
src/Actions/babylon.interpolateValueAction.ts

@@ -3,7 +3,7 @@
         private _target: any;
         private _property: string;
 
-        constructor(triggerOptions: any, target: any, public propertyPath: string, public value: any, public duration: number = 1000, condition?: Condition, public stopOtherAnimations?: boolean) {
+        constructor(triggerOptions: any, target: any, public propertyPath: string, public value: any, public duration: number = 1000, condition?: Condition, public stopOtherAnimations?: boolean, public onInterpolationDone?: () => void) {
             super(triggerOptions, condition);
 
             this._target = target;
@@ -51,7 +51,7 @@
                 scene.stopAnimation(this._target);
             }
 
-            scene.beginDirectAnimation(this._target, [animation], 0, 100);
+            scene.beginDirectAnimation(this._target, [animation], 0, 100, false, 1, this.onInterpolationDone);
         }
     }
 } 

+ 2 - 2
src/Animations/babylon.animation.js

@@ -15,7 +15,7 @@ var BABYLON;
             this.dataType = dataType;
             this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
         }
-        Animation.CreateAndStartAnimation = function (name, mesh, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
+        Animation.CreateAndStartAnimation = function (name, mesh, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
             var dataType = undefined;
             if (!isNaN(parseFloat(from)) && isFinite(from)) {
                 dataType = Animation.ANIMATIONTYPE_FLOAT;
@@ -44,7 +44,7 @@ var BABYLON;
                 animation.setEasingFunction(easingFunction);
             }
             mesh.animations.push(animation);
-            return mesh.getScene().beginAnimation(mesh, 0, totalFrame, (animation.loopMode === 1));
+            return mesh.getScene().beginAnimation(mesh, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
         };
         // Methods   
         Animation.prototype.reset = function () {

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

@@ -14,7 +14,7 @@
 
         public static CreateAndStartAnimation(name: string, mesh: AbstractMesh, targetProperty: string,
             framePerSecond: number, totalFrame: number,
-            from: any, to: any, loopMode?: number, easingFunction?: EasingFunction) {
+            from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void) {
 
             var dataType = undefined;
 
@@ -47,7 +47,7 @@
 
             mesh.animations.push(animation);
 
-            return mesh.getScene().beginAnimation(mesh, 0, totalFrame, (animation.loopMode === 1));
+            return mesh.getScene().beginAnimation(mesh, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
 
         }
 

+ 3 - 0
src/Debug/babylon.debugLayer.js

@@ -248,6 +248,7 @@ var BABYLON;
             BABYLON.StandardMaterial.BumpTextureEnabled = true;
             BABYLON.StandardMaterial.OpacityTextureEnabled = true;
             BABYLON.StandardMaterial.ReflectionTextureEnabled = true;
+            BABYLON.StandardMaterial.LightmapEnabled = true;
             this._scene.shadowsEnabled = true;
             this._scene.particlesEnabled = true;
             this._scene.postProcessesEnabled = true;
@@ -257,6 +258,7 @@ var BABYLON;
             this._scene.lensFlaresEnabled = true;
             this._scene.proceduralTexturesEnabled = true;
             this._scene.renderTargetsEnabled = true;
+            this._scene.probesEnabled = true;
             engine.getRenderingCanvas().removeEventListener("click", this._onCanvasClick);
         };
         DebugLayer.prototype.show = function (showUI, camera) {
@@ -522,6 +524,7 @@ var BABYLON;
                 this._generateCheckBox(this._optionsSubsetDiv, "Lights", this._scene.lightsEnabled, function (element) { _this._scene.lightsEnabled = element.checked; });
                 this._generateCheckBox(this._optionsSubsetDiv, "Particles", this._scene.particlesEnabled, function (element) { _this._scene.particlesEnabled = element.checked; });
                 this._generateCheckBox(this._optionsSubsetDiv, "Post-processes", this._scene.postProcessesEnabled, function (element) { _this._scene.postProcessesEnabled = element.checked; });
+                this._generateCheckBox(this._optionsSubsetDiv, "Probes", this._scene.probesEnabled, function (element) { _this._scene.probesEnabled = element.checked; });
                 this._generateCheckBox(this._optionsSubsetDiv, "Procedural textures", this._scene.proceduralTexturesEnabled, function (element) { _this._scene.proceduralTexturesEnabled = element.checked; });
                 this._generateCheckBox(this._optionsSubsetDiv, "Render targets", this._scene.renderTargetsEnabled, function (element) { _this._scene.renderTargetsEnabled = element.checked; });
                 this._generateCheckBox(this._optionsSubsetDiv, "Shadows", this._scene.shadowsEnabled, function (element) { _this._scene.shadowsEnabled = element.checked; });

+ 3 - 0
src/Debug/babylon.debugLayer.ts

@@ -354,6 +354,7 @@
             StandardMaterial.BumpTextureEnabled = true;
             StandardMaterial.OpacityTextureEnabled = true;
             StandardMaterial.ReflectionTextureEnabled = true;
+            StandardMaterial.LightmapEnabled = true;
 
             this._scene.shadowsEnabled = true;
             this._scene.particlesEnabled = true;
@@ -364,6 +365,7 @@
             this._scene.lensFlaresEnabled = true;
             this._scene.proceduralTexturesEnabled = true;
             this._scene.renderTargetsEnabled = true;
+            this._scene.probesEnabled = true;
 
             engine.getRenderingCanvas().removeEventListener("click", this._onCanvasClick);
         }
@@ -667,6 +669,7 @@
                 this._generateCheckBox(this._optionsSubsetDiv, "Lights", this._scene.lightsEnabled, (element) => { this._scene.lightsEnabled = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Particles", this._scene.particlesEnabled, (element) => { this._scene.particlesEnabled = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Post-processes", this._scene.postProcessesEnabled, (element) => { this._scene.postProcessesEnabled = element.checked });
+                this._generateCheckBox(this._optionsSubsetDiv, "Probes", this._scene.probesEnabled, (element) => { this._scene.probesEnabled = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Procedural textures", this._scene.proceduralTexturesEnabled, (element) => { this._scene.proceduralTexturesEnabled = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Render targets", this._scene.renderTargetsEnabled, (element) => { this._scene.renderTargetsEnabled = element.checked });
                 this._generateCheckBox(this._optionsSubsetDiv, "Shadows", this._scene.shadowsEnabled, (element) => { this._scene.shadowsEnabled = element.checked });

+ 5 - 14
src/Materials/Textures/babylon.baseTexture.js

@@ -89,23 +89,15 @@ var BABYLON;
         };
         BaseTexture.prototype.delayLoad = function () {
         };
+        BaseTexture.prototype.clone = function () {
+            return null;
+        };
         BaseTexture.prototype.releaseInternalTexture = function () {
-            if (!this._texture) {
-                return;
-            }
-            var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
-            this._texture.references--;
-            // Final reference ?
-            if (this._texture.references === 0) {
-                var index = texturesCache.indexOf(this._texture);
-                texturesCache.splice(index, 1);
-                this._scene.getEngine()._releaseTexture(this._texture);
+            if (this._texture) {
+                this._scene.getEngine().releaseInternalTexture(this._texture);
                 delete this._texture;
             }
         };
-        BaseTexture.prototype.clone = function () {
-            return null;
-        };
         BaseTexture.prototype.dispose = function () {
             // Remove from scene
             var index = this._scene.textures.indexOf(this);
@@ -115,7 +107,6 @@ var BABYLON;
             if (this._texture === undefined) {
                 return;
             }
-            this.releaseInternalTexture();
             // Callback
             if (this.onDispose) {
                 this.onDispose();

+ 6 - 20
src/Materials/Textures/babylon.baseTexture.ts

@@ -111,30 +111,19 @@
         }
 
         public delayLoad(): void {
+        }        
+
+        public clone(): BaseTexture {
+            return null;
         }
 
         public releaseInternalTexture(): void {
-            if (!this._texture) {
-                return;
-            }
-            var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
-            this._texture.references--;
-
-            // Final reference ?
-            if (this._texture.references === 0) {
-                var index = texturesCache.indexOf(this._texture);
-                texturesCache.splice(index, 1);
-
-                this._scene.getEngine()._releaseTexture(this._texture);
-
+            if (this._texture) {
+                this._scene.getEngine().releaseInternalTexture(this._texture);
                 delete this._texture;
             }
         }
 
-        public clone(): BaseTexture {
-            return null;
-        }
-
         public dispose(): void {
             // Remove from scene
             var index = this._scene.textures.indexOf(this);
@@ -147,9 +136,6 @@
                 return;
             }
 
-            this.releaseInternalTexture();
-
-
             // Callback
             if (this.onDispose) {
                 this.onDispose();

+ 3 - 0
src/Materials/Textures/babylon.cubeTexture.js

@@ -14,6 +14,9 @@ var BABYLON;
             this.url = rootUrl;
             this._noMipmap = noMipmap;
             this.hasAlpha = false;
+            if (!rootUrl) {
+                return;
+            }
             this._texture = this._getFromCache(rootUrl, noMipmap);
             if (!extensions) {
                 extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];

+ 4 - 0
src/Materials/Textures/babylon.cubeTexture.ts

@@ -15,6 +15,10 @@
             this._noMipmap = noMipmap;
             this.hasAlpha = false;
 
+            if (!rootUrl) {
+                return;
+            }
+
             this._texture = this._getFromCache(rootUrl, noMipmap);
 
             if (!extensions) {

+ 38 - 14
src/Materials/Textures/babylon.renderTargetTexture.js

@@ -7,10 +7,12 @@ var BABYLON;
 (function (BABYLON) {
     var RenderTargetTexture = (function (_super) {
         __extends(RenderTargetTexture, _super);
-        function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type) {
+        function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube) {
             if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
             if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
+            if (isCube === void 0) { isCube = false; }
             _super.call(this, null, scene, !generateMipMaps);
+            this.isCube = isCube;
             this.renderList = new Array();
             this.renderParticles = true;
             this.renderSprites = false;
@@ -22,7 +24,12 @@ var BABYLON;
             this._size = size;
             this._generateMipMaps = generateMipMaps;
             this._doNotChangeAspectRatio = doNotChangeAspectRatio;
-            this._texture = scene.getEngine().createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, type: type });
+            if (isCube) {
+                this._texture = scene.getEngine().createRenderTargetCubeTexture(size);
+            }
+            else {
+                this._texture = scene.getEngine().createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, type: type });
+            }
             // Rendering groups
             this._renderingManager = new BABYLON.RenderingManager(scene);
         }
@@ -75,11 +82,15 @@ var BABYLON;
         };
         RenderTargetTexture.prototype.resize = function (size, generateMipMaps) {
             this.releaseInternalTexture();
-            this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
+            if (this.isCube) {
+                this._texture = this.getScene().getEngine().createRenderTargetCubeTexture(size);
+            }
+            else {
+                this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
+            }
         };
         RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
             var scene = this.getScene();
-            var engine = scene.getEngine();
             if (this._waitingRenderList) {
                 this.renderList = [];
                 for (var index = 0; index < this._waitingRenderList.length; index++) {
@@ -91,10 +102,7 @@ var BABYLON;
             if (this.renderList && this.renderList.length === 0) {
                 return;
             }
-            // Bind
-            if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
-                engine.bindFramebuffer(this._texture);
-            }
+            // Prepare renderingManager
             this._renderingManager.reset();
             var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
             for (var meshIndex = 0; meshIndex < currentRenderList.length; meshIndex++) {
@@ -115,6 +123,25 @@ var BABYLON;
                     }
                 }
             }
+            if (this.isCube) {
+                for (var face = 0; face < 6; face++) {
+                    this.renderToTarget(this._texture._cubeFaces[face], currentRenderList, useCameraPostProcess, dumpForDebug);
+                }
+            }
+            else {
+                this.renderToTarget(this._texture, currentRenderList, useCameraPostProcess, dumpForDebug);
+            }
+            if (this.onAfterUnbind) {
+                this.onAfterUnbind();
+            }
+        };
+        RenderTargetTexture.prototype.renderToTarget = function (targetTexture, currentRenderList, useCameraPostProcess, dumpForDebug) {
+            var scene = this.getScene();
+            var engine = scene.getEngine();
+            // Bind
+            if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(targetTexture)) {
+                engine.bindFramebuffer(targetTexture);
+            }
             if (this.onBeforeRender) {
                 this.onBeforeRender();
             }
@@ -131,7 +158,7 @@ var BABYLON;
             // Render
             this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
             if (useCameraPostProcess) {
-                scene.postProcessManager._finalizeFrame(false, this._texture);
+                scene.postProcessManager._finalizeFrame(false, targetTexture);
             }
             if (!this._doNotChangeAspectRatio) {
                 scene.updateTransformMatrix(true);
@@ -140,14 +167,11 @@ var BABYLON;
                 this.onAfterRender();
             }
             // Dump ?
-            if (dumpForDebug) {
+            if (!this.isCube && dumpForDebug) {
                 BABYLON.Tools.DumpFramebuffer(this._size, this._size, engine);
             }
             // Unbind
-            engine.unBindFramebuffer(this._texture);
-            if (this.onAfterUnbind) {
-                this.onAfterUnbind();
-            }
+            engine.unBindFramebuffer(targetTexture);
         };
         RenderTargetTexture.prototype.clone = function () {
             var textureSize = this.getSize();

+ 39 - 18
src/Materials/Textures/babylon.renderTargetTexture.ts

@@ -19,7 +19,7 @@
         private _currentRefreshId = -1;
         private _refreshRate = 1;
 
-        constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio: boolean = true, type: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
+        constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio: boolean = true, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, public isCube = false) {
             super(null, scene, !generateMipMaps);
 
             this.name = name;
@@ -28,7 +28,11 @@
             this._generateMipMaps = generateMipMaps;
             this._doNotChangeAspectRatio = doNotChangeAspectRatio;
 
-            this._texture = scene.getEngine().createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, type: type });
+            if (isCube) {
+                this._texture = scene.getEngine().createRenderTargetCubeTexture(size);
+            } else {
+                this._texture = scene.getEngine().createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, type: type });
+            }
 
             // Rendering groups
             this._renderingManager = new RenderingManager(scene);
@@ -84,14 +88,17 @@
             this.resize(newSize, this._generateMipMaps);
         }
 
-        public resize(size:any, generateMipMaps?: boolean) {
+        public resize(size: any, generateMipMaps?: boolean) {
             this.releaseInternalTexture();
-            this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
+            if (this.isCube) {
+                this._texture = this.getScene().getEngine().createRenderTargetCubeTexture(size);
+            } else {
+                this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
+            }
         }
 
         public render(useCameraPostProcess?: boolean, dumpForDebug?: boolean) {
             var scene = this.getScene();
-            var engine = scene.getEngine();
 
             if (this._waitingRenderList) {
                 this.renderList = [];
@@ -107,11 +114,7 @@
                 return;
             }
 
-            // Bind
-            if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
-                engine.bindFramebuffer(this._texture);
-            }
-
+            // Prepare renderingManager
             this._renderingManager.reset();
 
             var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
@@ -135,7 +138,29 @@
                             this._renderingManager.dispatch(subMesh);
                         }
                     }
-                }                
+                }
+            }
+            
+            if (this.isCube) {
+                for (var face = 0; face < 6; face++) {
+                    this.renderToTarget(this._texture._cubeFaces[face], currentRenderList, useCameraPostProcess, dumpForDebug);
+                }
+            } else {
+                this.renderToTarget(this._texture, currentRenderList, useCameraPostProcess, dumpForDebug);
+            }
+
+            if (this.onAfterUnbind) {
+                this.onAfterUnbind();
+            }
+        }
+
+        renderToTarget(targetTexture: WebGLTexture, currentRenderList: AbstractMesh[], useCameraPostProcess: boolean, dumpForDebug: boolean): void {
+            var scene = this.getScene();
+            var engine = scene.getEngine();
+
+            // Bind
+            if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(targetTexture)) {
+                engine.bindFramebuffer(targetTexture);
             }
 
             if (this.onBeforeRender) {
@@ -157,7 +182,7 @@
             this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
 
             if (useCameraPostProcess) {
-                scene.postProcessManager._finalizeFrame(false, this._texture);
+                scene.postProcessManager._finalizeFrame(false, targetTexture);
             }
 
             if (!this._doNotChangeAspectRatio) {
@@ -169,16 +194,12 @@
             }
 
             // Dump ?
-            if (dumpForDebug) {
+            if (!this.isCube && dumpForDebug) {
                 Tools.DumpFramebuffer(this._size, this._size, engine);
             }
 
             // Unbind
-            engine.unBindFramebuffer(this._texture);
-
-            if (this.onAfterUnbind) {
-                this.onAfterUnbind();
-            }
+            engine.unBindFramebuffer(targetTexture);
         }
 
         public clone(): RenderTargetTexture {

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

@@ -341,7 +341,8 @@ var BABYLON;
             }
             var updatable = false;
             var stopChecking = false;
-            for (var kind in this._vertexBuffers) {
+            var kind;
+            for (kind in this._vertexBuffers) {
                 // using slice() to make a copy of the array and not just reference it
                 vertexData.set(this.getVerticesData(kind).slice(0), kind);
                 if (!stopChecking) {

+ 3 - 2
src/Mesh/babylon.geometry.ts

@@ -431,8 +431,8 @@
 
             var updatable = false;
             var stopChecking = false;
-
-            for (var kind in this._vertexBuffers) {
+            var kind;
+            for (kind in this._vertexBuffers) {
                 // using slice() to make a copy of the array and not just reference it
                 vertexData.set(this.getVerticesData(kind).slice(0), kind);
 
@@ -794,3 +794,4 @@
         }
     }
 }
+

+ 2 - 1
src/Mesh/babylon.mesh.js

@@ -1067,6 +1067,7 @@ var BABYLON;
             if (sideOrientation === void 0) { sideOrientation = Mesh.DEFAULTSIDE; }
             if (instance === void 0) { instance = null; }
             var pathArray;
+            var closeArray;
             if (closeArrayOrScene instanceof BABYLON.Scene) {
                 scene = closeArrayOrScene;
                 updatable = options.updatable;
@@ -1074,7 +1075,7 @@ var BABYLON;
                     pathArray = options.pathArray;
                     instance = options.instance;
                     closePath = options.closePath;
-                    var closeArray = options.closeArray;
+                    closeArray = options.closeArray;
                 }
             }
             else {

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

@@ -1250,6 +1250,7 @@
         public static CreateRibbon(name: string, options: { pathArray?: Vector3[][], closeArray?: boolean, closePath?: boolean, offset?: number, updatable?: boolean, sideOrientation?: number, instance?: Mesh }, scene: Scene): Mesh;
         public static CreateRibbon(name: string, options: any, closeArrayOrScene: any, closePath?: boolean, offset?: number, scene?: Scene, updatable?: boolean, sideOrientation: number = Mesh.DEFAULTSIDE, instance: Mesh = null): Mesh {
             var pathArray;
+            var closeArray;
             if (closeArrayOrScene instanceof Scene) {
                 scene = closeArrayOrScene;
                 updatable = options.updatable;
@@ -1257,7 +1258,7 @@
                     pathArray = options.pathArray;
                     instance = options.instance;
                     closePath = options.closePath;
-                    var closeArray = options.closeArray;
+                    closeArray = options.closeArray;
                 }
             } else {
                 pathArray = options;
@@ -1547,7 +1548,7 @@
         // Dashed Lines
         public static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh;
         public static CreateDashedLines(name: string, options: { points: Vector3[], dashSize?: number, gapSize?: number, dashNb?: number, updatable?: boolean, instance?: LinesMesh }, scene: Scene): LinesMesh;
-        public static CreateDashedLines(name: string, options: any, dashSizeOrScene: any, gapSize?: number, dashNb?: number, scene?: Scene, updatable?: boolean, instance?: LinesMesh):LinesMesh {
+        public static CreateDashedLines(name: string, options: any, dashSizeOrScene: any, gapSize?: number, dashNb?: number, scene?: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh {
             var points: Vector3[];
             var dashSize: number;
             if (Array.isArray(options)) {
@@ -1559,7 +1560,7 @@
                         dashSize: dashSize,
                         gapSize: gapSize,
                         dashNb: dashNb
-                    }    
+                    }
                 }
             } else {
                 scene = dashSizeOrScene,
@@ -2341,3 +2342,4 @@
 
 
 
+

+ 2 - 1
src/Mesh/babylon.mesh.vertexData.ts

@@ -937,7 +937,7 @@
             return vertexData;
         }
 
-        public static CreateLines(options: { points: Vector3[]}): VertexData {
+        public static CreateLines(options: { points: Vector3[] }): VertexData {
             var indices = [];
             var positions = [];
             var points = options.points;
@@ -1499,3 +1499,4 @@
 
 
 
+

+ 21 - 0
src/Probes/babylon.reflectionProbe.js

@@ -0,0 +1,21 @@
+var BABYLON;
+(function (BABYLON) {
+    var ReflectionProbe = (function () {
+        function ReflectionProbe(size, scene) {
+            this._scene = scene;
+            this._scene.reflectionProbes.push(this);
+        }
+        ReflectionProbe.prototype.getScene = function () {
+            return this._scene;
+        };
+        ReflectionProbe.prototype.dispose = function () {
+            var index = this._scene.reflectionProbes.indexOf(this);
+            if (index !== -1) {
+                // Remove from the scene if found 
+                this._scene.reflectionProbes.splice(index, 1);
+            }
+        };
+        return ReflectionProbe;
+    })();
+    BABYLON.ReflectionProbe = ReflectionProbe;
+})(BABYLON || (BABYLON = {}));

+ 24 - 0
src/Probes/babylon.reflectionProbe.ts

@@ -0,0 +1,24 @@
+module BABYLON {
+    export class ReflectionProbe{  
+        private _scene: Scene;
+          
+        constructor(size: number, scene: Scene) {
+            this._scene = scene;
+
+            this._scene.reflectionProbes.push(this);
+        }
+
+        public getScene(): Scene {
+            return this._scene;
+        }
+        
+        public dispose() {
+            var index = this._scene.reflectionProbes.indexOf(this);
+
+            if (index !== -1) {
+                // Remove from the scene if found 
+                this._scene.reflectionProbes.splice(index, 1);
+            }            
+        }
+    }    
+}

+ 2 - 2
src/Tools/babylon.tools.dds.js

@@ -139,13 +139,13 @@ var BABYLON;
                 }
                 var bpp = header[off_RGBbpp];
                 for (var face = 0; face < faces; face++) {
-                    var sampler = faces == 1 ? gl.TEXTURE_2D : (gl.TEXTURE_CUBE_MAP_POSITIVE_X + face);
+                    var sampler = faces === 1 ? gl.TEXTURE_2D : (gl.TEXTURE_CUBE_MAP_POSITIVE_X + face);
                     width = header[off_width];
                     height = header[off_height];
                     dataOffset = header[off_size] + 4;
                     for (i = 0; i < mipmapCount; ++i) {
                         if (info.isRGB) {
-                            if (bpp == 24) {
+                            if (bpp === 24) {
                                 dataLength = width * height * 3;
                                 byteArray = DDSTools.GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
                                 gl.texImage2D(sampler, i, gl.RGB, width, height, 0, gl.RGB, gl.UNSIGNED_BYTE, byteArray);

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

@@ -200,7 +200,7 @@
             var bpp = header[off_RGBbpp];
 
             for (var face = 0; face < faces; face++) {
-                var sampler = faces == 1 ? gl.TEXTURE_2D : (gl.TEXTURE_CUBE_MAP_POSITIVE_X + face);
+                var sampler = faces === 1 ? gl.TEXTURE_2D : (gl.TEXTURE_CUBE_MAP_POSITIVE_X + face);
 
                 width = header[off_width];
                 height = header[off_height];
@@ -208,7 +208,7 @@
 
                 for (i = 0; i < mipmapCount; ++i) {
                     if (info.isRGB) {
-                        if (bpp == 24) {
+                        if (bpp === 24) {
                             dataLength = width * height * 3;
                             byteArray = DDSTools.GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
                             gl.texImage2D(sampler, i, gl.RGB, width, height, 0, gl.RGB, gl.UNSIGNED_BYTE, byteArray);

+ 50 - 6
src/babylon.engine.js

@@ -1556,7 +1556,7 @@ var BABYLON;
                 texture._isDisabled = true;
             }
         };
-        Engine.prototype.createRenderTargetTexture = function (size, options) {
+        Engine.prototype.createRenderTargetTexture = function (size, options, face) {
             // old version had a "generateMipMaps" arg instead of options.
             // if options.generateMipMaps is undefined, consider that options itself if the generateMipmaps value
             // in the same way, generateDepthBuffer is defaulted to true
@@ -1586,11 +1586,14 @@ var BABYLON;
                 type = Engine.TEXTURETYPE_UNSIGNED_INT;
                 BABYLON.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
             }
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-            gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, getWebGLTextureType(gl, type), null);
+            if (face === undefined) {
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+            }
+            var target = face === undefined ? gl.TEXTURE_2D : (gl.TEXTURE_CUBE_MAP_POSITIVE_X + face);
+            gl.texImage2D(target, 0, gl.RGBA, width, height, 0, gl.RGBA, getWebGLTextureType(gl, type), null);
             var depthBuffer;
             // Create the depth buffer
             if (generateDepthBuffer) {
@@ -1626,6 +1629,28 @@ var BABYLON;
             this._loadedTexturesCache.push(texture);
             return texture;
         };
+        Engine.prototype.createRenderTargetCubeTexture = function (size) {
+            var gl = this._gl;
+            var texture = gl.createTexture();
+            texture.isCube = true;
+            texture.references = 1;
+            this._loadedTexturesCache.push(texture);
+            gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
+            gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
+            for (var face = 0; face < 6; face++) {
+                texture._cubeFaces[face] = this.createRenderTargetTexture(size, {}, face);
+            }
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+            gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
+            this._activeTexturesCache = [];
+            texture._width = size;
+            texture._height = size;
+            texture.isReady = true;
+            return texture;
+        };
         Engine.prototype.createCubeTexture = function (rootUrl, scene, extensions, noMipmap) {
             var _this = this;
             var gl = this._gl;
@@ -1818,6 +1843,25 @@ var BABYLON;
             this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
             return data;
         };
+        Engine.prototype.releaseInternalTexture = function (texture) {
+            if (!texture) {
+                return;
+            }
+            var index;
+            if (texture._cubeFaces) {
+                for (index = 0; index < 6; index++) {
+                    this.releaseInternalTexture(texture._cubeFaces[index]);
+                }
+            }
+            var texturesCache = this.getLoadedTexturesCache();
+            texture.references--;
+            // Final reference ?
+            if (texture.references === 0) {
+                index = texturesCache.indexOf(texture);
+                texturesCache.splice(index, 1);
+                this._releaseTexture(texture);
+            }
+        };
         // Dispose
         Engine.prototype.dispose = function () {
             this.hideLoadingUI();

+ 77 - 15
src/babylon.engine.ts

@@ -200,7 +200,7 @@
                 this._blendFunctionParameters[1] === value1 &&
                 this._blendFunctionParameters[2] === value2 &&
                 this._blendFunctionParameters[3] === value3
-                ) {
+            ) {
                 return;
             }
 
@@ -679,7 +679,7 @@
                     document.webkitPointerLockElement === canvas ||
                     document.msPointerLockElement === canvas ||
                     document.pointerLockElement === canvas
-                    );
+                );
             };
 
             document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
@@ -691,8 +691,8 @@
                 Engine.audioEngine = new AudioEngine();
             }
 			
-			//default loading screen
-			this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas);
+            //default loading screen
+            this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas);
 
             Tools.Log("Babylon.js engine (v" + Engine.Version + ") launched");
         }
@@ -962,14 +962,14 @@
         }
 
         public unBindFramebuffer(texture: WebGLTexture): void {
-            this._currentRenderTarget = null;           
+            this._currentRenderTarget = null;
             if (texture.generateMipMaps) {
                 var gl = this._gl;
                 gl.bindTexture(gl.TEXTURE_2D, texture);
                 gl.generateMipmap(gl.TEXTURE_2D);
                 gl.bindTexture(gl.TEXTURE_2D, null);
             }
-            
+
             this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, null);
         }
 
@@ -1843,7 +1843,7 @@
             }
         }
 
-        public createRenderTargetTexture(size: any, options): WebGLTexture {
+        public createRenderTargetTexture(size: any, options, face?: number): WebGLTexture {
             // old version had a "generateMipMaps" arg instead of options.
             // if options.generateMipMaps is undefined, consider that options itself if the generateMipmaps value
             // in the same way, generateDepthBuffer is defaulted to true
@@ -1878,11 +1878,17 @@
                 Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
             }
 
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-            gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, getWebGLTextureType(gl, type), null);
+
+            if (face === undefined) {
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+                gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+            }
+
+            var target = face === undefined ? gl.TEXTURE_2D : (gl.TEXTURE_CUBE_MAP_POSITIVE_X + face);
+
+            gl.texImage2D(target, 0, gl.RGBA, width, height, 0, gl.RGBA, getWebGLTextureType(gl, type), null);
 
             var depthBuffer: WebGLRenderbuffer;
             // Create the depth buffer
@@ -1925,6 +1931,37 @@
             return texture;
         }
 
+        public createRenderTargetCubeTexture(size: number): WebGLTexture {
+            var gl = this._gl;
+
+            var texture = gl.createTexture();
+            texture.isCube = true;
+            texture.references = 1;
+            this._loadedTexturesCache.push(texture);
+
+            gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
+            gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
+
+            for (var face = 0; face < 6; face++) {
+                texture._cubeFaces[face] = this.createRenderTargetTexture(size, {}, face);
+            }
+
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+            gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+
+            gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
+
+            this._activeTexturesCache = [];
+
+            texture._width = size;
+            texture._height = size;
+            texture.isReady = true;
+
+            return texture;
+        }
+
         public createCubeTexture(rootUrl: string, scene: Scene, extensions: string[], noMipmap?: boolean): WebGLTexture {
             var gl = this._gl;
 
@@ -2161,6 +2198,31 @@
             return data;
         }
 
+        public releaseInternalTexture(texture: WebGLTexture): void {
+            if (!texture) {
+                return;
+            }
+
+            var index;
+
+            if (texture._cubeFaces) {
+                for (index = 0; index < 6; index++) {
+                    this.releaseInternalTexture(texture._cubeFaces[index]);
+                }
+            }
+
+            var texturesCache = this.getLoadedTexturesCache();
+            texture.references--;
+
+            // Final reference ?
+            if (texture.references === 0) {
+                index = texturesCache.indexOf(texture);
+                texturesCache.splice(index, 1);
+
+                this._releaseTexture(texture);
+            }
+        }
+
         // Dispose
         public dispose(): void {
             this.hideLoadingUI();
@@ -2212,15 +2274,15 @@
         public hideLoadingUI(): void {
             this._loadingScreen.hideLoadingUI();
         }
-		
-		public get loadingScreen(): ILoadingScreen {
+
+        public get loadingScreen(): ILoadingScreen {
             return this._loadingScreen;
         }
 
         public set loadingScreen(loadingScreen: ILoadingScreen) {
             this._loadingScreen = loadingScreen;
         }
-        
+
         public set loadingUIText(text: string) {
             this._loadingScreen.loadingUIText = text;
         }

+ 1 - 0
src/babylon.mixins.ts

@@ -72,6 +72,7 @@ interface WebGLTexture {
     _cachedWrapU: number;
     _cachedWrapV: number;
     _isDisabled: boolean;
+    _cubeFaces: WebGLTexture[];
 }
 
 interface WebGLBuffer {

+ 4 - 3
src/babylon.scene.js

@@ -95,6 +95,9 @@ var BABYLON;
             this.customRenderTargets = new Array();
             // Imported meshes
             this.importedMeshesFiles = new Array();
+            // Probes
+            this.probesEnabled = true;
+            this.reflectionProbes = new Array();
             this._actionManagers = new Array();
             this._meshesForIntersections = new BABYLON.SmartArray(256);
             // Procedural textures
@@ -509,9 +512,7 @@ var BABYLON;
          * @see http://doc.babylonjs.com/page.php?p=22081
          */
         Scene.prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable) {
-            if (speedRatio === undefined) {
-                speedRatio = 1.0;
-            }
+            if (speedRatio === void 0) { speedRatio = 1.0; }
             this.stopAnimation(target);
             if (!animatable) {
                 animatable = new BABYLON.Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd);

+ 5 - 4
src/babylon.scene.ts

@@ -183,6 +183,10 @@
         // Imported meshes
         public importedMeshesFiles = new Array<String>();
 
+        // Probes
+        public probesEnabled = true;
+        public reflectionProbes = new Array<ReflectionProbe>();
+
         // Database
         public database; //ANY
 
@@ -690,10 +694,7 @@
          * @see BABYLON.Animatable
          * @see http://doc.babylonjs.com/page.php?p=22081
          */
-        public beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable {
-            if (speedRatio === undefined) {
-                speedRatio = 1.0;
-            }
+        public beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio: number = 1.0, onAnimationEnd?: () => void, animatable?: Animatable): Animatable {
 
             this.stopAnimation(target);