David Catuhe 7 years ago
parent
commit
e5b7355af5

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


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


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


+ 55 - 43
dist/preview release/babylon.max.js

@@ -54109,32 +54109,6 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
-    var getName = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src.currentSrc;
-        }
-        if (typeof src === "object") {
-            return src.toString();
-        }
-        return src;
-    };
-    var getVideo = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src;
-        }
-        var video = document.createElement("video");
-        if (typeof src === "string") {
-            video.src = src;
-        }
-        else {
-            src.forEach(function (url) {
-                var source = document.createElement("source");
-                source.src = url;
-                video.appendChild(source);
-            });
-        }
-        return video;
-    };
     var VideoTexture = /** @class */ (function (_super) {
         __extends(VideoTexture, _super);
         /**
@@ -54197,8 +54171,8 @@ var BABYLON;
             _this._generateMipMaps = generateMipMaps;
             _this._samplingMode = samplingMode;
             _this.autoUpdateTexture = settings.autoUpdateTexture;
-            _this.name = name || getName(src);
-            _this.video = getVideo(src);
+            _this.name = name || _this._getName(src);
+            _this.video = _this._getVideo(src);
             if (settings.autoPlay !== undefined) {
                 _this.video.autoplay = settings.autoPlay;
             }
@@ -54214,6 +54188,34 @@ var BABYLON;
             }
             return _this;
         }
+        VideoTexture.prototype._getName = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src.currentSrc;
+            }
+            if (typeof src === "object") {
+                return src.toString();
+            }
+            return src;
+        };
+        ;
+        VideoTexture.prototype._getVideo = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src;
+            }
+            var video = document.createElement("video");
+            if (typeof src === "string") {
+                video.src = src;
+            }
+            else {
+                src.forEach(function (url) {
+                    var source = document.createElement("source");
+                    source.src = url;
+                    video.appendChild(source);
+                });
+            }
+            return video;
+        };
+        ;
         /**
          * Internal method to initiate `update`.
          */
@@ -72205,10 +72207,10 @@ var BABYLON;
     var off_pfFlags = 20;
     var off_pfFourCC = 21;
     var off_RGBbpp = 22;
-    // var off_RMask = 23;
-    // var off_GMask = 24;
-    // var off_BMask = 25;
-    // var off_AMask = 26;
+    var off_RMask = 23;
+    var off_GMask = 24;
+    var off_BMask = 25;
+    var off_AMask = 26;
     // var off_caps1 = 27;
     var off_caps2 = 28;
     // var off_caps3 = 29;
@@ -72402,32 +72404,38 @@ var BABYLON;
             }
             return destArray;
         };
-        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 4;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
-                    byteArray[index + 3] = srcData[srcPos + 3];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
+                    byteArray[index + 3] = srcData[srcPos + aOffset];
                     index += 4;
                 }
             }
             return byteArray;
         };
-        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._ExtractLongWordOrder = function (value) {
+            if (value === 255 || value === -16777216) {
+                return 0;
+            }
+            return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
+        };
+        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 3;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
                     index += 3;
                 }
             }
@@ -72515,6 +72523,10 @@ var BABYLON;
                         return;
                 }
             }
+            var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
+            var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
+            var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
+            var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
             if (computeFormats) {
                 format = engine._getWebGLTextureType(info.textureType);
                 internalFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
@@ -72566,12 +72578,12 @@ var BABYLON;
                         else if (info.isRGB) {
                             if (bpp === 24) {
                                 dataLength = width * height * 3;
-                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGB, width, height, gl.RGB, gl.UNSIGNED_BYTE, byteArray);
                             }
                             else {
                                 dataLength = width * height * 4;
-                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGBA, width, height, gl.RGBA, gl.UNSIGNED_BYTE, byteArray);
                             }
                         }

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


File diff suppressed because it is too large
+ 12274 - 12271
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


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


