Explorar o código

Video Texture

Sebastien Vandenberghe %!s(int64=7) %!d(string=hai) anos
pai
achega
b702e7524b

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 15895 - 15931
Playground/babylon.d.txt


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 15748 - 15784
dist/preview release/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 10 - 10
dist/preview release/babylon.js


+ 41 - 260
dist/preview release/babylon.max.js

@@ -64781,7 +64781,7 @@ var BABYLON;
             if (settings.loop !== undefined) {
                 _this.video.loop = settings.loop;
             }
-            _this.video.addEventListener("canplay", _this._createInternalTexture);
+            _this.video.addEventListener("canplaythrough", _this._createInternalTexture);
             _this.video.addEventListener("paused", _this._updateInternalTexture);
             _this.video.addEventListener("seeked", _this._updateInternalTexture);
             _this.video.addEventListener("emptied", _this.reset);
@@ -64860,7 +64860,7 @@ var BABYLON;
         };
         VideoTexture.prototype.dispose = function () {
             _super.prototype.dispose.call(this);
-            this.video.removeEventListener("canplay", this._createInternalTexture);
+            this.video.removeEventListener("canplaythrough", this._createInternalTexture);
             this.video.removeEventListener("paused", this._updateInternalTexture);
             this.video.removeEventListener("seeked", this._updateInternalTexture);
             this.video.removeEventListener("emptied", this.reset);
@@ -80682,34 +80682,27 @@ var BABYLON;
          *
          * @param url The location of the HDR raw data (Panorama stored in RGBE format)
          * @param scene The scene the texture will be used in
-         * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * @param size The cubemap desired size (the more it increases the longer the generation will be)
          * @param noMipmap Forces to not generate the mipmap if true
          * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
-         * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
-         * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
+         * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
+         * @param reserved Reserved flag for internal use.
          */
-        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator, onLoad, onError) {
+        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             if (onLoad === void 0) { onLoad = null; }
             if (onError === void 0) { onError = null; }
             var _this = _super.call(this, scene) || this;
-            _this._useInGammaSpace = false;
             _this._generateHarmonics = true;
-            _this._isBABYLONPreprocessed = false;
             _this._onLoad = null;
             _this._onError = null;
             /**
              * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
              */
             _this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
-            /**
-             * Specifies wether the texture has been generated through the PMREMGenerator tool.
-             * This is usefull at run time to apply the good shader.
-             */
-            _this.isPMREM = false;
             _this._isBlocking = true;
             _this._rotationY = 0;
             /**
@@ -80727,26 +80720,9 @@ var BABYLON;
             _this._textureMatrix = BABYLON.Matrix.Identity();
             _this._onLoad = onLoad;
             _this._onError = onError;
-            _this.gammaSpace = false;
-            var caps = scene.getEngine().getCaps();
-            if (size) {
-                _this._isBABYLONPreprocessed = false;
-                _this._noMipmap = noMipmap;
-                _this._size = size;
-                _this._useInGammaSpace = useInGammaSpace;
-                _this._usePMREMGenerator = usePMREMGenerator &&
-                    caps.textureLOD &&
-                    caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            else {
-                _this._isBABYLONPreprocessed = true;
-                _this._noMipmap = false;
-                _this._useInGammaSpace = false;
-                _this._usePMREMGenerator = caps.textureLOD && caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            _this.isPMREM = _this._usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this._noMipmap = noMipmap;
+            _this._size = size;
             _this._texture = _this._getFromCache(url, _this._noMipmap);
             if (!_this._texture) {
                 if (!scene.useDelayedTextureLoading) {
@@ -80815,129 +80791,9 @@ var BABYLON;
             configurable: true
         });
         /**
-         * Occurs when the file is a preprocessed .babylon.hdr file.
-         */
-        HDRCubeTexture.prototype.loadBabylonTexture = function () {
-            var _this = this;
-            var mipLevels = 0;
-            var floatArrayView = null;
-            var scene = this.getScene();
-            var mipmapGenerator = (!this._useInGammaSpace && scene && scene.getEngine().getCaps().textureFloat) ? function (data) {
-                var mips = new Array();
-                if (!floatArrayView) {
-                    return mips;
-                }
-                var startIndex = 30;
-                for (var level = 0; level < mipLevels; level++) {
-                    mips.push([]);
-                    // Fill each pixel of the mip level.
-                    var faceSize = Math.pow(_this._size >> level, 2) * 3;
-                    for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                        var faceData = floatArrayView.subarray(startIndex, startIndex + faceSize);
-                        mips[level].push(faceData);
-                        startIndex += faceSize;
-                    }
-                }
-                return mips;
-            } : null;
-            var callback = function (buffer) {
-                var scene = _this.getScene();
-                if (!scene) {
-                    return null;
-                }
-                // Create Native Array Views
-                var intArrayView = new Int32Array(buffer);
-                floatArrayView = new Float32Array(buffer);
-                // Fill header.
-                var version = intArrayView[0]; // Version 1. (MAy be use in case of format changes for backward compaibility)
-                _this._size = intArrayView[1]; // CubeMap max mip face size.
-                // Update Texture Information.
-                if (!_this._texture) {
-                    return null;
-                }
-                _this._texture.updateSize(_this._size, _this._size);
-                // Fill polynomial information.
-                var sphericalPolynomial = new BABYLON.SphericalPolynomial();
-                sphericalPolynomial.x.copyFromFloats(floatArrayView[2], floatArrayView[3], floatArrayView[4]);
-                sphericalPolynomial.y.copyFromFloats(floatArrayView[5], floatArrayView[6], floatArrayView[7]);
-                sphericalPolynomial.z.copyFromFloats(floatArrayView[8], floatArrayView[9], floatArrayView[10]);
-                sphericalPolynomial.xx.copyFromFloats(floatArrayView[11], floatArrayView[12], floatArrayView[13]);
-                sphericalPolynomial.yy.copyFromFloats(floatArrayView[14], floatArrayView[15], floatArrayView[16]);
-                sphericalPolynomial.zz.copyFromFloats(floatArrayView[17], floatArrayView[18], floatArrayView[19]);
-                sphericalPolynomial.xy.copyFromFloats(floatArrayView[20], floatArrayView[21], floatArrayView[22]);
-                sphericalPolynomial.yz.copyFromFloats(floatArrayView[23], floatArrayView[24], floatArrayView[25]);
-                sphericalPolynomial.zx.copyFromFloats(floatArrayView[26], floatArrayView[27], floatArrayView[28]);
-                _this.sphericalPolynomial = sphericalPolynomial;
-                // Fill pixel data.
-                mipLevels = intArrayView[29]; // Number of mip levels.
-                var startIndex = 30;
-                var data = [];
-                var faceSize = Math.pow(_this._size, 2) * 3;
-                for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                    data.push(floatArrayView.subarray(startIndex, startIndex + faceSize));
-                    startIndex += faceSize;
-                }
-                var results = [];
-                var byteArray = null;
-                // Push each faces.
-                for (var k = 0; k < 6; k++) {
-                    var dataFace = null;
-                    // To be deprecated.
-                    if (version === 1) {
-                        var j = ([0, 2, 4, 1, 3, 5])[k]; // Transforms +X+Y+Z... to +X-X+Y-Y...
-                        dataFace = data[j];
-                    }
-                    // If special cases.
-                    if (!mipmapGenerator && dataFace) {
-                        if (!scene.getEngine().getCaps().textureFloat) {
-                            // 3 channels of 1 bytes per pixel in bytes.
-                            var byteBuffer = new ArrayBuffer(faceSize);
-                            byteArray = new Uint8Array(byteBuffer);
-                        }
-                        for (var i = 0; i < _this._size * _this._size; i++) {
-                            // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
-                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
-                            }
-                            // Convert to int texture for fallback.
-                            if (byteArray) {
-                                var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
-                                var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
-                                var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
-                                // May use luminance instead if the result is not accurate.
-                                var max = Math.max(Math.max(r, g), b);
-                                if (max > 255) {
-                                    var scale = 255 / max;
-                                    r *= scale;
-                                    g *= scale;
-                                    b *= scale;
-                                }
-                                byteArray[(i * 3) + 0] = r;
-                                byteArray[(i * 3) + 1] = g;
-                                byteArray[(i * 3) + 2] = b;
-                            }
-                        }
-                    }
-                    // Fill the array accordingly.
-                    if (byteArray) {
-                        results.push(byteArray);
-                    }
-                    else {
-                        results.push(dataFace);
-                    }
-                }
-                return results;
-            };
-            if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
          * Occurs when the file is raw .hdr file.
          */
