David Catuhe 8 gadi atpakaļ
vecāks
revīzija
79bbe4d489
30 mainītis faili ar 8362 papildinājumiem un 7463 dzēšanām
  1. 2 0
      Playground/babylon.d.txt
  2. 1 1
      Tools/Gulp/config.json
  3. 925 857
      dist/preview release/babylon.d.ts
  4. 45 45
      dist/preview release/babylon.js
  5. 343 30
      dist/preview release/babylon.max.js
  6. 925 857
      dist/preview release/babylon.module.d.ts
  7. 42 41
      dist/preview release/babylon.worker.js
  8. 2723 2650
      dist/preview release/customConfigurations/minimalViewer/babylon.d.ts
  9. 22 22
      dist/preview release/customConfigurations/minimalViewer/babylon.js
  10. 180 2
      dist/preview release/customConfigurations/minimalViewer/babylon.max.js
  11. 2723 2650
      dist/preview release/customConfigurations/minimalViewer/babylon.module.d.ts
  12. 3 3
      dist/preview release/inspector/babylon.inspector.bundle.js
  13. 12 0
      dist/preview release/inspector/babylon.inspector.d.ts
  14. 73 5
      dist/preview release/inspector/babylon.inspector.js
  15. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  16. 7 4
      dist/preview release/loaders/babylon.glTF1FileLoader.d.ts
  17. 10 13
      dist/preview release/loaders/babylon.glTF1FileLoader.js
  18. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  19. 12 5
      dist/preview release/loaders/babylon.glTF2FileLoader.d.ts
  20. 70 52
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  21. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  22. 12 5
      dist/preview release/loaders/babylon.glTFFileLoader.d.ts
  23. 71 53
      dist/preview release/loaders/babylon.glTFFileLoader.js
  24. 2 2
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  25. 4 2
      dist/preview release/loaders/babylon.objFileLoader.js
  26. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  27. 3 1
      dist/preview release/loaders/babylon.stlFileLoader.js
  28. 1 1
      dist/preview release/loaders/babylon.stlFileLoader.min.js
  29. 144 0
      src/Loading/babylon.loadingScreen.ts
  30. 0 155
      src/Tools/babylon.loadingScreen.ts

+ 2 - 0
Playground/babylon.d.txt

@@ -15431,3 +15431,5 @@ declare module BABYLON.GUI {
         constructor(name?: string);
     }
 }
+
+declare var engine: BABYLON.Engine;

+ 1 - 1
Tools/Gulp/config.json

