David Catuhe 6 years ago
parent
commit
affaa71c0a

File diff suppressed because it is too large
+ 10522 - 10487
Playground/babylon.d.txt


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


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


+ 132 - 9
dist/preview release/babylon.max.js

@@ -30512,6 +30512,7 @@ var BABYLON;
             _this["layers"] = [];
             _this["lensFlareSystems"] = [];
             _this["proceduralTextures"] = [];
+            _this["reflectionProbes"] = [];
             return _this;
         }
         /**
@@ -30558,6 +30559,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 _this.scene.addTexture(o);
             });
+            this.reflectionProbes.forEach(function (o) {
+                _this.scene.addReflectionProbe(o);
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.addFromContainer(this);
@@ -30607,6 +30611,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 _this.scene.removeTexture(o);
             });
+            this.reflectionProbes.forEach(function (o) {
+                _this.scene.removeReflectionProbe(o);
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.removeFromContainer(this);
@@ -30649,6 +30656,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 o.dispose();
             });
+            this.reflectionProbes.forEach(function (o) {
+                o.dispose();
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.dispose();
@@ -32722,7 +32732,7 @@ var BABYLON;
                 }
                 return parsedCustomTexture;
             }
-            if (parsedTexture.isCube) {
+            if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
                 return BABYLON.CubeTexture.Parse(parsedTexture, scene, rootUrl);
             }
             if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
@@ -32740,8 +32750,22 @@ var BABYLON;
                     return mirrorTexture;
                 }
                 else if (parsedTexture.isRenderTarget) {
-                    var renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
-                    renderTargetTexture._waitingRenderList = parsedTexture.renderList;
+                    var renderTargetTexture = null;
+                    if (parsedTexture.isCube) {
+                        // Search for an existing reflection probe (which contains a cube render target texture)
+                        if (scene.reflectionProbes) {
+                            for (var index = 0; index < scene.reflectionProbes.length; index++) {
+                                var probe = scene.reflectionProbes[index];
+                                if (probe.name === parsedTexture.name) {
+                                    return probe.cubeTexture;
+                                }
+                            }
+                        }
+                    }
+                    else {
+                        renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
+                        renderTargetTexture._waitingRenderList = parsedTexture.renderList;
+                    }
                     return renderTargetTexture;
                 }
                 else {
@@ -32762,12 +32786,12 @@ var BABYLON;
             // Update Sampling Mode
             if (parsedTexture.samplingMode) {
                 var sampling = parsedTexture.samplingMode;
-                if (texture._samplingMode !== sampling) {
+                if (texture && texture._samplingMode !== sampling) {
                     texture.updateSamplingMode(sampling);
                 }
             }
             // Animations
-            if (parsedTexture.animations) {
+            if (texture && parsedTexture.animations) {
                 for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
                     var parsedAnimation = parsedTexture.animations[animationIndex];
                     texture.animations.push(BABYLON.Animation.Parse(parsedAnimation));
@@ -79177,6 +79201,18 @@ var BABYLON;
                     }
                 }
             }
+            // Reflection probes
+            if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
+                for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
+                    var parsedReflectionProbe = parsedData.reflectionProbes[index];
+                    var reflectionProbe = BABYLON.ReflectionProbe.Parse(parsedReflectionProbe, scene, rootUrl);
+                    if (reflectionProbe) {
+                        container.reflectionProbes.push(reflectionProbe);
+                        log += (index === 0 ? "\n\tReflection Probes:" : "");
+                        log += "\n\t\t" + reflectionProbe.toString(fullDetails);
+                    }
+                }
+            }
             // Animations
             if (parsedData.animations !== undefined && parsedData.animations !== null) {
                 for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
@@ -115338,6 +115374,14 @@ var BABYLON;
             }
             // Animations
             BABYLON.Animation.AppendSerializedAnimations(scene, serializationObject);
+            // Reflection probes
+            if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
+                serializationObject.reflectionProbes = [];
+                for (index = 0; index < scene.reflectionProbes.length; index++) {
+                    var reflectionProbe = scene.reflectionProbes[index];
+                    serializationObject.reflectionProbes.push(reflectionProbe.serialize());
+                }
+            }
             // Materials
             serializationObject.materials = [];
             serializationObject.multiMaterials = [];
@@ -115459,8 +115503,25 @@ var BABYLON;
 
 //# sourceMappingURL=babylon.sceneSerializer.js.map
 
+
 var BABYLON;
 (function (BABYLON) {
+    BABYLON.AbstractScene.prototype.removeReflectionProbe = function (toRemove) {
+        if (!this.reflectionProbes) {
+            return -1;
+        }
+        var index = this.reflectionProbes.indexOf(toRemove);
+        if (index !== -1) {
+            this.reflectionProbes.splice(index, 1);
+        }
+        return index;
+    };
+    BABYLON.AbstractScene.prototype.addReflectionProbe = function (newReflectionProbe) {
+        if (!this.reflectionProbes) {
+            this.reflectionProbes = [];
+        }
+        this.reflectionProbes.push(newReflectionProbe);
+    };
     /**
      * Class used to generate realtime reflection / refraction cube textures
      * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
@@ -115520,16 +115581,16 @@ var BABYLON;
                 }
                 _this.position.addToRef(_this._add, _this._target);
                 BABYLON.Matrix.LookAtLHToRef(_this.position, _this._target, BABYLON.Vector3.Up(), _this._viewMatrix);
-                scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
+                if (scene.activeCamera) {
+                    _this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
+                    scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
+                }
                 scene._forcedViewPosition = _this.position;
             });
             this._renderTargetTexture.onAfterUnbindObservable.add(function () {
                 scene._forcedViewPosition = null;
                 scene.updateTransformMatrix(true);
             });
-            if (scene.activeCamera) {
-                this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
-            }
         }
         Object.defineProperty(ReflectionProbe.prototype, "samples", {
             /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
@@ -115605,6 +115666,68 @@ var BABYLON;
                 this._renderTargetTexture = null;
             }
         };
+        /**
+         * Converts the reflection probe information to a readable string for debug purpose.
+         * @param fullDetails Supports for multiple levels of logging within scene loading
+         * @returns the human readable reflection probe info
+         */
+        ReflectionProbe.prototype.toString = function (fullDetails) {
+            var ret = "Name: " + this.name;
+            if (fullDetails) {
+                ret += ", position: " + this.position.toString();
+                if (this._attachedMesh) {
+                    ret += ", attached mesh: " + this._attachedMesh.name;
+                }
+            }
+            return ret;
+        };
+        /**
+         * Get the class name of the relfection probe.
+         * @returns "ReflectionProbe"
+         */
+        ReflectionProbe.prototype.getClassName = function () {
+            return "ReflectionProbe";
+        };
+        /**
+         * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
+         * @returns The JSON representation of the texture
+         */
+        ReflectionProbe.prototype.serialize = function () {
+            var serializationObject = BABYLON.SerializationHelper.Serialize(this, this._renderTargetTexture.serialize());
+            serializationObject.isReflectionProbe = true;
+            return serializationObject;
+        };
+        /**
+         * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
+         * @param parsedReflectionProbe Define the JSON representation of the reflection probe
+         * @param scene Define the scene the parsed reflection probe should be instantiated in
+         * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
+         * @returns The parsed reflection probe if successful
+         */
+        ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
+            var reflectionProbe = null;
+            if (scene.reflectionProbes) {
+                for (var index = 0; index < scene.reflectionProbes.length; index++) {
+                    var rp = scene.reflectionProbes[index];
+                    if (rp.name === parsedReflectionProbe.name) {
+                        reflectionProbe = rp;
+                        break;
+                    }
+                }
+            }
+            reflectionProbe = BABYLON.SerializationHelper.Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
+            reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
+            if (parsedReflectionProbe._attachedMesh) {
+                reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
+            }
+            return reflectionProbe;
+        };
+        __decorate([
+            BABYLON.serializeAsMeshReference()
+        ], ReflectionProbe.prototype, "_attachedMesh", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], ReflectionProbe.prototype, "position", void 0);
         return ReflectionProbe;
     }());
     BABYLON.ReflectionProbe = ReflectionProbe;