-        HDRCubeTexture.prototype.loadHDRTexture = function () {
+        HDRCubeTexture.prototype.loadTexture = function () {
             var _this = this;
             var callback = function (buffer) {
                 var scene = _this.getScene();
@@ -80963,10 +80819,10 @@ var BABYLON;
                     }
                     var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
                     // If special cases.
-                    if (_this._useInGammaSpace || byteArray) {
+                    if (_this.gammaSpace || byteArray) {
                         for (var i = 0; i < _this._size * _this._size; i++) {
                             // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
+                            if (_this.gammaSpace) {
                                 dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
@@ -80999,39 +80855,9 @@ var BABYLON;
                 }
                 return results;
             };
-            var mipmapGenerator = null;
-            // TODO. Implement In code PMREM Generator following the LYS toolset generation.
-            // if (!this._noMipmap &&
-            //     this._usePMREMGenerator) {
-            //     mipmapGenerator = (data: ArrayBufferView[]) => {
-            //         // Custom setup of the generator matching with the PBR shader values.
-            //         var generator = new BABYLON.PMREMGenerator(data,
-            //             this._size,
-            //             this._size,
-            //             0,
-            //             3,
-            //             this.getScene().getEngine().getCaps().textureFloat,
-            //             2048,
-            //             0.25,
-            //             false,
-            //             true);
-            //         return generator.filterCubeMap();
-            //     };
-            // }
             var scene = this.getScene();
             if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
-         * Starts the loading process of the texture.
-         */
-        HDRCubeTexture.prototype.loadTexture = function () {
-            if (this._isBABYLONPreprocessed) {
-                this.loadBabylonTexture();
-            }
-            else {
-                this.loadHDRTexture();
+                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, null, this._onLoad, this._onError);
             }
         };
         HDRCubeTexture.prototype.clone = function () {
@@ -81039,8 +80865,7 @@ var BABYLON;
             if (!scene) {
                 return this;
             }
-            var size = (this._isBABYLONPreprocessed ? null : this._size);
-            var newTexture = new HDRCubeTexture(this.url, scene, size, this._noMipmap, this._generateHarmonics, this._useInGammaSpace, this._usePMREMGenerator);
+            var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
             // Base texture
             newTexture.level = this.level;
             newTexture.wrapU = this.wrapU;
@@ -81069,8 +80894,7 @@ var BABYLON;
         HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = null;
             if (parsedTexture.name && !parsedTexture.isRenderTarget) {
-                var size = parsedTexture.isBABYLONPreprocessed ? null : parsedTexture.size;
-                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace, parsedTexture.usePMREMGenerator);
+                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
                 texture.name = parsedTexture.name;
                 texture.hasAlpha = parsedTexture.hasAlpha;
                 texture.level = parsedTexture.level;
@@ -81101,63 +80925,14 @@ var BABYLON;
             serializationObject.level = this.level;
             serializationObject.size = this._size;
             serializationObject.coordinatesMode = this.coordinatesMode;
-            serializationObject.useInGammaSpace = this._useInGammaSpace;
+            serializationObject.useInGammaSpace = this.gammaSpace;
             serializationObject.generateHarmonics = this._generateHarmonics;
-            serializationObject.usePMREMGenerator = this._usePMREMGenerator;
-            serializationObject.isBABYLONPreprocessed = this._isBABYLONPreprocessed;
             serializationObject.customType = "BABYLON.HDRCubeTexture";
             serializationObject.noMipmap = this._noMipmap;
             serializationObject.isBlocking = this._isBlocking;
             serializationObject.rotationY = this._rotationY;
             return serializationObject;
         };
-        /**
-         * Saves as a file the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDROnDisk = function (url, size, onError) {
-            if (onError === void 0) { onError = null; }
-            var callback = function (buffer) {
-                var data = new Blob([buffer], { type: 'application/octet-stream' });
-                // Returns a URL you can use as a href.
-                var objUrl = window.URL.createObjectURL(data);
-                // Simulates a link to it and click to dowload.
-                var a = document.createElement("a");
-                document.body.appendChild(a);
-                a.style.display = "none";
-                a.href = objUrl;
-                a.download = "envmap.babylon.hdr";
-                a.click();
-            };
-            HDRCubeTexture.generateBabylonHDR(url, size, callback, onError);
-        };
-        /**
-         * Serializes the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDR = function (url, size, callback, onError) {
-            if (onError === void 0) { onError = null; }
-            // Needs the url tho create the texture.
-            if (!url) {
-                return;
-            }
-            // Check Power of two size.
-            if (!BABYLON.Tools.IsExponentOfTwo(size)) { // Need to check engine.needPOTTextures 
-                return;
-            }
-            // Coming Back in 3.x.
-            BABYLON.Tools.Error("Generation of Babylon HDR is coming back in 3.2.");
-        };
         HDRCubeTexture._facesMapping = [
             "right",
             "left",
@@ -87619,6 +87394,12 @@ var BABYLON;
                 this._webvrViewMatrix.invert();
             }
             parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
+            // Compute global position
+            this._workingMatrix = this._workingMatrix || BABYLON.Matrix.Identity();
+            this._webvrViewMatrix.invertToRef(this._workingMatrix);
+            this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
+            this._workingMatrix.getTranslationToRef(this._globalPosition);
+            this._markSyncedWithParent();
             return this._webvrViewMatrix;
         };
         WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
@@ -93897,8 +93678,8 @@ var BABYLON;
          * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
          * @param noMipmap defines if mipmaps should not be generated (default is false)
          * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
-         * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
-         * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          */
         function HDRCubeTextureAssetTask(
         /**
@@ -93910,7 +93691,7 @@ var BABYLON;
          */
         url, 
         /**
-         * Defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * Defines the desired size (the more it increases the longer the generation will be)
          */
         size, 
         /**
@@ -93924,23 +93705,23 @@ var BABYLON;
         /**
          * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
          */
-        useInGammaSpace, 
+        gammaSpace, 
         /**
-         * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * Internal Use Only
          */
-        usePMREMGenerator) {
+        reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             var _this = _super.call(this, name) || this;
             _this.name = name;
             _this.url = url;
             _this.size = size;
             _this.noMipmap = noMipmap;
             _this.generateHarmonics = generateHarmonics;
-            _this.useInGammaSpace = useInGammaSpace;
-            _this.usePMREMGenerator = usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this.reserved = reserved;
             return _this;
         }
         /**
@@ -93956,7 +93737,7 @@ var BABYLON;
             var onerror = function (message, exception) {
                 onError(message, exception);
             };
-            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.useInGammaSpace, this.usePMREMGenerator, onload, onerror);
+            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.gammaSpace, this.reserved, onload, onerror);
         };
         return HDRCubeTextureAssetTask;
     }(AbstractAssetTask));
@@ -94081,16 +93862,16 @@ var BABYLON;
          * @param size defines the size you want for the cubemap (can be null)
          * @param noMipmap defines if the texture must not receive mipmaps (false by default)
          * @param generateHarmonics defines if you want to automatically generate (true by default)
-         * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
-         * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
          */
-        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator) {
+        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
-            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator);
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
+            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
             this._tasks.push(task);
             return task;
         };

+ 41 - 260
dist/preview release/babylon.no-module.max.js

@@ -64748,7 +64748,7 @@ var BABYLON;
             if (settings.loop !== undefined) {
                 _this.video.loop = settings.loop;
             }
-            _this.video.addEventListener("canplay", _this._createInternalTexture);
+            _this.video.addEventListener("canplaythrough", _this._createInternalTexture);
             _this.video.addEventListener("paused", _this._updateInternalTexture);
             _this.video.addEventListener("seeked", _this._updateInternalTexture);
             _this.video.addEventListener("emptied", _this.reset);
@@ -64827,7 +64827,7 @@ var BABYLON;
         };
         VideoTexture.prototype.dispose = function () {
             _super.prototype.dispose.call(this);
-            this.video.removeEventListener("canplay", this._createInternalTexture);
+            this.video.removeEventListener("canplaythrough", this._createInternalTexture);
             this.video.removeEventListener("paused", this._updateInternalTexture);
             this.video.removeEventListener("seeked", this._updateInternalTexture);
             this.video.removeEventListener("emptied", this.reset);
@@ -80649,34 +80649,27 @@ var BABYLON;
          *
          * @param url The location of the HDR raw data (Panorama stored in RGBE format)
          * @param scene The scene the texture will be used in
-         * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * @param size The cubemap desired size (the more it increases the longer the generation will be)
          * @param noMipmap Forces to not generate the mipmap if true
          * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
-         * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
-         * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
+         * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
+         * @param reserved Reserved flag for internal use.
          */
-        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator, onLoad, onError) {
+        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             if (onLoad === void 0) { onLoad = null; }
             if (onError === void 0) { onError = null; }
             var _this = _super.call(this, scene) || this;
-            _this._useInGammaSpace = false;
             _this._generateHarmonics = true;
-            _this._isBABYLONPreprocessed = false;
             _this._onLoad = null;
             _this._onError = null;
             /**
              * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
              */
             _this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
-            /**
-             * Specifies wether the texture has been generated through the PMREMGenerator tool.
-             * This is usefull at run time to apply the good shader.
-             */
-            _this.isPMREM = false;
             _this._isBlocking = true;
             _this._rotationY = 0;
             /**
@@ -80694,26 +80687,9 @@ var BABYLON;
             _this._textureMatrix = BABYLON.Matrix.Identity();
             _this._onLoad = onLoad;
             _this._onError = onError;
-            _this.gammaSpace = false;
-            var caps = scene.getEngine().getCaps();
-            if (size) {
-                _this._isBABYLONPreprocessed = false;
-                _this._noMipmap = noMipmap;
-                _this._size = size;
-                _this._useInGammaSpace = useInGammaSpace;
-                _this._usePMREMGenerator = usePMREMGenerator &&
-                    caps.textureLOD &&
-                    caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            else {
-                _this._isBABYLONPreprocessed = true;
-                _this._noMipmap = false;
-                _this._useInGammaSpace = false;
-                _this._usePMREMGenerator = caps.textureLOD && caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            _this.isPMREM = _this._usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this._noMipmap = noMipmap;
+            _this._size = size;
             _this._texture = _this._getFromCache(url, _this._noMipmap);
             if (!_this._texture) {
                 if (!scene.useDelayedTextureLoading) {
@@ -80782,129 +80758,9 @@ var BABYLON;
             configurable: true
         });
         /**
-         * Occurs when the file is a preprocessed .babylon.hdr file.
-         */
-        HDRCubeTexture.prototype.loadBabylonTexture = function () {
-            var _this = this;
-            var mipLevels = 0;
-            var floatArrayView = null;
-            var scene = this.getScene();
-            var mipmapGenerator = (!this._useInGammaSpace && scene && scene.getEngine().getCaps().textureFloat) ? function (data) {
-                var mips = new Array();
-                if (!floatArrayView) {
-                    return mips;
-                }
-                var startIndex = 30;
-                for (var level = 0; level < mipLevels; level++) {
-                    mips.push([]);
-                    // Fill each pixel of the mip level.
-                    var faceSize = Math.pow(_this._size >> level, 2) * 3;
-                    for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                        var faceData = floatArrayView.subarray(startIndex, startIndex + faceSize);
-                        mips[level].push(faceData);
-                        startIndex += faceSize;
-                    }
-                }
-                return mips;
-            } : null;
-            var callback = function (buffer) {
-                var scene = _this.getScene();
-                if (!scene) {
-                    return null;
-                }
-                // Create Native Array Views
-                var intArrayView = new Int32Array(buffer);
-                floatArrayView = new Float32Array(buffer);
-                // Fill header.
-                var version = intArrayView[0]; // Version 1. (MAy be use in case of format changes for backward compaibility)
-                _this._size = intArrayView[1]; // CubeMap max mip face size.
-                // Update Texture Information.
-                if (!_this._texture) {
-                    return null;
-                }
-                _this._texture.updateSize(_this._size, _this._size);
-                // Fill polynomial information.
-                var sphericalPolynomial = new BABYLON.SphericalPolynomial();
-                sphericalPolynomial.x.copyFromFloats(floatArrayView[2], floatArrayView[3], floatArrayView[4]);
-                sphericalPolynomial.y.copyFromFloats(floatArrayView[5], floatArrayView[6], floatArrayView[7]);
-                sphericalPolynomial.z.copyFromFloats(floatArrayView[8], floatArrayView[9], floatArrayView[10]);
-                sphericalPolynomial.xx.copyFromFloats(floatArrayView[11], floatArrayView[12], floatArrayView[13]);
-                sphericalPolynomial.yy.copyFromFloats(floatArrayView[14], floatArrayView[15], floatArrayView[16]);
-                sphericalPolynomial.zz.copyFromFloats(floatArrayView[17], floatArrayView[18], floatArrayView[19]);
-                sphericalPolynomial.xy.copyFromFloats(floatArrayView[20], floatArrayView[21], floatArrayView[22]);
-                sphericalPolynomial.yz.copyFromFloats(floatArrayView[23], floatArrayView[24], floatArrayView[25]);
-                sphericalPolynomial.zx.copyFromFloats(floatArrayView[26], floatArrayView[27], floatArrayView[28]);
-                _this.sphericalPolynomial = sphericalPolynomial;
-                // Fill pixel data.
-                mipLevels = intArrayView[29]; // Number of mip levels.
-                var startIndex = 30;
-                var data = [];
-                var faceSize = Math.pow(_this._size, 2) * 3;
-                for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                    data.push(floatArrayView.subarray(startIndex, startIndex + faceSize));
-                    startIndex += faceSize;
-                }
-                var results = [];
-                var byteArray = null;
-                // Push each faces.
-                for (var k = 0; k < 6; k++) {
-                    var dataFace = null;
-                    // To be deprecated.
-                    if (version === 1) {
-                        var j = ([0, 2, 4, 1, 3, 5])[k]; // Transforms +X+Y+Z... to +X-X+Y-Y...
-                        dataFace = data[j];
-                    }
-                    // If special cases.
-                    if (!mipmapGenerator && dataFace) {
-                        if (!scene.getEngine().getCaps().textureFloat) {
-                            // 3 channels of 1 bytes per pixel in bytes.
-                            var byteBuffer = new ArrayBuffer(faceSize);
-                            byteArray = new Uint8Array(byteBuffer);
-                        }
-                        for (var i = 0; i < _this._size * _this._size; i++) {
-                            // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
-                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
-                            }
-                            // Convert to int texture for fallback.
-                            if (byteArray) {
-                                var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
-                                var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
-                                var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
-                                // May use luminance instead if the result is not accurate.
-                                var max = Math.max(Math.max(r, g), b);
-                                if (max > 255) {
-                                    var scale = 255 / max;
-                                    r *= scale;
-                                    g *= scale;
-                                    b *= scale;
-                                }
-                                byteArray[(i * 3) + 0] = r;
-                                byteArray[(i * 3) + 1] = g;
-                                byteArray[(i * 3) + 2] = b;
-                            }
-                        }
-                    }
-                    // Fill the array accordingly.
-                    if (byteArray) {
-                        results.push(byteArray);
-                    }
-                    else {
-                        results.push(dataFace);
-                    }
-                }
-                return results;
-            };
-            if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
          * Occurs when the file is raw .hdr file.
          */