@@ -431,7 +431,7 @@
         "loader" : 
         {
             "files": [
-                "../../src/Tools/babylon.loadingScreen.js",
+                "../../src/Loading/babylon.loadingScreen.js",
                 "../../src/Loading/babylon.sceneLoader.js",
                 "../../src/Loading/Plugins/babylon.babylonFileLoader.js",
                 "../../src/Tools/babylon.filesInput.js"

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


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


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


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 925 - 857
dist/preview release/babylon.module.d.ts


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


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 2723 - 2650
dist/preview release/customConfigurations/minimalViewer/babylon.d.ts


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


+ 180 - 2
dist/preview release/customConfigurations/minimalViewer/babylon.max.js

@@ -8540,7 +8540,7 @@ var BABYLON;
                     var buffer = vertexBuffer.getBuffer();
                     this.vertexAttribPointer(buffer, order, vertexBuffer.getSize(), this._gl.FLOAT, false, vertexBuffer.getStrideSize() * 4, vertexBuffer.getOffset() * 4);
                     if (vertexBuffer.getIsInstanced()) {
-                        this._gl.vertexAttribDivisor(order, 1);
+                        this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
                         if (!this._vaoRecordInProgress) {
                             this._currentInstanceLocations.push(order);
                             this._currentInstanceBuffers.push(buffer);
@@ -10277,6 +10277,9 @@ var BABYLON;
             this.releaseEffects();
             // Unbind
             this.unbindAllAttributes();
+            if (this._dummyFramebuffer) {
+                this._gl.deleteFramebuffer(this._dummyFramebuffer);
+            }
             this._gl = null;
             //WebVR
             this.disableVR();
@@ -10379,6 +10382,26 @@ var BABYLON;
                 this.fps = 1000.0 / (sum / (length - 1));
             }
         };
+        Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex) {
+            if (faceIndex === void 0) { faceIndex = -1; }
+            var gl = this._gl;
+            if (!this._dummyFramebuffer) {
+                this._dummyFramebuffer = gl.createFramebuffer();
+            }
+            gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
+            if (faceIndex > -1) {
+                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture, 0);
+            }
+            else {
+                gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
+            }
+            var readFormat = gl.RGBA;
+            var readType = gl.UNSIGNED_BYTE;
+            var buffer = new Uint8Array(4 * width * height);
+            gl.readPixels(0, 0, width, height, readFormat, readType, buffer);
+            gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+            return buffer;
+        };
         Engine.prototype._canRenderToFloatFramebuffer = function () {
             if (this._webGLVersion > 1) {
                 return this._caps.colorBufferFloat;
@@ -11962,6 +11985,30 @@ var BABYLON;
             return this;
         };
         /**
+         * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
+         * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
+         * The passed axis is also normalized.
+         * Returns the AbstractMesh.
+         * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
+         */
+        AbstractMesh.prototype.rotateAround = function (point, axis, amount) {
+            axis.normalize();
+            if (!this.rotationQuaternion) {
+                this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
+                this.rotation.copyFromFloats(0, 0, 0);
+            }
+            point.subtractToRef(this.position, BABYLON.Tmp.Vector3[0]);
+            BABYLON.Matrix.TranslationToRef(BABYLON.Tmp.Vector3[0].x, BABYLON.Tmp.Vector3[0].y, BABYLON.Tmp.Vector3[0].z, BABYLON.Tmp.Matrix[0]);
+            BABYLON.Tmp.Matrix[0].invertToRef(BABYLON.Tmp.Matrix[2]);
+            BABYLON.Matrix.RotationAxisToRef(axis, amount, BABYLON.Tmp.Matrix[1]);
+            BABYLON.Tmp.Matrix[2].multiplyToRef(BABYLON.Tmp.Matrix[1], BABYLON.Tmp.Matrix[2]);
+            BABYLON.Tmp.Matrix[2].multiplyToRef(BABYLON.Tmp.Matrix[0], BABYLON.Tmp.Matrix[2]);
+            BABYLON.Tmp.Matrix[2].decompose(BABYLON.Tmp.Vector3[0], BABYLON.Tmp.Quaternion[0], BABYLON.Tmp.Vector3[1]);
+            this.position.addInPlace(BABYLON.Tmp.Vector3[1]);
+            this.rotationQuaternion.multiplyInPlace(BABYLON.Tmp.Quaternion[0]);
+            return this;
+        };
+        /**
          * Translates the mesh along the axis vector for the passed distance in the given space.
          * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
          * Returns the AbstractMesh.
@@ -18525,6 +18572,7 @@ var BABYLON;
                 this.create();
             }
             this._instanced = instanced;
+            this._instanceDivisor = instanced ? 1 : 0;
         }
         Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride) {
             // a lot of these parameters are ignored as they are overriden by the buffer
@@ -18546,6 +18594,22 @@ var BABYLON;
         Buffer.prototype.getIsInstanced = function () {
             return this._instanced;
         };
+        Object.defineProperty(Buffer.prototype, "instanceDivisor", {
+            get: function () {
+                return this._instanceDivisor;
+            },
+            set: function (value) {
+                this._instanceDivisor = value;
+                if (value == 0) {
+                    this._instanced = false;
+                }
+                else {
+                    this._instanced = true;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         // Methods
         Buffer.prototype.create = function (data) {
             if (!data && this._buffer) {
@@ -18693,6 +18757,12 @@ var BABYLON;
         VertexBuffer.prototype.getIsInstanced = function () {
             return this._buffer.getIsInstanced();
         };
+        /**
+         * Returns the instancing divisor, zero for non-instanced (integer).
+         */
+        VertexBuffer.prototype.getInstanceDivisor = function () {
+            return this._buffer.instanceDivisor;
+        };
         // Methods
         /**
          * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
@@ -19006,6 +19076,18 @@ var BABYLON;
         BaseTexture.prototype.clone = function () {
             return null;
         };
+        BaseTexture.prototype.readPixels = function (faceIndex) {
+            if (faceIndex === void 0) { faceIndex = 0; }
+            if (!this._texture) {
+                return null;
+            }
+            var size = this.getSize();
+            var engine = this.getScene().getEngine();
+            if (this._texture.isCube) {
+                return engine._readTexturePixels(this._texture, size.width, size.height, faceIndex);
+            }
+            return engine._readTexturePixels(this._texture, size.width, size.height);
+        };
         BaseTexture.prototype.releaseInternalTexture = function () {
             if (this._texture) {
                 this._scene.getEngine().releaseInternalTexture(this._texture);
@@ -23519,6 +23601,11 @@ var BABYLON;
             for (var index = lightIndex; index < maxSimultaneousLights; index++) {
                 if (defines["LIGHT" + index] !== undefined) {
                     defines["LIGHT" + index] = false;
+                    defines["HEMILIGHT" + lightIndex] = false;
+                    defines["POINTLIGHT" + lightIndex] = false;
+                    defines["DIRLIGHT" + lightIndex] = false;
+                    defines["SPOTLIGHT" + lightIndex] = false;
+                    defines["SHADOW" + lightIndex] = false;
                 }
             }
             var caps = scene.getEngine().getCaps();
@@ -24137,20 +24224,24 @@ var BABYLON;
             return result;
         };
         // Force shader compilation including textures ready check
-        Material.prototype.forceCompilation = function (mesh, onCompiled) {
+        Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
             var _this = this;
             var subMesh = new BABYLON.BaseSubMesh();
             var scene = this.getScene();
+            var engine = scene.getEngine();
             var beforeRenderCallback = function () {
                 if (subMesh._materialDefines) {
                     subMesh._materialDefines._renderId = -1;
                 }
+                var alphaTestState = engine.getAlphaTesting();
+                engine.setAlphaTesting(options ? options.alphaTest : _this.needAlphaTesting());
                 if (_this.isReadyForSubMesh(mesh, subMesh)) {
                     scene.unregisterBeforeRender(beforeRenderCallback);
                     if (onCompiled) {
                         onCompiled(_this);
                     }
                 }
+                engine.setAlphaTesting(alphaTestState);
             };
             scene.registerBeforeRender(beforeRenderCallback);
         };
@@ -34968,6 +35059,9 @@ var BABYLON;
             return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
         };
         PBRBaseMaterial.prototype.needAlphaTesting = function () {
+            if (this._forceAlphaTest) {
+                return true;
+            }
             if (this._linkRefractionWithTransparency) {
                 return false;
             }
@@ -36809,6 +36903,9 @@ var BABYLON;
                 defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
                 defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
                 fallbacks.addCPUSkinningFallback(0, mesh);
+                if (this._options.uniforms.indexOf("mBones") === -1) {
+                    this._options.uniforms.push("mBones");
+                }
             }
             else {
                 defines.push("#define NUM_BONE_INFLUENCERS 0");
@@ -44414,6 +44511,87 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    var Debug;
+    (function (Debug) {
+        var PhysicsViewer = (function () {
+            function PhysicsViewer(scene) {
+                this._impostors = [];
+                this._meshes = [];
+                this._numMeshes = 0;
+                this._scene = scene || BABYLON.Engine.LastCreatedScene;
+                this._physicsEnginePlugin = this._scene.getPhysicsEngine().getPhysicsPlugin();
+            }
+            PhysicsViewer.prototype._updateDebugMeshes = function () {
+                var plugin = this._physicsEnginePlugin;
+                for (var i = 0; i < this._numMeshes; i++) {
+                    if (this._impostors[i].isDisposed) {
+                        this.hideImpostor(this._impostors[i--]);
+                    }
+                    else {
+                        plugin.syncMeshWithImpostor(this._meshes[i], this._impostors[i]);
+                    }
+                }
+            };
+            PhysicsViewer.prototype.showImpostor = function (impostor) {
+                for (var i = 0; i < this._numMeshes; i++) {
+                    if (this._impostors[i] == impostor) {
+                        return;
+                    }
+                }
+                var debugMesh = this._physicsEnginePlugin.getDebugMesh(impostor, this._scene);
+                if (debugMesh) {
+                    this._impostors[this._numMeshes] = impostor;
+                    this._meshes[this._numMeshes] = debugMesh;
+                    if (this._numMeshes === 0) {
+                        this._renderFunction = this._updateDebugMeshes.bind(this);
+                        this._scene.registerBeforeRender(this._renderFunction);
+                    }
+                    this._numMeshes++;
+                }
+            };
+            PhysicsViewer.prototype.hideImpostor = function (impostor) {
+                var removed = false;
+                for (var i = 0; i < this._numMeshes; i++) {
+                    if (this._impostors[i] == impostor) {
+                        this._scene.removeMesh(this._meshes[i]);
+                        this._meshes[i].dispose();
+                        this._numMeshes--;
+                        if (this._numMeshes > 0) {
+                            this._meshes[i] = this._meshes[this._numMeshes];
+                            this._impostors[i] = this._impostors[this._numMeshes];
+                            this._meshes[this._numMeshes] = null;
+                            this._impostors[this._numMeshes] = null;
+                        }
+                        else {
+                            this._meshes[0] = null;
+                            this._impostors[0] = null;
+                        }
+                        removed = true;
+                        break;
+                    }
+                }
+                if (removed && this._numMeshes === 0) {
+                    this._scene.unregisterBeforeRender(this._renderFunction);
+                }
+            };
+            PhysicsViewer.prototype.dispose = function () {
+                for (var i = 0; i < this._numMeshes; i++) {
+                    this.hideImpostor(this._impostors[i]);
+                }
+                this._impostors.length = 0;
+                this._scene = null;
+                this._physicsEnginePlugin = null;
+            };
+            return PhysicsViewer;
+        }());
+        Debug.PhysicsViewer = PhysicsViewer;
+    })(Debug = BABYLON.Debug || (BABYLON.Debug = {}));
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.physicsViewer.js.map
+
+var BABYLON;
+(function (BABYLON) {
     var BoundingBoxRenderer = (function () {
         function BoundingBoxRenderer(scene) {
             this.frontColor = new BABYLON.Color3(1, 1, 1);

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 2723 - 2650
dist/preview release/customConfigurations/minimalViewer/babylon.module.d.ts


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


+ 12 - 0
dist/preview release/inspector/babylon.inspector.d.ts

@@ -255,6 +255,10 @@ declare module INSPECTOR {
         'WorldSpaceCanvas2DNode': {
             type: typeof BABYLON.WorldSpaceCanvas2DNode;
         };
+        'PhysicsImpostor': {
+            type: typeof BABYLON.PhysicsImpostor;
+            properties: string[];
+        };
     };
 }
 
@@ -834,6 +838,14 @@ declare module INSPECTOR {
 }
 
 declare module INSPECTOR {
+    class PhysicsTab extends PropertyTab {
+        viewer: BABYLON.Debug.PhysicsViewer;
+        constructor(tabbar: TabBar, inspector: Inspector);
+        protected _getTree(): Array<TreeItem>;
+    }
+}
+
+declare module INSPECTOR {
     class SoundTab extends PropertyTab {
         constructor(tabbar: TabBar, inspector: Inspector);
         protected _getTree(): Array<TreeItem>;

+ 73 - 5
dist/preview release/inspector/babylon.inspector.js

@@ -9,8 +9,19 @@ var INSPECTOR;
             var _this = this;
             /** True if the inspector is built as a popup tab */
             this._popupMode = false;
-            //Load properties of GUI objects now as BABYLON.GUI has to be declared before 
-            INSPECTOR.loadGUIProperties();
+            // Load GUI library if not already done
+            if (!BABYLON.GUI) {
+                BABYLON.Tools.LoadScript("https://preview.babylonjs.com/gui/babylon.gui.js", function () {
+                    //Load properties of GUI objects now as BABYLON.GUI has to be declared before 
+                    INSPECTOR.loadGUIProperties();
+                }, function () {
+                    console.warn("Please add script https://preview.babylonjs.com/gui/babylon.gui.js to the HTML file");
+                });
+            }
+            else {
+                //Load properties of GUI objects now as BABYLON.GUI has to be declared before 
+                INSPECTOR.loadGUIProperties();
+            }
             //get Tabbar initialTab
             this._initialTab = initialTab;
             //get parentElement of our Inspector
@@ -243,6 +254,7 @@ var INSPECTOR;
          */
         Inspector.prototype.dispose = function () {
             if (!this._popupMode) {
+                this._tabbar.getActiveTab().dispose();
                 // Get canvas
                 var canvas = this._scene.getEngine().getRenderingCanvas();
                 // restore canvas style
@@ -703,7 +715,15 @@ var INSPECTOR;
         },
         'WorldSpaceCanvas2DNode': {
             type: BABYLON.WorldSpaceCanvas2DNode
-        }
+        },
+        'PhysicsImpostor': {
+            type: BABYLON.PhysicsImpostor,
+            properties: [
+                'friction',
+                'mass',
+                'restitution',
+            ]
+        },
     };
 })(INSPECTOR || (INSPECTOR = {}));
 