+ 132 - 9
dist/preview release/babylon.no-module.max.js

@@ -30479,6 +30479,7 @@ var BABYLON;
             _this["layers"] = [];
             _this["lensFlareSystems"] = [];
             _this["proceduralTextures"] = [];
+            _this["reflectionProbes"] = [];
             return _this;
         }
         /**
@@ -30525,6 +30526,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 _this.scene.addTexture(o);
             });
+            this.reflectionProbes.forEach(function (o) {
+                _this.scene.addReflectionProbe(o);
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.addFromContainer(this);
@@ -30574,6 +30578,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 _this.scene.removeTexture(o);
             });
+            this.reflectionProbes.forEach(function (o) {
+                _this.scene.removeReflectionProbe(o);
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.removeFromContainer(this);
@@ -30616,6 +30623,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 o.dispose();
             });
+            this.reflectionProbes.forEach(function (o) {
+                o.dispose();
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.dispose();
@@ -32689,7 +32699,7 @@ var BABYLON;
                 }
                 return parsedCustomTexture;
             }
-            if (parsedTexture.isCube) {
+            if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
                 return BABYLON.CubeTexture.Parse(parsedTexture, scene, rootUrl);
             }
             if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
@@ -32707,8 +32717,22 @@ var BABYLON;
                     return mirrorTexture;
                 }
                 else if (parsedTexture.isRenderTarget) {
-                    var renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
-                    renderTargetTexture._waitingRenderList = parsedTexture.renderList;
+                    var renderTargetTexture = null;
+                    if (parsedTexture.isCube) {
+                        // Search for an existing reflection probe (which contains a cube render target texture)
+                        if (scene.reflectionProbes) {
+                            for (var index = 0; index < scene.reflectionProbes.length; index++) {
+                                var probe = scene.reflectionProbes[index];
+                                if (probe.name === parsedTexture.name) {
+                                    return probe.cubeTexture;
+                                }
+                            }
+                        }
+                    }
+                    else {
+                        renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
+                        renderTargetTexture._waitingRenderList = parsedTexture.renderList;
+                    }
                     return renderTargetTexture;
                 }
                 else {
@@ -32729,12 +32753,12 @@ var BABYLON;
             // Update Sampling Mode
             if (parsedTexture.samplingMode) {
                 var sampling = parsedTexture.samplingMode;
-                if (texture._samplingMode !== sampling) {
+                if (texture && texture._samplingMode !== sampling) {
                     texture.updateSamplingMode(sampling);
                 }
             }
             // Animations
-            if (parsedTexture.animations) {
+            if (texture && parsedTexture.animations) {
                 for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
                     var parsedAnimation = parsedTexture.animations[animationIndex];
                     texture.animations.push(BABYLON.Animation.Parse(parsedAnimation));
@@ -79144,6 +79168,18 @@ var BABYLON;
                     }
                 }
             }
+            // Reflection probes
+            if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
+                for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
+                    var parsedReflectionProbe = parsedData.reflectionProbes[index];
+                    var reflectionProbe = BABYLON.ReflectionProbe.Parse(parsedReflectionProbe, scene, rootUrl);
+                    if (reflectionProbe) {
+                        container.reflectionProbes.push(reflectionProbe);
+                        log += (index === 0 ? "\n\tReflection Probes:" : "");
+                        log += "\n\t\t" + reflectionProbe.toString(fullDetails);
+                    }
+                }
+            }
             // Animations
             if (parsedData.animations !== undefined && parsedData.animations !== null) {
                 for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
@@ -115305,6 +115341,14 @@ var BABYLON;
             }
             // Animations
             BABYLON.Animation.AppendSerializedAnimations(scene, serializationObject);
+            // Reflection probes
+            if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
+                serializationObject.reflectionProbes = [];
+                for (index = 0; index < scene.reflectionProbes.length; index++) {
+                    var reflectionProbe = scene.reflectionProbes[index];
+                    serializationObject.reflectionProbes.push(reflectionProbe.serialize());
+                }
+            }
             // Materials
             serializationObject.materials = [];
             serializationObject.multiMaterials = [];
@@ -115426,8 +115470,25 @@ var BABYLON;
 
 //# sourceMappingURL=babylon.sceneSerializer.js.map
 
+
 var BABYLON;
 (function (BABYLON) {
+    BABYLON.AbstractScene.prototype.removeReflectionProbe = function (toRemove) {
+        if (!this.reflectionProbes) {
+            return -1;
+        }
+        var index = this.reflectionProbes.indexOf(toRemove);
+        if (index !== -1) {
+            this.reflectionProbes.splice(index, 1);
+        }
+        return index;
+    };
+    BABYLON.AbstractScene.prototype.addReflectionProbe = function (newReflectionProbe) {
+        if (!this.reflectionProbes) {
+            this.reflectionProbes = [];
+        }
+        this.reflectionProbes.push(newReflectionProbe);
+    };
     /**
      * Class used to generate realtime reflection / refraction cube textures
      * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
@@ -115487,16 +115548,16 @@ var BABYLON;
                 }
                 _this.position.addToRef(_this._add, _this._target);
                 BABYLON.Matrix.LookAtLHToRef(_this.position, _this._target, BABYLON.Vector3.Up(), _this._viewMatrix);
-                scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
+                if (scene.activeCamera) {
+                    _this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
+                    scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
+                }
                 scene._forcedViewPosition = _this.position;
             });
             this._renderTargetTexture.onAfterUnbindObservable.add(function () {
                 scene._forcedViewPosition = null;
                 scene.updateTransformMatrix(true);
             });
-            if (scene.activeCamera) {
-                this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
-            }
         }
         Object.defineProperty(ReflectionProbe.prototype, "samples", {
             /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
@@ -115572,6 +115633,68 @@ var BABYLON;
                 this._renderTargetTexture = null;
             }
         };
+        /**
+         * Converts the reflection probe information to a readable string for debug purpose.
+         * @param fullDetails Supports for multiple levels of logging within scene loading
+         * @returns the human readable reflection probe info
+         */
+        ReflectionProbe.prototype.toString = function (fullDetails) {
+            var ret = "Name: " + this.name;
+            if (fullDetails) {
+                ret += ", position: " + this.position.toString();
+                if (this._attachedMesh) {
+                    ret += ", attached mesh: " + this._attachedMesh.name;
+                }
+            }
+            return ret;
+        };
+        /**
+         * Get the class name of the relfection probe.
+         * @returns "ReflectionProbe"
+         */
+        ReflectionProbe.prototype.getClassName = function () {
+            return "ReflectionProbe";
+        };
+        /**
+         * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
+         * @returns The JSON representation of the texture
+         */
+        ReflectionProbe.prototype.serialize = function () {
+            var serializationObject = BABYLON.SerializationHelper.Serialize(this, this._renderTargetTexture.serialize());
+            serializationObject.isReflectionProbe = true;
+            return serializationObject;
+        };
+        /**
+         * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
+         * @param parsedReflectionProbe Define the JSON representation of the reflection probe
+         * @param scene Define the scene the parsed reflection probe should be instantiated in
+         * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
+         * @returns The parsed reflection probe if successful
+         */
+        ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
+            var reflectionProbe = null;
+            if (scene.reflectionProbes) {
+                for (var index = 0; index < scene.reflectionProbes.length; index++) {
+                    var rp = scene.reflectionProbes[index];
+                    if (rp.name === parsedReflectionProbe.name) {
+                        reflectionProbe = rp;
+                        break;
+                    }
+                }
+            }
+            reflectionProbe = BABYLON.SerializationHelper.Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
+            reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
+            if (parsedReflectionProbe._attachedMesh) {
+                reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
+            }
+            return reflectionProbe;
+        };
+        __decorate([
+            BABYLON.serializeAsMeshReference()
+        ], ReflectionProbe.prototype, "_attachedMesh", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], ReflectionProbe.prototype, "position", void 0);
         return ReflectionProbe;
     }());
     BABYLON.ReflectionProbe = ReflectionProbe;

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