-        HDRCubeTexture.prototype.loadHDRTexture = function () {
+        HDRCubeTexture.prototype.loadTexture = function () {
             var _this = this;
             var callback = function (buffer) {
                 var scene = _this.getScene();
@@ -80930,10 +80786,10 @@ var BABYLON;
                     }
                     var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
                     // If special cases.
-                    if (_this._useInGammaSpace || byteArray) {
+                    if (_this.gammaSpace || byteArray) {
                         for (var i = 0; i < _this._size * _this._size; i++) {
                             // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
+                            if (_this.gammaSpace) {
                                 dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
@@ -80966,39 +80822,9 @@ var BABYLON;
                 }
                 return results;
             };
-            var mipmapGenerator = null;
-            // TODO. Implement In code PMREM Generator following the LYS toolset generation.
-            // if (!this._noMipmap &&
-            //     this._usePMREMGenerator) {
-            //     mipmapGenerator = (data: ArrayBufferView[]) => {
-            //         // Custom setup of the generator matching with the PBR shader values.
-            //         var generator = new BABYLON.PMREMGenerator(data,
-            //             this._size,
-            //             this._size,
-            //             0,
-            //             3,
-            //             this.getScene().getEngine().getCaps().textureFloat,
-            //             2048,
-            //             0.25,
-            //             false,
-            //             true);
-            //         return generator.filterCubeMap();
-            //     };
-            // }
             var scene = this.getScene();
             if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
-         * Starts the loading process of the texture.
-         */
-        HDRCubeTexture.prototype.loadTexture = function () {
-            if (this._isBABYLONPreprocessed) {
-                this.loadBabylonTexture();
-            }
-            else {
-                this.loadHDRTexture();
+                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, null, this._onLoad, this._onError);
             }
         };
         HDRCubeTexture.prototype.clone = function () {
@@ -81006,8 +80832,7 @@ var BABYLON;
             if (!scene) {
                 return this;
             }
-            var size = (this._isBABYLONPreprocessed ? null : this._size);
-            var newTexture = new HDRCubeTexture(this.url, scene, size, this._noMipmap, this._generateHarmonics, this._useInGammaSpace, this._usePMREMGenerator);
+            var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
             // Base texture
             newTexture.level = this.level;
             newTexture.wrapU = this.wrapU;
@@ -81036,8 +80861,7 @@ var BABYLON;
         HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = null;
             if (parsedTexture.name && !parsedTexture.isRenderTarget) {
-                var size = parsedTexture.isBABYLONPreprocessed ? null : parsedTexture.size;
-                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace, parsedTexture.usePMREMGenerator);
+                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
                 texture.name = parsedTexture.name;
                 texture.hasAlpha = parsedTexture.hasAlpha;
                 texture.level = parsedTexture.level;
@@ -81068,63 +80892,14 @@ var BABYLON;
             serializationObject.level = this.level;
             serializationObject.size = this._size;
             serializationObject.coordinatesMode = this.coordinatesMode;
-            serializationObject.useInGammaSpace = this._useInGammaSpace;
+            serializationObject.useInGammaSpace = this.gammaSpace;
             serializationObject.generateHarmonics = this._generateHarmonics;
-            serializationObject.usePMREMGenerator = this._usePMREMGenerator;
-            serializationObject.isBABYLONPreprocessed = this._isBABYLONPreprocessed;
             serializationObject.customType = "BABYLON.HDRCubeTexture";
             serializationObject.noMipmap = this._noMipmap;
             serializationObject.isBlocking = this._isBlocking;
             serializationObject.rotationY = this._rotationY;
             return serializationObject;
         };
-        /**
-         * Saves as a file the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDROnDisk = function (url, size, onError) {
-            if (onError === void 0) { onError = null; }
-            var callback = function (buffer) {
-                var data = new Blob([buffer], { type: 'application/octet-stream' });
-                // Returns a URL you can use as a href.
-                var objUrl = window.URL.createObjectURL(data);
-                // Simulates a link to it and click to dowload.
-                var a = document.createElement("a");
-                document.body.appendChild(a);
-                a.style.display = "none";
-                a.href = objUrl;
-                a.download = "envmap.babylon.hdr";
-                a.click();
-            };
-            HDRCubeTexture.generateBabylonHDR(url, size, callback, onError);
-        };
-        /**
-         * Serializes the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDR = function (url, size, callback, onError) {
-            if (onError === void 0) { onError = null; }
-            // Needs the url tho create the texture.
-            if (!url) {
-                return;
-            }
-            // Check Power of two size.
-            if (!BABYLON.Tools.IsExponentOfTwo(size)) { // Need to check engine.needPOTTextures 
-                return;
-            }
-            // Coming Back in 3.x.
-            BABYLON.Tools.Error("Generation of Babylon HDR is coming back in 3.2.");
-        };
         HDRCubeTexture._facesMapping = [
             "right",
             "left",
@@ -87586,6 +87361,12 @@ var BABYLON;
                 this._webvrViewMatrix.invert();
             }
             parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
+            // Compute global position
+            this._workingMatrix = this._workingMatrix || BABYLON.Matrix.Identity();
+            this._webvrViewMatrix.invertToRef(this._workingMatrix);
+            this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
+            this._workingMatrix.getTranslationToRef(this._globalPosition);
+            this._markSyncedWithParent();
             return this._webvrViewMatrix;
         };
         WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
@@ -93864,8 +93645,8 @@ var BABYLON;
          * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
          * @param noMipmap defines if mipmaps should not be generated (default is false)
          * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
-         * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
-         * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          */
         function HDRCubeTextureAssetTask(
         /**
@@ -93877,7 +93658,7 @@ var BABYLON;
          */
         url, 
         /**
-         * Defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * Defines the desired size (the more it increases the longer the generation will be)
          */
         size, 
         /**
@@ -93891,23 +93672,23 @@ var BABYLON;
         /**
          * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
          */
-        useInGammaSpace, 
+        gammaSpace, 
         /**
-         * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * Internal Use Only
          */
-        usePMREMGenerator) {
+        reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             var _this = _super.call(this, name) || this;
             _this.name = name;
             _this.url = url;
             _this.size = size;
             _this.noMipmap = noMipmap;
             _this.generateHarmonics = generateHarmonics;
-            _this.useInGammaSpace = useInGammaSpace;
-            _this.usePMREMGenerator = usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this.reserved = reserved;
             return _this;
         }
         /**
@@ -93923,7 +93704,7 @@ var BABYLON;
             var onerror = function (message, exception) {
                 onError(message, exception);
             };
-            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.useInGammaSpace, this.usePMREMGenerator, onload, onerror);
+            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.gammaSpace, this.reserved, onload, onerror);
         };
         return HDRCubeTextureAssetTask;
     }(AbstractAssetTask));
@@ -94048,16 +93829,16 @@ var BABYLON;
          * @param size defines the size you want for the cubemap (can be null)
          * @param noMipmap defines if the texture must not receive mipmaps (false by default)
          * @param generateHarmonics defines if you want to automatically generate (true by default)
-         * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
-         * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
          */
-        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator) {
+        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
-            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator);
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
+            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
             this._tasks.push(task);
             return task;
         };

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 10 - 10
dist/preview release/babylon.worker.js


+ 41 - 260
dist/preview release/es6.js

@@ -64748,7 +64748,7 @@ var BABYLON;
             if (settings.loop !== undefined) {
                 _this.video.loop = settings.loop;
             }
-            _this.video.addEventListener("canplay", _this._createInternalTexture);
+            _this.video.addEventListener("canplaythrough", _this._createInternalTexture);
             _this.video.addEventListener("paused", _this._updateInternalTexture);
             _this.video.addEventListener("seeked", _this._updateInternalTexture);
             _this.video.addEventListener("emptied", _this.reset);
@@ -64827,7 +64827,7 @@ var BABYLON;
         };
         VideoTexture.prototype.dispose = function () {
             _super.prototype.dispose.call(this);
-            this.video.removeEventListener("canplay", this._createInternalTexture);
+            this.video.removeEventListener("canplaythrough", this._createInternalTexture);
             this.video.removeEventListener("paused", this._updateInternalTexture);
             this.video.removeEventListener("seeked", this._updateInternalTexture);
             this.video.removeEventListener("emptied", this.reset);
@@ -80649,34 +80649,27 @@ var BABYLON;
          *
          * @param url The location of the HDR raw data (Panorama stored in RGBE format)
          * @param scene The scene the texture will be used in
-         * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * @param size The cubemap desired size (the more it increases the longer the generation will be)
          * @param noMipmap Forces to not generate the mipmap if true
          * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
-         * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
-         * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
+         * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
+         * @param reserved Reserved flag for internal use.
          */
-        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator, onLoad, onError) {
+        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             if (onLoad === void 0) { onLoad = null; }
             if (onError === void 0) { onError = null; }
             var _this = _super.call(this, scene) || this;
-            _this._useInGammaSpace = false;
             _this._generateHarmonics = true;
-            _this._isBABYLONPreprocessed = false;
             _this._onLoad = null;
             _this._onError = null;
             /**
              * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
              */
             _this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
-            /**
-             * Specifies wether the texture has been generated through the PMREMGenerator tool.
-             * This is usefull at run time to apply the good shader.
-             */
-            _this.isPMREM = false;
             _this._isBlocking = true;
             _this._rotationY = 0;
             /**
@@ -80694,26 +80687,9 @@ var BABYLON;
             _this._textureMatrix = BABYLON.Matrix.Identity();
             _this._onLoad = onLoad;
             _this._onError = onError;
-            _this.gammaSpace = false;
-            var caps = scene.getEngine().getCaps();
-            if (size) {
-                _this._isBABYLONPreprocessed = false;
-                _this._noMipmap = noMipmap;
-                _this._size = size;
-                _this._useInGammaSpace = useInGammaSpace;
-                _this._usePMREMGenerator = usePMREMGenerator &&
-                    caps.textureLOD &&
-                    caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            else {
-                _this._isBABYLONPreprocessed = true;
-                _this._noMipmap = false;
-                _this._useInGammaSpace = false;
-                _this._usePMREMGenerator = caps.textureLOD && caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            _this.isPMREM = _this._usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this._noMipmap = noMipmap;
+            _this._size = size;
             _this._texture = _this._getFromCache(url, _this._noMipmap);
             if (!_this._texture) {
                 if (!scene.useDelayedTextureLoading) {
@@ -80782,129 +80758,9 @@ var BABYLON;
             configurable: true
         });
         /**
-         * Occurs when the file is a preprocessed .babylon.hdr file.
-         */
-        HDRCubeTexture.prototype.loadBabylonTexture = function () {
-            var _this = this;
-            var mipLevels = 0;
-            var floatArrayView = null;
-            var scene = this.getScene();
-            var mipmapGenerator = (!this._useInGammaSpace && scene && scene.getEngine().getCaps().textureFloat) ? function (data) {
-                var mips = new Array();
-                if (!floatArrayView) {
-                    return mips;
-                }
-                var startIndex = 30;
-                for (var level = 0; level < mipLevels; level++) {
-                    mips.push([]);
-                    // Fill each pixel of the mip level.
-                    var faceSize = Math.pow(_this._size >> level, 2) * 3;
-                    for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                        var faceData = floatArrayView.subarray(startIndex, startIndex + faceSize);
-                        mips[level].push(faceData);
-                        startIndex += faceSize;
-                    }
-                }
-                return mips;
-            } : null;
-            var callback = function (buffer) {
-                var scene = _this.getScene();
-                if (!scene) {
-                    return null;
-                }
-                // Create Native Array Views
-                var intArrayView = new Int32Array(buffer);
-                floatArrayView = new Float32Array(buffer);
-                // Fill header.
-                var version = intArrayView[0]; // Version 1. (MAy be use in case of format changes for backward compaibility)
-                _this._size = intArrayView[1]; // CubeMap max mip face size.
-                // Update Texture Information.
-                if (!_this._texture) {
-                    return null;
-                }
-                _this._texture.updateSize(_this._size, _this._size);
-                // Fill polynomial information.
-                var sphericalPolynomial = new BABYLON.SphericalPolynomial();
-                sphericalPolynomial.x.copyFromFloats(floatArrayView[2], floatArrayView[3], floatArrayView[4]);
-                sphericalPolynomial.y.copyFromFloats(floatArrayView[5], floatArrayView[6], floatArrayView[7]);
-                sphericalPolynomial.z.copyFromFloats(floatArrayView[8], floatArrayView[9], floatArrayView[10]);
-                sphericalPolynomial.xx.copyFromFloats(floatArrayView[11], floatArrayView[12], floatArrayView[13]);
-                sphericalPolynomial.yy.copyFromFloats(floatArrayView[14], floatArrayView[15], floatArrayView[16]);
-                sphericalPolynomial.zz.copyFromFloats(floatArrayView[17], floatArrayView[18], floatArrayView[19]);
-                sphericalPolynomial.xy.copyFromFloats(floatArrayView[20], floatArrayView[21], floatArrayView[22]);
-                sphericalPolynomial.yz.copyFromFloats(floatArrayView[23], floatArrayView[24], floatArrayView[25]);
-                sphericalPolynomial.zx.copyFromFloats(floatArrayView[26], floatArrayView[27], floatArrayView[28]);
-                _this.sphericalPolynomial = sphericalPolynomial;
-                // Fill pixel data.
-                mipLevels = intArrayView[29]; // Number of mip levels.
-                var startIndex = 30;
-                var data = [];
-                var faceSize = Math.pow(_this._size, 2) * 3;
-                for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                    data.push(floatArrayView.subarray(startIndex, startIndex + faceSize));
-                    startIndex += faceSize;
-                }
-                var results = [];
-                var byteArray = null;
-                // Push each faces.
-                for (var k = 0; k < 6; k++) {
-                    var dataFace = null;
-                    // To be deprecated.
-                    if (version === 1) {
-                        var j = ([0, 2, 4, 1, 3, 5])[k]; // Transforms +X+Y+Z... to +X-X+Y-Y...
-                        dataFace = data[j];
-                    }
-                    // If special cases.
-                    if (!mipmapGenerator && dataFace) {
-                        if (!scene.getEngine().getCaps().textureFloat) {
-                            // 3 channels of 1 bytes per pixel in bytes.
-                            var byteBuffer = new ArrayBuffer(faceSize);
-                            byteArray = new Uint8Array(byteBuffer);
-                        }
-                        for (var i = 0; i < _this._size * _this._size; i++) {
-                            // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
-                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
-                            }
-                            // Convert to int texture for fallback.
-                            if (byteArray) {
-                                var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
-                                var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
-                                var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
-                                // May use luminance instead if the result is not accurate.
-                                var max = Math.max(Math.max(r, g), b);
-                                if (max > 255) {
-                                    var scale = 255 / max;
-                                    r *= scale;
-                                    g *= scale;
-                                    b *= scale;
-                                }
-                                byteArray[(i * 3) + 0] = r;
-                                byteArray[(i * 3) + 1] = g;
-                                byteArray[(i * 3) + 2] = b;
-                            }
-                        }
-                    }
-                    // Fill the array accordingly.
-                    if (byteArray) {
-                        results.push(byteArray);
-                    }
-                    else {
-                        results.push(dataFace);
-                    }
-                }
-                return results;
-            };
-            if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
          * Occurs when the file is raw .hdr file.
          */