@@ -1816,7 +1836,12 @@ var INSPECTOR;
                 // Enter : validate the new value
                 var newValue = this._input.value;
                 this.updateObject();
-                this._property.value = newValue;
+                if (typeof this._property.value === 'number') {
+                    this._property.value = parseFloat(newValue);
+                }
+                else {
+                    this._property.value = newValue;
+                }
                 // Remove input
                 this.update();
                 // resume scheduler
@@ -2894,6 +2919,46 @@ var __extends = (this && this.__extends) || (function () {
 })();
 var INSPECTOR;
 (function (INSPECTOR) {
+    var PhysicsTab = (function (_super) {
+        __extends(PhysicsTab, _super);
+        function PhysicsTab(tabbar, inspector) {
+            return _super.call(this, tabbar, 'Physics', inspector) || this;
+        }
+        /* Overrides super */
+        PhysicsTab.prototype._getTree = function () {
+            var arr = [];
+            var scene = this._inspector.scene;
+            if (!scene.isPhysicsEnabled()) {
+                return arr;
+            }
+            if (!this.viewer) {
+                this.viewer = new BABYLON.Debug.PhysicsViewer(scene);
+            }
+            for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
+                var mesh = _a[_i];
+                if (mesh.physicsImpostor) {
+                    arr.push(new INSPECTOR.TreeItem(this, new PhysicsImpostorAdapter(mesh.physicsImpostor, this.viewer)));
+                }
+            }
+            return arr;
+        };
+        return PhysicsTab;
+    }(INSPECTOR.PropertyTab));
+    INSPECTOR.PhysicsTab = PhysicsTab;
+})(INSPECTOR || (INSPECTOR = {}));
+
+var __extends = (this && this.__extends) || (function () {
+    var extendStatics = Object.setPrototypeOf ||
+        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+    return function (d, b) {
+        extendStatics(d, b);
+        function __() { this.constructor = d; }
+        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+    };
+})();
+var INSPECTOR;
+(function (INSPECTOR) {
     var SoundTab = (function (_super) {
         __extends(SoundTab, _super);
         function SoundTab(tabbar, inspector) {
@@ -3939,7 +4004,10 @@ var INSPECTOR;
             _this._tabs.push(new INSPECTOR.ShaderTab(_this, _this._inspector));
             _this._tabs.push(new INSPECTOR.LightTab(_this, _this._inspector));
             _this._tabs.push(new INSPECTOR.MaterialTab(_this, _this._inspector));
-            _this._tabs.push(new INSPECTOR.GUITab(_this, _this._inspector));
+            if (BABYLON.GUI) {
+                _this._tabs.push(new INSPECTOR.GUITab(_this, _this._inspector));
+            }
+            _this._tabs.push(new INSPECTOR.PhysicsTab(_this, _this._inspector));
             _this._tabs.push(new INSPECTOR.CameraTab(_this, _this._inspector));
             _this._tabs.push(new INSPECTOR.SoundTab(_this, _this._inspector));
             _this._toolBar = new INSPECTOR.Toolbar(_this._inspector);

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


+ 7 - 4
dist/preview release/loaders/babylon.glTF1FileLoader.d.ts

@@ -5,14 +5,17 @@ declare module BABYLON {
         bin: ArrayBufferView;
     }
     interface IGLTFLoader {
-        importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onsuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror: () => void) => void;
-        loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onsuccess: () => void, onerror: () => void) => void;
+        importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void) => void;
+        loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void) => void;
     }
     class GLTFFileLoader implements ISceneLoaderPluginAsync {
-        static GLTFLoaderV1: IGLTFLoader;
-        static GLTFLoaderV2: IGLTFLoader;
+        static CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
+        static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static HomogeneousCoordinates: boolean;
         static IncrementalLoading: boolean;
+        onTextureLoaded: (texture: BaseTexture) => void;
+        onMaterialLoaded: (material: Material) => void;
+        onComplete: () => void;
         extensions: ISceneLoaderPluginExtensions;
         importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void): void;
         loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: () => void, onError: () => void): void;

+ 10 - 13
dist/preview release/loaders/babylon.glTF1FileLoader.js

@@ -53,17 +53,13 @@ var BABYLON;
                     return null;
                 }
             }