+ 132 - 9
dist/preview release/es6.js

@@ -30479,6 +30479,7 @@ var BABYLON;
             _this["layers"] = [];
             _this["lensFlareSystems"] = [];
             _this["proceduralTextures"] = [];
+            _this["reflectionProbes"] = [];
             return _this;
         }
         /**
@@ -30525,6 +30526,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 _this.scene.addTexture(o);
             });
+            this.reflectionProbes.forEach(function (o) {
+                _this.scene.addReflectionProbe(o);
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.addFromContainer(this);
@@ -30574,6 +30578,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 _this.scene.removeTexture(o);
             });
+            this.reflectionProbes.forEach(function (o) {
+                _this.scene.removeReflectionProbe(o);
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.removeFromContainer(this);
@@ -30616,6 +30623,9 @@ var BABYLON;
             this.textures.forEach(function (o) {
                 o.dispose();
             });
+            this.reflectionProbes.forEach(function (o) {
+                o.dispose();
+            });
             for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
                 var component = _a[_i];
                 component.dispose();
@@ -32689,7 +32699,7 @@ var BABYLON;
                 }
                 return parsedCustomTexture;
             }
-            if (parsedTexture.isCube) {
+            if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
                 return BABYLON.CubeTexture.Parse(parsedTexture, scene, rootUrl);
             }
             if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
@@ -32707,8 +32717,22 @@ var BABYLON;
                     return mirrorTexture;
                 }
                 else if (parsedTexture.isRenderTarget) {
-                    var renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
-                    renderTargetTexture._waitingRenderList = parsedTexture.renderList;
+                    var renderTargetTexture = null;
+                    if (parsedTexture.isCube) {
+                        // Search for an existing reflection probe (which contains a cube render target texture)
+                        if (scene.reflectionProbes) {
+                            for (var index = 0; index < scene.reflectionProbes.length; index++) {
+                                var probe = scene.reflectionProbes[index];
+                                if (probe.name === parsedTexture.name) {
+                                    return probe.cubeTexture;
+                                }
+                            }
+                        }
+                    }
+                    else {
+                        renderTargetTexture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
+                        renderTargetTexture._waitingRenderList = parsedTexture.renderList;
+                    }
                     return renderTargetTexture;
                 }
                 else {
@@ -32729,12 +32753,12 @@ var BABYLON;
             // Update Sampling Mode
             if (parsedTexture.samplingMode) {
                 var sampling = parsedTexture.samplingMode;
-                if (texture._samplingMode !== sampling) {
+                if (texture && texture._samplingMode !== sampling) {
                     texture.updateSamplingMode(sampling);
                 }
             }
             // Animations
-            if (parsedTexture.animations) {
+            if (texture && parsedTexture.animations) {
                 for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
                     var parsedAnimation = parsedTexture.animations[animationIndex];
                     texture.animations.push(BABYLON.Animation.Parse(parsedAnimation));
@@ -79144,6 +79168,18 @@ var BABYLON;
                     }
                 }
             }
+            // Reflection probes
+            if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
+                for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
+                    var parsedReflectionProbe = parsedData.reflectionProbes[index];
+                    var reflectionProbe = BABYLON.ReflectionProbe.Parse(parsedReflectionProbe, scene, rootUrl);
+                    if (reflectionProbe) {
+                        container.reflectionProbes.push(reflectionProbe);
+                        log += (index === 0 ? "\n\tReflection Probes:" : "");
+                        log += "\n\t\t" + reflectionProbe.toString(fullDetails);
+                    }
+                }
+            }
             // Animations
             if (parsedData.animations !== undefined && parsedData.animations !== null) {
                 for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
@@ -115305,6 +115341,14 @@ var BABYLON;
             }
             // Animations
             BABYLON.Animation.AppendSerializedAnimations(scene, serializationObject);
+            // Reflection probes
+            if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
+                serializationObject.reflectionProbes = [];
+                for (index = 0; index < scene.reflectionProbes.length; index++) {
+                    var reflectionProbe = scene.reflectionProbes[index];
+                    serializationObject.reflectionProbes.push(reflectionProbe.serialize());
+                }
+            }
             // Materials
             serializationObject.materials = [];
             serializationObject.multiMaterials = [];
@@ -115426,8 +115470,25 @@ var BABYLON;
 
 //# sourceMappingURL=babylon.sceneSerializer.js.map
 
+
 var BABYLON;
 (function (BABYLON) {
+    BABYLON.AbstractScene.prototype.removeReflectionProbe = function (toRemove) {
+        if (!this.reflectionProbes) {
+            return -1;
+        }
+        var index = this.reflectionProbes.indexOf(toRemove);
+        if (index !== -1) {
+            this.reflectionProbes.splice(index, 1);
+        }
+        return index;
+    };
+    BABYLON.AbstractScene.prototype.addReflectionProbe = function (newReflectionProbe) {
+        if (!this.reflectionProbes) {
+            this.reflectionProbes = [];
+        }
+        this.reflectionProbes.push(newReflectionProbe);
+    };
     /**
      * Class used to generate realtime reflection / refraction cube textures
      * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
@@ -115487,16 +115548,16 @@ var BABYLON;
                 }
                 _this.position.addToRef(_this._add, _this._target);
                 BABYLON.Matrix.LookAtLHToRef(_this.position, _this._target, BABYLON.Vector3.Up(), _this._viewMatrix);
-                scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
+                if (scene.activeCamera) {
+                    _this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
+                    scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
+                }
                 scene._forcedViewPosition = _this.position;
             });
             this._renderTargetTexture.onAfterUnbindObservable.add(function () {
                 scene._forcedViewPosition = null;
                 scene.updateTransformMatrix(true);
             });
-            if (scene.activeCamera) {
-                this._projectionMatrix = BABYLON.Matrix.PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
-            }
         }
         Object.defineProperty(ReflectionProbe.prototype, "samples", {
             /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
@@ -115572,6 +115633,68 @@ var BABYLON;
                 this._renderTargetTexture = null;
             }
         };
+        /**
+         * Converts the reflection probe information to a readable string for debug purpose.
+         * @param fullDetails Supports for multiple levels of logging within scene loading
+         * @returns the human readable reflection probe info
+         */
+        ReflectionProbe.prototype.toString = function (fullDetails) {
+            var ret = "Name: " + this.name;
+            if (fullDetails) {
+                ret += ", position: " + this.position.toString();
+                if (this._attachedMesh) {
+                    ret += ", attached mesh: " + this._attachedMesh.name;
+                }
+            }
+            return ret;
+        };
+        /**
+         * Get the class name of the relfection probe.
+         * @returns "ReflectionProbe"
+         */
+        ReflectionProbe.prototype.getClassName = function () {
+            return "ReflectionProbe";
+        };
+        /**
+         * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
+         * @returns The JSON representation of the texture
+         */
+        ReflectionProbe.prototype.serialize = function () {
+            var serializationObject = BABYLON.SerializationHelper.Serialize(this, this._renderTargetTexture.serialize());
+            serializationObject.isReflectionProbe = true;
+            return serializationObject;
+        };
+        /**
+         * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
+         * @param parsedReflectionProbe Define the JSON representation of the reflection probe
+         * @param scene Define the scene the parsed reflection probe should be instantiated in
+         * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
+         * @returns The parsed reflection probe if successful
+         */
+        ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
+            var reflectionProbe = null;
+            if (scene.reflectionProbes) {
+                for (var index = 0; index < scene.reflectionProbes.length; index++) {
+                    var rp = scene.reflectionProbes[index];
+                    if (rp.name === parsedReflectionProbe.name) {
+                        reflectionProbe = rp;
+                        break;
+                    }
+                }
+            }
+            reflectionProbe = BABYLON.SerializationHelper.Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
+            reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
+            if (parsedReflectionProbe._attachedMesh) {
+                reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
+            }
+            return reflectionProbe;
+        };
+        __decorate([
+            BABYLON.serializeAsMeshReference()
+        ], ReflectionProbe.prototype, "_attachedMesh", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3()
+        ], ReflectionProbe.prototype, "position", void 0);
         return ReflectionProbe;
     }());
     BABYLON.ReflectionProbe = ReflectionProbe;

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


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