+ 55 - 46
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -53903,32 +53903,6 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
-    var getName = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src.currentSrc;
-        }
-        if (typeof src === "object") {
-            return src.toString();
-        }
-        return src;
-    };
-    var getVideo = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src;
-        }
-        var video = document.createElement("video");
-        if (typeof src === "string") {
-            video.src = src;
-        }
-        else {
-            src.forEach(function (url) {
-                var source = document.createElement("source");
-                source.src = url;
-                video.appendChild(source);
-            });
-        }
-        return video;
-    };
     var VideoTexture = /** @class */ (function (_super) {
         __extends(VideoTexture, _super);
         /**
@@ -53991,8 +53965,8 @@ var BABYLON;
             _this._generateMipMaps = generateMipMaps;
             _this._samplingMode = samplingMode;
             _this.autoUpdateTexture = settings.autoUpdateTexture;
-            _this.name = name || getName(src);
-            _this.video = getVideo(src);
+            _this.name = name || _this._getName(src);
+            _this.video = _this._getVideo(src);
             if (settings.autoPlay !== undefined) {
                 _this.video.autoplay = settings.autoPlay;
             }
@@ -54008,6 +53982,34 @@ var BABYLON;
             }
             return _this;
         }
+        VideoTexture.prototype._getName = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src.currentSrc;
+            }
+            if (typeof src === "object") {
+                return src.toString();
+            }
+            return src;
+        };
+        ;
+        VideoTexture.prototype._getVideo = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src;
+            }
+            var video = document.createElement("video");
+            if (typeof src === "string") {
+                video.src = src;
+            }
+            else {
+                src.forEach(function (url) {
+                    var source = document.createElement("source");
+                    source.src = url;
+                    video.appendChild(source);
+                });
+            }
+            return video;
+        };
+        ;
         /**
          * Internal method to initiate `update`.
          */
@@ -71999,10 +72001,10 @@ var BABYLON;
     var off_pfFlags = 20;
     var off_pfFourCC = 21;
     var off_RGBbpp = 22;
-    // var off_RMask = 23;
-    // var off_GMask = 24;
-    // var off_BMask = 25;
-    // var off_AMask = 26;
+    var off_RMask = 23;
+    var off_GMask = 24;
+    var off_BMask = 25;
+    var off_AMask = 26;
     // var off_caps1 = 27;
     var off_caps2 = 28;
     // var off_caps3 = 29;
@@ -72196,32 +72198,38 @@ var BABYLON;
             }
             return destArray;
         };
-        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 4;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
-                    byteArray[index + 3] = srcData[srcPos + 3];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
+                    byteArray[index + 3] = srcData[srcPos + aOffset];
                     index += 4;
                 }
             }
             return byteArray;
         };
-        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._ExtractLongWordOrder = function (value) {
+            if (value === 255 || value === -16777216) {
+                return 0;
+            }
+            return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
+        };
+        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 3;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
                     index += 3;
                 }
             }
@@ -72309,6 +72317,10 @@ var BABYLON;
                         return;
                 }
             }
+            var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
+            var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
+            var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
+            var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
             if (computeFormats) {
                 format = engine._getWebGLTextureType(info.textureType);
                 internalFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
@@ -72360,12 +72372,12 @@ var BABYLON;
                         else if (info.isRGB) {
                             if (bpp === 24) {
                                 dataLength = width * height * 3;
-                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGB, width, height, gl.RGB, gl.UNSIGNED_BYTE, byteArray);
                             }
                             else {
                                 dataLength = width * height * 4;
-                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGBA, width, height, gl.RGBA, gl.UNSIGNED_BYTE, byteArray);
                             }
                         }
@@ -87635,9 +87647,6 @@ var BABYLON;
                     });
                 });
                 this._requests.push(request);