-            var loaders = {
-                1: GLTFFileLoader.GLTFLoaderV1,
-                2: GLTFFileLoader.GLTFLoaderV2
+            var createLoader = {
+                1: GLTFFileLoader.CreateGLTFLoaderV1,
+                2: GLTFFileLoader.CreateGLTFLoaderV2
             };
-            var loader = loaders[version.major];
-            if (loader === undefined) {
-                BABYLON.Tools.Error("Unsupported version");
-                return null;
-            }
+            var loader = createLoader[version.major](this);
             if (loader === null) {
-                BABYLON.Tools.Error("v" + version.major + " loader is not available");
+                BABYLON.Tools.Error("Unsupported version");
                 return null;
             }
             return loader;
@@ -193,8 +189,7 @@ var BABYLON;
         };
         return GLTFFileLoader;
     }());
-    GLTFFileLoader.GLTFLoaderV1 = null;
-    GLTFFileLoader.GLTFLoaderV2 = null;
+    // V1 options
     GLTFFileLoader.HomogeneousCoordinates = false;
     GLTFFileLoader.IncrementalLoading = true;
     BABYLON.GLTFFileLoader = GLTFFileLoader;
@@ -225,7 +220,9 @@ var BABYLON;
         };
         return BinaryReader;
     }());
-    BABYLON.SceneLoader.RegisterPlugin(new GLTFFileLoader());
+    if (BABYLON.SceneLoader) {
+        BABYLON.SceneLoader.RegisterPlugin(new GLTFFileLoader());
+    }
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=babylon.glTFFileLoader.js.map
@@ -1756,7 +1753,7 @@ var BABYLON;
         GLTFLoader.Extensions = {};
         GLTF1.GLTFLoader = GLTFLoader;
         ;
-        BABYLON.GLTFFileLoader.GLTFLoaderV1 = new GLTFLoader();
+        BABYLON.GLTFFileLoader.CreateGLTFLoaderV1 = function () { return new GLTFLoader(); };
     })(GLTF1 = BABYLON.GLTF1 || (BABYLON.GLTF1 = {}));
 })(BABYLON || (BABYLON = {}));
 

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


+ 12 - 5
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -5,14 +5,17 @@ declare module BABYLON {
         bin: ArrayBufferView;
     }
     interface IGLTFLoader {
-        importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onsuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror: () => void) => void;
-        loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onsuccess: () => void, onerror: () => void) => void;
+        importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void) => void;
+        loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void) => void;
     }
     class GLTFFileLoader implements ISceneLoaderPluginAsync {
-        static GLTFLoaderV1: IGLTFLoader;
-        static GLTFLoaderV2: IGLTFLoader;
+        static CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
+        static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static HomogeneousCoordinates: boolean;
         static IncrementalLoading: boolean;
+        onTextureLoaded: (texture: BaseTexture) => void;
+        onMaterialLoaded: (material: Material) => void;
+        onComplete: () => void;
         extensions: ISceneLoaderPluginExtensions;
         importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void): void;
         loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: () => void, onError: () => void): void;
@@ -183,7 +186,7 @@ declare module BABYLON.GLTF2 {
         alphaCutoff: number;
         doubleSided?: boolean;
         index?: number;
-        babylonMaterial?: PBRMaterial;
+        babylonMaterial?: Material;
     }
     interface IGLTFMeshPrimitive extends IGLTFProperty {
         attributes: {
@@ -269,6 +272,7 @@ declare module BABYLON.GLTF2 {
 
 declare module BABYLON.GLTF2 {
     class GLTFLoader implements IGLTFLoader {
+        private _parent;
         private _gltf;
         private _errors;
         private _babylonScene;
@@ -285,6 +289,7 @@ declare module BABYLON.GLTF2 {
         static RegisterExtension(extension: GLTFLoaderExtension): void;
         readonly gltf: IGLTF;
         readonly babylonScene: Scene;
+        constructor(parent: GLTFFileLoader);
         importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void): void;
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void): void;
         private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess, onError);
@@ -300,6 +305,7 @@ declare module BABYLON.GLTF2 {
         private _createBone(node, skin);
         private _loadMesh(node);
         private _loadMeshData(node, mesh, babylonMesh);
+        private _assignMaterial(multiMaterial, index, subMaterial);
         private _loadVertexDataAsync(primitive, onSuccess);
         private _createMorphTargets(node, mesh, primitive, babylonMesh);
         private _loadMorphTargetsData(mesh, primitive, vertexData, babylonMesh);
@@ -390,5 +396,6 @@ declare module BABYLON.GLTF2.Extensions {
     class KHRMaterialsPbrSpecularGlossiness extends GLTFLoaderExtension {
         readonly name: string;
         protected loadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean;
+        private _loadSpecularGlossinessProperties(loader, material, properties);
     }
 }

+ 70 - 52
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -53,17 +53,13 @@ var BABYLON;
                     return null;
                 }
             }
-            var loaders = {
-                1: GLTFFileLoader.GLTFLoaderV1,
-                2: GLTFFileLoader.GLTFLoaderV2
+            var createLoader = {
+                1: GLTFFileLoader.CreateGLTFLoaderV1,
+                2: GLTFFileLoader.CreateGLTFLoaderV2
             };
-            var loader = loaders[version.major];
-            if (loader === undefined) {
-                BABYLON.Tools.Error("Unsupported version");
-                return null;
-            }
+            var loader = createLoader[version.major](this);
             if (loader === null) {
-                BABYLON.Tools.Error("v" + version.major + " loader is not available");
+                BABYLON.Tools.Error("Unsupported version");
                 return null;
             }
             return loader;
@@ -193,8 +189,7 @@ var BABYLON;
         };
         return GLTFFileLoader;
     }());
-    GLTFFileLoader.GLTFLoaderV1 = null;
-    GLTFFileLoader.GLTFLoaderV2 = null;
+    // V1 options
     GLTFFileLoader.HomogeneousCoordinates = false;
     GLTFFileLoader.IncrementalLoading = true;
     BABYLON.GLTFFileLoader = GLTFFileLoader;
@@ -225,7 +220,9 @@ var BABYLON;
         };
         return BinaryReader;
     }());
