Pārlūkot izejas kodu

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

Popov72 4 gadi atpakaļ
vecāks
revīzija
ceea56a870
46 mainītis faili ar 380 papildinājumiem un 273 dzēšanām
  1. 2 3
      Playground/src/components/rendererComponent.tsx
  2. 7 3
      dist/preview release/babylon.d.ts
  3. 1 1
      dist/preview release/babylon.js
  4. 39 21
      dist/preview release/babylon.max.js
  5. 1 1
      dist/preview release/babylon.max.js.map
  6. 14 6
      dist/preview release/babylon.module.d.ts
  7. 10 6
      dist/preview release/documentation.d.ts
  8. 9 8
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  9. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.js.map
  10. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  11. 9 8
      dist/preview release/loaders/babylon.glTFFileLoader.js
  12. 1 1
      dist/preview release/loaders/babylon.glTFFileLoader.js.map
  13. 1 1
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  14. 1 1
      dist/preview release/loaders/babylon.objFileLoader.js.map
  15. 9 8
      dist/preview release/loaders/babylonjs.loaders.js
  16. 1 1
      dist/preview release/loaders/babylonjs.loaders.js.map
  17. 2 2
      dist/preview release/loaders/babylonjs.loaders.min.js
  18. 55 41
      dist/preview release/serializers/babylon.glTF2Serializer.js
  19. 1 1
      dist/preview release/serializers/babylon.glTF2Serializer.js.map
  20. 1 1
      dist/preview release/serializers/babylon.glTF2Serializer.min.js
  21. 3 3
      dist/preview release/serializers/babylonjs.serializers.d.ts
  22. 55 41
      dist/preview release/serializers/babylonjs.serializers.js
  23. 1 1
      dist/preview release/serializers/babylonjs.serializers.js.map
  24. 1 1
      dist/preview release/serializers/babylonjs.serializers.min.js
  25. 7 7
      dist/preview release/serializers/babylonjs.serializers.module.d.ts
  26. 14 6
      dist/preview release/viewer/babylon.module.d.ts
  27. 4 4
      dist/preview release/viewer/babylon.viewer.js
  28. 2 2
      dist/preview release/viewer/babylon.viewer.max.js
  29. 2 0
      dist/preview release/what's new.md
  30. 2 2
      ktx2Decoder/src/Transcoders/mscTranscoder.ts
  31. 1 1
      loaders/src/OBJ/objFileLoader.ts
  32. 9 10
      loaders/src/glTF/2.0/glTFLoader.ts
  33. 2 2
      package.json
  34. 1 1
      serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts
  35. 63 46
      serializers/src/glTF/2.0/glTFMaterialExporter.ts
  36. 1 1
      src/Cameras/Inputs/freeCameraDeviceOrientationInput.ts
  37. 1 1
      src/Engines/engine.ts
  38. 1 1
      src/Engines/nativeEngine.ts
  39. 24 17
      src/Loading/sceneLoader.ts
  40. 7 0
      src/Materials/PBR/pbrSpecularGlossinessMaterial.ts
  41. 2 2
      src/Materials/Textures/Filtering/hdrFiltering.ts
  42. 1 1
      src/Misc/basis.ts
  43. 2 2
      src/Misc/deferred.ts
  44. 1 1
      src/Particles/pointsCloudSystem.ts
  45. 5 2
      src/Sprites/spriteManager.ts
  46. 2 2
      tests/unit/babylon/src/Misc/babylon.promise.tests.ts

+ 2 - 3
Playground/src/components/rendererComponent.tsx

@@ -77,13 +77,13 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
         });
     }
 
-    private async _loadScriptAsync(url: string) {
+    private async _loadScriptAsync(url: string): Promise<void> {
         return new Promise((resolve, reject) => {
             let script = document.createElement('script');
             script.src = url;
             script.onload = () => {
                 resolve();
-            }
+            };
             document.head.appendChild(script);
         });
     }
@@ -94,7 +94,6 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
 
         const displayInspector = this._scene?.debugLayer.isVisible();
 