-                request.onCompleteObservable.add(function () {
-                    _this._requests.splice(_this._requests.indexOf(request), 1);
-                });
             };
             GLTFLoader.prototype._tryCatchOnError = function (handler) {
                 if (this._disposed) {

+ 55 - 46
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -53889,32 +53889,6 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
-    var getName = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src.currentSrc;
-        }
-        if (typeof src === "object") {
-            return src.toString();
-        }
-        return src;
-    };
-    var getVideo = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src;
-        }
-        var video = document.createElement("video");
-        if (typeof src === "string") {
-            video.src = src;
-        }
-        else {
-            src.forEach(function (url) {
-                var source = document.createElement("source");
-                source.src = url;
-                video.appendChild(source);
-            });
-        }
-        return video;
-    };
     var VideoTexture = /** @class */ (function (_super) {
         __extends(VideoTexture, _super);
         /**
@@ -53977,8 +53951,8 @@ var BABYLON;
             _this._generateMipMaps = generateMipMaps;
             _this._samplingMode = samplingMode;
             _this.autoUpdateTexture = settings.autoUpdateTexture;
-            _this.name = name || getName(src);
-            _this.video = getVideo(src);
+            _this.name = name || _this._getName(src);
+            _this.video = _this._getVideo(src);
             if (settings.autoPlay !== undefined) {
                 _this.video.autoplay = settings.autoPlay;
             }
@@ -53994,6 +53968,34 @@ var BABYLON;
             }
             return _this;
         }
+        VideoTexture.prototype._getName = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src.currentSrc;
+            }
+            if (typeof src === "object") {
+                return src.toString();
+            }
+            return src;
+        };
+        ;
+        VideoTexture.prototype._getVideo = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src;
+            }
+            var video = document.createElement("video");
+            if (typeof src === "string") {
+                video.src = src;
+            }
+            else {
+                src.forEach(function (url) {
+                    var source = document.createElement("source");
+                    source.src = url;
+                    video.appendChild(source);
+                });
+            }
+            return video;
+        };
+        ;
         /**
          * Internal method to initiate `update`.
          */
@@ -71985,10 +71987,10 @@ var BABYLON;
     var off_pfFlags = 20;
     var off_pfFourCC = 21;
     var off_RGBbpp = 22;
-    // var off_RMask = 23;
-    // var off_GMask = 24;
-    // var off_BMask = 25;
-    // var off_AMask = 26;
+    var off_RMask = 23;
+    var off_GMask = 24;
+    var off_BMask = 25;
+    var off_AMask = 26;
     // var off_caps1 = 27;
     var off_caps2 = 28;
     // var off_caps3 = 29;
@@ -72182,32 +72184,38 @@ var BABYLON;
             }
             return destArray;
         };
-        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 4;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
-                    byteArray[index + 3] = srcData[srcPos + 3];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
+                    byteArray[index + 3] = srcData[srcPos + aOffset];
                     index += 4;
                 }
             }
             return byteArray;
         };
-        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._ExtractLongWordOrder = function (value) {
+            if (value === 255 || value === -16777216) {
+                return 0;
+            }
+            return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
+        };
+        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 3;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
                     index += 3;
                 }
             }
@@ -72295,6 +72303,10 @@ var BABYLON;
                         return;
                 }
             }
+            var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
+            var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
+            var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
+            var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
             if (computeFormats) {
                 format = engine._getWebGLTextureType(info.textureType);
                 internalFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
@@ -72346,12 +72358,12 @@ var BABYLON;
                         else if (info.isRGB) {
                             if (bpp === 24) {
                                 dataLength = width * height * 3;
-                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGB, width, height, gl.RGB, gl.UNSIGNED_BYTE, byteArray);
                             }
                             else {
                                 dataLength = width * height * 4;
-                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGBA, width, height, gl.RGBA, gl.UNSIGNED_BYTE, byteArray);
                             }
                         }
@@ -87621,9 +87633,6 @@ var BABYLON;
                     });
                 });
                 this._requests.push(request);