-    BABYLON.SceneLoader.RegisterPlugin(new GLTFFileLoader());
+    if (BABYLON.SceneLoader) {
+        BABYLON.SceneLoader.RegisterPlugin(new GLTFFileLoader());
+    }
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=babylon.glTFFileLoader.js.map
@@ -288,7 +285,8 @@ var BABYLON;
     var GLTF2;
     (function (GLTF2) {
         var GLTFLoader = (function () {
-            function GLTFLoader() {
+            function GLTFLoader(parent) {
+                this._parent = parent;
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -369,6 +367,9 @@ var BABYLON;
                 this._errors.forEach(function (error) { return BABYLON.Tools.Error(error); });
                 this._errors = [];
                 this._clear();
+                if (this._parent.onComplete) {
+                    this._parent.onComplete();
+                }
             };
             GLTFLoader.prototype._loadData = function (data) {
                 this._gltf = data.json;
@@ -563,11 +564,11 @@ var BABYLON;
                             _this.loadMaterial(primitive.material, function (babylonSubMaterial) {
                                 if (_this._renderReady) {
                                     babylonSubMaterial.forceCompilation(babylonMesh, function (babylonSubMaterial) {
-                                        babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
+                                        _this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
                                     });
                                 }
                                 else {
-                                    babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
+                                    _this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
                                 }
                             });
                         }
@@ -585,6 +586,12 @@ var BABYLON;
                     _loop_1(i);
                 }
             };
+            GLTFLoader.prototype._assignMaterial = function (multiMaterial, index, subMaterial) {
+                multiMaterial.subMaterials[index] = subMaterial;
+                if (this._parent.onMaterialLoaded) {
+                    this._parent.onMaterialLoaded(subMaterial);
+                }
+            };
             GLTFLoader.prototype._loadVertexDataAsync = function (primitive, onSuccess) {
                 var _this = this;
                 var attributes = primitive.attributes;
@@ -995,25 +1002,26 @@ var BABYLON;
                 return this._defaultMaterial;
             };
             GLTFLoader.prototype._loadMaterialMetallicRoughnessProperties = function (material) {
+                var babylonMaterial = material.babylonMaterial;
                 // Ensure metallic workflow
-                material.babylonMaterial.metallic = 1;
-                material.babylonMaterial.roughness = 1;
+                babylonMaterial.metallic = 1;
+                babylonMaterial.roughness = 1;
                 var properties = material.pbrMetallicRoughness;
                 if (!properties) {
                     return;
                 }
-                material.babylonMaterial.albedoColor = properties.baseColorFactor ? BABYLON.Color3.FromArray(properties.baseColorFactor) : new BABYLON.Color3(1, 1, 1);
-                material.babylonMaterial.metallic = properties.metallicFactor === undefined ? 1 : properties.metallicFactor;
-                material.babylonMaterial.roughness = properties.roughnessFactor === undefined ? 1 : properties.roughnessFactor;
+                babylonMaterial.albedoColor = properties.baseColorFactor ? BABYLON.Color3.FromArray(properties.baseColorFactor) : new BABYLON.Color3(1, 1, 1);
+                babylonMaterial.metallic = properties.metallicFactor === undefined ? 1 : properties.metallicFactor;
+                babylonMaterial.roughness = properties.roughnessFactor === undefined ? 1 : properties.roughnessFactor;
                 if (properties.baseColorTexture) {
-                    material.babylonMaterial.albedoTexture = this.loadTexture(properties.baseColorTexture);
+                    babylonMaterial.albedoTexture = this.loadTexture(properties.baseColorTexture);
                     this.loadMaterialAlphaProperties(material);
                 }
                 if (properties.metallicRoughnessTexture) {
-                    material.babylonMaterial.metallicTexture = this.loadTexture(properties.metallicRoughnessTexture);
-                    material.babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
-                    material.babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
-                    material.babylonMaterial.useRoughnessFromMetallicTextureAlpha = false;
+                    babylonMaterial.metallicTexture = this.loadTexture(properties.metallicRoughnessTexture);
+                    babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
+                    babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
+                    babylonMaterial.useRoughnessFromMetallicTextureAlpha = false;
                 }
             };
             GLTFLoader.prototype.loadMaterial = function (index, assign) {
@@ -1032,47 +1040,50 @@ var BABYLON;
                 assign(material.babylonMaterial);
             };
             GLTFLoader.prototype.createPbrMaterial = function (material) {
-                material.babylonMaterial = new BABYLON.PBRMaterial(material.name || "mat" + material.index, this._babylonScene);
-                material.babylonMaterial.sideOrientation = BABYLON.Material.CounterClockWiseSideOrientation;
-                material.babylonMaterial.useScalarInLinearSpace = true;
+                var babylonMaterial = new BABYLON.PBRMaterial(material.name || "mat" + material.index, this._babylonScene);
+                babylonMaterial.sideOrientation = BABYLON.Material.CounterClockWiseSideOrientation;
+                babylonMaterial.useScalarInLinearSpace = true;
+                material.babylonMaterial = babylonMaterial;
             };
             GLTFLoader.prototype.loadMaterialBaseProperties = function (material) {
-                material.babylonMaterial.useEmissiveAsIllumination = (material.emissiveFactor || material.emissiveTexture) ? true : false;
-                material.babylonMaterial.emissiveColor = material.emissiveFactor ? BABYLON.Color3.FromArray(material.emissiveFactor) : new BABYLON.Color3(0, 0, 0);
+                var babylonMaterial = material.babylonMaterial;
+                babylonMaterial.useEmissiveAsIllumination = (material.emissiveFactor || material.emissiveTexture) ? true : false;
+                babylonMaterial.emissiveColor = material.emissiveFactor ? BABYLON.Color3.FromArray(material.emissiveFactor) : new BABYLON.Color3(0, 0, 0);
                 if (material.doubleSided) {
-                    material.babylonMaterial.backFaceCulling = false;
-                    material.babylonMaterial.twoSidedLighting = true;
+                    babylonMaterial.backFaceCulling = false;
+                    babylonMaterial.twoSidedLighting = true;
                 }
                 if (material.normalTexture) {
-                    material.babylonMaterial.bumpTexture = this.loadTexture(material.normalTexture);
+                    babylonMaterial.bumpTexture = this.loadTexture(material.normalTexture);
                     if (material.normalTexture.scale !== undefined) {
-                        material.babylonMaterial.bumpTexture.level = material.normalTexture.scale;
+                        babylonMaterial.bumpTexture.level = material.normalTexture.scale;
                     }
                 }
                 if (material.occlusionTexture) {
-                    material.babylonMaterial.ambientTexture = this.loadTexture(material.occlusionTexture);
-                    material.babylonMaterial.useAmbientInGrayScale = true;
+                    babylonMaterial.ambientTexture = this.loadTexture(material.occlusionTexture);
+                    babylonMaterial.useAmbientInGrayScale = true;
                     if (material.occlusionTexture.strength !== undefined) {
-                        material.babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength;
+                        babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength;
                     }
                 }
                 if (material.emissiveTexture) {
-                    material.babylonMaterial.emissiveTexture = this.loadTexture(material.emissiveTexture);
+                    babylonMaterial.emissiveTexture = this.loadTexture(material.emissiveTexture);
                 }
             };
             GLTFLoader.prototype.loadMaterialAlphaProperties = function (material) {
+                var babylonMaterial = material.babylonMaterial;
                 var alphaMode = material.alphaMode || "OPAQUE";
                 switch (alphaMode) {
                     case "OPAQUE":
                         // default is opaque
                         break;
                     case "MASK":
-                        material.babylonMaterial.albedoTexture.hasAlpha = true;
-                        material.babylonMaterial.useAlphaFromAlbedoTexture = false;
+                        babylonMaterial.albedoTexture.hasAlpha = true;
+                        babylonMaterial.useAlphaFromAlbedoTexture = false;
                         break;
                     case "BLEND":
-                        material.babylonMaterial.albedoTexture.hasAlpha = true;
-                        material.babylonMaterial.useAlphaFromAlbedoTexture = true;
+                        babylonMaterial.albedoTexture.hasAlpha = true;
+                        babylonMaterial.useAlphaFromAlbedoTexture = true;
                         break;
                     default:
                         BABYLON.Tools.Warn("Invalid alpha mode '" + material.alphaMode + "'");
@@ -1132,17 +1143,20 @@ var BABYLON;
                 babylonTexture.coordinatesIndex = texCoord;
                 babylonTexture.wrapU = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapS);
                 babylonTexture.wrapV = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapT);
-                babylonTexture.name = texture.name;
+                babylonTexture.name = texture.name || "texture" + textureInfo.index;
                 // Cache the texture
                 texture.babylonTextures = texture.babylonTextures || [];
                 texture.babylonTextures[texCoord] = babylonTexture;
+                if (this._parent.onTextureLoaded) {
+                    this._parent.onTextureLoaded(babylonTexture);
+                }
                 return babylonTexture;
             };
             return GLTFLoader;
         }());
         GLTFLoader.Extensions = {};
         GLTF2.GLTFLoader = GLTFLoader;