-        HDRCubeTexture.prototype.loadHDRTexture = function () {
+        HDRCubeTexture.prototype.loadTexture = function () {
             var _this = this;
             var callback = function (buffer) {
                 var scene = _this.getScene();
@@ -80930,10 +80786,10 @@ var BABYLON;
                     }
                     var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
                     // If special cases.
-                    if (_this._useInGammaSpace || byteArray) {
+                    if (_this.gammaSpace || byteArray) {
                         for (var i = 0; i < _this._size * _this._size; i++) {
                             // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
+                            if (_this.gammaSpace) {
                                 dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
@@ -80966,39 +80822,9 @@ var BABYLON;
                 }
                 return results;
             };
-            var mipmapGenerator = null;
-            // TODO. Implement In code PMREM Generator following the LYS toolset generation.
-            // if (!this._noMipmap &&
-            //     this._usePMREMGenerator) {
-            //     mipmapGenerator = (data: ArrayBufferView[]) => {
-            //         // Custom setup of the generator matching with the PBR shader values.
-            //         var generator = new BABYLON.PMREMGenerator(data,
-            //             this._size,
-            //             this._size,
-            //             0,
-            //             3,
-            //             this.getScene().getEngine().getCaps().textureFloat,
-            //             2048,
-            //             0.25,
-            //             false,
-            //             true);
-            //         return generator.filterCubeMap();
-            //     };
-            // }
             var scene = this.getScene();
             if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
-         * Starts the loading process of the texture.
-         */
-        HDRCubeTexture.prototype.loadTexture = function () {
-            if (this._isBABYLONPreprocessed) {
-                this.loadBabylonTexture();
-            }
-            else {
-                this.loadHDRTexture();
+                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, null, this._onLoad, this._onError);
             }
         };
         HDRCubeTexture.prototype.clone = function () {
@@ -81006,8 +80832,7 @@ var BABYLON;
             if (!scene) {
                 return this;
             }
-            var size = (this._isBABYLONPreprocessed ? null : this._size);
-            var newTexture = new HDRCubeTexture(this.url, scene, size, this._noMipmap, this._generateHarmonics, this._useInGammaSpace, this._usePMREMGenerator);
+            var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
             // Base texture
             newTexture.level = this.level;
             newTexture.wrapU = this.wrapU;
@@ -81036,8 +80861,7 @@ var BABYLON;
         HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = null;
             if (parsedTexture.name && !parsedTexture.isRenderTarget) {
-                var size = parsedTexture.isBABYLONPreprocessed ? null : parsedTexture.size;
-                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace, parsedTexture.usePMREMGenerator);
+                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
                 texture.name = parsedTexture.name;
                 texture.hasAlpha = parsedTexture.hasAlpha;
                 texture.level = parsedTexture.level;
@@ -81068,63 +80892,14 @@ var BABYLON;
             serializationObject.level = this.level;
             serializationObject.size = this._size;
             serializationObject.coordinatesMode = this.coordinatesMode;
-            serializationObject.useInGammaSpace = this._useInGammaSpace;
+            serializationObject.useInGammaSpace = this.gammaSpace;
             serializationObject.generateHarmonics = this._generateHarmonics;
-            serializationObject.usePMREMGenerator = this._usePMREMGenerator;
-            serializationObject.isBABYLONPreprocessed = this._isBABYLONPreprocessed;
             serializationObject.customType = "BABYLON.HDRCubeTexture";
             serializationObject.noMipmap = this._noMipmap;
             serializationObject.isBlocking = this._isBlocking;
             serializationObject.rotationY = this._rotationY;
             return serializationObject;
         };
-        /**
-         * Saves as a file the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDROnDisk = function (url, size, onError) {
-            if (onError === void 0) { onError = null; }
-            var callback = function (buffer) {
-                var data = new Blob([buffer], { type: 'application/octet-stream' });
-                // Returns a URL you can use as a href.
-                var objUrl = window.URL.createObjectURL(data);
-                // Simulates a link to it and click to dowload.
-                var a = document.createElement("a");
-                document.body.appendChild(a);
-                a.style.display = "none";
-                a.href = objUrl;
-                a.download = "envmap.babylon.hdr";
-                a.click();
-            };
-            HDRCubeTexture.generateBabylonHDR(url, size, callback, onError);
-        };
-        /**
-         * Serializes the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDR = function (url, size, callback, onError) {
-            if (onError === void 0) { onError = null; }
-            // Needs the url tho create the texture.
-            if (!url) {
-                return;
-            }
-            // Check Power of two size.
-            if (!BABYLON.Tools.IsExponentOfTwo(size)) { // Need to check engine.needPOTTextures 
-                return;
-            }
-            // Coming Back in 3.x.
-            BABYLON.Tools.Error("Generation of Babylon HDR is coming back in 3.2.");
-        };
         HDRCubeTexture._facesMapping = [
             "right",
             "left",
@@ -87586,6 +87361,12 @@ var BABYLON;
                 this._webvrViewMatrix.invert();
             }
             parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
+            // Compute global position
+            this._workingMatrix = this._workingMatrix || BABYLON.Matrix.Identity();
+            this._webvrViewMatrix.invertToRef(this._workingMatrix);
+            this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
+            this._workingMatrix.getTranslationToRef(this._globalPosition);
+            this._markSyncedWithParent();
             return this._webvrViewMatrix;
         };
         WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
@@ -93864,8 +93645,8 @@ var BABYLON;
          * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
          * @param noMipmap defines if mipmaps should not be generated (default is false)
          * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
-         * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
-         * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          */
         function HDRCubeTextureAssetTask(
         /**
@@ -93877,7 +93658,7 @@ var BABYLON;
          */
         url, 
         /**
-         * Defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * Defines the desired size (the more it increases the longer the generation will be)
          */
         size, 
         /**
@@ -93891,23 +93672,23 @@ var BABYLON;
         /**
          * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
          */
-        useInGammaSpace, 
+        gammaSpace, 
         /**
-         * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * Internal Use Only
          */
-        usePMREMGenerator) {
+        reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             var _this = _super.call(this, name) || this;
             _this.name = name;
             _this.url = url;
             _this.size = size;
             _this.noMipmap = noMipmap;
             _this.generateHarmonics = generateHarmonics;
-            _this.useInGammaSpace = useInGammaSpace;
-            _this.usePMREMGenerator = usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this.reserved = reserved;
             return _this;
         }
         /**
@@ -93923,7 +93704,7 @@ var BABYLON;
             var onerror = function (message, exception) {
                 onError(message, exception);
             };
-            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.useInGammaSpace, this.usePMREMGenerator, onload, onerror);
+            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.gammaSpace, this.reserved, onload, onerror);
         };
         return HDRCubeTextureAssetTask;
     }(AbstractAssetTask));
@@ -94048,16 +93829,16 @@ var BABYLON;
          * @param size defines the size you want for the cubemap (can be null)
          * @param noMipmap defines if the texture must not receive mipmaps (false by default)
          * @param generateHarmonics defines if you want to automatically generate (true by default)
-         * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
-         * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
          */
-        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator) {
+        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
-            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator);
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
+            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
             this._tasks.push(task);
             return task;
         };

+ 2 - 25
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 4330,
+  "errors": 4325,
   "babylon.typedoc.json": {
-    "errors": 4330,
+    "errors": 4325,
     "Animatable": {
       "Class": {
         "Comments": {
@@ -6930,29 +6930,6 @@
               }
             }
           }
-        },
-        "generateBabylonHDR": {
-          "Naming": {
-            "NotPascalCase": true
-          },
-          "Comments": {
-            "UselessReturn": true
-          },
-          "Parameter": {
-            "callback": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "generateBabylonHDROnDisk": {
-          "Naming": {
-            "NotPascalCase": true
-          },
-          "Comments": {
-            "UselessReturn": true
-          }
         }
       }
     },

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 10 - 10
dist/preview release/viewer/babylon.viewer.js


+ 41 - 260
dist/preview release/viewer/babylon.viewer.max.js

@@ -64869,7 +64869,7 @@ var BABYLON;
             if (settings.loop !== undefined) {
                 _this.video.loop = settings.loop;
             }
-            _this.video.addEventListener("canplay", _this._createInternalTexture);
+            _this.video.addEventListener("canplaythrough", _this._createInternalTexture);
             _this.video.addEventListener("paused", _this._updateInternalTexture);
             _this.video.addEventListener("seeked", _this._updateInternalTexture);
             _this.video.addEventListener("emptied", _this.reset);
@@ -64948,7 +64948,7 @@ var BABYLON;
         };
         VideoTexture.prototype.dispose = function () {
             _super.prototype.dispose.call(this);
-            this.video.removeEventListener("canplay", this._createInternalTexture);
+            this.video.removeEventListener("canplaythrough", this._createInternalTexture);
             this.video.removeEventListener("paused", this._updateInternalTexture);
             this.video.removeEventListener("seeked", this._updateInternalTexture);
             this.video.removeEventListener("emptied", this.reset);
@@ -80770,34 +80770,27 @@ var BABYLON;
          *
          * @param url The location of the HDR raw data (Panorama stored in RGBE format)
          * @param scene The scene the texture will be used in
-         * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * @param size The cubemap desired size (the more it increases the longer the generation will be)
          * @param noMipmap Forces to not generate the mipmap if true
          * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
-         * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
-         * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
+         * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
+         * @param reserved Reserved flag for internal use.
          */
-        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator, onLoad, onError) {
+        function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             if (onLoad === void 0) { onLoad = null; }
             if (onError === void 0) { onError = null; }
             var _this = _super.call(this, scene) || this;
-            _this._useInGammaSpace = false;
             _this._generateHarmonics = true;
-            _this._isBABYLONPreprocessed = false;
             _this._onLoad = null;
             _this._onError = null;
             /**
              * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
              */
             _this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
-            /**
-             * Specifies wether the texture has been generated through the PMREMGenerator tool.
-             * This is usefull at run time to apply the good shader.
-             */
-            _this.isPMREM = false;
             _this._isBlocking = true;
             _this._rotationY = 0;
             /**
@@ -80815,26 +80808,9 @@ var BABYLON;
             _this._textureMatrix = BABYLON.Matrix.Identity();
             _this._onLoad = onLoad;
             _this._onError = onError;
-            _this.gammaSpace = false;
-            var caps = scene.getEngine().getCaps();
-            if (size) {
-                _this._isBABYLONPreprocessed = false;
-                _this._noMipmap = noMipmap;
-                _this._size = size;
-                _this._useInGammaSpace = useInGammaSpace;
-                _this._usePMREMGenerator = usePMREMGenerator &&
-                    caps.textureLOD &&
-                    caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            else {
-                _this._isBABYLONPreprocessed = true;
-                _this._noMipmap = false;
-                _this._useInGammaSpace = false;
-                _this._usePMREMGenerator = caps.textureLOD && caps.textureFloat &&
-                    !_this._useInGammaSpace;
-            }
-            _this.isPMREM = _this._usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this._noMipmap = noMipmap;
+            _this._size = size;
             _this._texture = _this._getFromCache(url, _this._noMipmap);
             if (!_this._texture) {
                 if (!scene.useDelayedTextureLoading) {
@@ -80903,129 +80879,9 @@ var BABYLON;
             configurable: true
         });
         /**
-         * Occurs when the file is a preprocessed .babylon.hdr file.
-         */
-        HDRCubeTexture.prototype.loadBabylonTexture = function () {
-            var _this = this;
-            var mipLevels = 0;
-            var floatArrayView = null;
-            var scene = this.getScene();
-            var mipmapGenerator = (!this._useInGammaSpace && scene && scene.getEngine().getCaps().textureFloat) ? function (data) {
-                var mips = new Array();
-                if (!floatArrayView) {
-                    return mips;
-                }
-                var startIndex = 30;
-                for (var level = 0; level < mipLevels; level++) {
-                    mips.push([]);
-                    // Fill each pixel of the mip level.
-                    var faceSize = Math.pow(_this._size >> level, 2) * 3;
-                    for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                        var faceData = floatArrayView.subarray(startIndex, startIndex + faceSize);
-                        mips[level].push(faceData);
-                        startIndex += faceSize;
-                    }
-                }
-                return mips;
-            } : null;
-            var callback = function (buffer) {
-                var scene = _this.getScene();
-                if (!scene) {
-                    return null;
-                }
-                // Create Native Array Views
-                var intArrayView = new Int32Array(buffer);
-                floatArrayView = new Float32Array(buffer);
-                // Fill header.
-                var version = intArrayView[0]; // Version 1. (MAy be use in case of format changes for backward compaibility)
-                _this._size = intArrayView[1]; // CubeMap max mip face size.
-                // Update Texture Information.
-                if (!_this._texture) {
-                    return null;
-                }
-                _this._texture.updateSize(_this._size, _this._size);
-                // Fill polynomial information.
-                var sphericalPolynomial = new BABYLON.SphericalPolynomial();
-                sphericalPolynomial.x.copyFromFloats(floatArrayView[2], floatArrayView[3], floatArrayView[4]);
-                sphericalPolynomial.y.copyFromFloats(floatArrayView[5], floatArrayView[6], floatArrayView[7]);
-                sphericalPolynomial.z.copyFromFloats(floatArrayView[8], floatArrayView[9], floatArrayView[10]);
-                sphericalPolynomial.xx.copyFromFloats(floatArrayView[11], floatArrayView[12], floatArrayView[13]);
-                sphericalPolynomial.yy.copyFromFloats(floatArrayView[14], floatArrayView[15], floatArrayView[16]);
-                sphericalPolynomial.zz.copyFromFloats(floatArrayView[17], floatArrayView[18], floatArrayView[19]);
-                sphericalPolynomial.xy.copyFromFloats(floatArrayView[20], floatArrayView[21], floatArrayView[22]);
-                sphericalPolynomial.yz.copyFromFloats(floatArrayView[23], floatArrayView[24], floatArrayView[25]);
-                sphericalPolynomial.zx.copyFromFloats(floatArrayView[26], floatArrayView[27], floatArrayView[28]);
-                _this.sphericalPolynomial = sphericalPolynomial;
-                // Fill pixel data.
-                mipLevels = intArrayView[29]; // Number of mip levels.
-                var startIndex = 30;
-                var data = [];
-                var faceSize = Math.pow(_this._size, 2) * 3;
-                for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                    data.push(floatArrayView.subarray(startIndex, startIndex + faceSize));
-                    startIndex += faceSize;
-                }
-                var results = [];
-                var byteArray = null;
-                // Push each faces.
-                for (var k = 0; k < 6; k++) {
-                    var dataFace = null;
-                    // To be deprecated.
-                    if (version === 1) {
-                        var j = ([0, 2, 4, 1, 3, 5])[k]; // Transforms +X+Y+Z... to +X-X+Y-Y...
-                        dataFace = data[j];
-                    }
-                    // If special cases.
-                    if (!mipmapGenerator && dataFace) {
-                        if (!scene.getEngine().getCaps().textureFloat) {
-                            // 3 channels of 1 bytes per pixel in bytes.
-                            var byteBuffer = new ArrayBuffer(faceSize);
-                            byteArray = new Uint8Array(byteBuffer);
-                        }
-                        for (var i = 0; i < _this._size * _this._size; i++) {
-                            // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
-                                dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
-                                dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
-                            }
-                            // Convert to int texture for fallback.
-                            if (byteArray) {
-                                var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
-                                var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
-                                var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
-                                // May use luminance instead if the result is not accurate.
-                                var max = Math.max(Math.max(r, g), b);
-                                if (max > 255) {
-                                    var scale = 255 / max;
-                                    r *= scale;
-                                    g *= scale;
-                                    b *= scale;
-                                }
-                                byteArray[(i * 3) + 0] = r;
-                                byteArray[(i * 3) + 1] = g;
-                                byteArray[(i * 3) + 2] = b;
-                            }
-                        }
-                    }
-                    // Fill the array accordingly.
-                    if (byteArray) {
-                        results.push(byteArray);
-                    }
-                    else {
-                        results.push(dataFace);
-                    }
-                }
-                return results;
-            };
-            if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
          * Occurs when the file is raw .hdr file.
          */