-                request.onCompleteObservable.add(function () {
-                    _this._requests.splice(_this._requests.indexOf(request), 1);
-                });
             };
             GLTFLoader.prototype._tryCatchOnError = function (handler) {
                 if (this._disposed) {

+ 55 - 43
dist/preview release/es6.js

@@ -54095,32 +54095,6 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
-    var getName = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src.currentSrc;
-        }
-        if (typeof src === "object") {
-            return src.toString();
-        }
-        return src;
-    };
-    var getVideo = function (src) {
-        if (src instanceof HTMLVideoElement) {
-            return src;
-        }
-        var video = document.createElement("video");
-        if (typeof src === "string") {
-            video.src = src;
-        }
-        else {
-            src.forEach(function (url) {
-                var source = document.createElement("source");
-                source.src = url;
-                video.appendChild(source);
-            });
-        }
-        return video;
-    };
     var VideoTexture = /** @class */ (function (_super) {
         __extends(VideoTexture, _super);
         /**
@@ -54183,8 +54157,8 @@ var BABYLON;
             _this._generateMipMaps = generateMipMaps;
             _this._samplingMode = samplingMode;
             _this.autoUpdateTexture = settings.autoUpdateTexture;
-            _this.name = name || getName(src);
-            _this.video = getVideo(src);
+            _this.name = name || _this._getName(src);
+            _this.video = _this._getVideo(src);
             if (settings.autoPlay !== undefined) {
                 _this.video.autoplay = settings.autoPlay;
             }
@@ -54200,6 +54174,34 @@ var BABYLON;
             }
             return _this;
         }
+        VideoTexture.prototype._getName = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src.currentSrc;
+            }
+            if (typeof src === "object") {
+                return src.toString();
+            }
+            return src;
+        };
+        ;
+        VideoTexture.prototype._getVideo = function (src) {
+            if (src instanceof HTMLVideoElement) {
+                return src;
+            }
+            var video = document.createElement("video");
+            if (typeof src === "string") {
+                video.src = src;
+            }
+            else {
+                src.forEach(function (url) {
+                    var source = document.createElement("source");
+                    source.src = url;
+                    video.appendChild(source);
+                });
+            }
+            return video;
+        };
+        ;
         /**
          * Internal method to initiate `update`.
          */
@@ -72191,10 +72193,10 @@ var BABYLON;
     var off_pfFlags = 20;
     var off_pfFourCC = 21;
     var off_RGBbpp = 22;
-    // var off_RMask = 23;
-    // var off_GMask = 24;
-    // var off_BMask = 25;
-    // var off_AMask = 26;
+    var off_RMask = 23;
+    var off_GMask = 24;
+    var off_BMask = 25;
+    var off_AMask = 26;
     // var off_caps1 = 27;
     var off_caps2 = 28;
     // var off_caps3 = 29;
@@ -72388,32 +72390,38 @@ var BABYLON;
             }
             return destArray;
         };
-        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 4;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
-                    byteArray[index + 3] = srcData[srcPos + 3];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
+                    byteArray[index + 3] = srcData[srcPos + aOffset];
                     index += 4;
                 }
             }
             return byteArray;
         };
-        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
+        DDSTools._ExtractLongWordOrder = function (value) {
+            if (value === 255 || value === -16777216) {
+                return 0;
+            }
+            return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
+        };
+        DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 3;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
                     index += 3;
                 }
             }
@@ -72501,6 +72509,10 @@ var BABYLON;
                         return;
                 }
             }
+            var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
+            var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
+            var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
+            var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
             if (computeFormats) {
                 format = engine._getWebGLTextureType(info.textureType);
                 internalFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
@@ -72552,12 +72564,12 @@ var BABYLON;
                         else if (info.isRGB) {
                             if (bpp === 24) {
                                 dataLength = width * height * 3;
-                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGB, width, height, gl.RGB, gl.UNSIGNED_BYTE, byteArray);
                             }
                             else {
                                 dataLength = width * height * 4;
-                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGBA, width, height, gl.RGBA, gl.UNSIGNED_BYTE, byteArray);
                             }
                         }

+ 0 - 3
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -1891,9 +1891,6 @@ var BABYLON;
                     });
                 });
                 this._requests.push(request);
-                request.onCompleteObservable.add(function () {
-                    _this._requests.splice(_this._requests.indexOf(request), 1);
-                });
             };
             GLTFLoader.prototype._tryCatchOnError = function (handler) {
                 if (this._disposed) {

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


+ 0 - 3
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -4057,9 +4057,6 @@ var BABYLON;
                     });
                 });
                 this._requests.push(request);
-                request.onCompleteObservable.add(function () {
-                    _this._requests.splice(_this._requests.indexOf(request), 1);
-                });
             };
             GLTFLoader.prototype._tryCatchOnError = function (handler) {
                 if (this._disposed) {

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


+ 0 - 3
dist/preview release/loaders/babylonjs.loaders.js

@@ -5031,9 +5031,6 @@ var BABYLON;
                     });
                 });
                 this._requests.push(request);