-        BABYLON.GLTFFileLoader.GLTFLoaderV2 = new GLTFLoader();
+        BABYLON.GLTFFileLoader.CreateGLTFLoaderV2 = function (parent) { return new GLTFLoader(parent); };
     })(GLTF2 = BABYLON.GLTF2 || (BABYLON.GLTF2 = {}));
 })(BABYLON || (BABYLON = {}));
 
@@ -1391,19 +1405,23 @@ var BABYLON;
                     }
                     loader.createPbrMaterial(material);
                     loader.loadMaterialBaseProperties(material);
-                    material.babylonMaterial.albedoColor = properties.diffuseFactor ? BABYLON.Color3.FromArray(properties.diffuseFactor) : new BABYLON.Color3(1, 1, 1);
-                    material.babylonMaterial.reflectivityColor = properties.specularFactor ? BABYLON.Color3.FromArray(properties.specularFactor) : new BABYLON.Color3(1, 1, 1);
-                    material.babylonMaterial.microSurface = properties.glossinessFactor === undefined ? 1 : properties.glossinessFactor;
+                    this._loadSpecularGlossinessProperties(loader, material, properties);
+                    assign(material.babylonMaterial);
+                    return true;
+                };
+                KHRMaterialsPbrSpecularGlossiness.prototype._loadSpecularGlossinessProperties = function (loader, material, properties) {
+                    var babylonMaterial = material.babylonMaterial;
+                    babylonMaterial.albedoColor = properties.diffuseFactor ? BABYLON.Color3.FromArray(properties.diffuseFactor) : new BABYLON.Color3(1, 1, 1);
+                    babylonMaterial.reflectivityColor = properties.specularFactor ? BABYLON.Color3.FromArray(properties.specularFactor) : new BABYLON.Color3(1, 1, 1);
+                    babylonMaterial.microSurface = properties.glossinessFactor === undefined ? 1 : properties.glossinessFactor;
                     if (properties.diffuseTexture) {
-                        material.babylonMaterial.albedoTexture = loader.loadTexture(properties.diffuseTexture);
+                        babylonMaterial.albedoTexture = loader.loadTexture(properties.diffuseTexture);
                         loader.loadMaterialAlphaProperties(material);
                     }
                     if (properties.specularGlossinessTexture) {
-                        material.babylonMaterial.reflectivityTexture = loader.loadTexture(properties.specularGlossinessTexture);
-                        material.babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
+                        babylonMaterial.reflectivityTexture = loader.loadTexture(properties.specularGlossinessTexture);
+                        babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
                     }
-                    assign(material.babylonMaterial);
-                    return true;
                 };
                 return KHRMaterialsPbrSpecularGlossiness;
             }(GLTF2.GLTFLoaderExtension));

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


+ 12 - 5
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -5,14 +5,17 @@ declare module BABYLON {
         bin: ArrayBufferView;
     }
     interface IGLTFLoader {
-        importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onsuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror: () => void) => void;
-        loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onsuccess: () => void, onerror: () => void) => void;
+        importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void) => void;
+        loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void) => void;
     }
     class GLTFFileLoader implements ISceneLoaderPluginAsync {
-        static GLTFLoaderV1: IGLTFLoader;
-        static GLTFLoaderV2: IGLTFLoader;
+        static CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
+        static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
         static HomogeneousCoordinates: boolean;
         static IncrementalLoading: boolean;
+        onTextureLoaded: (texture: BaseTexture) => void;
+        onMaterialLoaded: (material: Material) => void;
+        onComplete: () => void;
         extensions: ISceneLoaderPluginExtensions;
         importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void): void;
         loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: () => void, onError: () => void): void;
@@ -678,7 +681,7 @@ declare module BABYLON.GLTF2 {
         alphaCutoff: number;
         doubleSided?: boolean;
         index?: number;
-        babylonMaterial?: PBRMaterial;
+        babylonMaterial?: Material;
     }
     interface IGLTFMeshPrimitive extends IGLTFProperty {
         attributes: {
@@ -764,6 +767,7 @@ declare module BABYLON.GLTF2 {
 
 declare module BABYLON.GLTF2 {
     class GLTFLoader implements IGLTFLoader {
+        private _parent;
         private _gltf;
         private _errors;
         private _babylonScene;
@@ -780,6 +784,7 @@ declare module BABYLON.GLTF2 {
         static RegisterExtension(extension: GLTFLoaderExtension): void;
         readonly gltf: IGLTF;
         readonly babylonScene: Scene;
+        constructor(parent: GLTFFileLoader);
         importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onError: () => void): void;
         loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onError: () => void): void;
         private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess, onError);
@@ -795,6 +800,7 @@ declare module BABYLON.GLTF2 {
         private _createBone(node, skin);
         private _loadMesh(node);
         private _loadMeshData(node, mesh, babylonMesh);
+        private _assignMaterial(multiMaterial, index, subMaterial);
         private _loadVertexDataAsync(primitive, onSuccess);
         private _createMorphTargets(node, mesh, primitive, babylonMesh);
         private _loadMorphTargetsData(mesh, primitive, vertexData, babylonMesh);
@@ -885,5 +891,6 @@ declare module BABYLON.GLTF2.Extensions {
     class KHRMaterialsPbrSpecularGlossiness extends GLTFLoaderExtension {
         readonly name: string;
         protected loadMaterial(loader: GLTFLoader, material: IGLTFMaterial, assign: (material: Material) => void): boolean;
+        private _loadSpecularGlossinessProperties(loader, material, properties);
     }
 }

+ 71 - 53
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -53,17 +53,13 @@ var BABYLON;
                     return null;
                 }
             }
-            var loaders = {
-                1: GLTFFileLoader.GLTFLoaderV1,
-                2: GLTFFileLoader.GLTFLoaderV2
+            var createLoader = {
+                1: GLTFFileLoader.CreateGLTFLoaderV1,
+                2: GLTFFileLoader.CreateGLTFLoaderV2
             };
-            var loader = loaders[version.major];
-            if (loader === undefined) {
-                BABYLON.Tools.Error("Unsupported version");
-                return null;
-            }
+            var loader = createLoader[version.major](this);
             if (loader === null) {
-                BABYLON.Tools.Error("v" + version.major + " loader is not available");
+                BABYLON.Tools.Error("Unsupported version");
                 return null;
             }
             return loader;
@@ -193,8 +189,7 @@ var BABYLON;
         };
         return GLTFFileLoader;
     }());