-        HDRCubeTexture.prototype.loadHDRTexture = function () {
+        HDRCubeTexture.prototype.loadTexture = function () {
             var _this = this;
             var callback = function (buffer) {
                 var scene = _this.getScene();
@@ -81051,10 +80907,10 @@ var BABYLON;
                     }
                     var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
                     // If special cases.
-                    if (_this._useInGammaSpace || byteArray) {
+                    if (_this.gammaSpace || byteArray) {
                         for (var i = 0; i < _this._size * _this._size; i++) {
                             // Put in gamma space if requested.
-                            if (_this._useInGammaSpace) {
+                            if (_this.gammaSpace) {
                                 dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], BABYLON.ToGammaSpace);
                                 dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], BABYLON.ToGammaSpace);
@@ -81087,39 +80943,9 @@ var BABYLON;
                 }
                 return results;
             };
-            var mipmapGenerator = null;
-            // TODO. Implement In code PMREM Generator following the LYS toolset generation.
-            // if (!this._noMipmap &&
-            //     this._usePMREMGenerator) {
-            //     mipmapGenerator = (data: ArrayBufferView[]) => {
-            //         // Custom setup of the generator matching with the PBR shader values.
-            //         var generator = new BABYLON.PMREMGenerator(data,
-            //             this._size,
-            //             this._size,
-            //             0,
-            //             3,
-            //             this.getScene().getEngine().getCaps().textureFloat,
-            //             2048,
-            //             0.25,
-            //             false,
-            //             true);
-            //         return generator.filterCubeMap();
-            //     };
-            // }
             var scene = this.getScene();
             if (scene) {
-                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, mipmapGenerator, this._onLoad, this._onError);
-            }
-        };
-        /**
-         * Starts the loading process of the texture.
-         */
-        HDRCubeTexture.prototype.loadTexture = function () {
-            if (this._isBABYLONPreprocessed) {
-                this.loadBabylonTexture();
-            }
-            else {
-                this.loadHDRTexture();
+                this._texture = scene.getEngine().createRawCubeTextureFromUrl(this.url, scene, this._size, BABYLON.Engine.TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT, this._noMipmap, callback, null, this._onLoad, this._onError);
             }
         };
         HDRCubeTexture.prototype.clone = function () {
@@ -81127,8 +80953,7 @@ var BABYLON;
             if (!scene) {
                 return this;
             }
-            var size = (this._isBABYLONPreprocessed ? null : this._size);
-            var newTexture = new HDRCubeTexture(this.url, scene, size, this._noMipmap, this._generateHarmonics, this._useInGammaSpace, this._usePMREMGenerator);
+            var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
             // Base texture
             newTexture.level = this.level;
             newTexture.wrapU = this.wrapU;
@@ -81157,8 +80982,7 @@ var BABYLON;
         HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = null;
             if (parsedTexture.name && !parsedTexture.isRenderTarget) {
-                var size = parsedTexture.isBABYLONPreprocessed ? null : parsedTexture.size;
-                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace, parsedTexture.usePMREMGenerator);
+                texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
                 texture.name = parsedTexture.name;
                 texture.hasAlpha = parsedTexture.hasAlpha;
                 texture.level = parsedTexture.level;
@@ -81189,63 +81013,14 @@ var BABYLON;
             serializationObject.level = this.level;
             serializationObject.size = this._size;
             serializationObject.coordinatesMode = this.coordinatesMode;
-            serializationObject.useInGammaSpace = this._useInGammaSpace;
+            serializationObject.useInGammaSpace = this.gammaSpace;
             serializationObject.generateHarmonics = this._generateHarmonics;
-            serializationObject.usePMREMGenerator = this._usePMREMGenerator;
-            serializationObject.isBABYLONPreprocessed = this._isBABYLONPreprocessed;
             serializationObject.customType = "BABYLON.HDRCubeTexture";
             serializationObject.noMipmap = this._noMipmap;
             serializationObject.isBlocking = this._isBlocking;
             serializationObject.rotationY = this._rotationY;
             return serializationObject;
         };