-
         if (this._engine) {
             try {
                 this._engine.dispose();

+ 7 - 3
dist/preview release/babylon.d.ts

@@ -48625,7 +48625,7 @@ declare module BABYLON {
          * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
          * @returns a promise that will resolve on orientation change
          */
-        static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
+        static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
         /**
          * @hidden
          */
@@ -62005,7 +62005,7 @@ declare module BABYLON {
           * @param onFinished Callback when filtering is done
           * @return Promise called when prefiltering is done
           */
-        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
+        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
     }
 }
 declare module BABYLON {
@@ -63029,6 +63029,10 @@ declare module BABYLON {
          */
         specularGlossinessTexture: BaseTexture;
         /**
+         * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+        */
+        get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
+        /**
          * Instantiates a new PBRSpecularGlossinessMaterial instance.
          *
          * @param name The material name
@@ -75019,7 +75023,7 @@ declare module BABYLON {
         /**
          * The resolve method of the promise associated with this deferred object.
          */
-        get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
+        get resolve(): (value: T | PromiseLike<T>) => void;
         /**
          * The reject method of the promise associated with this deferred object.
          */

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/babylon.js


+ 39 - 21
dist/preview release/babylon.max.js

@@ -65367,6 +65367,8 @@ __webpack_require__.r(__webpack_exports__);
 /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
 /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
 /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
+/* harmony import */ var _Misc_stringTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/stringTools */ "./Misc/stringTools.ts");
+
 
 
 
@@ -65498,8 +65500,8 @@ var SceneLoader = /** @class */ (function () {
         return null;
     };
     SceneLoader._LoadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
-        var directLoad = SceneLoader._GetDirectLoad(fileInfo.name);
-        var registeredPlugin = pluginExtension ? SceneLoader._GetPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._GetPluginForDirectLoad(fileInfo.name) : SceneLoader._GetPluginForFilename(fileInfo.name));
+        var directLoad = SceneLoader._GetDirectLoad(fileInfo.url);
+        var registeredPlugin = pluginExtension ? SceneLoader._GetPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._GetPluginForDirectLoad(fileInfo.url) : SceneLoader._GetPluginForFilename(fileInfo.url));
         var plugin;
         if (registeredPlugin.plugin.createPlugin !== undefined) {
             plugin = registeredPlugin.plugin.createPlugin();
@@ -65565,8 +65567,21 @@ var SceneLoader = /** @class */ (function () {
                 ? plugin.requestFile(scene, fileInfo.url, successCallback, onProgress, useArrayBuffer, errorCallback)
                 : scene._requestFile(fileInfo.url, successCallback, onProgress, true, useArrayBuffer, errorCallback);
         };
-        var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
-        if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
+        if (_Misc_stringTools__WEBPACK_IMPORTED_MODULE_9__["StringTools"].StartsWith(fileInfo.url, "file:")) {
+            // Loading file from disk via input file or drag'n'drop
+            if (fileInfo.file) {
+                var errorCallback = function (error) {
+                    onError(error.message, error);
+                };
+                request = plugin.readFile
+                    ? plugin.readFile(scene, fileInfo.file, dataCallback, onProgress, useArrayBuffer, errorCallback)
+                    : scene._readFile(fileInfo.file, dataCallback, onProgress, useArrayBuffer, errorCallback);
+            }
+            else {
+                onError("Unable to find file named " + fileInfo.name);
+            }
+        }
+        else {
             var engine = scene.getEngine();
             var canUseOfflineSupport = engine.enableOfflineSupport;
             if (canUseOfflineSupport) {
@@ -65589,20 +65604,6 @@ var SceneLoader = /** @class */ (function () {
                 manifestChecked();
             }
         }
-        // Loading file from disk via input file or drag'n'drop
-        else {
-            if (file) {
-                var errorCallback = function (error) {
-                    onError(error.message, error);
-                };
-                request = plugin.readFile
-                    ? plugin.readFile(scene, file, dataCallback, onProgress, useArrayBuffer, errorCallback)
-                    : scene._readFile(file, dataCallback, onProgress, useArrayBuffer, errorCallback);
-            }
-            else {
-                onError("Unable to find file named " + fileInfo.name);
-            }
-        }
         return plugin;
     };
     SceneLoader._GetFileInfo = function (rootUrl, sceneFilename) {
@@ -65620,6 +65621,10 @@ var SceneLoader = /** @class */ (function () {
             name = sceneFile.name;
             file = sceneFile;
         }
+        else if (typeof sceneFilename === "string" && _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsBase64(sceneFilename)) {
+            url = rootUrl + sceneFilename;
+            name = "";
+        }
         else {
             var filename = sceneFilename;
             if (filename.substr(0, 1) === "/") {
@@ -65629,6 +65634,9 @@ var SceneLoader = /** @class */ (function () {
             url = rootUrl + filename;
             name = filename;
         }
+        if (_Misc_stringTools__WEBPACK_IMPORTED_MODULE_9__["StringTools"].StartsWith(url, "file:") && name) {
+            file = _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[name.toLowerCase()];
+        }
         return {
             url: url,
             rootUrl: rootUrl,
@@ -89147,6 +89155,16 @@ var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
         _this._useMicroSurfaceFromReflectivityMapAlpha = true;
         return _this;
     }
+    Object.defineProperty(PBRSpecularGlossinessMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", {
+        /**
+         * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+        */
+        get: function () {
+            return this._useMicroSurfaceFromReflectivityMapAlpha;
+        },
+        enumerable: false,
+        configurable: true
+    });
     /**
      * Return the currrent class name of the material.
      */
@@ -89995,7 +90013,7 @@ var HDRFiltering = /** @class */ (function () {
         if (onFinished === void 0) { onFinished = null; }
         if (this._engine.webGLVersion === 1) {
             _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.");
-            return;
+            return Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.");
         }
         return new Promise(function (resolve) {
             _this._effectRenderer = new _Materials_effectRenderer__WEBPACK_IMPORTED_MODULE_3__["EffectRenderer"](_this._engine);
@@ -189470,7 +189488,7 @@ var SpriteManager = /** @class */ (function () {
                     }
                     celldata.frames = frametemp;
                 }
-                var spritemap = Reflect.ownKeys(celldata.frames);
+                var spritemap = (Reflect).ownKeys(celldata.frames);
                 this._spriteMap = spritemap;
                 this._packedAndReady = true;
                 this._cellData = celldata.frames;
@@ -189499,7 +189517,7 @@ var SpriteManager = /** @class */ (function () {
             xmlhttp_1.onload = function () {
                 try {
                     var celldata = JSON.parse(xmlhttp_1.response);
-                    var spritemap = Reflect.ownKeys(celldata.frames);
+                    var spritemap = (Reflect).ownKeys(celldata.frames);
                     _this._spriteMap = spritemap;
                     _this._packedAndReady = true;
                     _this._cellData = celldata.frames;

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 14 - 6
dist/preview release/babylon.module.d.ts

@@ -50449,7 +50449,7 @@ declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
          * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
          * @returns a promise that will resolve on orientation change
          */
-        static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
+        static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
         /**
          * @hidden
          */
@@ -64888,7 +64888,7 @@ declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
           * @param onFinished Callback when filtering is done
           * @return Promise called when prefiltering is done
           */
-        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
+        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
     }
 }
 declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
@@ -65984,6 +65984,10 @@ declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
          */
         specularGlossinessTexture: BaseTexture;
         /**
+         * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+        */
+        get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
+        /**
          * Instantiates a new PBRSpecularGlossinessMaterial instance.
          *
          * @param name The material name
@@ -79164,7 +79168,7 @@ declare module "babylonjs/Misc/deferred" {
         /**
          * The resolve method of the promise associated with this deferred object.
          */
-        get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
+        get resolve(): (value: T | PromiseLike<T>) => void;
         /**
          * The reject method of the promise associated with this deferred object.
          */
@@ -130333,7 +130337,7 @@ declare module BABYLON {
          * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
          * @returns a promise that will resolve on orientation change
          */
-        static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
+        static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
         /**
          * @hidden
          */
@@ -143713,7 +143717,7 @@ declare module BABYLON {
           * @param onFinished Callback when filtering is done
           * @return Promise called when prefiltering is done
           */
-        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
+        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
     }
 }
 declare module BABYLON {
@@ -144737,6 +144741,10 @@ declare module BABYLON {
          */
         specularGlossinessTexture: BaseTexture;
         /**
+         * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+        */
+        get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
+        /**
          * Instantiates a new PBRSpecularGlossinessMaterial instance.
          *
          * @param name The material name
@@ -156727,7 +156735,7 @@ declare module BABYLON {
         /**
          * The resolve method of the promise associated with this deferred object.
          */
-        get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
+        get resolve(): (value: T | PromiseLike<T>) => void;
         /**
          * The reject method of the promise associated with this deferred object.
          */

+ 10 - 6
dist/preview release/documentation.d.ts

@@ -48625,7 +48625,7 @@ declare module BABYLON {
          * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
          * @returns a promise that will resolve on orientation change
          */
-        static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
+        static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
         /**
          * @hidden
          */
@@ -62005,7 +62005,7 @@ declare module BABYLON {
           * @param onFinished Callback when filtering is done
           * @return Promise called when prefiltering is done
           */
-        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
+        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
     }
 }
 declare module BABYLON {
@@ -63029,6 +63029,10 @@ declare module BABYLON {
          */
         specularGlossinessTexture: BaseTexture;
         /**
+         * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+        */
+        get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
+        /**
          * Instantiates a new PBRSpecularGlossinessMaterial instance.
          *
          * @param name The material name
@@ -75019,7 +75023,7 @@ declare module BABYLON {
         /**
          * The resolve method of the promise associated with this deferred object.
          */
-        get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
+        get resolve(): (value: T | PromiseLike<T>) => void;
         /**
          * The reject method of the promise associated with this deferred object.
          */
@@ -85310,8 +85314,8 @@ declare module BABYLON.GLTF2.Exporter {
          */
         private _convertSpecGlossFactorsToMetallicRoughnessAsync;
         /**
-         * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
-         * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
+         * Converts a Babylon PBR Base Material to a glTF Material
+         * @param babylonPBRMaterial BJS PBR Base Material
          * @param mimeType mime type to use for the textures
          * @param images array of glTF image interfaces
          * @param textures array of glTF texture interfaces
@@ -85319,7 +85323,7 @@ declare module BABYLON.GLTF2.Exporter {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
+        _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
         private setMetallicRoughnessPbrMaterial;
         private getPixelsFromTexture;
         /**

+ 9 - 8
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -3072,6 +3072,7 @@ __webpack_require__.r(__webpack_exports__);
 
 
 
+
 /**
  * Helper class for working with arrays when loading the glTF asset
  */
@@ -3230,10 +3231,9 @@ var GLTFLoader = /** @class */ (function () {
     /** @hidden */
     GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, forAssetContainer, data, rootUrl, onProgress, fileName) {
         var _this = this;
+        if (fileName === void 0) { fileName = ""; }
         return Promise.resolve().then(function () {
             _this._babylonScene = scene;
-            _this._rootUrl = rootUrl;
-            _this._fileName = fileName || "scene";
             _this._forAssetContainer = forAssetContainer;
             _this._loadData(data);
             var nodes = null;
@@ -3256,7 +3256,7 @@ var GLTFLoader = /** @class */ (function () {
                     return node;
                 });
             }
-            return _this._loadAsync(nodes, function () {
+            return _this._loadAsync(rootUrl, fileName, nodes, function () {
                 return {
                     meshes: _this._getMeshes(),
                     particleSystems: [],
@@ -3272,18 +3272,19 @@ var GLTFLoader = /** @class */ (function () {
     /** @hidden */
     GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
         var _this = this;
+        if (fileName === void 0) { fileName = ""; }
         return Promise.resolve().then(function () {
             _this._babylonScene = scene;
-            _this._rootUrl = rootUrl;
-            _this._fileName = fileName || "scene";
             _this._loadData(data);
-            return _this._loadAsync(null, function () { return undefined; });
+            return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; });
         });
     };
-    GLTFLoader.prototype._loadAsync = function (nodes, resultFunc) {
+    GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) {
         var _this = this;
         return Promise.resolve().then(function () {
-            _this._uniqueRootUrl = (_this._rootUrl.indexOf("file:") === -1 && _this._fileName) ? _this._rootUrl : "" + _this._rootUrl + Date.now() + "/";
+            _this._rootUrl = rootUrl;
+            _this._uniqueRootUrl = (!babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(rootUrl, "file:") && fileName) ? rootUrl : "" + rootUrl + Date.now() + "/";
+            _this._fileName = fileName;
             _this._loadExtensions();
             _this._checkExtensions();
             var loadingToReadyCounterName = _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].LOADING] + " => " + _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].READY];

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 9 - 8
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -5424,6 +5424,7 @@ __webpack_require__.r(__webpack_exports__);
 
 
 
+
 /**
  * Helper class for working with arrays when loading the glTF asset
  */
@@ -5582,10 +5583,9 @@ var GLTFLoader = /** @class */ (function () {
     /** @hidden */
     GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, forAssetContainer, data, rootUrl, onProgress, fileName) {
         var _this = this;
+        if (fileName === void 0) { fileName = ""; }
         return Promise.resolve().then(function () {
             _this._babylonScene = scene;
-            _this._rootUrl = rootUrl;
-            _this._fileName = fileName || "scene";
             _this._forAssetContainer = forAssetContainer;
             _this._loadData(data);
             var nodes = null;
@@ -5608,7 +5608,7 @@ var GLTFLoader = /** @class */ (function () {
                     return node;
                 });
             }
-            return _this._loadAsync(nodes, function () {
+            return _this._loadAsync(rootUrl, fileName, nodes, function () {
                 return {
                     meshes: _this._getMeshes(),
                     particleSystems: [],
@@ -5624,18 +5624,19 @@ var GLTFLoader = /** @class */ (function () {
     /** @hidden */
     GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
         var _this = this;
+        if (fileName === void 0) { fileName = ""; }
         return Promise.resolve().then(function () {
             _this._babylonScene = scene;
-            _this._rootUrl = rootUrl;
-            _this._fileName = fileName || "scene";
             _this._loadData(data);
-            return _this._loadAsync(null, function () { return undefined; });
+            return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; });
         });
     };
-    GLTFLoader.prototype._loadAsync = function (nodes, resultFunc) {
+    GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) {
         var _this = this;
         return Promise.resolve().then(function () {
-            _this._uniqueRootUrl = (_this._rootUrl.indexOf("file:") === -1 && _this._fileName) ? _this._rootUrl : "" + _this._rootUrl + Date.now() + "/";
+            _this._rootUrl = rootUrl;
+            _this._uniqueRootUrl = (!babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(rootUrl, "file:") && fileName) ? rootUrl : "" + rootUrl + Date.now() + "/";
+            _this._fileName = fileName;
             _this._loadExtensions();
             _this._checkExtensions();
             var loadingToReadyCounterName = _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].LOADING] + " => " + _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].READY];

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.min.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.js.map


+ 9 - 8
dist/preview release/loaders/babylonjs.loaders.js

@@ -6807,6 +6807,7 @@ __webpack_require__.r(__webpack_exports__);
 
 
 
+
 /**
  * Helper class for working with arrays when loading the glTF asset
  */
@@ -6965,10 +6966,9 @@ var GLTFLoader = /** @class */ (function () {
     /** @hidden */
     GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, forAssetContainer, data, rootUrl, onProgress, fileName) {
         var _this = this;
+        if (fileName === void 0) { fileName = ""; }
         return Promise.resolve().then(function () {
             _this._babylonScene = scene;
-            _this._rootUrl = rootUrl;
-            _this._fileName = fileName || "scene";
             _this._forAssetContainer = forAssetContainer;
             _this._loadData(data);
             var nodes = null;
@@ -6991,7 +6991,7 @@ var GLTFLoader = /** @class */ (function () {
                     return node;
                 });
             }
-            return _this._loadAsync(nodes, function () {
+            return _this._loadAsync(rootUrl, fileName, nodes, function () {
                 return {
                     meshes: _this._getMeshes(),
                     particleSystems: [],
@@ -7007,18 +7007,19 @@ var GLTFLoader = /** @class */ (function () {
     /** @hidden */
     GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
         var _this = this;
+        if (fileName === void 0) { fileName = ""; }
         return Promise.resolve().then(function () {
             _this._babylonScene = scene;
-            _this._rootUrl = rootUrl;
-            _this._fileName = fileName || "scene";
             _this._loadData(data);
-            return _this._loadAsync(null, function () { return undefined; });
+            return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; });
         });
     };
-    GLTFLoader.prototype._loadAsync = function (nodes, resultFunc) {
+    GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) {
         var _this = this;
         return Promise.resolve().then(function () {
-            _this._uniqueRootUrl = (_this._rootUrl.indexOf("file:") === -1 && _this._fileName) ? _this._rootUrl : "" + _this._rootUrl + Date.now() + "/";
+            _this._rootUrl = rootUrl;
+            _this._uniqueRootUrl = (!babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(rootUrl, "file:") && fileName) ? rootUrl : "" + rootUrl + Date.now() + "/";
+            _this._fileName = fileName;
             _this._loadExtensions();
             _this._checkExtensions();
             var loadingToReadyCounterName = _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].LOADING] + " => " + _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].READY];

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 2 - 2
dist/preview release/loaders/babylonjs.loaders.min.js


+ 55 - 41
dist/preview release/serializers/babylon.glTF2Serializer.js

@@ -560,7 +560,7 @@ var KHR_lights_punctual = /** @class */ (function () {
                             }
                             parentNode.extensions[NAME] = lightReference;
                             // Do not export the original node
-                            resolve(undefined);
+                            resolve(null);
                             return;
                         }
                     }
@@ -3793,7 +3793,6 @@ __webpack_require__.r(__webpack_exports__);
 
 
 
-
 /**
  * Utility methods for working with glTF material conversion properties.  This class should only be used internally
  * @hidden
@@ -3835,10 +3834,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
             if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]) {
                 promises.push(this._convertStandardMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
             }
-            else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]) {
-                promises.push(this._convertPBRMetallicRoughnessMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
-            }
-            else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]) {
+            else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]) {
                 promises.push(this._convertPBRMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
             }
             else {
@@ -4469,21 +4465,26 @@ var _GLTFMaterialExporter = /** @class */ (function () {
      */
     _GLTFMaterialExporter.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
         var promises = [];
+        var baseColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.baseColor;
+        var metallic = babylonPBRMaterial.metallic || babylonPBRMaterial.metallic;
+        var roughness = babylonPBRMaterial.roughness || babylonPBRMaterial.roughness;
         var metallicRoughness = {
-            baseColor: babylonPBRMaterial.albedoColor,
-            metallic: babylonPBRMaterial.metallic,
-            roughness: babylonPBRMaterial.roughness
+            baseColor: baseColor,
+            metallic: metallic,
+            roughness: roughness
         };
         if (hasTextureCoords) {
-            if (babylonPBRMaterial.albedoTexture) {
+            var albedoTexture = babylonPBRMaterial.albedoTexture || babylonPBRMaterial.baseTexture;
+            if (albedoTexture) {
                 promises.push(this._exportTextureAsync(babylonPBRMaterial.albedoTexture, mimeType).then(function (glTFTexture) {
                     if (glTFTexture) {
                         glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
                     }
                 }));
             }
-            if (babylonPBRMaterial.metallicTexture) {
-                promises.push(this._exportTextureAsync(babylonPBRMaterial.metallicTexture, mimeType).then(function (glTFTexture) {
+            var metallicTexture = babylonPBRMaterial.metallicTexture || babylonPBRMaterial.metallicRoughnessTexture;
+            if (metallicTexture) {
+                promises.push(this._exportTextureAsync(metallicTexture, mimeType).then(function (glTFTexture) {
                     if (glTFTexture) {
                         glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFTexture;
                     }
@@ -4604,30 +4605,36 @@ var _GLTFMaterialExporter = /** @class */ (function () {
         return Promise.resolve().then(function () {
             var samplers = _this._exporter._samplers;
             var textures = _this._exporter._textures;
+            var diffuseColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.diffuseColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
+            var specularColor = babylonPBRMaterial.reflectivityColor || babylonPBRMaterial.specularColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
+            var glossiness = babylonPBRMaterial.microSurface || babylonPBRMaterial.glossiness || 1;
             var specGloss = {
-                diffuseColor: babylonPBRMaterial.albedoColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White(),
-                specularColor: babylonPBRMaterial.reflectivityColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White(),
-                glossiness: babylonPBRMaterial.microSurface || 1,
+                diffuseColor: diffuseColor,
+                specularColor: specularColor,
+                glossiness: glossiness,
             };
             var samplerIndex = null;
-            var sampler = _this._getGLTFTextureSampler(babylonPBRMaterial.albedoTexture);
+            var albedoTexture = babylonPBRMaterial.albedoTexture || babylonPBRMaterial.diffuseTexture;
+            var reflectivityTexture = babylonPBRMaterial.reflectivityTexture || babylonPBRMaterial.specularGlossinessTexture;
+            var sampler = _this._getGLTFTextureSampler(albedoTexture);
             if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
                 samplers.push(sampler);
                 samplerIndex = samplers.length - 1;
             }
-            if (babylonPBRMaterial.reflectivityTexture && !babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha) {
+            var useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha || babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha;
+            if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) {
                 return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
             }
-            if ((babylonPBRMaterial.albedoTexture || babylonPBRMaterial.reflectivityTexture) && hasTextureCoords) {
-                return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(babylonPBRMaterial.albedoTexture, babylonPBRMaterial.reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
+            if ((albedoTexture || reflectivityTexture) && hasTextureCoords) {
+                return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
                     if (metallicRoughnessFactors.baseColorTextureBase64) {
-                        var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.albedoTexture ? babylonPBRMaterial.albedoTexture.coordinatesIndex : null, samplerIndex);
+                        var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, albedoTexture ? albedoTexture.coordinatesIndex : null, samplerIndex);
                         if (glTFBaseColorTexture) {
                             glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
                         }
                     }
                     if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
-                        var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.reflectivityTexture ? babylonPBRMaterial.reflectivityTexture.coordinatesIndex : null, samplerIndex);
+                        var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, reflectivityTexture ? reflectivityTexture.coordinatesIndex : null, samplerIndex);
                         if (glTFMRColorTexture) {
                             glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
                         }
@@ -4641,8 +4648,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
         });
     };
     /**
-     * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
-     * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
+     * Converts a Babylon PBR Base Material to a glTF Material
+     * @param babylonPBRMaterial BJS PBR Base Material
      * @param mimeType mime type to use for the textures
      * @param images array of glTF image interfaces
      * @param textures array of glTF texture interfaces
@@ -4658,12 +4665,14 @@ var _GLTFMaterialExporter = /** @class */ (function () {
         };
         var useMetallicRoughness = babylonPBRMaterial.isMetallicWorkflow();
         if (useMetallicRoughness) {
-            if (babylonPBRMaterial.albedoColor) {
+            var albedoColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.diffuseColor || babylonPBRMaterial.baseColor;
+            var alpha = babylonPBRMaterial.alpha;
+            if (albedoColor) {
                 glTFPbrMetallicRoughness.baseColorFactor = [
-                    babylonPBRMaterial.albedoColor.r,
-                    babylonPBRMaterial.albedoColor.g,
-                    babylonPBRMaterial.albedoColor.b,
-                    babylonPBRMaterial.alpha
+                    albedoColor.r,
+                    albedoColor.g,
+                    albedoColor.b,
+                    alpha
                 ];
             }
             return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) {
@@ -4697,40 +4706,44 @@ var _GLTFMaterialExporter = /** @class */ (function () {
                 glTFPbrMetallicRoughness.roughnessFactor = metallicRoughness.roughness;
             }
             if (babylonPBRMaterial.backFaceCulling != null && !babylonPBRMaterial.backFaceCulling) {
-                if (!babylonPBRMaterial.twoSidedLighting) {
+                if (!(babylonPBRMaterial.twoSidedLighting || babylonPBRMaterial.doubleSided)) {
                     babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Tools"].Warn(babylonPBRMaterial.name + ": Back-face culling enabled and two-sided lighting disabled is not supported in glTF.");
                 }
                 glTFMaterial.doubleSided = true;
             }
             if (hasTextureCoords) {
-                if (babylonPBRMaterial.bumpTexture) {
-                    var promise = this._exportTextureAsync(babylonPBRMaterial.bumpTexture, mimeType).then(function (glTFTexture) {
+                var bumpTexture_1 = babylonPBRMaterial.bumpTexture || babylonPBRMaterial.normalTexture;
+                if (bumpTexture_1) {
+                    var promise = this._exportTextureAsync(bumpTexture_1, mimeType).then(function (glTFTexture) {
                         if (glTFTexture) {
                             glTFMaterial.normalTexture = glTFTexture;
-                            if (babylonPBRMaterial.bumpTexture.level !== 1) {
-                                glTFMaterial.normalTexture.scale = babylonPBRMaterial.bumpTexture.level;
+                            if (bumpTexture_1.level !== 1) {
+                                glTFMaterial.normalTexture.scale = bumpTexture_1.level;
                             }
                         }
                     });
                     promises.push(promise);
                 }
-                if (babylonPBRMaterial.ambientTexture) {
-                    var promise = this._exportTextureAsync(babylonPBRMaterial.ambientTexture, mimeType).then(function (glTFTexture) {
+                var ambientTexture = babylonPBRMaterial.ambientTexture || babylonPBRMaterial.occlusionTexture;
+                if (ambientTexture) {
+                    var promise = this._exportTextureAsync(ambientTexture, mimeType).then(function (glTFTexture) {
                         if (glTFTexture) {
                             var occlusionTexture = {
                                 index: glTFTexture.index,
                                 texCoord: glTFTexture.texCoord
                             };
                             glTFMaterial.occlusionTexture = occlusionTexture;
-                            if (babylonPBRMaterial.ambientTextureStrength) {
-                                occlusionTexture.strength = babylonPBRMaterial.ambientTextureStrength;
+                            var ambientTextureStrength = babylonPBRMaterial.ambientTextureStrength || babylonPBRMaterial.occlusionStrength;
+                            if (ambientTextureStrength) {
+                                occlusionTexture.strength = ambientTextureStrength;
                             }
                         }
                     });
                     promises.push(promise);
                 }
-                if (babylonPBRMaterial.emissiveTexture) {
-                    var promise = this._exportTextureAsync(babylonPBRMaterial.emissiveTexture, mimeType).then(function (glTFTexture) {
+                var emissiveTexture = babylonPBRMaterial.emissiveTexture || babylonPBRMaterial.emissiveTexture;
+                if (emissiveTexture) {
+                    var promise = this._exportTextureAsync(emissiveTexture, mimeType).then(function (glTFTexture) {
                         if (glTFTexture) {
                             glTFMaterial.emissiveTexture = glTFTexture;
                         }
@@ -4738,8 +4751,9 @@ var _GLTFMaterialExporter = /** @class */ (function () {
                     promises.push(promise);
                 }
             }
-            if (!_GLTFMaterialExporter.FuzzyEquals(babylonPBRMaterial.emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black(), _GLTFMaterialExporter._Epsilon)) {
-                glTFMaterial.emissiveFactor = babylonPBRMaterial.emissiveColor.asArray();
+            var emissiveColor = babylonPBRMaterial.emissiveColor || babylonPBRMaterial.emissiveColor;
+            if (!_GLTFMaterialExporter.FuzzyEquals(emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black(), _GLTFMaterialExporter._Epsilon)) {
+                glTFMaterial.emissiveFactor = emissiveColor.asArray();
             }
             glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness;
             materials.push(glTFMaterial);

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/serializers/babylon.glTF2Serializer.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/serializers/babylon.glTF2Serializer.min.js


+ 3 - 3
dist/preview release/serializers/babylonjs.serializers.d.ts

@@ -297,8 +297,8 @@ declare module BABYLON.GLTF2.Exporter {
          */
         private _convertSpecGlossFactorsToMetallicRoughnessAsync;
         /**
-         * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
-         * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
+         * Converts a Babylon PBR Base Material to a glTF Material
+         * @param babylonPBRMaterial BJS PBR Base Material
          * @param mimeType mime type to use for the textures
          * @param images array of glTF image interfaces
          * @param textures array of glTF texture interfaces
@@ -306,7 +306,7 @@ declare module BABYLON.GLTF2.Exporter {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
+        _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
         private setMetallicRoughnessPbrMaterial;
         private getPixelsFromTexture;
         /**

+ 55 - 41
dist/preview release/serializers/babylonjs.serializers.js

@@ -745,7 +745,7 @@ var KHR_lights_punctual = /** @class */ (function () {
                             }
                             parentNode.extensions[NAME] = lightReference;
                             // Do not export the original node
-                            resolve(undefined);
+                            resolve(null);
                             return;
                         }
                     }
@@ -3978,7 +3978,6 @@ __webpack_require__.r(__webpack_exports__);
 
 
 
-
 /**
  * Utility methods for working with glTF material conversion properties.  This class should only be used internally
  * @hidden
@@ -4020,10 +4019,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
             if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]) {
                 promises.push(this._convertStandardMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
             }
-            else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]) {
-                promises.push(this._convertPBRMetallicRoughnessMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
-            }
-            else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]) {
+            else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]) {
                 promises.push(this._convertPBRMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
             }
             else {
@@ -4654,21 +4650,26 @@ var _GLTFMaterialExporter = /** @class */ (function () {
      */
     _GLTFMaterialExporter.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) {
         var promises = [];
+        var baseColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.baseColor;
+        var metallic = babylonPBRMaterial.metallic || babylonPBRMaterial.metallic;
+        var roughness = babylonPBRMaterial.roughness || babylonPBRMaterial.roughness;
         var metallicRoughness = {
-            baseColor: babylonPBRMaterial.albedoColor,
-            metallic: babylonPBRMaterial.metallic,
-            roughness: babylonPBRMaterial.roughness
+            baseColor: baseColor,
+            metallic: metallic,
+            roughness: roughness
         };
         if (hasTextureCoords) {
-            if (babylonPBRMaterial.albedoTexture) {
+            var albedoTexture = babylonPBRMaterial.albedoTexture || babylonPBRMaterial.baseTexture;
+            if (albedoTexture) {
                 promises.push(this._exportTextureAsync(babylonPBRMaterial.albedoTexture, mimeType).then(function (glTFTexture) {
                     if (glTFTexture) {
                         glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
                     }
                 }));
             }
-            if (babylonPBRMaterial.metallicTexture) {
-                promises.push(this._exportTextureAsync(babylonPBRMaterial.metallicTexture, mimeType).then(function (glTFTexture) {
+            var metallicTexture = babylonPBRMaterial.metallicTexture || babylonPBRMaterial.metallicRoughnessTexture;
+            if (metallicTexture) {
+                promises.push(this._exportTextureAsync(metallicTexture, mimeType).then(function (glTFTexture) {
                     if (glTFTexture) {
                         glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFTexture;
                     }
@@ -4789,30 +4790,36 @@ var _GLTFMaterialExporter = /** @class */ (function () {
         return Promise.resolve().then(function () {
             var samplers = _this._exporter._samplers;
             var textures = _this._exporter._textures;
+            var diffuseColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.diffuseColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
+            var specularColor = babylonPBRMaterial.reflectivityColor || babylonPBRMaterial.specularColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
+            var glossiness = babylonPBRMaterial.microSurface || babylonPBRMaterial.glossiness || 1;
             var specGloss = {
-                diffuseColor: babylonPBRMaterial.albedoColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White(),
-                specularColor: babylonPBRMaterial.reflectivityColor || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White(),
-                glossiness: babylonPBRMaterial.microSurface || 1,
+                diffuseColor: diffuseColor,
+                specularColor: specularColor,
+                glossiness: glossiness,
             };
             var samplerIndex = null;
-            var sampler = _this._getGLTFTextureSampler(babylonPBRMaterial.albedoTexture);
+            var albedoTexture = babylonPBRMaterial.albedoTexture || babylonPBRMaterial.diffuseTexture;
+            var reflectivityTexture = babylonPBRMaterial.reflectivityTexture || babylonPBRMaterial.specularGlossinessTexture;
+            var sampler = _this._getGLTFTextureSampler(albedoTexture);
             if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
                 samplers.push(sampler);
                 samplerIndex = samplers.length - 1;
             }
-            if (babylonPBRMaterial.reflectivityTexture && !babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha) {
+            var useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha || babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha;
+            if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) {
                 return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
             }
-            if ((babylonPBRMaterial.albedoTexture || babylonPBRMaterial.reflectivityTexture) && hasTextureCoords) {
-                return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(babylonPBRMaterial.albedoTexture, babylonPBRMaterial.reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
+            if ((albedoTexture || reflectivityTexture) && hasTextureCoords) {
+                return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) {
                     if (metallicRoughnessFactors.baseColorTextureBase64) {
-                        var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.albedoTexture ? babylonPBRMaterial.albedoTexture.coordinatesIndex : null, samplerIndex);
+                        var glTFBaseColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, albedoTexture ? albedoTexture.coordinatesIndex : null, samplerIndex);
                         if (glTFBaseColorTexture) {
                             glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
                         }
                     }
                     if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
-                        var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.reflectivityTexture ? babylonPBRMaterial.reflectivityTexture.coordinatesIndex : null, samplerIndex);
+                        var glTFMRColorTexture = _this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, reflectivityTexture ? reflectivityTexture.coordinatesIndex : null, samplerIndex);
                         if (glTFMRColorTexture) {
                             glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
                         }
@@ -4826,8 +4833,8 @@ var _GLTFMaterialExporter = /** @class */ (function () {
         });
     };
     /**
-     * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
-     * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
+     * Converts a Babylon PBR Base Material to a glTF Material
+     * @param babylonPBRMaterial BJS PBR Base Material
      * @param mimeType mime type to use for the textures
      * @param images array of glTF image interfaces
      * @param textures array of glTF texture interfaces
@@ -4843,12 +4850,14 @@ var _GLTFMaterialExporter = /** @class */ (function () {
         };
         var useMetallicRoughness = babylonPBRMaterial.isMetallicWorkflow();
         if (useMetallicRoughness) {
-            if (babylonPBRMaterial.albedoColor) {
+            var albedoColor = babylonPBRMaterial.albedoColor || babylonPBRMaterial.diffuseColor || babylonPBRMaterial.baseColor;
+            var alpha = babylonPBRMaterial.alpha;
+            if (albedoColor) {
                 glTFPbrMetallicRoughness.baseColorFactor = [
-                    babylonPBRMaterial.albedoColor.r,
-                    babylonPBRMaterial.albedoColor.g,
-                    babylonPBRMaterial.albedoColor.b,
-                    babylonPBRMaterial.alpha
+                    albedoColor.r,
+                    albedoColor.g,
+                    albedoColor.b,
+                    alpha
                 ];
             }
             return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) {
@@ -4882,40 +4891,44 @@ var _GLTFMaterialExporter = /** @class */ (function () {
                 glTFPbrMetallicRoughness.roughnessFactor = metallicRoughness.roughness;
             }
             if (babylonPBRMaterial.backFaceCulling != null && !babylonPBRMaterial.backFaceCulling) {
-                if (!babylonPBRMaterial.twoSidedLighting) {
+                if (!(babylonPBRMaterial.twoSidedLighting || babylonPBRMaterial.doubleSided)) {
                     babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Tools"].Warn(babylonPBRMaterial.name + ": Back-face culling enabled and two-sided lighting disabled is not supported in glTF.");
                 }
                 glTFMaterial.doubleSided = true;
             }
             if (hasTextureCoords) {
-                if (babylonPBRMaterial.bumpTexture) {
-                    var promise = this._exportTextureAsync(babylonPBRMaterial.bumpTexture, mimeType).then(function (glTFTexture) {
+                var bumpTexture_1 = babylonPBRMaterial.bumpTexture || babylonPBRMaterial.normalTexture;
+                if (bumpTexture_1) {
+                    var promise = this._exportTextureAsync(bumpTexture_1, mimeType).then(function (glTFTexture) {
                         if (glTFTexture) {
                             glTFMaterial.normalTexture = glTFTexture;
-                            if (babylonPBRMaterial.bumpTexture.level !== 1) {
-                                glTFMaterial.normalTexture.scale = babylonPBRMaterial.bumpTexture.level;
+                            if (bumpTexture_1.level !== 1) {
+                                glTFMaterial.normalTexture.scale = bumpTexture_1.level;
                             }
                         }
                     });
                     promises.push(promise);
                 }
-                if (babylonPBRMaterial.ambientTexture) {
-                    var promise = this._exportTextureAsync(babylonPBRMaterial.ambientTexture, mimeType).then(function (glTFTexture) {
+                var ambientTexture = babylonPBRMaterial.ambientTexture || babylonPBRMaterial.occlusionTexture;
+                if (ambientTexture) {
+                    var promise = this._exportTextureAsync(ambientTexture, mimeType).then(function (glTFTexture) {
                         if (glTFTexture) {
                             var occlusionTexture = {
                                 index: glTFTexture.index,
                                 texCoord: glTFTexture.texCoord
                             };
                             glTFMaterial.occlusionTexture = occlusionTexture;
-                            if (babylonPBRMaterial.ambientTextureStrength) {
-                                occlusionTexture.strength = babylonPBRMaterial.ambientTextureStrength;
+                            var ambientTextureStrength = babylonPBRMaterial.ambientTextureStrength || babylonPBRMaterial.occlusionStrength;
+                            if (ambientTextureStrength) {
+                                occlusionTexture.strength = ambientTextureStrength;
                             }
                         }
                     });
                     promises.push(promise);
                 }
-                if (babylonPBRMaterial.emissiveTexture) {
-                    var promise = this._exportTextureAsync(babylonPBRMaterial.emissiveTexture, mimeType).then(function (glTFTexture) {
+                var emissiveTexture = babylonPBRMaterial.emissiveTexture || babylonPBRMaterial.emissiveTexture;
+                if (emissiveTexture) {
+                    var promise = this._exportTextureAsync(emissiveTexture, mimeType).then(function (glTFTexture) {
                         if (glTFTexture) {
                             glTFMaterial.emissiveTexture = glTFTexture;
                         }
@@ -4923,8 +4936,9 @@ var _GLTFMaterialExporter = /** @class */ (function () {
                     promises.push(promise);
                 }
             }
-            if (!_GLTFMaterialExporter.FuzzyEquals(babylonPBRMaterial.emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black(), _GLTFMaterialExporter._Epsilon)) {
-                glTFMaterial.emissiveFactor = babylonPBRMaterial.emissiveColor.asArray();
+            var emissiveColor = babylonPBRMaterial.emissiveColor || babylonPBRMaterial.emissiveColor;
+            if (!_GLTFMaterialExporter.FuzzyEquals(emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black(), _GLTFMaterialExporter._Epsilon)) {
+                glTFMaterial.emissiveFactor = emissiveColor.asArray();
             }
             glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness;
             materials.push(glTFMaterial);

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/serializers/babylonjs.serializers.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
dist/preview release/serializers/babylonjs.serializers.min.js


+ 7 - 7
dist/preview release/serializers/babylonjs.serializers.module.d.ts

@@ -128,7 +128,7 @@ declare module "babylonjs-serializers/glTF/2.0/glTFMaterialExporter" {
     import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
     import { Material } from "babylonjs/Materials/material";
     import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
-    import { PBRMaterial } from "babylonjs/Materials/PBR/pbrMaterial";
+    import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
     import { PBRMetallicRoughnessMaterial } from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
     import { _Exporter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
     /**
@@ -319,8 +319,8 @@ declare module "babylonjs-serializers/glTF/2.0/glTFMaterialExporter" {
          */
         private _convertSpecGlossFactorsToMetallicRoughnessAsync;
         /**
-         * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
-         * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
+         * Converts a Babylon PBR Base Material to a glTF Material
+         * @param babylonPBRMaterial BJS PBR Base Material
          * @param mimeType mime type to use for the textures
          * @param images array of glTF image interfaces
          * @param textures array of glTF texture interfaces
@@ -328,7 +328,7 @@ declare module "babylonjs-serializers/glTF/2.0/glTFMaterialExporter" {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
+        _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
         private setMetallicRoughnessPbrMaterial;
         private getPixelsFromTexture;
         /**
@@ -1674,8 +1674,8 @@ declare module BABYLON.GLTF2.Exporter {
          */
         private _convertSpecGlossFactorsToMetallicRoughnessAsync;
         /**
-         * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
-         * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
+         * Converts a Babylon PBR Base Material to a glTF Material
+         * @param babylonPBRMaterial BJS PBR Base Material
          * @param mimeType mime type to use for the textures
          * @param images array of glTF image interfaces
          * @param textures array of glTF texture interfaces
@@ -1683,7 +1683,7 @@ declare module BABYLON.GLTF2.Exporter {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
+        _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
         private setMetallicRoughnessPbrMaterial;
         private getPixelsFromTexture;
         /**

+ 14 - 6
dist/preview release/viewer/babylon.module.d.ts

@@ -50449,7 +50449,7 @@ declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
          * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
          * @returns a promise that will resolve on orientation change
          */
-        static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
+        static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
         /**
          * @hidden
          */
@@ -64888,7 +64888,7 @@ declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
           * @param onFinished Callback when filtering is done
           * @return Promise called when prefiltering is done
           */
-        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
+        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
     }
 }
 declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
@@ -65984,6 +65984,10 @@ declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
          */
         specularGlossinessTexture: BaseTexture;
         /**
+         * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+        */
+        get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
+        /**
          * Instantiates a new PBRSpecularGlossinessMaterial instance.
          *
          * @param name The material name
@@ -79164,7 +79168,7 @@ declare module "babylonjs/Misc/deferred" {
         /**
          * The resolve method of the promise associated with this deferred object.
          */
-        get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
+        get resolve(): (value: T | PromiseLike<T>) => void;
         /**
          * The reject method of the promise associated with this deferred object.
          */
@@ -130333,7 +130337,7 @@ declare module BABYLON {
          * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
          * @returns a promise that will resolve on orientation change
          */
-        static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
+        static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
         /**
          * @hidden
          */
@@ -143713,7 +143717,7 @@ declare module BABYLON {
           * @param onFinished Callback when filtering is done
           * @return Promise called when prefiltering is done
           */
-        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
+        prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
     }
 }
 declare module BABYLON {
@@ -144737,6 +144741,10 @@ declare module BABYLON {
          */
         specularGlossinessTexture: BaseTexture;
         /**
+         * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+        */
+        get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
+        /**
          * Instantiates a new PBRSpecularGlossinessMaterial instance.
          *
          * @param name The material name
@@ -156727,7 +156735,7 @@ declare module BABYLON {
         /**
          * The resolve method of the promise associated with this deferred object.
          */
-        get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
+        get resolve(): (value: T | PromiseLike<T>) => void;
         /**
          * The reject method of the promise associated with this deferred object.
          */

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 4 - 4
dist/preview release/viewer/babylon.viewer.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 2 - 2
dist/preview release/viewer/babylon.viewer.max.js


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

@@ -37,6 +37,8 @@
 
 - Fix issue with the Promise polyfill where a return value was expected from resolve() ([Deltakosh](https://github.com/deltakosh))
 - Fix an issue with keyboard control (re)attachment. ([#9411](https://github.com/BabylonJS/Babylon.js/issues/9411)) ([RaananW](https://github.com/RaananW))
+- Fix issue where PBRSpecularGlossiness materials were excluded from export ([Drigax](https://github.com/drigax))
+- Fix direct loading of a glTF string that has base64-encoded URI. ([bghgary](https://github.com/bghgary))
 
 ## Breaking changes
 

+ 2 - 2
ktx2Decoder/src/Transcoders/mscTranscoder.ts

@@ -27,10 +27,10 @@ export class MSCTranscoder extends Transcoder {
         return MSCTranscoder.Name;
     }
 
-    private _mscBasisTranscoderPromise: Promise<any>;
+    private _mscBasisTranscoderPromise: Promise<void>;
     private _mscBasisModule: any;
 
-    private _getMSCBasisTranscoder(): Promise<any> {
+    private _getMSCBasisTranscoder(): Promise<void> {
         if (this._mscBasisTranscoderPromise) {
             return this._mscBasisTranscoderPromise;
         }

+ 1 - 1
loaders/src/OBJ/objFileLoader.ts

@@ -961,7 +961,7 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
             babylonMeshesArray.push(babylonMesh);
         }
 
-        let mtlPromises: Array<Promise<any>> = [];
+        let mtlPromises: Array<Promise<void>> = [];
         //load the materials
         //Check if we have a file to load
         if (fileToLoad !== "" && this._meshLoadOptions.SkipMaterials === false) {

+ 9 - 10
loaders/src/glTF/2.0/glTFLoader.ts

@@ -35,6 +35,7 @@ import { Logger } from 'babylonjs/Misc/logger';
 import { Light } from 'babylonjs/Lights/light';
 import { TmpVectors } from 'babylonjs/Maths/math.vector';
 import { BoundingInfo } from 'babylonjs/Culling/boundingInfo';
+import { StringTools } from 'babylonjs/Misc/stringTools';
 
 interface TypedArrayLike extends ArrayBufferView {
     readonly length: number;
@@ -224,11 +225,9 @@ export class GLTFLoader implements IGLTFLoader {
     }
 
     /** @hidden */
-    public importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult> {
+    public importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName = ""): Promise<ISceneLoaderAsyncResult> {
         return Promise.resolve().then(() => {
             this._babylonScene = scene;
-            this._rootUrl = rootUrl;
-            this._fileName = fileName || "scene";
             this._forAssetContainer = forAssetContainer;
             this._loadData(data);
 
@@ -255,7 +254,7 @@ export class GLTFLoader implements IGLTFLoader {
                 });
             }
 
-            return this._loadAsync(nodes, () => {
+            return this._loadAsync(rootUrl, fileName, nodes, () => {
                 return {
                     meshes: this._getMeshes(),
                     particleSystems: [],
@@ -270,19 +269,19 @@ export class GLTFLoader implements IGLTFLoader {
     }
 
     /** @hidden */
-    public loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void> {
+    public loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName = ""): Promise<void> {
         return Promise.resolve().then(() => {
             this._babylonScene = scene;
-            this._rootUrl = rootUrl;
-            this._fileName = fileName || "scene";
             this._loadData(data);
-            return this._loadAsync(null, () => undefined);
+            return this._loadAsync(rootUrl, fileName, null, () => undefined);
         });
     }
 
-    private _loadAsync<T>(nodes: Nullable<Array<number>>, resultFunc: () => T): Promise<T> {
+    private _loadAsync<T>(rootUrl: string, fileName: string, nodes: Nullable<Array<number>>, resultFunc: () => T): Promise<T> {
         return Promise.resolve().then(() => {
-            this._uniqueRootUrl = (this._rootUrl.indexOf("file:") === -1 && this._fileName) ? this._rootUrl : `${this._rootUrl}${Date.now()}/`;
+            this._rootUrl = rootUrl;
+            this._uniqueRootUrl = (!StringTools.StartsWith(rootUrl, "file:") && fileName) ? rootUrl : `${rootUrl}${Date.now()}/`;
+            this._fileName = fileName;
 
             this._loadExtensions();
             this._checkExtensions();

+ 2 - 2
package.json

@@ -103,7 +103,7 @@
         "tslib": ">=1.10.0",
         "tslint": "^6.1.2",
         "typedoc": "^0.17.7",
-        "typescript": "^4.0.2",
+        "typescript": "^4.1.2",
         "webpack": "~4.43.0",
         "webpack-bundle-analyzer": "^3.8.0",
         "webpack-cli": "^3.3.11",
@@ -112,4 +112,4 @@
         "xhr2": "^0.2.0",
         "xmlbuilder": "15.1.1"
     }
-}
+}

+ 1 - 1
serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts

@@ -186,7 +186,7 @@ export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
                             parentNode.extensions[NAME] = lightReference;
 
                             // Do not export the original node
-                            resolve(undefined);
+                            resolve(null);
                             return;
                         }
                     }

+ 63 - 46
serializers/src/glTF/2.0/glTFMaterialExporter.ts

@@ -11,8 +11,11 @@ import { Texture } from "babylonjs/Materials/Textures/texture";
 import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
 import { Material } from "babylonjs/Materials/material";
 import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
+import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
+import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
 import { PBRMaterial } from "babylonjs/Materials/PBR/pbrMaterial";
 import { PBRMetallicRoughnessMaterial } from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
+import { PBRSpecularGlossinessMaterial } from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
 import { Scene } from "babylonjs/scene";
 
 import { _Exporter } from "./glTFExporter";
@@ -127,10 +130,7 @@ export class _GLTFMaterialExporter {
             if (babylonMaterial instanceof StandardMaterial) {
                 promises.push(this._convertStandardMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
             }
-            else if (babylonMaterial instanceof PBRMetallicRoughnessMaterial) {
-                promises.push(this._convertPBRMetallicRoughnessMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
-            }
-            else if (babylonMaterial instanceof PBRMaterial) {
+            else if (babylonMaterial instanceof PBRBaseMaterial) {
                 promises.push(this._convertPBRMaterialAsync(babylonMaterial, mimeType, hasTextureCoords));
             }
             else {
@@ -801,24 +801,29 @@ export class _GLTFMaterialExporter {
      * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
      * @returns glTF PBR Metallic Roughness factors
      */
-    private _convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, glTFPbrMetallicRoughness: IMaterialPbrMetallicRoughness, hasTextureCoords: boolean): Promise<_IPBRMetallicRoughness> {
+    private _convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, glTFPbrMetallicRoughness: IMaterialPbrMetallicRoughness, hasTextureCoords: boolean): Promise<_IPBRMetallicRoughness> {
         const promises = [];
+        const baseColor = (babylonPBRMaterial as PBRMaterial).albedoColor || (babylonPBRMaterial as PBRMetallicRoughnessMaterial).baseColor;
+        const metallic = (babylonPBRMaterial as PBRMaterial).metallic || (babylonPBRMaterial as PBRMetallicRoughnessMaterial).metallic;
+        const roughness = (babylonPBRMaterial as PBRMaterial).roughness || (babylonPBRMaterial as PBRMetallicRoughnessMaterial).roughness;
         const metallicRoughness: _IPBRMetallicRoughness = {
-            baseColor: babylonPBRMaterial.albedoColor,
-            metallic: babylonPBRMaterial.metallic,
-            roughness: babylonPBRMaterial.roughness
+            baseColor: baseColor,
+            metallic: metallic,
+            roughness: roughness
         };
 
         if (hasTextureCoords) {
-            if (babylonPBRMaterial.albedoTexture) {
-                promises.push(this._exportTextureAsync(babylonPBRMaterial.albedoTexture, mimeType).then((glTFTexture) => {
+            const albedoTexture = (babylonPBRMaterial as PBRMaterial).albedoTexture || (babylonPBRMaterial as PBRMetallicRoughnessMaterial).baseTexture;
+            if (albedoTexture) {
+                promises.push(this._exportTextureAsync((babylonPBRMaterial as any).albedoTexture, mimeType).then((glTFTexture) => {
                     if (glTFTexture) {
                         glTFPbrMetallicRoughness.baseColorTexture = glTFTexture;
                     }
                 }));
             }
-            if (babylonPBRMaterial.metallicTexture) {
-                promises.push(this._exportTextureAsync(babylonPBRMaterial.metallicTexture, mimeType).then((glTFTexture) => {
+            const metallicTexture = (babylonPBRMaterial as PBRMaterial).metallicTexture || (babylonPBRMaterial as PBRMetallicRoughnessMaterial).metallicRoughnessTexture;
+            if (metallicTexture) {
+                promises.push(this._exportTextureAsync(metallicTexture, mimeType).then((glTFTexture) => {
                     if (glTFTexture) {
                         glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFTexture;
                     }
@@ -941,34 +946,40 @@ export class _GLTFMaterialExporter {
      * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
      * @returns glTF PBR Metallic Roughness factors
      */
-    private _convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, glTFPbrMetallicRoughness: IMaterialPbrMetallicRoughness, hasTextureCoords: boolean): Promise<_IPBRMetallicRoughness> {
+    private _convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, glTFPbrMetallicRoughness: IMaterialPbrMetallicRoughness, hasTextureCoords: boolean): Promise<_IPBRMetallicRoughness> {
         return Promise.resolve().then(() => {
             const samplers = this._exporter._samplers;
             const textures = this._exporter._textures;
+            const diffuseColor = (babylonPBRMaterial as PBRMaterial).albedoColor || (babylonPBRMaterial as PBRSpecularGlossinessMaterial).diffuseColor || Color3.White();
+            const specularColor = (babylonPBRMaterial as PBRMaterial).reflectivityColor || (babylonPBRMaterial as PBRSpecularGlossinessMaterial).specularColor || Color3.White();
+            const glossiness = (babylonPBRMaterial as PBRMaterial).microSurface || (babylonPBRMaterial as PBRSpecularGlossinessMaterial).glossiness || 1;
             const specGloss: _IPBRSpecularGlossiness = {
-                diffuseColor: babylonPBRMaterial.albedoColor || Color3.White(),
-                specularColor: babylonPBRMaterial.reflectivityColor || Color3.White(),
-                glossiness: babylonPBRMaterial.microSurface || 1,
+                diffuseColor: diffuseColor,
+                specularColor: specularColor,
+                glossiness: glossiness,
             };
             let samplerIndex: Nullable<number> = null;
-            const sampler = this._getGLTFTextureSampler(babylonPBRMaterial.albedoTexture);
+            const albedoTexture = (babylonPBRMaterial as PBRMaterial).albedoTexture || (babylonPBRMaterial as PBRSpecularGlossinessMaterial).diffuseTexture;
+            const reflectivityTexture = (babylonPBRMaterial as PBRMaterial).reflectivityTexture || (babylonPBRMaterial as PBRSpecularGlossinessMaterial).specularGlossinessTexture;
+            const sampler = this._getGLTFTextureSampler(albedoTexture);
             if (sampler.magFilter != null && sampler.minFilter != null && sampler.wrapS != null && sampler.wrapT != null) {
                 samplers.push(sampler);
                 samplerIndex = samplers.length - 1;
             }
-            if (babylonPBRMaterial.reflectivityTexture && !babylonPBRMaterial.useMicroSurfaceFromReflectivityMapAlpha) {
+            const useMicrosurfaceFromReflectivityMapAlpha = (babylonPBRMaterial as PBRMaterial).useMicroSurfaceFromReflectivityMapAlpha || (babylonPBRMaterial as PBRSpecularGlossinessMaterial).useMicroSurfaceFromReflectivityMapAlpha;
+            if (reflectivityTexture  && !useMicrosurfaceFromReflectivityMapAlpha) {
                 return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");
             }
-            if ((babylonPBRMaterial.albedoTexture || babylonPBRMaterial.reflectivityTexture) && hasTextureCoords) {
-                return this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(babylonPBRMaterial.albedoTexture, babylonPBRMaterial.reflectivityTexture, specGloss, mimeType).then((metallicRoughnessFactors) => {
+            if ((albedoTexture || reflectivityTexture) && hasTextureCoords) {
+                return this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then((metallicRoughnessFactors) => {
                     if (metallicRoughnessFactors.baseColorTextureBase64) {
-                        const glTFBaseColorTexture = this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.albedoTexture ? babylonPBRMaterial.albedoTexture.coordinatesIndex : null, samplerIndex);
+                        const glTFBaseColorTexture = this._getTextureInfoFromBase64(metallicRoughnessFactors.baseColorTextureBase64, "bjsBaseColorTexture_" + (textures.length) + ".png", mimeType, albedoTexture ? albedoTexture.coordinatesIndex : null, samplerIndex);
                         if (glTFBaseColorTexture) {
                             glTFPbrMetallicRoughness.baseColorTexture = glTFBaseColorTexture;
                         }
                     }
                     if (metallicRoughnessFactors.metallicRoughnessTextureBase64) {
-                        const glTFMRColorTexture = this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, babylonPBRMaterial.reflectivityTexture ? babylonPBRMaterial.reflectivityTexture.coordinatesIndex : null, samplerIndex);
+                        const glTFMRColorTexture = this._getTextureInfoFromBase64(metallicRoughnessFactors.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + (textures.length) + ".png", mimeType, reflectivityTexture ? reflectivityTexture.coordinatesIndex : null, samplerIndex);
                         if (glTFMRColorTexture) {
                             glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFMRColorTexture;
                         }
@@ -984,8 +995,8 @@ export class _GLTFMaterialExporter {
     }
 
     /**
-     * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
-     * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
+     * Converts a Babylon PBR Base Material to a glTF Material
+     * @param babylonPBRMaterial BJS PBR Base Material
      * @param mimeType mime type to use for the textures
      * @param images array of glTF image interfaces
      * @param textures array of glTF texture interfaces
@@ -993,7 +1004,7 @@ export class _GLTFMaterialExporter {
      * @param imageData map of image file name to data
      * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
      */
-    public _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial> {
+    public _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial> {
         const glTFPbrMetallicRoughness: IMaterialPbrMetallicRoughness = {};
         const glTFMaterial: IMaterial = {
             name: babylonPBRMaterial.name
@@ -1001,12 +1012,14 @@ export class _GLTFMaterialExporter {
         const useMetallicRoughness = babylonPBRMaterial.isMetallicWorkflow();
 
         if (useMetallicRoughness) {
-            if (babylonPBRMaterial.albedoColor) {
+            const albedoColor = (babylonPBRMaterial as PBRMaterial).albedoColor || (babylonPBRMaterial as PBRSpecularGlossinessMaterial).diffuseColor || (babylonPBRMaterial as PBRMetallicRoughnessMaterial).baseColor;
+            const alpha = babylonPBRMaterial.alpha;
+            if (albedoColor) {
                 glTFPbrMetallicRoughness.baseColorFactor = [
-                    babylonPBRMaterial.albedoColor.r,
-                    babylonPBRMaterial.albedoColor.g,
-                    babylonPBRMaterial.albedoColor.b,
-                    babylonPBRMaterial.alpha
+                    albedoColor.r,
+                    albedoColor.g,
+                    albedoColor.b,
+                    alpha
                 ];
             }
             return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then((metallicRoughness) => {
@@ -1020,12 +1033,12 @@ export class _GLTFMaterialExporter {
         }
     }
 
-    private setMetallicRoughnessPbrMaterial(metallicRoughness: Nullable<_IPBRMetallicRoughness>, babylonPBRMaterial: PBRMaterial, glTFMaterial: IMaterial, glTFPbrMetallicRoughness: IMaterialPbrMetallicRoughness, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial> {
+    private setMetallicRoughnessPbrMaterial(metallicRoughness: Nullable<_IPBRMetallicRoughness>, babylonPBRMaterial: PBRBaseMaterial, glTFMaterial: IMaterial, glTFPbrMetallicRoughness: IMaterialPbrMetallicRoughness, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial> {
         const materialMap = this._exporter._materialMap;
         const materials = this._exporter._materials;
         let promises = [];
         if (metallicRoughness) {
-            _GLTFMaterialExporter._SetAlphaMode(glTFMaterial, babylonPBRMaterial);
+            _GLTFMaterialExporter._SetAlphaMode(glTFMaterial, (babylonPBRMaterial as PBRMaterial));
             if (!(_GLTFMaterialExporter.FuzzyEquals(metallicRoughness.baseColor, Color3.White(), _GLTFMaterialExporter._Epsilon) && babylonPBRMaterial.alpha >= _GLTFMaterialExporter._Epsilon)) {
                 glTFPbrMetallicRoughness.baseColorFactor = [
                     metallicRoughness.baseColor.r,
@@ -1043,19 +1056,20 @@ export class _GLTFMaterialExporter {
             }
 
             if (babylonPBRMaterial.backFaceCulling != null && !babylonPBRMaterial.backFaceCulling) {
-                if (!babylonPBRMaterial.twoSidedLighting) {
+                if (!((babylonPBRMaterial as PBRMaterial).twoSidedLighting || (babylonPBRMaterial as PBRBaseSimpleMaterial).doubleSided)) {
                     Tools.Warn(babylonPBRMaterial.name + ": Back-face culling enabled and two-sided lighting disabled is not supported in glTF.");
                 }
                 glTFMaterial.doubleSided = true;
             }
 
             if (hasTextureCoords) {
-                if (babylonPBRMaterial.bumpTexture) {
-                    let promise = this._exportTextureAsync(babylonPBRMaterial.bumpTexture, mimeType).then((glTFTexture) => {
+                const bumpTexture = (babylonPBRMaterial as PBRMaterial).bumpTexture || (babylonPBRMaterial as PBRBaseSimpleMaterial).normalTexture;
+                if (bumpTexture) {
+                    let promise = this._exportTextureAsync(bumpTexture, mimeType).then((glTFTexture) => {
                         if (glTFTexture) {
                             glTFMaterial.normalTexture = glTFTexture;
-                            if (babylonPBRMaterial.bumpTexture.level !== 1) {
-                                glTFMaterial.normalTexture.scale = babylonPBRMaterial.bumpTexture.level;
+                            if (bumpTexture.level !== 1) {
+                                glTFMaterial.normalTexture.scale = bumpTexture.level;
                             }
                         }
                     }
@@ -1063,8 +1077,9 @@ export class _GLTFMaterialExporter {
                     promises.push(promise);
 
                 }
-                if (babylonPBRMaterial.ambientTexture) {
-                    let promise = this._exportTextureAsync(babylonPBRMaterial.ambientTexture, mimeType).then((glTFTexture) => {
+                const ambientTexture = (babylonPBRMaterial as PBRMaterial).ambientTexture || (babylonPBRMaterial as PBRBaseSimpleMaterial).occlusionTexture;
+                if (ambientTexture) {
+                    let promise = this._exportTextureAsync(ambientTexture, mimeType).then((glTFTexture) => {
                         if (glTFTexture) {
                             let occlusionTexture: IMaterialOcclusionTextureInfo = {
                                 index: glTFTexture.index,
@@ -1072,17 +1087,18 @@ export class _GLTFMaterialExporter {
                             };
 
                             glTFMaterial.occlusionTexture = occlusionTexture;
-
-                            if (babylonPBRMaterial.ambientTextureStrength) {
-                                occlusionTexture.strength = babylonPBRMaterial.ambientTextureStrength;
+                            const ambientTextureStrength = (babylonPBRMaterial as PBRMaterial).ambientTextureStrength || (babylonPBRMaterial as PBRBaseSimpleMaterial).occlusionStrength;
+                            if (ambientTextureStrength) {
+                                occlusionTexture.strength = ambientTextureStrength;
                             }
                         }
                     });
                     promises.push(promise);
 
                 }
-                if (babylonPBRMaterial.emissiveTexture) {
-                    let promise = this._exportTextureAsync(babylonPBRMaterial.emissiveTexture, mimeType).then((glTFTexture) => {
+                const emissiveTexture = (babylonPBRMaterial as PBRMaterial).emissiveTexture || (babylonPBRMaterial as PBRBaseSimpleMaterial).emissiveTexture;
+                if (emissiveTexture) {
+                    let promise = this._exportTextureAsync(emissiveTexture, mimeType).then((glTFTexture) => {
                         if (glTFTexture) {
                             glTFMaterial.emissiveTexture = glTFTexture;
                         }
@@ -1090,8 +1106,9 @@ export class _GLTFMaterialExporter {
                     promises.push(promise);
                 }
             }
-            if (!_GLTFMaterialExporter.FuzzyEquals(babylonPBRMaterial.emissiveColor, Color3.Black(), _GLTFMaterialExporter._Epsilon)) {
-                glTFMaterial.emissiveFactor = babylonPBRMaterial.emissiveColor.asArray();
+            const emissiveColor = (babylonPBRMaterial as PBRMaterial).emissiveColor || (babylonPBRMaterial as PBRBaseSimpleMaterial).emissiveColor;
+            if (!_GLTFMaterialExporter.FuzzyEquals(emissiveColor, Color3.Black(), _GLTFMaterialExporter._Epsilon)) {
+                glTFMaterial.emissiveFactor = emissiveColor.asArray();
             }
 
             glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness;

+ 1 - 1
src/Cameras/Inputs/freeCameraDeviceOrientationInput.ts

@@ -56,7 +56,7 @@ export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera
      * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
      * @returns a promise that will resolve on orientation change
      */
-    public static WaitForOrientationChangeAsync(timeout?: number) {
+    public static WaitForOrientationChangeAsync(timeout?: number): Promise<void> {
         return new Promise((res, rej) => {
             var gotValue = false;
             var eventHandler = () => {

+ 1 - 1
src/Engines/engine.ts

@@ -1699,7 +1699,7 @@ export class Engine extends ThinEngine {
         this._gl.deleteBuffer(buffer);
     }
 
-    private _clientWaitAsync(sync: WebGLSync, flags = 0, interval_ms = 10) {
+    private _clientWaitAsync(sync: WebGLSync, flags = 0, interval_ms = 10): Promise<void> {
         let gl = <WebGL2RenderingContext>(this._gl as any);
         return new Promise((resolve, reject) => {
             let check = () => {

+ 1 - 1
src/Engines/nativeEngine.ts

@@ -1793,7 +1793,7 @@ export class NativeEngine extends Engine {
             // Reorder from [+X, +Y, +Z, -X, -Y, -Z] to [+X, -X, +Y, -Y, +Z, -Z].
             const reorderedFiles = [files[0], files[3], files[1], files[4], files[2], files[5]];
             Promise.all(reorderedFiles.map((file) => Tools.LoadFileAsync(file).then((data) => new Uint8Array(data as ArrayBuffer)))).then((data) => {
-                return new Promise((resolve, reject) => {
+                return new Promise((resolve: (_: void) => void, reject) => {
                     this._native.loadCubeTexture(texture._hardwareTexture!.underlyingResource, data, !noMipmap, resolve, reject);
                 });
             }).then(() => {

+ 24 - 17
src/Loading/sceneLoader.ts

@@ -19,6 +19,7 @@ import { RequestFileError, ReadFileError } from '../Misc/fileTools';
 import { TransformNode } from '../Meshes/transformNode';
 import { Geometry } from '../Meshes/geometry';
 import { Light } from '../Lights/light';
+import { StringTools } from '../Misc/stringTools';
 
 /**
  * Type used for the success callback of ImportMesh
@@ -461,8 +462,8 @@ export class SceneLoader {
     }
 
     private static _LoadData(fileInfo: IFileInfo, scene: Scene, onSuccess: (plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync, data: any, responseURL?: string) => void, onProgress: ((event: ISceneLoaderProgressEvent) => void) | undefined, onError: (message: string, exception?: any) => void, onDispose: () => void, pluginExtension: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync> {
-        const directLoad = SceneLoader._GetDirectLoad(fileInfo.name);
-        const registeredPlugin = pluginExtension ? SceneLoader._GetPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._GetPluginForDirectLoad(fileInfo.name) : SceneLoader._GetPluginForFilename(fileInfo.name));
+        const directLoad = SceneLoader._GetDirectLoad(fileInfo.url);
+        const registeredPlugin = pluginExtension ? SceneLoader._GetPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._GetPluginForDirectLoad(fileInfo.url) : SceneLoader._GetPluginForFilename(fileInfo.url));
 
         let plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync;
         if ((registeredPlugin.plugin as ISceneLoaderPluginFactory).createPlugin !== undefined) {
@@ -542,9 +543,20 @@ export class SceneLoader {
                 : scene._requestFile(fileInfo.url, successCallback, onProgress, true, useArrayBuffer, errorCallback);
         };
 
-        const file = fileInfo.file || FilesInputStore.FilesToLoad[fileInfo.name.toLowerCase()];
+        if (StringTools.StartsWith(fileInfo.url, "file:")) {
+            // Loading file from disk via input file or drag'n'drop
+            if (fileInfo.file) {
+                const errorCallback = (error: ReadFileError) => {
+                    onError(error.message, error);
+                };
 
-        if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
+                request = plugin.readFile
+                    ? plugin.readFile(scene, fileInfo.file, dataCallback, onProgress, useArrayBuffer, errorCallback)
+                    : scene._readFile(fileInfo.file, dataCallback, onProgress, useArrayBuffer, errorCallback);
+            } else {
+                onError("Unable to find file named " + fileInfo.name);
+            }
+        } else {
             const engine = scene.getEngine();
             let canUseOfflineSupport = engine.enableOfflineSupport;
             if (canUseOfflineSupport) {
@@ -568,20 +580,7 @@ export class SceneLoader {
                 manifestChecked();
             }
         }
-        // Loading file from disk via input file or drag'n'drop
-        else {
-            if (file) {
-                const errorCallback = (error: ReadFileError) => {
-                    onError(error.message, error);
-                };
 
-                request = plugin.readFile
-                    ? plugin.readFile(scene, file, dataCallback, onProgress, useArrayBuffer, errorCallback)
-                    : scene._readFile(file, dataCallback, onProgress, useArrayBuffer, errorCallback);
-            } else {
-                onError("Unable to find file named " + fileInfo.name);
-            }
-        }
         return plugin;
     }
 
@@ -601,6 +600,10 @@ export class SceneLoader {
             name = sceneFile.name;
             file = sceneFile;
         }
+        else if (typeof sceneFilename === "string" && Tools.IsBase64(sceneFilename)) {
+            url = rootUrl + sceneFilename;
+            name = "";
+        }
         else {
             const filename = sceneFilename as string;
             if (filename.substr(0, 1) === "/") {
@@ -612,6 +615,10 @@ export class SceneLoader {
             name = filename;
         }
 
+        if (StringTools.StartsWith(url, "file:") && name) {
+            file = FilesInputStore.FilesToLoad[name.toLowerCase()];
+        }
+
         return {
             url: url,
             rootUrl: rootUrl,

+ 7 - 0
src/Materials/PBR/pbrSpecularGlossinessMaterial.ts

@@ -50,6 +50,13 @@ export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
     public specularGlossinessTexture: BaseTexture;
 
     /**
+     * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
+    */
+    public get useMicroSurfaceFromReflectivityMapAlpha() {
+        return this._useMicroSurfaceFromReflectivityMapAlpha;
+    }
+
+    /**
      * Instantiates a new PBRSpecularGlossinessMaterial instance.
      *
      * @param name The material name

+ 2 - 2
src/Materials/Textures/Filtering/hdrFiltering.ts

@@ -196,10 +196,10 @@ export class HDRFiltering {
       * @param onFinished Callback when filtering is done
       * @return Promise called when prefiltering is done
       */
-    public prefilter(texture: BaseTexture, onFinished: Nullable<() => void> = null) {
+    public prefilter(texture: BaseTexture, onFinished: Nullable<() => void> = null): Promise<void> {
         if (!this._engine._features.allowTexturePrefiltering) {
             Logger.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.");
-            return;
+            return Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.");
         }
 
         return new Promise((resolve) => {

+ 1 - 1
src/Misc/basis.ts

@@ -265,7 +265,7 @@ function workerFunc(): void {
                 // Override wasm binary
                 Module = { wasmBinary: (event.data.wasmBinary) };
                 importScripts(event.data.url);
-                transcoderModulePromise = new Promise((res) => {
+                transcoderModulePromise = new Promise((res: (_: void) => void) => {
                     Module.onRuntimeInitialized = () => {
                         Module.initializeBasis();
                         res();

+ 2 - 2
src/Misc/deferred.ts

@@ -7,7 +7,7 @@ export class Deferred<T> {
      */
     public readonly promise: Promise<T>;
 
-    private _resolve: (value?: T | PromiseLike<T>) => void;
+    private _resolve: (value: T | PromiseLike<T>) => void;
     private _reject: (reason?: any) => void;
 
     /**
@@ -28,7 +28,7 @@ export class Deferred<T> {
      * Constructor for this deferred object.
      */
     constructor() {
-        this.promise = new Promise((resolve, reject) => {
+        this.promise = new Promise((resolve: (value: T | PromiseLike<T>) => void, reject) => {
             this._resolve = resolve;
             this._reject = reject;
         });

+ 1 - 1
src/Particles/pointsCloudSystem.ts

@@ -470,7 +470,7 @@ export class PointsCloudSystem implements IDisposable {
 
         var clone = <Mesh>mesh.clone();
         clone.setEnabled(false);
-        this._promises.push(new Promise((resolve) => {
+        this._promises.push(new Promise((resolve: (_: void) => void) => {
             BaseTexture.WhenAllReady(textureList, () => {
                 let n = pointsGroup._textureNb;
                 if (n < 0) {

+ 5 - 2
src/Sprites/spriteManager.ts

@@ -17,6 +17,9 @@ import { ISize } from '../Maths/math.size';
 
 declare type Ray = import("../Culling/ray").Ray;
 
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect
+declare const Reflect: any;
+
 /**
  * Defines the minimum interface to fullfil in order to be a sprite manager.
  */
@@ -303,7 +306,7 @@ export class SpriteManager implements ISpriteManager {
                     celldata.frames = frametemp;
                 }
 
-                let spritemap = (<string[]>(<any>Reflect).ownKeys(celldata.frames));
+                let spritemap = (<string[]>(Reflect).ownKeys(celldata.frames));
 
                 this._spriteMap = spritemap;
                 this._packedAndReady = true;
@@ -333,7 +336,7 @@ export class SpriteManager implements ISpriteManager {
             xmlhttp.onload = () => {
                 try {
                     let celldata  = JSON.parse(xmlhttp.response);
-                    let spritemap = (<string[]>(<any>Reflect).ownKeys(celldata.frames));
+                    let spritemap = (<string[]>(Reflect).ownKeys(celldata.frames));
                     this._spriteMap = spritemap;
                     this._packedAndReady = true;
                     this._cellData = celldata.frames;

+ 2 - 2
tests/unit/babylon/src/Misc/babylon.promise.tests.ts

@@ -21,7 +21,7 @@ describe('Babylon.Promise', function() {
     describe('#Composition', () => {
         it('should chain promises correctly #1', (done) => {
             var tempString = "";
-            var p1 = new Promise((resolve, reject) => {
+            var p1 = new Promise((resolve: (_: void) => void, reject) => {
                 tempString = "Initial";
                 resolve();
             }).then(() => {
@@ -43,7 +43,7 @@ describe('Babylon.Promise', function() {
 
         it('should chain promises correctly #2', (done) => {
             var tempString = "";
-            var p1 = new Promise((resolve, reject) => {
+            var p1 = new Promise((resolve: (_: void) => void, reject) => {
                 tempString = "Initial";
                 resolve();
             }).then(() => {