-    GLTFFileLoader.GLTFLoaderV1 = null;
-    GLTFFileLoader.GLTFLoaderV2 = null;
+    // V1 options
     GLTFFileLoader.HomogeneousCoordinates = false;
     GLTFFileLoader.IncrementalLoading = true;
     BABYLON.GLTFFileLoader = GLTFFileLoader;
@@ -225,7 +220,9 @@ var BABYLON;
         };
         return BinaryReader;
     }());
-    BABYLON.SceneLoader.RegisterPlugin(new GLTFFileLoader());
+    if (BABYLON.SceneLoader) {
+        BABYLON.SceneLoader.RegisterPlugin(new GLTFFileLoader());
+    }
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=babylon.glTFFileLoader.js.map
@@ -1756,7 +1753,7 @@ var BABYLON;
         GLTFLoader.Extensions = {};
         GLTF1.GLTFLoader = GLTFLoader;
         ;
-        BABYLON.GLTFFileLoader.GLTFLoaderV1 = new GLTFLoader();
+        BABYLON.GLTFFileLoader.CreateGLTFLoaderV1 = function () { return new GLTFLoader(); };
     })(GLTF1 = BABYLON.GLTF1 || (BABYLON.GLTF1 = {}));
 })(BABYLON || (BABYLON = {}));
 
@@ -2441,7 +2438,8 @@ var BABYLON;
     var GLTF2;
     (function (GLTF2) {
         var GLTFLoader = (function () {
-            function GLTFLoader() {
+            function GLTFLoader(parent) {
+                this._parent = parent;
             }
             GLTFLoader.RegisterExtension = function (extension) {
                 if (GLTFLoader.Extensions[extension.name]) {
@@ -2522,6 +2520,9 @@ var BABYLON;
                 this._errors.forEach(function (error) { return BABYLON.Tools.Error(error); });
                 this._errors = [];
                 this._clear();
+                if (this._parent.onComplete) {
+                    this._parent.onComplete();
+                }
             };
             GLTFLoader.prototype._loadData = function (data) {
                 this._gltf = data.json;
@@ -2716,11 +2717,11 @@ var BABYLON;
                             _this.loadMaterial(primitive.material, function (babylonSubMaterial) {
                                 if (_this._renderReady) {
                                     babylonSubMaterial.forceCompilation(babylonMesh, function (babylonSubMaterial) {
-                                        babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
+                                        _this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
                                     });
                                 }
                                 else {
-                                    babylonMultiMaterial.subMaterials[i] = babylonSubMaterial;
+                                    _this._assignMaterial(babylonMultiMaterial, i, babylonSubMaterial);
                                 }
                             });
                         }
@@ -2738,6 +2739,12 @@ var BABYLON;
                     _loop_1(i);
                 }
             };
+            GLTFLoader.prototype._assignMaterial = function (multiMaterial, index, subMaterial) {
+                multiMaterial.subMaterials[index] = subMaterial;
+                if (this._parent.onMaterialLoaded) {
+                    this._parent.onMaterialLoaded(subMaterial);
+                }
+            };
             GLTFLoader.prototype._loadVertexDataAsync = function (primitive, onSuccess) {
                 var _this = this;
                 var attributes = primitive.attributes;
@@ -3148,25 +3155,26 @@ var BABYLON;
                 return this._defaultMaterial;
             };
             GLTFLoader.prototype._loadMaterialMetallicRoughnessProperties = function (material) {
+                var babylonMaterial = material.babylonMaterial;
                 // Ensure metallic workflow
-                material.babylonMaterial.metallic = 1;
-                material.babylonMaterial.roughness = 1;
+                babylonMaterial.metallic = 1;
+                babylonMaterial.roughness = 1;
                 var properties = material.pbrMetallicRoughness;
                 if (!properties) {
                     return;
                 }
-                material.babylonMaterial.albedoColor = properties.baseColorFactor ? BABYLON.Color3.FromArray(properties.baseColorFactor) : new BABYLON.Color3(1, 1, 1);
-                material.babylonMaterial.metallic = properties.metallicFactor === undefined ? 1 : properties.metallicFactor;
-                material.babylonMaterial.roughness = properties.roughnessFactor === undefined ? 1 : properties.roughnessFactor;
+                babylonMaterial.albedoColor = properties.baseColorFactor ? BABYLON.Color3.FromArray(properties.baseColorFactor) : new BABYLON.Color3(1, 1, 1);
+                babylonMaterial.metallic = properties.metallicFactor === undefined ? 1 : properties.metallicFactor;
+                babylonMaterial.roughness = properties.roughnessFactor === undefined ? 1 : properties.roughnessFactor;
                 if (properties.baseColorTexture) {
-                    material.babylonMaterial.albedoTexture = this.loadTexture(properties.baseColorTexture);
+                    babylonMaterial.albedoTexture = this.loadTexture(properties.baseColorTexture);
                     this.loadMaterialAlphaProperties(material);
                 }
                 if (properties.metallicRoughnessTexture) {
-                    material.babylonMaterial.metallicTexture = this.loadTexture(properties.metallicRoughnessTexture);
-                    material.babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
-                    material.babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
-                    material.babylonMaterial.useRoughnessFromMetallicTextureAlpha = false;
+                    babylonMaterial.metallicTexture = this.loadTexture(properties.metallicRoughnessTexture);
+                    babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
+                    babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
+                    babylonMaterial.useRoughnessFromMetallicTextureAlpha = false;
                 }
             };
             GLTFLoader.prototype.loadMaterial = function (index, assign) {
@@ -3185,47 +3193,50 @@ var BABYLON;
                 assign(material.babylonMaterial);
             };
             GLTFLoader.prototype.createPbrMaterial = function (material) {
-                material.babylonMaterial = new BABYLON.PBRMaterial(material.name || "mat" + material.index, this._babylonScene);
-                material.babylonMaterial.sideOrientation = BABYLON.Material.CounterClockWiseSideOrientation;
-                material.babylonMaterial.useScalarInLinearSpace = true;
+                var babylonMaterial = new BABYLON.PBRMaterial(material.name || "mat" + material.index, this._babylonScene);
+                babylonMaterial.sideOrientation = BABYLON.Material.CounterClockWiseSideOrientation;
+                babylonMaterial.useScalarInLinearSpace = true;
+                material.babylonMaterial = babylonMaterial;
             };
             GLTFLoader.prototype.loadMaterialBaseProperties = function (material) {
-                material.babylonMaterial.useEmissiveAsIllumination = (material.emissiveFactor || material.emissiveTexture) ? true : false;
-                material.babylonMaterial.emissiveColor = material.emissiveFactor ? BABYLON.Color3.FromArray(material.emissiveFactor) : new BABYLON.Color3(0, 0, 0);
+                var babylonMaterial = material.babylonMaterial;
+                babylonMaterial.useEmissiveAsIllumination = (material.emissiveFactor || material.emissiveTexture) ? true : false;
+                babylonMaterial.emissiveColor = material.emissiveFactor ? BABYLON.Color3.FromArray(material.emissiveFactor) : new BABYLON.Color3(0, 0, 0);
                 if (material.doubleSided) {
-                    material.babylonMaterial.backFaceCulling = false;
-                    material.babylonMaterial.twoSidedLighting = true;
+                    babylonMaterial.backFaceCulling = false;
+                    babylonMaterial.twoSidedLighting = true;
                 }
                 if (material.normalTexture) {
-                    material.babylonMaterial.bumpTexture = this.loadTexture(material.normalTexture);
+                    babylonMaterial.bumpTexture = this.loadTexture(material.normalTexture);
                     if (material.normalTexture.scale !== undefined) {
-                        material.babylonMaterial.bumpTexture.level = material.normalTexture.scale;
+                        babylonMaterial.bumpTexture.level = material.normalTexture.scale;
                     }
                 }
                 if (material.occlusionTexture) {
-                    material.babylonMaterial.ambientTexture = this.loadTexture(material.occlusionTexture);
-                    material.babylonMaterial.useAmbientInGrayScale = true;
+                    babylonMaterial.ambientTexture = this.loadTexture(material.occlusionTexture);
+                    babylonMaterial.useAmbientInGrayScale = true;
                     if (material.occlusionTexture.strength !== undefined) {
-                        material.babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength;
+                        babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength;
                     }
                 }
                 if (material.emissiveTexture) {
-                    material.babylonMaterial.emissiveTexture = this.loadTexture(material.emissiveTexture);
+                    babylonMaterial.emissiveTexture = this.loadTexture(material.emissiveTexture);
                 }
             };
             GLTFLoader.prototype.loadMaterialAlphaProperties = function (material) {
+                var babylonMaterial = material.babylonMaterial;
                 var alphaMode = material.alphaMode || "OPAQUE";
                 switch (alphaMode) {
                     case "OPAQUE":
                         // default is opaque
                         break;
                     case "MASK":
-                        material.babylonMaterial.albedoTexture.hasAlpha = true;
-                        material.babylonMaterial.useAlphaFromAlbedoTexture = false;
+                        babylonMaterial.albedoTexture.hasAlpha = true;
+                        babylonMaterial.useAlphaFromAlbedoTexture = false;
                         break;
                     case "BLEND":
-                        material.babylonMaterial.albedoTexture.hasAlpha = true;
-                        material.babylonMaterial.useAlphaFromAlbedoTexture = true;
+                        babylonMaterial.albedoTexture.hasAlpha = true;
+                        babylonMaterial.useAlphaFromAlbedoTexture = true;
                         break;
                     default:
                         BABYLON.Tools.Warn("Invalid alpha mode '" + material.alphaMode + "'");
@@ -3285,17 +3296,20 @@ var BABYLON;
                 babylonTexture.coordinatesIndex = texCoord;
                 babylonTexture.wrapU = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapS);
                 babylonTexture.wrapV = GLTF2.GLTFUtils.GetWrapMode(sampler.wrapT);
-                babylonTexture.name = texture.name;
+                babylonTexture.name = texture.name || "texture" + textureInfo.index;
                 // Cache the texture
                 texture.babylonTextures = texture.babylonTextures || [];
                 texture.babylonTextures[texCoord] = babylonTexture;
+                if (this._parent.onTextureLoaded) {
+                    this._parent.onTextureLoaded(babylonTexture);
+                }
                 return babylonTexture;
             };
             return GLTFLoader;
         }());
         GLTFLoader.Extensions = {};
         GLTF2.GLTFLoader = GLTFLoader;
-        BABYLON.GLTFFileLoader.GLTFLoaderV2 = new GLTFLoader();
+        BABYLON.GLTFFileLoader.CreateGLTFLoaderV2 = function (parent) { return new GLTFLoader(parent); };
     })(GLTF2 = BABYLON.GLTF2 || (BABYLON.GLTF2 = {}));
 })(BABYLON || (BABYLON = {}));
 