-        /**
-         * Saves as a file the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDROnDisk = function (url, size, onError) {
-            if (onError === void 0) { onError = null; }
-            var callback = function (buffer) {
-                var data = new Blob([buffer], { type: 'application/octet-stream' });
-                // Returns a URL you can use as a href.
-                var objUrl = window.URL.createObjectURL(data);
-                // Simulates a link to it and click to dowload.
-                var a = document.createElement("a");
-                document.body.appendChild(a);
-                a.style.display = "none";
-                a.href = objUrl;
-                a.download = "envmap.babylon.hdr";
-                a.click();
-            };
-            HDRCubeTexture.generateBabylonHDR(url, size, callback, onError);
-        };
-        /**
-         * Serializes the data contained in the texture in a binary format.
-         * This can be used to prevent the long loading tie associated with creating the seamless texture as well
-         * as the spherical used in the lighting.
-         * @param url The HDR file url.
-         * @param size The size of the texture data to generate (one of the cubemap face desired width).
-         * @param onError Method called if any error happens during download.
-         * @return The packed binary data.
-         */
-        HDRCubeTexture.generateBabylonHDR = function (url, size, callback, onError) {
-            if (onError === void 0) { onError = null; }
-            // Needs the url tho create the texture.
-            if (!url) {
-                return;
-            }
-            // Check Power of two size.
-            if (!BABYLON.Tools.IsExponentOfTwo(size)) { // Need to check engine.needPOTTextures 
-                return;
-            }
-            // Coming Back in 3.x.
-            BABYLON.Tools.Error("Generation of Babylon HDR is coming back in 3.2.");
-        };
         HDRCubeTexture._facesMapping = [
             "right",
             "left",
@@ -87707,6 +87482,12 @@ var BABYLON;
                 this._webvrViewMatrix.invert();
             }
             parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