-                request.onCompleteObservable.add(function () {
-                    _this._requests.splice(_this._requests.indexOf(request), 1);
-                });
             };
             GLTFLoader.prototype._tryCatchOnError = function (handler) {
                 if (this._disposed) {

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


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


+ 1 - 0
dist/preview release/what's new.md

@@ -9,6 +9,7 @@
 
 ## Updates
 - Tons of functions and classes received the code comments they deserved (All the community)
+- Added support for all RGBA orders (BGR, RGB, etc..) for the DDS loader ([deltakosh](https://github.com/deltakosh))
 - Improved [SceneOptimizer](http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer) to provide better adapatability ([deltakosh](https://github.com/deltakosh))
 - Improved `scene.isReady()` function which now takes in account shadows and LOD ([deltakosh](https://github.com/deltakosh))
 - New watcher configuration for VSCode. Now the task only compiles changed files ([sebavan](https://github.com/sebavan))

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

@@ -19,35 +19,6 @@
         autoUpdateTexture: boolean;
     }
 
-    const getName = (src: string | string[] | HTMLVideoElement): string => {
-        if (src instanceof HTMLVideoElement) {
-            return src.currentSrc;
-        }
-
-        if (typeof src === "object") {
-            return src.toString();
-        }
-
-        return src;
-    };
-
-    const getVideo = (src: string | string[] | HTMLVideoElement): HTMLVideoElement => {
-        if (src instanceof HTMLVideoElement) {
-            return src;
-        }
-        const video: HTMLVideoElement = document.createElement("video");
-        if (typeof src === "string") {
-            video.src = src;
-        } else {
-            src.forEach(url => {
-                const source = document.createElement("source");
-                source.src = url;
-                video.appendChild(source);
-            });
-        }
-        return video;
-    };
-
     export class VideoTexture extends Texture {
         /**
          * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
@@ -93,8 +64,8 @@
             this._samplingMode = samplingMode;
             this.autoUpdateTexture = settings.autoUpdateTexture;
 
-            this.name = name || getName(src);
-            this.video = getVideo(src);
+            this.name = name || this._getName(src);
+            this.video = this._getVideo(src);
 
             if (settings.autoPlay !== undefined) {
                 this.video.autoplay = settings.autoPlay;
@@ -113,6 +84,35 @@
             }
         }
 
+        private _getName(src: string | string[] | HTMLVideoElement): string {
+            if (src instanceof HTMLVideoElement) {
+                return src.currentSrc;
+            }
+    
+            if (typeof src === "object") {
+                return src.toString();
+            }
+    
+            return src;
+        };
+    
+        private _getVideo(src: string | string[] | HTMLVideoElement): HTMLVideoElement {
+            if (src instanceof HTMLVideoElement) {
+                return src;
+            }
+            const video: HTMLVideoElement = document.createElement("video");
+            if (typeof src === "string") {
+                video.src = src;
+            } else {
+                src.forEach(url => {
+                    const source = document.createElement("source");
+                    source.src = url;
+                    video.appendChild(source);
+                });
+            }
+            return video;
+        };
+
         private _createInternalTexture = (): void => {
             if (this._texture != null) {
                 return;

+ 16 - 0
src/Mesh/babylon.geometry.ts

@@ -776,6 +776,13 @@
                 }
             }
 
+            if (this.isVerticesDataPresent(VertexBuffer.TangentKind)) {
+                serializationObject.tangets = this.toNumberArray(this.getVerticesData(VertexBuffer.TangentKind));
+                if (this.isVertexBufferUpdatable(VertexBuffer.TangentKind)) {
+                    serializationObject.tangets._updatable = true;
+                }
+            }            
+
             if (this.isVerticesDataPresent(VertexBuffer.UVKind)) {
                 serializationObject.uvs = this.toNumberArray(this.getVerticesData(VertexBuffer.UVKind));
                 if (this.isVertexBufferUpdatable(VertexBuffer.UVKind)) {
@@ -890,6 +897,11 @@
                     mesh.setVerticesData(VertexBuffer.NormalKind, normalsData, false);
                 }
 
+                if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
+                    var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
+                    mesh.setVerticesData(VertexBuffer.TangentKind, tangentsData, false);
+                }                
+
                 if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
                     var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
                     mesh.setVerticesData(VertexBuffer.UVKind, uvsData, false);
@@ -959,6 +971,10 @@
 
                 mesh.setVerticesData(VertexBuffer.NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
 
+                if (parsedGeometry.tangents) {
+                    mesh.setVerticesData(VertexBuffer.TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
+                }                
+
                 if (parsedGeometry.uvs) {
                     mesh.setVerticesData(VertexBuffer.UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
                 }

+ 30 - 15
src/Tools/babylon.dds.ts

@@ -76,10 +76,10 @@
     var off_pfFlags = 20;
     var off_pfFourCC = 21;
     var off_RGBbpp = 22;
-    // var off_RMask = 23;
-    // var off_GMask = 24;
-    // var off_BMask = 25;
-    // var off_AMask = 26;
+    var off_RMask = 23;
+    var off_GMask = 24;
+    var off_BMask = 25;
+    var off_AMask = 26;
     // var off_caps1 = 27;
     var off_caps2 = 28;
     // var off_caps3 = 29;
@@ -311,17 +311,18 @@
             return destArray;
         }
 
-        private static _GetRGBAArrayBuffer(width: number, height: number, dataOffset: number, dataLength: number, arrayBuffer: ArrayBuffer): Uint8Array {
+        private static _GetRGBAArrayBuffer(width: number, height: number, dataOffset: number, dataLength: number, arrayBuffer: ArrayBuffer, rOffset: number, gOffset: number, bOffset: number, aOffset: number): Uint8Array {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 4;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
-                    byteArray[index + 3] = srcData[srcPos + 3];
+
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
+                    byteArray[index + 3] = srcData[srcPos + aOffset];
                     index += 4;
                 }
             }
@@ -329,16 +330,25 @@
             return byteArray;
         }
 
-        private static _GetRGBArrayBuffer(width: number, height: number, dataOffset: number, dataLength: number, arrayBuffer: ArrayBuffer): Uint8Array {
+        private static _ExtractLongWordOrder(value: number): number {
+            if (value === 255 || value === -16777216) {
+                return 0;
+            }
+
+            return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
+        }
+
+        private static _GetRGBArrayBuffer(width: number, height: number, dataOffset: number, dataLength: number, arrayBuffer: ArrayBuffer, rOffset: number, gOffset: number, bOffset: number): Uint8Array {
             var byteArray = new Uint8Array(dataLength);
             var srcData = new Uint8Array(arrayBuffer, dataOffset);
             var index = 0;
             for (var y = 0; y < height; y++) {
                 for (var x = 0; x < width; x++) {
                     var srcPos = (x + y * width) * 3;
-                    byteArray[index] = srcData[srcPos + 2];
-                    byteArray[index + 1] = srcData[srcPos + 1];
-                    byteArray[index + 2] = srcData[srcPos];
+
+                    byteArray[index] = srcData[srcPos + rOffset];
+                    byteArray[index + 1] = srcData[srcPos + gOffset];
+                    byteArray[index + 2] = srcData[srcPos + bOffset];
                     index += 3;
                 }
             }
@@ -439,6 +449,11 @@
                 }
             }
 
+            let rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
+            let gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
+            let bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
+            let aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);            
+
             if (computeFormats) {
                 format = engine._getWebGLTextureType(info.textureType);
                 internalFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
@@ -496,11 +511,11 @@
                         } else if (info.isRGB) {
                             if (bpp === 24) {
                                 dataLength = width * height * 3;
-                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGB, width, height, gl.RGB, gl.UNSIGNED_BYTE, byteArray);
                             } else { // 32
                                 dataLength = width * height * 4;
-                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
+                                byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
                                 engine._uploadDataToTexture(sampler, i, gl.RGBA, width, height, gl.RGBA, gl.UNSIGNED_BYTE, byteArray);
                             }
                         } else if (info.isLuminance) {