+ 40 - 42
dist/preview release/inspector/babylon.inspector.d.ts

@@ -25,48 +25,46 @@ declare module INSPECTOR {
 }
 declare module INSPECTOR {
 }
-declare module INSPECTOR {
-    export class Inspector {
-            /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
-            static DOCUMENT: HTMLDocument;
-            /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
-            static WINDOW: Window;
-            onGUILoaded: BABYLON.Observable<any>;
-            static GUIObject: any;
-            /** The inspector is created with the given engine.
-                * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
-                * If the parameter 'popup' is true, the inspector is created in another popup.
-                */
-            constructor(scene: BABYLON.Scene, popup?: boolean, initialTab?: number | string, parentElement?: BABYLON.Nullable<HTMLElement>, newColors?: {
-                    backgroundColor?: string;
-                    backgroundColorLighter?: string;
-                    backgroundColorLighter2?: string;
-                    backgroundColorLighter3?: string;
-                    color?: string;
-                    colorTop?: string;
-                    colorBot?: string;
-            });
-            readonly scene: BABYLON.Scene;
-            readonly popupMode: boolean;
-            /**
-                * Filter the list of item present in the tree.
-                * All item returned should have the given filter contained in the item id.
-             */
-            filterItem(filter: string): void;
-            /** Display the mesh tab on the given object */
-            displayObjectDetails(mesh: BABYLON.AbstractMesh): void;
-            /** Clean the whole tree of item and rebuilds it */
-            refresh(): void;
-            /** Remove the inspector panel when it's built as a right panel:
-                * remove the right panel and remove the wrapper
-                */
-            dispose(): void;
-            /** Open the inspector in a new popup
-                * Set 'firstTime' to true if there is no inspector created beforehands
-                */
-            openPopup(firstTime?: boolean): void;
-            getActiveTabIndex(): number;
-    }
+export declare class Inspector {
+        /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
+        static DOCUMENT: HTMLDocument;
+        /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
+        static WINDOW: Window;
+        onGUILoaded: BABYLON.Observable<any>;
+        static GUIObject: any;
+        /** The inspector is created with the given engine.
+            * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
+            * If the parameter 'popup' is true, the inspector is created in another popup.
+            */
+        constructor(scene: BABYLON.Scene, popup?: boolean, initialTab?: number | string, parentElement?: BABYLON.Nullable<HTMLElement>, newColors?: {
+                backgroundColor?: string;
+                backgroundColorLighter?: string;
+                backgroundColorLighter2?: string;
+                backgroundColorLighter3?: string;
+                color?: string;
+                colorTop?: string;
+                colorBot?: string;
+        });
+        readonly scene: BABYLON.Scene;
+        readonly popupMode: boolean;
+        /**
+            * Filter the list of item present in the tree.
+            * All item returned should have the given filter contained in the item id.
+         */
+        filterItem(filter: string): void;
+        /** Display the mesh tab on the given object */
+        displayObjectDetails(mesh: BABYLON.AbstractMesh): void;
+        /** Clean the whole tree of item and rebuilds it */
+        refresh(): void;
+        /** Remove the inspector panel when it's built as a right panel:
+            * remove the right panel and remove the wrapper
+            */
+        dispose(): void;
+        /** Open the inspector in a new popup
+            * Set 'firstTime' to true if there is no inspector created beforehands
+            */
+        openPopup(firstTime?: boolean): void;
+        getActiveTabIndex(): number;
 }
 declare module INSPECTOR {
     export const PROPERTIES: {

+ 82 - 86
dist/preview release/inspector/babylon.inspector.module.d.ts

@@ -94,50 +94,48 @@ declare module 'babylonjs-inspector/treetools' {
     export * from 'babylonjs-inspector/treetools/SoundInteractions';
 }
 
-declare module 'babylonjs-inspector/Inspector' {
-    import { AbstractMesh, Nullable, Scene, Observable } from "babylonjs";
-    
-    export class Inspector {
-            /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
-            static DOCUMENT: HTMLDocument;
-            /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
-            static WINDOW: Window;
-            onGUILoaded: Observable<any>;
-            static GUIObject: any;
-            /** The inspector is created with the given engine.
-                * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
-                * If the parameter 'popup' is true, the inspector is created in another popup.
-                */
-            constructor(scene: Scene, popup?: boolean, initialTab?: number | string, parentElement?: Nullable<HTMLElement>, newColors?: {
-                    backgroundColor?: string;
-                    backgroundColorLighter?: string;
-                    backgroundColorLighter2?: string;
-                    backgroundColorLighter3?: string;
-                    color?: string;
-                    colorTop?: string;
-                    colorBot?: string;
-            });
-            readonly scene: Scene;
-            readonly popupMode: boolean;
-            /**
-                * Filter the list of item present in the tree.
-                * All item returned should have the given filter contained in the item id.
-             */
-            filterItem(filter: string): void;
-            /** Display the mesh tab on the given object */
-            displayObjectDetails(mesh: AbstractMesh): void;
-            /** Clean the whole tree of item and rebuilds it */
-            refresh(): void;
-            /** Remove the inspector panel when it's built as a right panel:
-                * remove the right panel and remove the wrapper
-                */
-            dispose(): void;
-            /** Open the inspector in a new popup
-                * Set 'firstTime' to true if there is no inspector created beforehands
-                */
-            openPopup(firstTime?: boolean): void;
-            getActiveTabIndex(): number;
-    }
+import { AbstractMesh, Nullable, Scene, Observable } from "babylonjs";
+
+export declare class Inspector {
+        /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
+        static DOCUMENT: HTMLDocument;
+        /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
+        static WINDOW: Window;
+        onGUILoaded: Observable<any>;
+        static GUIObject: any;
+        /** The inspector is created with the given engine.
+            * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
+            * If the parameter 'popup' is true, the inspector is created in another popup.
+            */
+        constructor(scene: Scene, popup?: boolean, initialTab?: number | string, parentElement?: Nullable<HTMLElement>, newColors?: {
+                backgroundColor?: string;
+                backgroundColorLighter?: string;
+                backgroundColorLighter2?: string;
+                backgroundColorLighter3?: string;
+                color?: string;
+                colorTop?: string;
+                colorBot?: string;
+        });
+        readonly scene: Scene;
+        readonly popupMode: boolean;
+        /**
+            * Filter the list of item present in the tree.
+            * All item returned should have the given filter contained in the item id.
+         */
+        filterItem(filter: string): void;
+        /** Display the mesh tab on the given object */
+        displayObjectDetails(mesh: AbstractMesh): void;
+        /** Clean the whole tree of item and rebuilds it */
+        refresh(): void;
+        /** Remove the inspector panel when it's built as a right panel:
+            * remove the right panel and remove the wrapper
+            */
+        dispose(): void;
+        /** Open the inspector in a new popup
+            * Set 'firstTime' to true if there is no inspector created beforehands
+            */
+        openPopup(firstTime?: boolean): void;
+        getActiveTabIndex(): number;
 }
 
 declare module 'babylonjs-inspector/properties' {
@@ -1263,48 +1261,46 @@ declare module INSPECTOR {
 }
 declare module INSPECTOR {
 }
-declare module INSPECTOR {
-    export class Inspector {
-            /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
-            static DOCUMENT: HTMLDocument;
-            /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
-            static WINDOW: Window;
-            onGUILoaded: BABYLON.Observable<any>;
-            static GUIObject: any;
-            /** The inspector is created with the given engine.
-                * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
-                * If the parameter 'popup' is true, the inspector is created in another popup.
-                */
-            constructor(scene: BABYLON.Scene, popup?: boolean, initialTab?: number | string, parentElement?: BABYLON.Nullable<HTMLElement>, newColors?: {
-                    backgroundColor?: string;
-                    backgroundColorLighter?: string;
-                    backgroundColorLighter2?: string;
-                    backgroundColorLighter3?: string;
-                    color?: string;
-                    colorTop?: string;
-                    colorBot?: string;
-            });
-            readonly scene: BABYLON.Scene;
-            readonly popupMode: boolean;
-            /**
-                * Filter the list of item present in the tree.
-                * All item returned should have the given filter contained in the item id.
-             */
-            filterItem(filter: string): void;
-            /** Display the mesh tab on the given object */
-            displayObjectDetails(mesh: BABYLON.AbstractMesh): void;
-            /** Clean the whole tree of item and rebuilds it */
-            refresh(): void;
-            /** Remove the inspector panel when it's built as a right panel:
-                * remove the right panel and remove the wrapper
-                */
-            dispose(): void;
-            /** Open the inspector in a new popup
-                * Set 'firstTime' to true if there is no inspector created beforehands
-                */
-            openPopup(firstTime?: boolean): void;
-            getActiveTabIndex(): number;
-    }
+export declare class Inspector {
+        /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
+        static DOCUMENT: HTMLDocument;
+        /** The HTML window. In popup mode, it's the popup itself. Otherwise, it's the current tab */
+        static WINDOW: Window;
+        onGUILoaded: BABYLON.Observable<any>;
+        static GUIObject: any;
+        /** The inspector is created with the given engine.
+            * If the parameter 'popup' is false, the inspector is created as a right panel on the main window.
+            * If the parameter 'popup' is true, the inspector is created in another popup.
+            */
+        constructor(scene: BABYLON.Scene, popup?: boolean, initialTab?: number | string, parentElement?: BABYLON.Nullable<HTMLElement>, newColors?: {
+                backgroundColor?: string;
+                backgroundColorLighter?: string;
+                backgroundColorLighter2?: string;
+                backgroundColorLighter3?: string;
+                color?: string;
+                colorTop?: string;
+                colorBot?: string;
+        });
+        readonly scene: BABYLON.Scene;
+        readonly popupMode: boolean;
+        /**
+            * Filter the list of item present in the tree.
+            * All item returned should have the given filter contained in the item id.
+         */
+        filterItem(filter: string): void;
+        /** Display the mesh tab on the given object */
+        displayObjectDetails(mesh: BABYLON.AbstractMesh): void;
+        /** Clean the whole tree of item and rebuilds it */
+        refresh(): void;
+        /** Remove the inspector panel when it's built as a right panel:
+            * remove the right panel and remove the wrapper
+            */
+        dispose(): void;
+        /** Open the inspector in a new popup
+            * Set 'firstTime' to true if there is no inspector created beforehands
+            */
+        openPopup(firstTime?: boolean): void;
+        getActiveTabIndex(): number;
 }
 declare module INSPECTOR {
     export const PROPERTIES: {

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


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


+ 15 - 15
gui/src/2D/advancedDynamicTexture.ts

@@ -260,15 +260,15 @@ export class AdvancedDynamicTexture extends DynamicTexture {
         this._clipboardData = value;
     }
 
-     /**
-     * Creates a new AdvancedDynamicTexture
-     * @param name defines the name of the texture
-     * @param width defines the width of the texture
-     * @param height defines the height of the texture
-     * @param scene defines the hosting scene
-     * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
-     * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
-     */
+    /**
+    * Creates a new AdvancedDynamicTexture
+    * @param name defines the name of the texture
+    * @param width defines the width of the texture
+    * @param height defines the height of the texture
+    * @param scene defines the hosting scene
+    * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
+    * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
+    */
     constructor(name: string, width = 0, height = 0, scene: Nullable<Scene>, generateMipMaps = false, samplingMode = Texture.NEAREST_SAMPLINGMODE) {
         super(name, { width: width, height: height }, scene, generateMipMaps, samplingMode, Engine.TEXTUREFORMAT_RGBA);
 
@@ -628,7 +628,7 @@ export class AdvancedDynamicTexture extends DynamicTexture {
             if (pi.type !== PointerEventTypes.POINTERMOVE
                 && pi.type !== PointerEventTypes.POINTERUP
                 && pi.type !== PointerEventTypes.POINTERDOWN) {
-                    return;
+                return;
             }
 
             if (!scene) {
@@ -664,7 +664,7 @@ export class AdvancedDynamicTexture extends DynamicTexture {
         this.onClipboardObservable.notifyObservers(ev);
         evt.preventDefault();
     }
-     /** @hidden */
+    /** @hidden */
     private onClipboardCut = (evt: ClipboardEvent) => {
         let ev = new ClipboardInfo(ClipboardEventTypes.CUT, evt);
         this.onClipboardObservable.notifyObservers(ev);
@@ -677,9 +677,9 @@ export class AdvancedDynamicTexture extends DynamicTexture {
         evt.preventDefault();
     }
 
-   /**
-    * Register the clipboard Events onto the canvas
-    */
+    /**
+     * Register the clipboard Events onto the canvas
+     */
     public registerClipboardEvents(): void {
         self.addEventListener("copy", this.onClipboardCopy, false);
         self.addEventListener("cut", this.onClipboardCut, false);
@@ -690,7 +690,7 @@ export class AdvancedDynamicTexture extends DynamicTexture {
      */
     public unRegisterClipboardEvents(): void {
         self.removeEventListener("copy", this.onClipboardCopy);
-        self.removeEventListener("cut",  this.onClipboardCut);
+        self.removeEventListener("cut", this.onClipboardCut);
         self.removeEventListener("paste", this.onClipboardPaste);
     }