+            // Compute global position
+            this._workingMatrix = this._workingMatrix || BABYLON.Matrix.Identity();
+            this._webvrViewMatrix.invertToRef(this._workingMatrix);
+            this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
+            this._workingMatrix.getTranslationToRef(this._globalPosition);
+            this._markSyncedWithParent();
             return this._webvrViewMatrix;
         };
         WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
@@ -93985,8 +93766,8 @@ var BABYLON;
          * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
          * @param noMipmap defines if mipmaps should not be generated (default is false)
          * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
-         * @param useInGammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
-         * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          */
         function HDRCubeTextureAssetTask(
         /**
@@ -93998,7 +93779,7 @@ var BABYLON;
          */
         url, 
         /**
-         * Defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
+         * Defines the desired size (the more it increases the longer the generation will be)
          */
         size, 
         /**
@@ -94012,23 +93793,23 @@ var BABYLON;
         /**
          * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
          */
-        useInGammaSpace, 
+        gammaSpace, 
         /**
-         * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
+         * Internal Use Only
          */
-        usePMREMGenerator) {
+        reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
             var _this = _super.call(this, name) || this;
             _this.name = name;
             _this.url = url;
             _this.size = size;
             _this.noMipmap = noMipmap;
             _this.generateHarmonics = generateHarmonics;
-            _this.useInGammaSpace = useInGammaSpace;
-            _this.usePMREMGenerator = usePMREMGenerator;
+            _this.gammaSpace = gammaSpace;
+            _this.reserved = reserved;
             return _this;
         }
         /**
@@ -94044,7 +93825,7 @@ var BABYLON;
             var onerror = function (message, exception) {
                 onError(message, exception);
             };
-            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.useInGammaSpace, this.usePMREMGenerator, onload, onerror);
+            this.texture = new BABYLON.HDRCubeTexture(this.url, scene, this.size, this.noMipmap, this.generateHarmonics, this.gammaSpace, this.reserved, onload, onerror);
         };
         return HDRCubeTextureAssetTask;
     }(AbstractAssetTask));
@@ -94169,16 +93950,16 @@ var BABYLON;
          * @param size defines the size you want for the cubemap (can be null)
          * @param noMipmap defines if the texture must not receive mipmaps (false by default)
          * @param generateHarmonics defines if you want to automatically generate (true by default)
-         * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
-         * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
+         * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
+         * @param reserved Internal use only
          * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
          */