@@ -3544,19 +3558,23 @@ var BABYLON;
                     }
                     loader.createPbrMaterial(material);
                     loader.loadMaterialBaseProperties(material);
-                    material.babylonMaterial.albedoColor = properties.diffuseFactor ? BABYLON.Color3.FromArray(properties.diffuseFactor) : new BABYLON.Color3(1, 1, 1);
-                    material.babylonMaterial.reflectivityColor = properties.specularFactor ? BABYLON.Color3.FromArray(properties.specularFactor) : new BABYLON.Color3(1, 1, 1);
-                    material.babylonMaterial.microSurface = properties.glossinessFactor === undefined ? 1 : properties.glossinessFactor;
+                    this._loadSpecularGlossinessProperties(loader, material, properties);
+                    assign(material.babylonMaterial);
+                    return true;
+                };
+                KHRMaterialsPbrSpecularGlossiness.prototype._loadSpecularGlossinessProperties = function (loader, material, properties) {
+                    var babylonMaterial = material.babylonMaterial;
+                    babylonMaterial.albedoColor = properties.diffuseFactor ? BABYLON.Color3.FromArray(properties.diffuseFactor) : new BABYLON.Color3(1, 1, 1);
+                    babylonMaterial.reflectivityColor = properties.specularFactor ? BABYLON.Color3.FromArray(properties.specularFactor) : new BABYLON.Color3(1, 1, 1);
+                    babylonMaterial.microSurface = properties.glossinessFactor === undefined ? 1 : properties.glossinessFactor;
                     if (properties.diffuseTexture) {
-                        material.babylonMaterial.albedoTexture = loader.loadTexture(properties.diffuseTexture);
+                        babylonMaterial.albedoTexture = loader.loadTexture(properties.diffuseTexture);
                         loader.loadMaterialAlphaProperties(material);
                     }
                     if (properties.specularGlossinessTexture) {
-                        material.babylonMaterial.reflectivityTexture = loader.loadTexture(properties.specularGlossinessTexture);
-                        material.babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
+                        babylonMaterial.reflectivityTexture = loader.loadTexture(properties.specularGlossinessTexture);
+                        babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
                     }
-                    assign(material.babylonMaterial);
-                    return true;
                 };
                 return KHRMaterialsPbrSpecularGlossiness;
             }(GLTF2.GLTFLoaderExtension));

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


+ 4 - 2
dist/preview release/loaders/babylon.objFileLoader.js

@@ -769,8 +769,10 @@ var BABYLON;
     }());
     OBJFileLoader.OPTIMIZE_WITH_UV = false;
     BABYLON.OBJFileLoader = OBJFileLoader;
-    //Add this loader into the register plugin
-    BABYLON.SceneLoader.RegisterPlugin(new OBJFileLoader());
+    if (BABYLON.SceneLoader) {
+        //Add this loader into the register plugin
+        BABYLON.SceneLoader.RegisterPlugin(new OBJFileLoader());
+    }
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=babylon.objFileLoader.js.map

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


+ 3 - 1
dist/preview release/loaders/babylon.stlFileLoader.js

@@ -155,7 +155,9 @@ var BABYLON;
         return STLFileLoader;
     }());
     BABYLON.STLFileLoader = STLFileLoader;
-    BABYLON.SceneLoader.RegisterPlugin(new STLFileLoader());
+    if (BABYLON.SceneLoader) {
+        BABYLON.SceneLoader.RegisterPlugin(new STLFileLoader());
+    }
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=babylon.stlFileLoader.js.map

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


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 144 - 0
src/Loading/babylon.loadingScreen.ts


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 155
src/Tools/babylon.loadingScreen.ts