-        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator) {
+        AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
             if (noMipmap === void 0) { noMipmap = false; }
             if (generateHarmonics === void 0) { generateHarmonics = true; }
-            if (useInGammaSpace === void 0) { useInGammaSpace = false; }
-            if (usePMREMGenerator === void 0) { usePMREMGenerator = false; }
-            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, useInGammaSpace, usePMREMGenerator);
+            if (gammaSpace === void 0) { gammaSpace = false; }
+            if (reserved === void 0) { reserved = false; }
+            var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
             this._tasks.push(task);
             return task;
         };

+ 2 - 2
src/Materials/Textures/babylon.videoTexture.ts

@@ -75,7 +75,7 @@
                 this.video.loop = settings.loop;
             }
 
-            this.video.addEventListener("canplay", this._createInternalTexture);
+            this.video.addEventListener("canplaythrough", this._createInternalTexture);
             this.video.addEventListener("paused", this._updateInternalTexture);
             this.video.addEventListener("seeked", this._updateInternalTexture);
             this.video.addEventListener("emptied", this.reset);
@@ -212,7 +212,7 @@
 
         public dispose(): void {
             super.dispose();            
-            this.video.removeEventListener("canplay", this._createInternalTexture);
+            this.video.removeEventListener("canplaythrough", this._createInternalTexture);
             this.video.removeEventListener("paused", this._updateInternalTexture);
             this.video.removeEventListener("seeked", this._updateInternalTexture);
             this.video.removeEventListener("emptied", this.reset);