浏览代码

Update d.txt

David Catuhe 7 年之前
父节点
当前提交
85a802b8e6
共有 38 个文件被更改,包括 50360 次插入8281 次删除
  1. 41560 0
      Playground/babylon.d.txt
  2. 7586 7571
      dist/preview release/babylon.d.ts
  3. 43 43
      dist/preview release/babylon.js
  4. 57 5
      dist/preview release/babylon.max.js
  5. 57 5
      dist/preview release/babylon.no-module.max.js
  6. 21 21
      dist/preview release/babylon.worker.js
  7. 57 5
      dist/preview release/es6.js
  8. 2 2
      dist/preview release/inspector/babylon.inspector.js
  9. 1 1
      dist/preview release/inspector/babylon.inspector.min.js
  10. 28 16
      dist/preview release/loaders/babylon.glTF1FileLoader.d.ts
  11. 89 45
      dist/preview release/loaders/babylon.glTF1FileLoader.js
  12. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  13. 35 24
      dist/preview release/loaders/babylon.glTF2FileLoader.d.ts
  14. 165 121
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  15. 2 2
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  16. 35 24
      dist/preview release/loaders/babylon.glTFFileLoader.d.ts
  17. 165 121
      dist/preview release/loaders/babylon.glTFFileLoader.js
  18. 4 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  19. 18 15
      dist/preview release/loaders/babylon.stlFileLoader.js
  20. 1 1
      dist/preview release/loaders/babylon.stlFileLoader.min.js
  21. 35 24
      dist/preview release/loaders/babylonjs.loaders.d.ts
  22. 183 136
      dist/preview release/loaders/babylonjs.loaders.js
  23. 4 4
      dist/preview release/loaders/babylonjs.loaders.min.js
  24. 35 24
      dist/preview release/loaders/babylonjs.loaders.module.d.ts
  25. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.d.ts
  26. 21 2
      dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.js
  27. 1 1
      dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js
  28. 9 3
      dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.js
  29. 1 1
      dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js
  30. 1 1
      dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.d.ts
  31. 3 3
      dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.js
  32. 1 1
      dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.min.js
  33. 2 1
      dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.d.ts
  34. 33 8
      dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.js
  35. 1 1
      dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.min.js
  36. 2 1
      dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.module.d.ts
  37. 30 30
      dist/preview release/viewer/babylon.viewer.js
  38. 69 13
      dist/preview release/viewer/babylon.viewer.max.js

文件差异内容过多而无法显示
+ 41560 - 0
Playground/babylon.d.txt


文件差异内容过多而无法显示
+ 7586 - 7571
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 43 - 43
dist/preview release/babylon.js


+ 57 - 5
dist/preview release/babylon.max.js

@@ -27667,7 +27667,6 @@ var BABYLON;
             this.activeCamera = camera;
             if (!this.activeCamera)
                 throw new Error("Active camera not set");
-            BABYLON.Tools.StartPerformanceCounter("Rendering camera " + this.activeCamera.name);
             // Viewport
             engine.setViewport(this.activeCamera.viewport);
             // Camera
@@ -27711,7 +27710,7 @@ var BABYLON;
                 this._renderId++;
                 needsRestoreFrameBuffer = true; // Restore back buffer
             }
-            // Render EffecttLayer Texture
+            // Render EffectLayer Texture
             var stencilState = this._engine.getStencilBuffer();
             var renderEffects = false;
             var needStencil = false;
@@ -27813,7 +27812,6 @@ var BABYLON;
             this._renderTargets.reset();
             this._alternateRendering = false;
             this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
-            BABYLON.Tools.EndPerformanceCounter("Rendering camera " + this.activeCamera.name);
         };
         Scene.prototype._processSubCameras = function (camera) {
             if (camera.cameraRigMode === BABYLON.Camera.RIG_MODE_NONE) {
@@ -53799,11 +53797,11 @@ var BABYLON;
             engine.setDepthFunctionToLessOrEqual();
             effect.setBool("alphaTest", true);
             engine.setColorWrite(false);
-            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, max * 6);
+            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, (offset / 4) * 6);
             engine.setColorWrite(true);
             effect.setBool("alphaTest", false);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, max * 6);
+            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, (offset / 4) * 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
         };
         SpriteManager.prototype.dispose = function () {
@@ -98914,6 +98912,8 @@ var BABYLON;
             this._physicsTime = new BABYLON.PerfCounter();
             this._captureAnimationsTime = false;
             this._animationsTime = new BABYLON.PerfCounter();
+            this._captureCameraRenderTime = false;
+            this._cameraRenderTime = new BABYLON.PerfCounter();
             // Observers
             this._onBeforeActiveMeshesEvaluationObserver = null;
             this._onAfterActiveMeshesEvaluationObserver = null;
@@ -98930,6 +98930,8 @@ var BABYLON;
             this._onBeforePhysicsObserver = null;
             this._onAfterPhysicsObserver = null;
             this._onAfterAnimationsObserver = null;
+            this._onBeforeCameraRenderObserver = null;
+            this._onAfterCameraRenderObserver = null;
             // Before render
             this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
                 if (_this._captureActiveMeshesEvaluationTime) {
@@ -99339,6 +99341,52 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
+            /**
+             * Gets the perf counter used for camera render time capture
+             */
+            get: function () {
+                return this._cameraRenderTime;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
+            /**
+             * Gets the camera render time capture status
+             */
+            get: function () {
+                return this._captureCameraRenderTime;
+            },
+            /**
+             * Enable or disable the camera render time capture
+             */
+            set: function (value) {
+                var _this = this;
+                if (value === this._captureCameraRenderTime) {
+                    return;
+                }
+                this._captureCameraRenderTime = value;
+                if (value) {
+                    this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
+                        _this._cameraRenderTime.beginMonitoring();
+                        BABYLON.Tools.StartPerformanceCounter("Rendering camera " + camera.name);
+                    });
+                    this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
+                        _this._cameraRenderTime.endMonitoring(false);
+                        BABYLON.Tools.EndPerformanceCounter("Rendering camera " + camera.name);
+                    });
+                }
+                else {
+                    this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
+                    this._onBeforeCameraRenderObserver = null;
+                    this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
+                    this._onAfterCameraRenderObserver = null;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
             /**
              * Gets the perf counter used for draw calls
@@ -99390,6 +99438,10 @@ var BABYLON;
             this._onAfterPhysicsObserver = null;
             this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
             this._onAfterAnimationsObserver = null;
+            this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
+            this._onBeforeCameraRenderObserver = null;
+            this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
+            this._onAfterCameraRenderObserver = null;
             this.scene = null;
         };
         return SceneInstrumentation;

+ 57 - 5
dist/preview release/babylon.no-module.max.js

@@ -27634,7 +27634,6 @@ var BABYLON;
             this.activeCamera = camera;
             if (!this.activeCamera)
                 throw new Error("Active camera not set");
-            BABYLON.Tools.StartPerformanceCounter("Rendering camera " + this.activeCamera.name);
             // Viewport
             engine.setViewport(this.activeCamera.viewport);
             // Camera
@@ -27678,7 +27677,7 @@ var BABYLON;
                 this._renderId++;
                 needsRestoreFrameBuffer = true; // Restore back buffer
             }
-            // Render EffecttLayer Texture
+            // Render EffectLayer Texture
             var stencilState = this._engine.getStencilBuffer();
             var renderEffects = false;
             var needStencil = false;
@@ -27780,7 +27779,6 @@ var BABYLON;
             this._renderTargets.reset();
             this._alternateRendering = false;
             this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
-            BABYLON.Tools.EndPerformanceCounter("Rendering camera " + this.activeCamera.name);
         };
         Scene.prototype._processSubCameras = function (camera) {
             if (camera.cameraRigMode === BABYLON.Camera.RIG_MODE_NONE) {
@@ -53766,11 +53764,11 @@ var BABYLON;
             engine.setDepthFunctionToLessOrEqual();
             effect.setBool("alphaTest", true);
             engine.setColorWrite(false);
-            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, max * 6);
+            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, (offset / 4) * 6);
             engine.setColorWrite(true);
             effect.setBool("alphaTest", false);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, max * 6);
+            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, (offset / 4) * 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
         };
         SpriteManager.prototype.dispose = function () {
@@ -98881,6 +98879,8 @@ var BABYLON;
             this._physicsTime = new BABYLON.PerfCounter();
             this._captureAnimationsTime = false;
             this._animationsTime = new BABYLON.PerfCounter();
+            this._captureCameraRenderTime = false;
+            this._cameraRenderTime = new BABYLON.PerfCounter();
             // Observers
             this._onBeforeActiveMeshesEvaluationObserver = null;
             this._onAfterActiveMeshesEvaluationObserver = null;
@@ -98897,6 +98897,8 @@ var BABYLON;
             this._onBeforePhysicsObserver = null;
             this._onAfterPhysicsObserver = null;
             this._onAfterAnimationsObserver = null;
+            this._onBeforeCameraRenderObserver = null;
+            this._onAfterCameraRenderObserver = null;
             // Before render
             this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
                 if (_this._captureActiveMeshesEvaluationTime) {
@@ -99306,6 +99308,52 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
+            /**
+             * Gets the perf counter used for camera render time capture
+             */
+            get: function () {
+                return this._cameraRenderTime;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
+            /**
+             * Gets the camera render time capture status
+             */
+            get: function () {
+                return this._captureCameraRenderTime;
+            },
+            /**
+             * Enable or disable the camera render time capture
+             */
+            set: function (value) {
+                var _this = this;
+                if (value === this._captureCameraRenderTime) {
+                    return;
+                }
+                this._captureCameraRenderTime = value;
+                if (value) {
+                    this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
+                        _this._cameraRenderTime.beginMonitoring();
+                        BABYLON.Tools.StartPerformanceCounter("Rendering camera " + camera.name);
+                    });
+                    this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
+                        _this._cameraRenderTime.endMonitoring(false);
+                        BABYLON.Tools.EndPerformanceCounter("Rendering camera " + camera.name);
+                    });
+                }
+                else {
+                    this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
+                    this._onBeforeCameraRenderObserver = null;
+                    this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
+                    this._onAfterCameraRenderObserver = null;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
             /**
              * Gets the perf counter used for draw calls
@@ -99357,6 +99405,10 @@ var BABYLON;
             this._onAfterPhysicsObserver = null;
             this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
             this._onAfterAnimationsObserver = null;
+            this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
+            this._onBeforeCameraRenderObserver = null;
+            this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
+            this._onAfterCameraRenderObserver = null;
             this.scene = null;
         };
         return SceneInstrumentation;

文件差异内容过多而无法显示
+ 21 - 21
dist/preview release/babylon.worker.js


+ 57 - 5
dist/preview release/es6.js

@@ -27634,7 +27634,6 @@ var BABYLON;
             this.activeCamera = camera;
             if (!this.activeCamera)
                 throw new Error("Active camera not set");
-            BABYLON.Tools.StartPerformanceCounter("Rendering camera " + this.activeCamera.name);
             // Viewport
             engine.setViewport(this.activeCamera.viewport);
             // Camera
@@ -27678,7 +27677,7 @@ var BABYLON;
                 this._renderId++;
                 needsRestoreFrameBuffer = true; // Restore back buffer
             }
-            // Render EffecttLayer Texture
+            // Render EffectLayer Texture
             var stencilState = this._engine.getStencilBuffer();
             var renderEffects = false;
             var needStencil = false;
@@ -27780,7 +27779,6 @@ var BABYLON;
             this._renderTargets.reset();
             this._alternateRendering = false;
             this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
-            BABYLON.Tools.EndPerformanceCounter("Rendering camera " + this.activeCamera.name);
         };
         Scene.prototype._processSubCameras = function (camera) {
             if (camera.cameraRigMode === BABYLON.Camera.RIG_MODE_NONE) {
@@ -53766,11 +53764,11 @@ var BABYLON;
             engine.setDepthFunctionToLessOrEqual();
             effect.setBool("alphaTest", true);
             engine.setColorWrite(false);
-            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, max * 6);
+            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, (offset / 4) * 6);
             engine.setColorWrite(true);
             effect.setBool("alphaTest", false);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
-            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, max * 6);
+            engine.drawElementsType(BABYLON.Material.TriangleFillMode, 0, (offset / 4) * 6);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
         };
         SpriteManager.prototype.dispose = function () {
@@ -98881,6 +98879,8 @@ var BABYLON;
             this._physicsTime = new BABYLON.PerfCounter();
             this._captureAnimationsTime = false;
             this._animationsTime = new BABYLON.PerfCounter();
+            this._captureCameraRenderTime = false;
+            this._cameraRenderTime = new BABYLON.PerfCounter();
             // Observers
             this._onBeforeActiveMeshesEvaluationObserver = null;
             this._onAfterActiveMeshesEvaluationObserver = null;
@@ -98897,6 +98897,8 @@ var BABYLON;
             this._onBeforePhysicsObserver = null;
             this._onAfterPhysicsObserver = null;
             this._onAfterAnimationsObserver = null;
+            this._onBeforeCameraRenderObserver = null;
+            this._onAfterCameraRenderObserver = null;
             // Before render
             this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
                 if (_this._captureActiveMeshesEvaluationTime) {
@@ -99306,6 +99308,52 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
+            /**
+             * Gets the perf counter used for camera render time capture
+             */
+            get: function () {
+                return this._cameraRenderTime;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
+            /**
+             * Gets the camera render time capture status
+             */
+            get: function () {
+                return this._captureCameraRenderTime;
+            },
+            /**
+             * Enable or disable the camera render time capture
+             */
+            set: function (value) {
+                var _this = this;
+                if (value === this._captureCameraRenderTime) {
+                    return;
+                }
+                this._captureCameraRenderTime = value;
+                if (value) {
+                    this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
+                        _this._cameraRenderTime.beginMonitoring();
+                        BABYLON.Tools.StartPerformanceCounter("Rendering camera " + camera.name);
+                    });
+                    this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
+                        _this._cameraRenderTime.endMonitoring(false);
+                        BABYLON.Tools.EndPerformanceCounter("Rendering camera " + camera.name);
+                    });
+                }
+                else {
+                    this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
+                    this._onBeforeCameraRenderObserver = null;
+                    this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
+                    this._onAfterCameraRenderObserver = null;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
             /**
              * Gets the perf counter used for draw calls
@@ -99357,6 +99405,10 @@ var BABYLON;
             this._onAfterPhysicsObserver = null;
             this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
             this._onAfterAnimationsObserver = null;
+            this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
+            this._onBeforeCameraRenderObserver = null;
+            this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
+            this._onAfterCameraRenderObserver = null;
             this.scene = null;
         };
         return SceneInstrumentation;

+ 2 - 2
dist/preview release/inspector/babylon.inspector.js

@@ -4220,8 +4220,8 @@ var INSPECTOR;
                 });
                 defaults.extensions[extension.name] = extensionDefaults;
             });
-            var data = '{ "asset": { "version": "2.0" }, "scenes": [ { } ] }';
-            return loader.loadAsync(scene, data, "").then(function () {
+            var data = '{ "asset": { "version": "2.0" } }';
+            return loader.importMeshAsync([], scene, data, "").then(function () {
                 scene.dispose();
                 engine.dispose();
                 return (GLTFTab._LoaderDefaults = defaults);

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/inspector/babylon.inspector.min.js


+ 28 - 16
dist/preview release/loaders/babylon.glTF1FileLoader.d.ts

@@ -143,22 +143,6 @@ declare module BABYLON {
         /** @hidden */
         _normalizeAnimationGroupsToBeginAtZero: boolean;
         /**
-         * Defines if the loader logging is enabled.
-         */
-        loggingEnabled: boolean;
-        /**
-         * Observable raised when the loader logs a message.
-         */
-        readonly onLogObservable: Observable<string>;
-        private _logIndentLevel;
-        private static readonly _logSpaces;
-        /** @hidden */
-        _log(message: string): void;
-        /** @hidden */
-        _logOpen(message: string): void;
-        /** @hidden */
-        _logClose(): void;
-        /**
          * Function called before loading a url referenced by the asset.
          */
         preprocessUrlAsync: (url: string) => Promise<string>;
@@ -237,6 +221,14 @@ declare module BABYLON {
          * The loader state or null if the loader is not active.
          */
         readonly loaderState: Nullable<GLTFLoaderState>;
+        /**
+         * Defines if the loader logging is enabled.
+         */
+        loggingEnabled: boolean;
+        /**
+         * Defines if the loader should capture performance counters.
+         */
+        capturePerformanceCounters: boolean;
         private _loader;
         /**
          * Name of the loader ("gltf")
@@ -308,6 +300,26 @@ declare module BABYLON {
         private static _parseVersion(version);
         private static _compareVersion(a, b);
         private static _decodeBufferToText(buffer);
+        private static readonly _logSpaces;
+        private _logIndentLevel;
+        private _loggingEnabled;
+        /** @hidden */
+        _log: (message: string) => void;
+        /** @hidden */
+        _logOpen(message: string): void;
+        /** @hidden */
+        _logClose(): void;
+        private _logEnabled(message);
+        private _logDisabled(message);
+        private _capturePerformanceCounters;
+        /** @hidden */
+        _startPerformanceCounter: (counterName: string) => void;
+        /** @hidden */
+        _endPerformanceCounter: (counterName: string) => void;
+        private _startPerformanceCounterEnabled(counterName);
+        private _startPerformanceCounterDisabled(counterName);
+        private _endPerformanceCounterEnabled(counterName);
+        private _endPerformanceCounterDisabled(counterName);
     }
 }
 

+ 89 - 45
dist/preview release/loaders/babylon.glTF1FileLoader.js

@@ -92,15 +92,6 @@ var BABYLON;
             /** @hidden */
             this._normalizeAnimationGroupsToBeginAtZero = true;
             /**
-             * Defines if the loader logging is enabled.
-             */
-            this.loggingEnabled = false;
-            /**
-             * Observable raised when the loader logs a message.
-             */
-            this.onLogObservable = new BABYLON.Observable();
-            this._logIndentLevel = 0;
-            /**
              * Function called before loading a url referenced by the asset.
              */
             this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
@@ -148,6 +139,15 @@ var BABYLON;
                 ".gltf": { isBinary: false },
                 ".glb": { isBinary: true }
             };
+            this._logIndentLevel = 0;
+            this._loggingEnabled = false;
+            /** @hidden */
+            this._log = this._logDisabled;
+            this._capturePerformanceCounters = false;
+            /** @hidden */
+            this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+            /** @hidden */
+            this._endPerformanceCounter = this._endPerformanceCounterDisabled;
         }
         Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
             /**
@@ -162,23 +162,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        /** @hidden */
-        GLTFFileLoader.prototype._log = function (message) {
-            if (this.loggingEnabled) {
-                var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
-                this.onLogObservable.notifyObservers("" + spaces + message);
-                BABYLON.Tools.Log("" + spaces + message);
-            }
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logOpen = function (message) {
-            this._log(message);
-            this._logIndentLevel++;
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logClose = function () {
-            --this._logIndentLevel;
-        };
         Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
             /**
              * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
@@ -292,6 +275,52 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
+            /**
+             * Defines if the loader logging is enabled.
+             */
+            get: function () {
+                return this._loggingEnabled;
+            },
+            set: function (value) {
+                if (this._loggingEnabled === value) {
+                    return;
+                }
+                this._loggingEnabled = value;
+                if (this._loggingEnabled) {
+                    this._log = this._logEnabled;
+                }
+                else {
+                    this._log = this._logDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
+            /**
+             * Defines if the loader should capture performance counters.
+             */
+            get: function () {
+                return this._capturePerformanceCounters;
+            },
+            set: function (value) {
+                if (this._capturePerformanceCounters === value) {
+                    return;
+                }
+                this._capturePerformanceCounters = value;
+                if (this._capturePerformanceCounters) {
+                    this._startPerformanceCounter = this._startPerformanceCounterEnabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterEnabled;
+                }
+                else {
+                    this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         /**
          * Disposes the loader, releases resources during load, and cancels any outstanding requests.
          */
@@ -387,18 +416,15 @@ var BABYLON;
             return new GLTFFileLoader();
         };
         GLTFFileLoader.prototype._parse = function (data) {
+            this._startPerformanceCounter("Parse");
             var parsedData;
             if (data instanceof ArrayBuffer) {
-                if (this.loggingEnabled) {
-                    this._log("Parsing binary");
-                }
+                this._log("Parsing binary");
                 parsedData = this._parseBinary(data);
             }
             else {
-                if (this.loggingEnabled) {
-                    this._log("Parsing JSON");
-                    this._log("JSON length: " + data.length);
-                }
+                this._log("Parsing JSON");
+                this._log("JSON length: " + data.length);
                 parsedData = {
                     json: JSON.parse(data),
                     bin: null
@@ -406,19 +432,14 @@ var BABYLON;
             }
             this.onParsedObservable.notifyObservers(parsedData);
             this.onParsedObservable.clear();
+            this._endPerformanceCounter("Parse");
             return parsedData;
         };
         GLTFFileLoader.prototype._getLoader = function (loaderData) {
             var asset = loaderData.json.asset || {};
-            if (this.loggingEnabled) {
-                this._log("Asset version: " + asset.version);
-                if (asset.minVersion) {
-                    this._log("Asset minimum version: " + asset.minVersion);
-                }
-                if (asset.generator) {
-                    this._log("Asset generator: " + asset.generator);
-                }
-            }
+            this._log("Asset version: " + asset.version);
+            asset.minVersion && this._log("Asset minimum version: " + asset.minVersion);
+            asset.generator && this._log("Asset generator: " + asset.generator);
             var version = GLTFFileLoader._parseVersion(asset.version);
             if (!version) {
                 throw new Error("Invalid version: " + asset.version);
@@ -446,9 +467,7 @@ var BABYLON;
             var Binary = {
                 Magic: 0x46546C67
             };
-            if (this.loggingEnabled) {
-                this._log("Binary length: " + data.byteLength);
-            }
+            this._log("Binary length: " + data.byteLength);
             var binaryReader = new BinaryReader(data);
             var magic = binaryReader.readUint32();
             if (magic !== Binary.Magic) {
@@ -567,6 +586,31 @@ var BABYLON;
             }
             return result;
         };
+        /** @hidden */
+        GLTFFileLoader.prototype._logOpen = function (message) {
+            this._log(message);
+            this._logIndentLevel++;
+        };
+        /** @hidden */
+        GLTFFileLoader.prototype._logClose = function () {
+            --this._logIndentLevel;
+        };
+        GLTFFileLoader.prototype._logEnabled = function (message) {
+            var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
+            BABYLON.Tools.Log("" + spaces + message);
+        };
+        GLTFFileLoader.prototype._logDisabled = function (message) {
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.StartPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) {
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.EndPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) {
+        };
         // #endregion
         // #region V1 options
         /**

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


+ 35 - 24
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -143,22 +143,6 @@ declare module BABYLON {
         /** @hidden */
         _normalizeAnimationGroupsToBeginAtZero: boolean;
         /**
-         * Defines if the loader logging is enabled.
-         */
-        loggingEnabled: boolean;
-        /**
-         * Observable raised when the loader logs a message.
-         */
-        readonly onLogObservable: Observable<string>;
-        private _logIndentLevel;
-        private static readonly _logSpaces;
-        /** @hidden */
-        _log(message: string): void;
-        /** @hidden */
-        _logOpen(message: string): void;
-        /** @hidden */
-        _logClose(): void;
-        /**
          * Function called before loading a url referenced by the asset.
          */
         preprocessUrlAsync: (url: string) => Promise<string>;
@@ -237,6 +221,14 @@ declare module BABYLON {
          * The loader state or null if the loader is not active.
          */
         readonly loaderState: Nullable<GLTFLoaderState>;
+        /**
+         * Defines if the loader logging is enabled.
+         */
+        loggingEnabled: boolean;
+        /**
+         * Defines if the loader should capture performance counters.
+         */
+        capturePerformanceCounters: boolean;
         private _loader;
         /**
          * Name of the loader ("gltf")
@@ -308,6 +300,26 @@ declare module BABYLON {
         private static _parseVersion(version);
         private static _compareVersion(a, b);
         private static _decodeBufferToText(buffer);
+        private static readonly _logSpaces;
+        private _logIndentLevel;
+        private _loggingEnabled;
+        /** @hidden */
+        _log: (message: string) => void;
+        /** @hidden */
+        _logOpen(message: string): void;
+        /** @hidden */
+        _logClose(): void;
+        private _logEnabled(message);
+        private _logDisabled(message);
+        private _capturePerformanceCounters;
+        /** @hidden */
+        _startPerformanceCounter: (counterName: string) => void;
+        /** @hidden */
+        _endPerformanceCounter: (counterName: string) => void;
+        private _startPerformanceCounterEnabled(counterName);
+        private _startPerformanceCounterDisabled(counterName);
+        private _endPerformanceCounterEnabled(counterName);
+        private _endPerformanceCounterDisabled(counterName);
     }
 }
 
@@ -433,8 +445,8 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
+        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
-        _onReadyObservable: Observable<IGLTFLoader>;
         private _disposed;
         private _state;
         private _extensions;
@@ -466,7 +478,6 @@ declare module BABYLON.GLTF2 {
         private _loadExtensions();
         private _checkExtensions();
         private _createRootNode();
-        private _loadNodesAsync(nodes);
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
         private _forEachPrimitive(node, callback);
         private _getMeshes();
@@ -647,12 +658,12 @@ declare module BABYLON.GLTF2.Extensions {
          * Dispose the loader to cancel the loading of the next level of LODs.
          */
         onMaterialLODsLoadedObservable: Observable<number>;
-        private _loadingNodeLOD;
-        private _loadNodeSignals;
-        private _loadNodePromises;
-        private _loadingMaterialLOD;
-        private _loadMaterialSignals;
-        private _loadMaterialPromises;
+        private _nodeIndexLOD;
+        private _nodeSignalLODs;
+        private _nodePromiseLODs;
+        private _materialIndexLOD;
+        private _materialSignalLODs;
+        private _materialPromiseLODs;
         constructor(loader: GLTFLoader);
         dispose(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;

+ 165 - 121
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -92,15 +92,6 @@ var BABYLON;
             /** @hidden */
             this._normalizeAnimationGroupsToBeginAtZero = true;
             /**
-             * Defines if the loader logging is enabled.
-             */
-            this.loggingEnabled = false;
-            /**
-             * Observable raised when the loader logs a message.
-             */
-            this.onLogObservable = new BABYLON.Observable();
-            this._logIndentLevel = 0;
-            /**
              * Function called before loading a url referenced by the asset.
              */
             this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
@@ -148,6 +139,15 @@ var BABYLON;
                 ".gltf": { isBinary: false },
                 ".glb": { isBinary: true }
             };
+            this._logIndentLevel = 0;
+            this._loggingEnabled = false;
+            /** @hidden */
+            this._log = this._logDisabled;
+            this._capturePerformanceCounters = false;
+            /** @hidden */
+            this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+            /** @hidden */
+            this._endPerformanceCounter = this._endPerformanceCounterDisabled;
         }
         Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
             /**
@@ -162,23 +162,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        /** @hidden */
-        GLTFFileLoader.prototype._log = function (message) {
-            if (this.loggingEnabled) {
-                var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
-                this.onLogObservable.notifyObservers("" + spaces + message);
-                BABYLON.Tools.Log("" + spaces + message);
-            }
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logOpen = function (message) {
-            this._log(message);
-            this._logIndentLevel++;
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logClose = function () {
-            --this._logIndentLevel;
-        };
         Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
             /**
              * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
@@ -292,6 +275,52 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
+            /**
+             * Defines if the loader logging is enabled.
+             */
+            get: function () {
+                return this._loggingEnabled;
+            },
+            set: function (value) {
+                if (this._loggingEnabled === value) {
+                    return;
+                }
+                this._loggingEnabled = value;
+                if (this._loggingEnabled) {
+                    this._log = this._logEnabled;
+                }
+                else {
+                    this._log = this._logDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
+            /**
+             * Defines if the loader should capture performance counters.
+             */
+            get: function () {
+                return this._capturePerformanceCounters;
+            },
+            set: function (value) {
+                if (this._capturePerformanceCounters === value) {
+                    return;
+                }
+                this._capturePerformanceCounters = value;
+                if (this._capturePerformanceCounters) {
+                    this._startPerformanceCounter = this._startPerformanceCounterEnabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterEnabled;
+                }
+                else {
+                    this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         /**
          * Disposes the loader, releases resources during load, and cancels any outstanding requests.
          */
@@ -387,18 +416,15 @@ var BABYLON;
             return new GLTFFileLoader();
         };
         GLTFFileLoader.prototype._parse = function (data) {
+            this._startPerformanceCounter("Parse");
             var parsedData;
             if (data instanceof ArrayBuffer) {
-                if (this.loggingEnabled) {
-                    this._log("Parsing binary");
-                }
+                this._log("Parsing binary");
                 parsedData = this._parseBinary(data);
             }
             else {
-                if (this.loggingEnabled) {
-                    this._log("Parsing JSON");
-                    this._log("JSON length: " + data.length);
-                }
+                this._log("Parsing JSON");
+                this._log("JSON length: " + data.length);
                 parsedData = {
                     json: JSON.parse(data),
                     bin: null
@@ -406,19 +432,14 @@ var BABYLON;
             }
             this.onParsedObservable.notifyObservers(parsedData);
             this.onParsedObservable.clear();
+            this._endPerformanceCounter("Parse");
             return parsedData;
         };
         GLTFFileLoader.prototype._getLoader = function (loaderData) {
             var asset = loaderData.json.asset || {};
-            if (this.loggingEnabled) {
-                this._log("Asset version: " + asset.version);
-                if (asset.minVersion) {
-                    this._log("Asset minimum version: " + asset.minVersion);
-                }
-                if (asset.generator) {
-                    this._log("Asset generator: " + asset.generator);
-                }
-            }
+            this._log("Asset version: " + asset.version);
+            asset.minVersion && this._log("Asset minimum version: " + asset.minVersion);
+            asset.generator && this._log("Asset generator: " + asset.generator);
             var version = GLTFFileLoader._parseVersion(asset.version);
             if (!version) {
                 throw new Error("Invalid version: " + asset.version);
@@ -446,9 +467,7 @@ var BABYLON;
             var Binary = {
                 Magic: 0x46546C67
             };
-            if (this.loggingEnabled) {
-                this._log("Binary length: " + data.byteLength);
-            }
+            this._log("Binary length: " + data.byteLength);
             var binaryReader = new BinaryReader(data);
             var magic = binaryReader.readUint32();
             if (magic !== Binary.Magic) {
@@ -567,6 +586,31 @@ var BABYLON;
             }
             return result;
         };
+        /** @hidden */
+        GLTFFileLoader.prototype._logOpen = function (message) {
+            this._log(message);
+            this._logIndentLevel++;
+        };
+        /** @hidden */
+        GLTFFileLoader.prototype._logClose = function () {
+            --this._logIndentLevel;
+        };
+        GLTFFileLoader.prototype._logEnabled = function (message) {
+            var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
+            BABYLON.Tools.Log("" + spaces + message);
+        };
+        GLTFFileLoader.prototype._logDisabled = function (message) {
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.StartPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) {
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.EndPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) {
+        };
         // #endregion
         // #region V1 options
         /**
@@ -649,7 +693,6 @@ var BABYLON;
         var GLTFLoader = /** @class */ (function () {
             function GLTFLoader(parent) {
                 this._completePromises = new Array();
-                this._onReadyObservable = new BABYLON.Observable();
                 this._disposed = false;
                 this._state = null;
                 this._extensions = {};
@@ -689,8 +732,8 @@ var BABYLON;
                 this._requests.length = 0;
                 delete this._gltf;
                 delete this._babylonScene;
+                delete this._readyPromise;
                 this._completePromises.length = 0;
-                this._onReadyObservable.clear();
                 for (var name_1 in this._extensions) {
                     this._extensions[name_1].dispose();
                 }
@@ -713,14 +756,14 @@ var BABYLON;
                             for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) {
                                 var node = _a[_i];
                                 if (node.name) {
-                                    nodeMap_1[node.name] = node;
+                                    nodeMap_1[node.name] = node._index;
                                 }
                             }
                         }
                         var names = (meshesNames instanceof Array) ? meshesNames : [meshesNames];
                         nodes = names.map(function (name) {
                             var node = nodeMap_1[name];
-                            if (!node) {
+                            if (node === undefined) {
                                 throw new Error("Failed to find node '" + name + "'");
                             }
                             return node;
@@ -749,13 +792,17 @@ var BABYLON;
             GLTFLoader.prototype._loadAsync = function (nodes) {
                 var _this = this;
                 return Promise.resolve().then(function () {
+                    _this._parent._startPerformanceCounter("Loading => Ready");
+                    _this._parent._startPerformanceCounter("Loading => Complete");
                     _this._state = BABYLON.GLTFLoaderState.LOADING;
                     _this._parent._log("Loading");
+                    var readyDeferred = new BABYLON.Deferred();
+                    _this._readyPromise = readyDeferred.promise;
                     _this._loadExtensions();
                     _this._checkExtensions();
                     var promises = new Array();
                     if (nodes) {
-                        promises.push(_this._loadNodesAsync(nodes));
+                        promises.push(_this._loadSceneAsync("#/nodes", { nodes: nodes, _index: -1 }));
                     }
                     else {
                         var scene = GLTFLoader._GetProperty("#/scene", _this._gltf.scenes, _this._gltf.scene || 0);
@@ -770,16 +817,18 @@ var BABYLON;
                     var resultPromise = Promise.all(promises).then(function () {
                         _this._state = BABYLON.GLTFLoaderState.READY;
                         _this._parent._log("Ready");
-                        _this._onReadyObservable.notifyObservers(_this);
+                        readyDeferred.resolve();
                         _this._startAnimations();
                     });
                     resultPromise.then(function () {
+                        _this._parent._endPerformanceCounter("Loading => Ready");
                         if (_this._rootBabylonMesh) {
                             _this._rootBabylonMesh.setEnabled(true);
                         }
                         BABYLON.Tools.SetImmediate(function () {
                             if (!_this._disposed) {
                                 Promise.all(_this._completePromises).then(function () {
+                                    _this._parent._endPerformanceCounter("Loading => Complete");
                                     _this._state = BABYLON.GLTFLoaderState.COMPLETE;
                                     _this._parent._log("Complete");
                                     _this._parent.onCompleteObservable.notifyObservers(undefined);
@@ -895,15 +944,6 @@ var BABYLON;
                 this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh);
                 return rootNode;
             };
-            GLTFLoader.prototype._loadNodesAsync = function (nodes) {
-                var promises = new Array();
-                for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
-                    var node = nodes_1[_i];
-                    promises.push(this._loadNodeAsync("#/nodes/" + node._index, node));
-                }
-                promises.push(this._loadAnimationsAsync());
-                return Promise.all(promises).then(function () { });
-            };
             GLTFLoader.prototype._loadSceneAsync = function (context, scene) {
                 var promise = GLTF2.GLTFLoaderExtension._LoadSceneAsync(this, context, scene);
                 if (promise) {
@@ -939,8 +979,8 @@ var BABYLON;
                 meshes.push(this._rootBabylonMesh);
                 var nodes = this._gltf.nodes;
                 if (nodes) {
-                    for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
-                        var node = nodes_2[_i];
+                    for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
+                        var node = nodes_1[_i];
                         if (node._babylonMesh) {
                             meshes.push(node._babylonMesh);
                         }
@@ -2058,6 +2098,8 @@ var BABYLON;
                 throw new Error(context + ": Invalid mesh primitive mode (" + mode + ")");
             };
             GLTFLoader.prototype._compileMaterialsAsync = function () {
+                var _this = this;
+                this._parent._startPerformanceCounter("Compile materials");
                 var promises = new Array();
                 if (this._gltf.materials) {
                     for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) {
@@ -2079,9 +2121,13 @@ var BABYLON;
                         }
                     }
                 }
-                return Promise.all(promises).then(function () { });
+                return Promise.all(promises).then(function () {
+                    _this._parent._endPerformanceCounter("Compile materials");
+                });
             };
             GLTFLoader.prototype._compileShadowGeneratorsAsync = function () {
+                var _this = this;
+                this._parent._startPerformanceCounter("Compile shadow generators");
                 var promises = new Array();
                 var lights = this._babylonScene.lights;
                 for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
@@ -2091,7 +2137,9 @@ var BABYLON;
                         promises.push(generator.forceCompilationAsync());
                     }
                 }
-                return Promise.all(promises).then(function () { });
+                return Promise.all(promises).then(function () {
+                    _this._parent._endPerformanceCounter("Compile shadow generators");
+                });
             };
             GLTFLoader.prototype._applyExtensions = function (actionAsync) {
                 for (var _i = 0, _a = GLTFLoader._ExtensionNames; _i < _a.length; _i++) {
@@ -2313,29 +2361,45 @@ var BABYLON;
                      * Dispose the loader to cancel the loading of the next level of LODs.
                      */
                     _this.onMaterialLODsLoadedObservable = new BABYLON.Observable();
-                    _this._loadingNodeLOD = null;
-                    _this._loadNodeSignals = {};
-                    _this._loadNodePromises = new Array();
-                    _this._loadingMaterialLOD = null;
-                    _this._loadMaterialSignals = {};
-                    _this._loadMaterialPromises = new Array();
-                    _this._loader._onReadyObservable.addOnce(function () {
+                    _this._nodeIndexLOD = null;
+                    _this._nodeSignalLODs = new Array();
+                    _this._nodePromiseLODs = new Array();
+                    _this._materialIndexLOD = null;
+                    _this._materialSignalLODs = new Array();
+                    _this._materialPromiseLODs = new Array();
+                    _this._loader._readyPromise.then(function () {
                         var _loop_1 = function (indexLOD) {
-                            Promise.all(_this._loadNodePromises[indexLOD]).then(function () {
+                            var promise = Promise.all(_this._nodePromiseLODs[indexLOD]).then(function () {
+                                if (indexLOD !== 0) {
+                                    _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
+                                }
                                 _this._loader._parent._log("Loaded node LOD " + indexLOD);
                                 _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
+                                if (indexLOD !== _this._nodePromiseLODs.length - 1) {
+                                    _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
+                                    _this._nodeSignalLODs[indexLOD].resolve();
+                                }
                             });
+                            _this._loader._completePromises.push(promise);
                         };
-                        for (var indexLOD = 0; indexLOD < _this._loadNodePromises.length; indexLOD++) {
+                        for (var indexLOD = 0; indexLOD < _this._nodePromiseLODs.length; indexLOD++) {
                             _loop_1(indexLOD);
                         }
                         var _loop_2 = function (indexLOD) {
-                            Promise.all(_this._loadMaterialPromises[indexLOD]).then(function () {
+                            var promise = Promise.all(_this._materialPromiseLODs[indexLOD]).then(function () {
+                                if (indexLOD !== 0) {
+                                    _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
+                                }
                                 _this._loader._parent._log("Loaded material LOD " + indexLOD);
                                 _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
+                                if (indexLOD !== _this._materialPromiseLODs.length - 1) {
+                                    _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
+                                    _this._materialSignalLODs[indexLOD].resolve();
+                                }
                             });
+                            _this._loader._completePromises.push(promise);
                         };
-                        for (var indexLOD = 0; indexLOD < _this._loadMaterialPromises.length; indexLOD++) {
+                        for (var indexLOD = 0; indexLOD < _this._materialPromiseLODs.length; indexLOD++) {
                             _loop_2(indexLOD);
                         }
                     });
@@ -2343,10 +2407,12 @@ var BABYLON;
                 }
                 MSFT_lod.prototype.dispose = function () {
                     _super.prototype.dispose.call(this);
-                    this._loadingNodeLOD = null;
-                    this._loadNodeSignals = {};
-                    this._loadingMaterialLOD = null;
-                    this._loadMaterialSignals = {};
+                    this._nodeIndexLOD = null;
+                    this._nodeSignalLODs.length = 0;
+                    this._nodePromiseLODs.length = 0;
+                    this._materialIndexLOD = null;
+                    this._materialSignalLODs.length = 0;
+                    this._materialPromiseLODs.length = 0;
                     this.onMaterialLODsLoadedObservable.clear();
                     this.onNodeLODsLoadedObservable.clear();
                 };
@@ -2359,10 +2425,8 @@ var BABYLON;
                         var _loop_3 = function (indexLOD) {
                             var nodeLOD = nodeLODs[indexLOD];
                             if (indexLOD !== 0) {
-                                _this._loadingNodeLOD = nodeLOD;
-                                if (!_this._loadNodeSignals[nodeLOD._index]) {
-                                    _this._loadNodeSignals[nodeLOD._index] = new BABYLON.Deferred();
-                                }
+                                _this._nodeIndexLOD = indexLOD;
+                                _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new BABYLON.Deferred();
                             }
                             var promise = _this._loader._loadNodeAsync("#/nodes/" + nodeLOD._index, nodeLOD).then(function () {
                                 if (indexLOD !== 0) {
@@ -2372,23 +2436,15 @@ var BABYLON;
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }
-                                if (indexLOD !== nodeLODs.length - 1) {
-                                    var nodeIndex = nodeLODs[indexLOD + 1]._index;
-                                    if (_this._loadNodeSignals[nodeIndex]) {
-                                        _this._loadNodeSignals[nodeIndex].resolve();
-                                        delete _this._loadNodeSignals[nodeIndex];
-                                    }
-                                }
                             });
                             if (indexLOD === 0) {
                                 firstPromise = promise;
                             }
                             else {
-                                _this._loader._completePromises.push(promise);
-                                _this._loadingNodeLOD = null;
+                                _this._nodeIndexLOD = null;
                             }
-                            _this._loadNodePromises[indexLOD] = _this._loadNodePromises[indexLOD] || [];
-                            _this._loadNodePromises[indexLOD].push(promise);
+                            _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || [];
+                            _this._nodePromiseLODs[indexLOD].push(promise);
                         };
                         for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
                             _loop_3(indexLOD);
@@ -2400,7 +2456,7 @@ var BABYLON;
                 MSFT_lod.prototype._loadMaterialAsync = function (context, material, mesh, babylonMesh, babylonDrawMode, assign) {
                     var _this = this;
                     // Don't load material LODs if already loading a node LOD.
-                    if (this._loadingNodeLOD) {
+                    if (this._nodeIndexLOD) {
                         return null;
                     }
                     return this._loadExtensionAsync(context, material, function (extensionContext, extension) {
@@ -2410,10 +2466,7 @@ var BABYLON;
                         var _loop_4 = function (indexLOD) {
                             var materialLOD = materialLODs[indexLOD];
                             if (indexLOD !== 0) {
-                                _this._loadingMaterialLOD = materialLOD;
-                                if (!_this._loadMaterialSignals[materialLOD._index]) {
-                                    _this._loadMaterialSignals[materialLOD._index] = new BABYLON.Deferred();
-                                }
+                                _this._materialIndexLOD = indexLOD;
                             }
                             var promise = _this._loader._loadMaterialAsync("#/materials/" + materialLOD._index, materialLOD, mesh, babylonMesh, babylonDrawMode, indexLOD === 0 ? assign : function () { }).then(function () {
                                 if (indexLOD !== 0) {
@@ -2425,23 +2478,15 @@ var BABYLON;
                                         delete previousBabylonDataLOD[babylonDrawMode];
                                     }
                                 }
-                                if (indexLOD !== materialLODs.length - 1) {
-                                    var materialIndex = materialLODs[indexLOD + 1]._index;
-                                    if (_this._loadMaterialSignals[materialIndex]) {
-                                        _this._loadMaterialSignals[materialIndex].resolve();
-                                        delete _this._loadMaterialSignals[materialIndex];
-                                    }
-                                }
                             });
                             if (indexLOD === 0) {
                                 firstPromise = promise;
                             }
                             else {
-                                _this._loader._completePromises.push(promise);
-                                _this._loadingMaterialLOD = null;
+                                _this._materialIndexLOD = null;
                             }
-                            _this._loadMaterialPromises[indexLOD] = _this._loadMaterialPromises[indexLOD] || [];
-                            _this._loadMaterialPromises[indexLOD].push(promise);
+                            _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || [];
+                            _this._materialPromiseLODs[indexLOD].push(promise);
                         };
                         for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {
                             _loop_4(indexLOD);
@@ -2452,21 +2497,20 @@ var BABYLON;
                 };
                 MSFT_lod.prototype._loadUriAsync = function (context, uri) {
                     var _this = this;
-                    if (this._loadingMaterialLOD || this._loadingNodeLOD) {
-                        if (this._loader._parent.loggingEnabled) {
-                            this._loader._parent._log("deferred");
-                        }
-                    }
                     // Defer the loading of uris if loading a material or node LOD.
-                    if (this._loadingMaterialLOD) {
-                        var index = this._loadingMaterialLOD._index;
-                        return this._loadMaterialSignals[index].promise.then(function () {
+                    if (this._materialIndexLOD !== null) {
+                        this._loader._parent._log("deferred");
+                        var previousIndexLOD = this._materialIndexLOD - 1;
+                        this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new BABYLON.Deferred();
+                        return this._materialSignalLODs[previousIndexLOD].promise.then(function () {
                             return _this._loader._loadUriAsync(context, uri);
                         });
                     }
-                    else if (this._loadingNodeLOD) {
-                        var index = this._loadingNodeLOD._index;
-                        return this._loadNodeSignals[index].promise.then(function () {
+                    else if (this._nodeIndexLOD !== null) {
+                        this._loader._parent._log("deferred");
+                        var previousIndexLOD = this._nodeIndexLOD - 1;
+                        this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new BABYLON.Deferred();
+                        return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () {
                             return _this._loader._loadUriAsync(context, uri);
                         });
                     }

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 35 - 24
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -143,22 +143,6 @@ declare module BABYLON {
         /** @hidden */
         _normalizeAnimationGroupsToBeginAtZero: boolean;
         /**
-         * Defines if the loader logging is enabled.
-         */
-        loggingEnabled: boolean;
-        /**
-         * Observable raised when the loader logs a message.
-         */
-        readonly onLogObservable: Observable<string>;
-        private _logIndentLevel;
-        private static readonly _logSpaces;
-        /** @hidden */
-        _log(message: string): void;
-        /** @hidden */
-        _logOpen(message: string): void;
-        /** @hidden */
-        _logClose(): void;
-        /**
          * Function called before loading a url referenced by the asset.
          */
         preprocessUrlAsync: (url: string) => Promise<string>;
@@ -237,6 +221,14 @@ declare module BABYLON {
          * The loader state or null if the loader is not active.
          */
         readonly loaderState: Nullable<GLTFLoaderState>;
+        /**
+         * Defines if the loader logging is enabled.
+         */
+        loggingEnabled: boolean;
+        /**
+         * Defines if the loader should capture performance counters.
+         */
+        capturePerformanceCounters: boolean;
         private _loader;
         /**
          * Name of the loader ("gltf")
@@ -308,6 +300,26 @@ declare module BABYLON {
         private static _parseVersion(version);
         private static _compareVersion(a, b);
         private static _decodeBufferToText(buffer);
+        private static readonly _logSpaces;
+        private _logIndentLevel;
+        private _loggingEnabled;
+        /** @hidden */
+        _log: (message: string) => void;
+        /** @hidden */
+        _logOpen(message: string): void;
+        /** @hidden */
+        _logClose(): void;
+        private _logEnabled(message);
+        private _logDisabled(message);
+        private _capturePerformanceCounters;
+        /** @hidden */
+        _startPerformanceCounter: (counterName: string) => void;
+        /** @hidden */
+        _endPerformanceCounter: (counterName: string) => void;
+        private _startPerformanceCounterEnabled(counterName);
+        private _startPerformanceCounterDisabled(counterName);
+        private _endPerformanceCounterEnabled(counterName);
+        private _endPerformanceCounterDisabled(counterName);
     }
 }
 
@@ -995,8 +1007,8 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
+        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
-        _onReadyObservable: Observable<IGLTFLoader>;
         private _disposed;
         private _state;
         private _extensions;
@@ -1028,7 +1040,6 @@ declare module BABYLON.GLTF2 {
         private _loadExtensions();
         private _checkExtensions();
         private _createRootNode();
-        private _loadNodesAsync(nodes);
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
         private _forEachPrimitive(node, callback);
         private _getMeshes();
@@ -1209,12 +1220,12 @@ declare module BABYLON.GLTF2.Extensions {
          * Dispose the loader to cancel the loading of the next level of LODs.
          */
         onMaterialLODsLoadedObservable: Observable<number>;
-        private _loadingNodeLOD;
-        private _loadNodeSignals;
-        private _loadNodePromises;
-        private _loadingMaterialLOD;
-        private _loadMaterialSignals;
-        private _loadMaterialPromises;
+        private _nodeIndexLOD;
+        private _nodeSignalLODs;
+        private _nodePromiseLODs;
+        private _materialIndexLOD;
+        private _materialSignalLODs;
+        private _materialPromiseLODs;
         constructor(loader: GLTFLoader);
         dispose(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;

+ 165 - 121
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -92,15 +92,6 @@ var BABYLON;
             /** @hidden */
             this._normalizeAnimationGroupsToBeginAtZero = true;
             /**
-             * Defines if the loader logging is enabled.
-             */
-            this.loggingEnabled = false;
-            /**
-             * Observable raised when the loader logs a message.
-             */
-            this.onLogObservable = new BABYLON.Observable();
-            this._logIndentLevel = 0;
-            /**
              * Function called before loading a url referenced by the asset.
              */
             this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
@@ -148,6 +139,15 @@ var BABYLON;
                 ".gltf": { isBinary: false },
                 ".glb": { isBinary: true }
             };
+            this._logIndentLevel = 0;
+            this._loggingEnabled = false;
+            /** @hidden */
+            this._log = this._logDisabled;
+            this._capturePerformanceCounters = false;
+            /** @hidden */
+            this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+            /** @hidden */
+            this._endPerformanceCounter = this._endPerformanceCounterDisabled;
         }
         Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
             /**
@@ -162,23 +162,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        /** @hidden */
-        GLTFFileLoader.prototype._log = function (message) {
-            if (this.loggingEnabled) {
-                var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
-                this.onLogObservable.notifyObservers("" + spaces + message);
-                BABYLON.Tools.Log("" + spaces + message);
-            }
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logOpen = function (message) {
-            this._log(message);
-            this._logIndentLevel++;
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logClose = function () {
-            --this._logIndentLevel;
-        };
         Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
             /**
              * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
@@ -292,6 +275,52 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
+            /**
+             * Defines if the loader logging is enabled.
+             */
+            get: function () {
+                return this._loggingEnabled;
+            },
+            set: function (value) {
+                if (this._loggingEnabled === value) {
+                    return;
+                }
+                this._loggingEnabled = value;
+                if (this._loggingEnabled) {
+                    this._log = this._logEnabled;
+                }
+                else {
+                    this._log = this._logDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
+            /**
+             * Defines if the loader should capture performance counters.
+             */
+            get: function () {
+                return this._capturePerformanceCounters;
+            },
+            set: function (value) {
+                if (this._capturePerformanceCounters === value) {
+                    return;
+                }
+                this._capturePerformanceCounters = value;
+                if (this._capturePerformanceCounters) {
+                    this._startPerformanceCounter = this._startPerformanceCounterEnabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterEnabled;
+                }
+                else {
+                    this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         /**
          * Disposes the loader, releases resources during load, and cancels any outstanding requests.
          */
@@ -387,18 +416,15 @@ var BABYLON;
             return new GLTFFileLoader();
         };
         GLTFFileLoader.prototype._parse = function (data) {
+            this._startPerformanceCounter("Parse");
             var parsedData;
             if (data instanceof ArrayBuffer) {
-                if (this.loggingEnabled) {
-                    this._log("Parsing binary");
-                }
+                this._log("Parsing binary");
                 parsedData = this._parseBinary(data);
             }
             else {
-                if (this.loggingEnabled) {
-                    this._log("Parsing JSON");
-                    this._log("JSON length: " + data.length);
-                }
+                this._log("Parsing JSON");
+                this._log("JSON length: " + data.length);
                 parsedData = {
                     json: JSON.parse(data),
                     bin: null
@@ -406,19 +432,14 @@ var BABYLON;
             }
             this.onParsedObservable.notifyObservers(parsedData);
             this.onParsedObservable.clear();
+            this._endPerformanceCounter("Parse");
             return parsedData;
         };
         GLTFFileLoader.prototype._getLoader = function (loaderData) {
             var asset = loaderData.json.asset || {};
-            if (this.loggingEnabled) {
-                this._log("Asset version: " + asset.version);
-                if (asset.minVersion) {
-                    this._log("Asset minimum version: " + asset.minVersion);
-                }
-                if (asset.generator) {
-                    this._log("Asset generator: " + asset.generator);
-                }
-            }
+            this._log("Asset version: " + asset.version);
+            asset.minVersion && this._log("Asset minimum version: " + asset.minVersion);
+            asset.generator && this._log("Asset generator: " + asset.generator);
             var version = GLTFFileLoader._parseVersion(asset.version);
             if (!version) {
                 throw new Error("Invalid version: " + asset.version);
@@ -446,9 +467,7 @@ var BABYLON;
             var Binary = {
                 Magic: 0x46546C67
             };
-            if (this.loggingEnabled) {
-                this._log("Binary length: " + data.byteLength);
-            }
+            this._log("Binary length: " + data.byteLength);
             var binaryReader = new BinaryReader(data);
             var magic = binaryReader.readUint32();
             if (magic !== Binary.Magic) {
@@ -567,6 +586,31 @@ var BABYLON;
             }
             return result;
         };
+        /** @hidden */
+        GLTFFileLoader.prototype._logOpen = function (message) {
+            this._log(message);
+            this._logIndentLevel++;
+        };
+        /** @hidden */
+        GLTFFileLoader.prototype._logClose = function () {
+            --this._logIndentLevel;
+        };
+        GLTFFileLoader.prototype._logEnabled = function (message) {
+            var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
+            BABYLON.Tools.Log("" + spaces + message);
+        };
+        GLTFFileLoader.prototype._logDisabled = function (message) {
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.StartPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) {
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.EndPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) {
+        };
         // #endregion
         // #region V1 options
         /**
@@ -2850,7 +2894,6 @@ var BABYLON;
         var GLTFLoader = /** @class */ (function () {
             function GLTFLoader(parent) {
                 this._completePromises = new Array();
-                this._onReadyObservable = new BABYLON.Observable();
                 this._disposed = false;
                 this._state = null;
                 this._extensions = {};
@@ -2890,8 +2933,8 @@ var BABYLON;
                 this._requests.length = 0;
                 delete this._gltf;
                 delete this._babylonScene;
+                delete this._readyPromise;
                 this._completePromises.length = 0;
-                this._onReadyObservable.clear();
                 for (var name_1 in this._extensions) {
                     this._extensions[name_1].dispose();
                 }
@@ -2914,14 +2957,14 @@ var BABYLON;
                             for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) {
                                 var node = _a[_i];
                                 if (node.name) {
-                                    nodeMap_1[node.name] = node;
+                                    nodeMap_1[node.name] = node._index;
                                 }
                             }
                         }
                         var names = (meshesNames instanceof Array) ? meshesNames : [meshesNames];
                         nodes = names.map(function (name) {
                             var node = nodeMap_1[name];
-                            if (!node) {
+                            if (node === undefined) {
                                 throw new Error("Failed to find node '" + name + "'");
                             }
                             return node;
@@ -2950,13 +2993,17 @@ var BABYLON;
             GLTFLoader.prototype._loadAsync = function (nodes) {
                 var _this = this;
                 return Promise.resolve().then(function () {
+                    _this._parent._startPerformanceCounter("Loading => Ready");
+                    _this._parent._startPerformanceCounter("Loading => Complete");
                     _this._state = BABYLON.GLTFLoaderState.LOADING;
                     _this._parent._log("Loading");
+                    var readyDeferred = new BABYLON.Deferred();
+                    _this._readyPromise = readyDeferred.promise;
                     _this._loadExtensions();
                     _this._checkExtensions();
                     var promises = new Array();
                     if (nodes) {
-                        promises.push(_this._loadNodesAsync(nodes));
+                        promises.push(_this._loadSceneAsync("#/nodes", { nodes: nodes, _index: -1 }));
                     }
                     else {
                         var scene = GLTFLoader._GetProperty("#/scene", _this._gltf.scenes, _this._gltf.scene || 0);
@@ -2971,16 +3018,18 @@ var BABYLON;
                     var resultPromise = Promise.all(promises).then(function () {
                         _this._state = BABYLON.GLTFLoaderState.READY;
                         _this._parent._log("Ready");
-                        _this._onReadyObservable.notifyObservers(_this);
+                        readyDeferred.resolve();
                         _this._startAnimations();
                     });
                     resultPromise.then(function () {
+                        _this._parent._endPerformanceCounter("Loading => Ready");
                         if (_this._rootBabylonMesh) {
                             _this._rootBabylonMesh.setEnabled(true);
                         }
                         BABYLON.Tools.SetImmediate(function () {
                             if (!_this._disposed) {
                                 Promise.all(_this._completePromises).then(function () {
+                                    _this._parent._endPerformanceCounter("Loading => Complete");
                                     _this._state = BABYLON.GLTFLoaderState.COMPLETE;
                                     _this._parent._log("Complete");
                                     _this._parent.onCompleteObservable.notifyObservers(undefined);
@@ -3096,15 +3145,6 @@ var BABYLON;
                 this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh);
                 return rootNode;
             };
-            GLTFLoader.prototype._loadNodesAsync = function (nodes) {
-                var promises = new Array();
-                for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
-                    var node = nodes_1[_i];
-                    promises.push(this._loadNodeAsync("#/nodes/" + node._index, node));
-                }
-                promises.push(this._loadAnimationsAsync());
-                return Promise.all(promises).then(function () { });
-            };
             GLTFLoader.prototype._loadSceneAsync = function (context, scene) {
                 var promise = GLTF2.GLTFLoaderExtension._LoadSceneAsync(this, context, scene);
                 if (promise) {
@@ -3140,8 +3180,8 @@ var BABYLON;
                 meshes.push(this._rootBabylonMesh);
                 var nodes = this._gltf.nodes;
                 if (nodes) {
-                    for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
-                        var node = nodes_2[_i];
+                    for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
+                        var node = nodes_1[_i];
                         if (node._babylonMesh) {
                             meshes.push(node._babylonMesh);
                         }
@@ -4259,6 +4299,8 @@ var BABYLON;
                 throw new Error(context + ": Invalid mesh primitive mode (" + mode + ")");
             };
             GLTFLoader.prototype._compileMaterialsAsync = function () {
+                var _this = this;
+                this._parent._startPerformanceCounter("Compile materials");
                 var promises = new Array();
                 if (this._gltf.materials) {
                     for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) {
@@ -4280,9 +4322,13 @@ var BABYLON;
                         }
                     }
                 }
-                return Promise.all(promises).then(function () { });
+                return Promise.all(promises).then(function () {
+                    _this._parent._endPerformanceCounter("Compile materials");
+                });
             };
             GLTFLoader.prototype._compileShadowGeneratorsAsync = function () {
+                var _this = this;
+                this._parent._startPerformanceCounter("Compile shadow generators");
                 var promises = new Array();
                 var lights = this._babylonScene.lights;
                 for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
@@ -4292,7 +4338,9 @@ var BABYLON;
                         promises.push(generator.forceCompilationAsync());
                     }
                 }
-                return Promise.all(promises).then(function () { });
+                return Promise.all(promises).then(function () {
+                    _this._parent._endPerformanceCounter("Compile shadow generators");
+                });
             };
             GLTFLoader.prototype._applyExtensions = function (actionAsync) {
                 for (var _i = 0, _a = GLTFLoader._ExtensionNames; _i < _a.length; _i++) {
@@ -4514,29 +4562,45 @@ var BABYLON;
                      * Dispose the loader to cancel the loading of the next level of LODs.
                      */
                     _this.onMaterialLODsLoadedObservable = new BABYLON.Observable();
-                    _this._loadingNodeLOD = null;
-                    _this._loadNodeSignals = {};
-                    _this._loadNodePromises = new Array();
-                    _this._loadingMaterialLOD = null;
-                    _this._loadMaterialSignals = {};
-                    _this._loadMaterialPromises = new Array();
-                    _this._loader._onReadyObservable.addOnce(function () {
+                    _this._nodeIndexLOD = null;
+                    _this._nodeSignalLODs = new Array();
+                    _this._nodePromiseLODs = new Array();
+                    _this._materialIndexLOD = null;
+                    _this._materialSignalLODs = new Array();
+                    _this._materialPromiseLODs = new Array();
+                    _this._loader._readyPromise.then(function () {
                         var _loop_1 = function (indexLOD) {
-                            Promise.all(_this._loadNodePromises[indexLOD]).then(function () {
+                            var promise = Promise.all(_this._nodePromiseLODs[indexLOD]).then(function () {
+                                if (indexLOD !== 0) {
+                                    _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
+                                }
                                 _this._loader._parent._log("Loaded node LOD " + indexLOD);
                                 _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
+                                if (indexLOD !== _this._nodePromiseLODs.length - 1) {
+                                    _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
+                                    _this._nodeSignalLODs[indexLOD].resolve();
+                                }
                             });
+                            _this._loader._completePromises.push(promise);
                         };
-                        for (var indexLOD = 0; indexLOD < _this._loadNodePromises.length; indexLOD++) {
+                        for (var indexLOD = 0; indexLOD < _this._nodePromiseLODs.length; indexLOD++) {
                             _loop_1(indexLOD);
                         }
                         var _loop_2 = function (indexLOD) {
-                            Promise.all(_this._loadMaterialPromises[indexLOD]).then(function () {
+                            var promise = Promise.all(_this._materialPromiseLODs[indexLOD]).then(function () {
+                                if (indexLOD !== 0) {
+                                    _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
+                                }
                                 _this._loader._parent._log("Loaded material LOD " + indexLOD);
                                 _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
+                                if (indexLOD !== _this._materialPromiseLODs.length - 1) {
+                                    _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
+                                    _this._materialSignalLODs[indexLOD].resolve();
+                                }
                             });
+                            _this._loader._completePromises.push(promise);
                         };
-                        for (var indexLOD = 0; indexLOD < _this._loadMaterialPromises.length; indexLOD++) {
+                        for (var indexLOD = 0; indexLOD < _this._materialPromiseLODs.length; indexLOD++) {
                             _loop_2(indexLOD);
                         }
                     });
@@ -4544,10 +4608,12 @@ var BABYLON;
                 }
                 MSFT_lod.prototype.dispose = function () {
                     _super.prototype.dispose.call(this);
-                    this._loadingNodeLOD = null;
-                    this._loadNodeSignals = {};
-                    this._loadingMaterialLOD = null;
-                    this._loadMaterialSignals = {};
+                    this._nodeIndexLOD = null;
+                    this._nodeSignalLODs.length = 0;
+                    this._nodePromiseLODs.length = 0;
+                    this._materialIndexLOD = null;
+                    this._materialSignalLODs.length = 0;
+                    this._materialPromiseLODs.length = 0;
                     this.onMaterialLODsLoadedObservable.clear();
                     this.onNodeLODsLoadedObservable.clear();
                 };
@@ -4560,10 +4626,8 @@ var BABYLON;
                         var _loop_3 = function (indexLOD) {
                             var nodeLOD = nodeLODs[indexLOD];
                             if (indexLOD !== 0) {
-                                _this._loadingNodeLOD = nodeLOD;
-                                if (!_this._loadNodeSignals[nodeLOD._index]) {
-                                    _this._loadNodeSignals[nodeLOD._index] = new BABYLON.Deferred();
-                                }
+                                _this._nodeIndexLOD = indexLOD;
+                                _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new BABYLON.Deferred();
                             }
                             var promise = _this._loader._loadNodeAsync("#/nodes/" + nodeLOD._index, nodeLOD).then(function () {
                                 if (indexLOD !== 0) {
@@ -4573,23 +4637,15 @@ var BABYLON;
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }
-                                if (indexLOD !== nodeLODs.length - 1) {
-                                    var nodeIndex = nodeLODs[indexLOD + 1]._index;
-                                    if (_this._loadNodeSignals[nodeIndex]) {
-                                        _this._loadNodeSignals[nodeIndex].resolve();
-                                        delete _this._loadNodeSignals[nodeIndex];
-                                    }
-                                }
                             });
                             if (indexLOD === 0) {
                                 firstPromise = promise;
                             }
                             else {
-                                _this._loader._completePromises.push(promise);
-                                _this._loadingNodeLOD = null;
+                                _this._nodeIndexLOD = null;
                             }
-                            _this._loadNodePromises[indexLOD] = _this._loadNodePromises[indexLOD] || [];
-                            _this._loadNodePromises[indexLOD].push(promise);
+                            _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || [];
+                            _this._nodePromiseLODs[indexLOD].push(promise);
                         };
                         for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
                             _loop_3(indexLOD);
@@ -4601,7 +4657,7 @@ var BABYLON;
                 MSFT_lod.prototype._loadMaterialAsync = function (context, material, mesh, babylonMesh, babylonDrawMode, assign) {
                     var _this = this;
                     // Don't load material LODs if already loading a node LOD.
-                    if (this._loadingNodeLOD) {
+                    if (this._nodeIndexLOD) {
                         return null;
                     }
                     return this._loadExtensionAsync(context, material, function (extensionContext, extension) {
@@ -4611,10 +4667,7 @@ var BABYLON;
                         var _loop_4 = function (indexLOD) {
                             var materialLOD = materialLODs[indexLOD];
                             if (indexLOD !== 0) {
-                                _this._loadingMaterialLOD = materialLOD;
-                                if (!_this._loadMaterialSignals[materialLOD._index]) {
-                                    _this._loadMaterialSignals[materialLOD._index] = new BABYLON.Deferred();
-                                }
+                                _this._materialIndexLOD = indexLOD;
                             }
                             var promise = _this._loader._loadMaterialAsync("#/materials/" + materialLOD._index, materialLOD, mesh, babylonMesh, babylonDrawMode, indexLOD === 0 ? assign : function () { }).then(function () {
                                 if (indexLOD !== 0) {
@@ -4626,23 +4679,15 @@ var BABYLON;
                                         delete previousBabylonDataLOD[babylonDrawMode];
                                     }
                                 }
-                                if (indexLOD !== materialLODs.length - 1) {
-                                    var materialIndex = materialLODs[indexLOD + 1]._index;
-                                    if (_this._loadMaterialSignals[materialIndex]) {
-                                        _this._loadMaterialSignals[materialIndex].resolve();
-                                        delete _this._loadMaterialSignals[materialIndex];
-                                    }
-                                }
                             });
                             if (indexLOD === 0) {
                                 firstPromise = promise;
                             }
                             else {
-                                _this._loader._completePromises.push(promise);
-                                _this._loadingMaterialLOD = null;
+                                _this._materialIndexLOD = null;
                             }
-                            _this._loadMaterialPromises[indexLOD] = _this._loadMaterialPromises[indexLOD] || [];
-                            _this._loadMaterialPromises[indexLOD].push(promise);
+                            _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || [];
+                            _this._materialPromiseLODs[indexLOD].push(promise);
                         };
                         for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {
                             _loop_4(indexLOD);
@@ -4653,21 +4698,20 @@ var BABYLON;
                 };
                 MSFT_lod.prototype._loadUriAsync = function (context, uri) {
                     var _this = this;
-                    if (this._loadingMaterialLOD || this._loadingNodeLOD) {
-                        if (this._loader._parent.loggingEnabled) {
-                            this._loader._parent._log("deferred");
-                        }
-                    }
                     // Defer the loading of uris if loading a material or node LOD.
-                    if (this._loadingMaterialLOD) {
-                        var index = this._loadingMaterialLOD._index;
-                        return this._loadMaterialSignals[index].promise.then(function () {
+                    if (this._materialIndexLOD !== null) {
+                        this._loader._parent._log("deferred");
+                        var previousIndexLOD = this._materialIndexLOD - 1;
+                        this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new BABYLON.Deferred();
+                        return this._materialSignalLODs[previousIndexLOD].promise.then(function () {
                             return _this._loader._loadUriAsync(context, uri);
                         });
                     }
-                    else if (this._loadingNodeLOD) {
-                        var index = this._loadingNodeLOD._index;
-                        return this._loadNodeSignals[index].promise.then(function () {
+                    else if (this._nodeIndexLOD !== null) {
+                        this._loader._parent._log("deferred");
+                        var previousIndexLOD = this._nodeIndexLOD - 1;
+                        this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new BABYLON.Deferred();
+                        return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () {
                             return _this._loader._loadUriAsync(context, uri);
                         });
                     }

文件差异内容过多而无法显示
+ 4 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 18 - 15
dist/preview release/loaders/babylon.stlFileLoader.js

@@ -16,23 +16,26 @@ var BABYLON;
         }
         STLFileLoader.prototype.importMesh = function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons) {
             var matches;
-            if (this.isBinary(data)) {
-                // binary .stl
-                var babylonMesh = new BABYLON.Mesh("stlmesh", scene);
-                this.parseBinary(babylonMesh, data);
-                if (meshes) {
-                    meshes.push(babylonMesh);
+            if (typeof data !== "string") {
+                if (this.isBinary(data)) {
+                    // binary .stl
+                    var babylonMesh = new BABYLON.Mesh("stlmesh", scene);
+                    this.parseBinary(babylonMesh, data);
+                    if (meshes) {
+                        meshes.push(babylonMesh);
+                    }
+                    return true;
                 }
-                return true;
-            }
-            // ASCII .stl
-            // convert to string
-            var array_buffer = new Uint8Array(data);
-            var str = '';
-            for (var i = 0; i < data.byteLength; i++) {
-                str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
+                // ASCII .stl
+                // convert to string
+                var array_buffer = new Uint8Array(data);
+                var str = '';
+                for (var i = 0; i < data.byteLength; i++) {
+                    str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
+                }
+                data = str;
             }
-            data = str;
+            //if arrived here, data is a string, containing the STLA data.
             while (matches = this.solidPattern.exec(data)) {
                 var meshName = matches[1];
                 var meshNameFromEnd = matches[3];

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.stlFileLoader.min.js


+ 35 - 24
dist/preview release/loaders/babylonjs.loaders.d.ts

@@ -239,22 +239,6 @@ declare module BABYLON {
         /** @hidden */
         _normalizeAnimationGroupsToBeginAtZero: boolean;
         /**
-         * Defines if the loader logging is enabled.
-         */
-        loggingEnabled: boolean;
-        /**
-         * Observable raised when the loader logs a message.
-         */
-        readonly onLogObservable: Observable<string>;
-        private _logIndentLevel;
-        private static readonly _logSpaces;
-        /** @hidden */
-        _log(message: string): void;
-        /** @hidden */
-        _logOpen(message: string): void;
-        /** @hidden */
-        _logClose(): void;
-        /**
          * Function called before loading a url referenced by the asset.
          */
         preprocessUrlAsync: (url: string) => Promise<string>;
@@ -333,6 +317,14 @@ declare module BABYLON {
          * The loader state or null if the loader is not active.
          */
         readonly loaderState: Nullable<GLTFLoaderState>;
+        /**
+         * Defines if the loader logging is enabled.
+         */
+        loggingEnabled: boolean;
+        /**
+         * Defines if the loader should capture performance counters.
+         */
+        capturePerformanceCounters: boolean;
         private _loader;
         /**
          * Name of the loader ("gltf")
@@ -404,6 +396,26 @@ declare module BABYLON {
         private static _parseVersion(version);
         private static _compareVersion(a, b);
         private static _decodeBufferToText(buffer);
+        private static readonly _logSpaces;
+        private _logIndentLevel;
+        private _loggingEnabled;
+        /** @hidden */
+        _log: (message: string) => void;
+        /** @hidden */
+        _logOpen(message: string): void;
+        /** @hidden */
+        _logClose(): void;
+        private _logEnabled(message);
+        private _logDisabled(message);
+        private _capturePerformanceCounters;
+        /** @hidden */
+        _startPerformanceCounter: (counterName: string) => void;
+        /** @hidden */
+        _endPerformanceCounter: (counterName: string) => void;
+        private _startPerformanceCounterEnabled(counterName);
+        private _startPerformanceCounterDisabled(counterName);
+        private _endPerformanceCounterEnabled(counterName);
+        private _endPerformanceCounterDisabled(counterName);
     }
 }
 
@@ -1091,8 +1103,8 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
+        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
-        _onReadyObservable: Observable<IGLTFLoader>;
         private _disposed;
         private _state;
         private _extensions;
@@ -1124,7 +1136,6 @@ declare module BABYLON.GLTF2 {
         private _loadExtensions();
         private _checkExtensions();
         private _createRootNode();
-        private _loadNodesAsync(nodes);
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
         private _forEachPrimitive(node, callback);
         private _getMeshes();
@@ -1305,12 +1316,12 @@ declare module BABYLON.GLTF2.Extensions {
          * Dispose the loader to cancel the loading of the next level of LODs.
          */
         onMaterialLODsLoadedObservable: Observable<number>;
-        private _loadingNodeLOD;
-        private _loadNodeSignals;
-        private _loadNodePromises;
-        private _loadingMaterialLOD;
-        private _loadMaterialSignals;
-        private _loadMaterialPromises;
+        private _nodeIndexLOD;
+        private _nodeSignalLODs;
+        private _nodePromiseLODs;
+        private _materialIndexLOD;
+        private _materialSignalLODs;
+        private _materialPromiseLODs;
         constructor(loader: GLTFLoader);
         dispose(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;

+ 183 - 136
dist/preview release/loaders/babylonjs.loaders.js

@@ -41,23 +41,26 @@ var BABYLON;
         }
         STLFileLoader.prototype.importMesh = function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons) {
             var matches;
-            if (this.isBinary(data)) {
-                // binary .stl
-                var babylonMesh = new BABYLON.Mesh("stlmesh", scene);
-                this.parseBinary(babylonMesh, data);
-                if (meshes) {
-                    meshes.push(babylonMesh);
+            if (typeof data !== "string") {
+                if (this.isBinary(data)) {
+                    // binary .stl
+                    var babylonMesh = new BABYLON.Mesh("stlmesh", scene);
+                    this.parseBinary(babylonMesh, data);
+                    if (meshes) {
+                        meshes.push(babylonMesh);
+                    }
+                    return true;
                 }
-                return true;
-            }
-            // ASCII .stl
-            // convert to string
-            var array_buffer = new Uint8Array(data);
-            var str = '';
-            for (var i = 0; i < data.byteLength; i++) {
-                str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
+                // ASCII .stl
+                // convert to string
+                var array_buffer = new Uint8Array(data);
+                var str = '';
+                for (var i = 0; i < data.byteLength; i++) {
+                    str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
+                }
+                data = str;
             }
-            data = str;
+            //if arrived here, data is a string, containing the STLA data.
             while (matches = this.solidPattern.exec(data)) {
                 var meshName = matches[1];
                 var meshNameFromEnd = matches[3];
@@ -1092,15 +1095,6 @@ var BABYLON;
             /** @hidden */
             this._normalizeAnimationGroupsToBeginAtZero = true;
             /**
-             * Defines if the loader logging is enabled.
-             */
-            this.loggingEnabled = false;
-            /**
-             * Observable raised when the loader logs a message.
-             */
-            this.onLogObservable = new BABYLON.Observable();
-            this._logIndentLevel = 0;
-            /**
              * Function called before loading a url referenced by the asset.
              */
             this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
@@ -1148,6 +1142,15 @@ var BABYLON;
                 ".gltf": { isBinary: false },
                 ".glb": { isBinary: true }
             };
+            this._logIndentLevel = 0;
+            this._loggingEnabled = false;
+            /** @hidden */
+            this._log = this._logDisabled;
+            this._capturePerformanceCounters = false;
+            /** @hidden */
+            this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+            /** @hidden */
+            this._endPerformanceCounter = this._endPerformanceCounterDisabled;
         }
         Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
             /**
@@ -1162,23 +1165,6 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        /** @hidden */
-        GLTFFileLoader.prototype._log = function (message) {
-            if (this.loggingEnabled) {
-                var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
-                this.onLogObservable.notifyObservers("" + spaces + message);
-                BABYLON.Tools.Log("" + spaces + message);
-            }
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logOpen = function (message) {
-            this._log(message);
-            this._logIndentLevel++;
-        };
-        /** @hidden */
-        GLTFFileLoader.prototype._logClose = function () {
-            --this._logIndentLevel;
-        };
         Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
             /**
              * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
@@ -1292,6 +1278,52 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
+            /**
+             * Defines if the loader logging is enabled.
+             */
+            get: function () {
+                return this._loggingEnabled;
+            },
+            set: function (value) {
+                if (this._loggingEnabled === value) {
+                    return;
+                }
+                this._loggingEnabled = value;
+                if (this._loggingEnabled) {
+                    this._log = this._logEnabled;
+                }
+                else {
+                    this._log = this._logDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
+            /**
+             * Defines if the loader should capture performance counters.
+             */
+            get: function () {
+                return this._capturePerformanceCounters;
+            },
+            set: function (value) {
+                if (this._capturePerformanceCounters === value) {
+                    return;
+                }
+                this._capturePerformanceCounters = value;
+                if (this._capturePerformanceCounters) {
+                    this._startPerformanceCounter = this._startPerformanceCounterEnabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterEnabled;
+                }
+                else {
+                    this._startPerformanceCounter = this._startPerformanceCounterDisabled;
+                    this._endPerformanceCounter = this._endPerformanceCounterDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         /**
          * Disposes the loader, releases resources during load, and cancels any outstanding requests.
          */
@@ -1387,18 +1419,15 @@ var BABYLON;
             return new GLTFFileLoader();
         };
         GLTFFileLoader.prototype._parse = function (data) {
+            this._startPerformanceCounter("Parse");
             var parsedData;
             if (data instanceof ArrayBuffer) {
-                if (this.loggingEnabled) {
-                    this._log("Parsing binary");
-                }
+                this._log("Parsing binary");
                 parsedData = this._parseBinary(data);
             }
             else {
-                if (this.loggingEnabled) {
-                    this._log("Parsing JSON");
-                    this._log("JSON length: " + data.length);
-                }
+                this._log("Parsing JSON");
+                this._log("JSON length: " + data.length);
                 parsedData = {
                     json: JSON.parse(data),
                     bin: null
@@ -1406,19 +1435,14 @@ var BABYLON;
             }
             this.onParsedObservable.notifyObservers(parsedData);
             this.onParsedObservable.clear();
+            this._endPerformanceCounter("Parse");
             return parsedData;
         };
         GLTFFileLoader.prototype._getLoader = function (loaderData) {
             var asset = loaderData.json.asset || {};
-            if (this.loggingEnabled) {
-                this._log("Asset version: " + asset.version);
-                if (asset.minVersion) {
-                    this._log("Asset minimum version: " + asset.minVersion);
-                }
-                if (asset.generator) {
-                    this._log("Asset generator: " + asset.generator);
-                }
-            }
+            this._log("Asset version: " + asset.version);
+            asset.minVersion && this._log("Asset minimum version: " + asset.minVersion);
+            asset.generator && this._log("Asset generator: " + asset.generator);
             var version = GLTFFileLoader._parseVersion(asset.version);
             if (!version) {
                 throw new Error("Invalid version: " + asset.version);
@@ -1446,9 +1470,7 @@ var BABYLON;
             var Binary = {
                 Magic: 0x46546C67
             };
-            if (this.loggingEnabled) {
-                this._log("Binary length: " + data.byteLength);
-            }
+            this._log("Binary length: " + data.byteLength);
             var binaryReader = new BinaryReader(data);
             var magic = binaryReader.readUint32();
             if (magic !== Binary.Magic) {
@@ -1567,6 +1589,31 @@ var BABYLON;
             }
             return result;
         };
+        /** @hidden */
+        GLTFFileLoader.prototype._logOpen = function (message) {
+            this._log(message);
+            this._logIndentLevel++;
+        };
+        /** @hidden */
+        GLTFFileLoader.prototype._logClose = function () {
+            --this._logIndentLevel;
+        };
+        GLTFFileLoader.prototype._logEnabled = function (message) {
+            var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
+            BABYLON.Tools.Log("" + spaces + message);
+        };
+        GLTFFileLoader.prototype._logDisabled = function (message) {
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.StartPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) {
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
+            BABYLON.Tools.EndPerformanceCounter(counterName);
+        };
+        GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) {
+        };
         // #endregion
         // #region V1 options
         /**
@@ -3832,7 +3879,6 @@ var BABYLON;
         var GLTFLoader = /** @class */ (function () {
             function GLTFLoader(parent) {
                 this._completePromises = new Array();
-                this._onReadyObservable = new BABYLON.Observable();
                 this._disposed = false;
                 this._state = null;
                 this._extensions = {};
@@ -3872,8 +3918,8 @@ var BABYLON;
                 this._requests.length = 0;
                 delete this._gltf;
                 delete this._babylonScene;
+                delete this._readyPromise;
                 this._completePromises.length = 0;
-                this._onReadyObservable.clear();
                 for (var name_1 in this._extensions) {
                     this._extensions[name_1].dispose();
                 }
@@ -3896,14 +3942,14 @@ var BABYLON;
                             for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) {
                                 var node = _a[_i];
                                 if (node.name) {
-                                    nodeMap_1[node.name] = node;
+                                    nodeMap_1[node.name] = node._index;
                                 }
                             }
                         }
                         var names = (meshesNames instanceof Array) ? meshesNames : [meshesNames];
                         nodes = names.map(function (name) {
                             var node = nodeMap_1[name];
-                            if (!node) {
+                            if (node === undefined) {
                                 throw new Error("Failed to find node '" + name + "'");
                             }
                             return node;
@@ -3932,13 +3978,17 @@ var BABYLON;
             GLTFLoader.prototype._loadAsync = function (nodes) {
                 var _this = this;
                 return Promise.resolve().then(function () {
+                    _this._parent._startPerformanceCounter("Loading => Ready");
+                    _this._parent._startPerformanceCounter("Loading => Complete");
                     _this._state = BABYLON.GLTFLoaderState.LOADING;
                     _this._parent._log("Loading");
+                    var readyDeferred = new BABYLON.Deferred();
+                    _this._readyPromise = readyDeferred.promise;
                     _this._loadExtensions();
                     _this._checkExtensions();
                     var promises = new Array();
                     if (nodes) {
-                        promises.push(_this._loadNodesAsync(nodes));
+                        promises.push(_this._loadSceneAsync("#/nodes", { nodes: nodes, _index: -1 }));
                     }
                     else {
                         var scene = GLTFLoader._GetProperty("#/scene", _this._gltf.scenes, _this._gltf.scene || 0);
@@ -3953,16 +4003,18 @@ var BABYLON;
                     var resultPromise = Promise.all(promises).then(function () {
                         _this._state = BABYLON.GLTFLoaderState.READY;
                         _this._parent._log("Ready");
-                        _this._onReadyObservable.notifyObservers(_this);
+                        readyDeferred.resolve();
                         _this._startAnimations();
                     });
                     resultPromise.then(function () {
+                        _this._parent._endPerformanceCounter("Loading => Ready");
                         if (_this._rootBabylonMesh) {
                             _this._rootBabylonMesh.setEnabled(true);
                         }
                         BABYLON.Tools.SetImmediate(function () {
                             if (!_this._disposed) {
                                 Promise.all(_this._completePromises).then(function () {
+                                    _this._parent._endPerformanceCounter("Loading => Complete");
                                     _this._state = BABYLON.GLTFLoaderState.COMPLETE;
                                     _this._parent._log("Complete");
                                     _this._parent.onCompleteObservable.notifyObservers(undefined);
@@ -4078,15 +4130,6 @@ var BABYLON;
                 this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh);
                 return rootNode;
             };
-            GLTFLoader.prototype._loadNodesAsync = function (nodes) {
-                var promises = new Array();
-                for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
-                    var node = nodes_1[_i];
-                    promises.push(this._loadNodeAsync("#/nodes/" + node._index, node));
-                }
-                promises.push(this._loadAnimationsAsync());
-                return Promise.all(promises).then(function () { });
-            };
             GLTFLoader.prototype._loadSceneAsync = function (context, scene) {
                 var promise = GLTF2.GLTFLoaderExtension._LoadSceneAsync(this, context, scene);
                 if (promise) {
@@ -4122,8 +4165,8 @@ var BABYLON;
                 meshes.push(this._rootBabylonMesh);
                 var nodes = this._gltf.nodes;
                 if (nodes) {
-                    for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
-                        var node = nodes_2[_i];
+                    for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
+                        var node = nodes_1[_i];
                         if (node._babylonMesh) {
                             meshes.push(node._babylonMesh);
                         }
@@ -5241,6 +5284,8 @@ var BABYLON;
                 throw new Error(context + ": Invalid mesh primitive mode (" + mode + ")");
             };
             GLTFLoader.prototype._compileMaterialsAsync = function () {
+                var _this = this;
+                this._parent._startPerformanceCounter("Compile materials");
                 var promises = new Array();
                 if (this._gltf.materials) {
                     for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) {
@@ -5262,9 +5307,13 @@ var BABYLON;
                         }
                     }
                 }
-                return Promise.all(promises).then(function () { });
+                return Promise.all(promises).then(function () {
+                    _this._parent._endPerformanceCounter("Compile materials");
+                });
             };
             GLTFLoader.prototype._compileShadowGeneratorsAsync = function () {
+                var _this = this;
+                this._parent._startPerformanceCounter("Compile shadow generators");
                 var promises = new Array();
                 var lights = this._babylonScene.lights;
                 for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
@@ -5274,7 +5323,9 @@ var BABYLON;
                         promises.push(generator.forceCompilationAsync());
                     }
                 }
-                return Promise.all(promises).then(function () { });
+                return Promise.all(promises).then(function () {
+                    _this._parent._endPerformanceCounter("Compile shadow generators");
+                });
             };
             GLTFLoader.prototype._applyExtensions = function (actionAsync) {
                 for (var _i = 0, _a = GLTFLoader._ExtensionNames; _i < _a.length; _i++) {
@@ -5487,29 +5538,45 @@ var BABYLON;
                      * Dispose the loader to cancel the loading of the next level of LODs.
                      */
                     _this.onMaterialLODsLoadedObservable = new BABYLON.Observable();
-                    _this._loadingNodeLOD = null;
-                    _this._loadNodeSignals = {};
-                    _this._loadNodePromises = new Array();
-                    _this._loadingMaterialLOD = null;
-                    _this._loadMaterialSignals = {};
-                    _this._loadMaterialPromises = new Array();
-                    _this._loader._onReadyObservable.addOnce(function () {
+                    _this._nodeIndexLOD = null;
+                    _this._nodeSignalLODs = new Array();
+                    _this._nodePromiseLODs = new Array();
+                    _this._materialIndexLOD = null;
+                    _this._materialSignalLODs = new Array();
+                    _this._materialPromiseLODs = new Array();
+                    _this._loader._readyPromise.then(function () {
                         var _loop_1 = function (indexLOD) {
-                            Promise.all(_this._loadNodePromises[indexLOD]).then(function () {
+                            var promise = Promise.all(_this._nodePromiseLODs[indexLOD]).then(function () {
+                                if (indexLOD !== 0) {
+                                    _this._loader._parent._endPerformanceCounter("Node LOD " + indexLOD);
+                                }
                                 _this._loader._parent._log("Loaded node LOD " + indexLOD);
                                 _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
+                                if (indexLOD !== _this._nodePromiseLODs.length - 1) {
+                                    _this._loader._parent._startPerformanceCounter("Node LOD " + (indexLOD + 1));
+                                    _this._nodeSignalLODs[indexLOD].resolve();
+                                }
                             });
+                            _this._loader._completePromises.push(promise);
                         };
-                        for (var indexLOD = 0; indexLOD < _this._loadNodePromises.length; indexLOD++) {
+                        for (var indexLOD = 0; indexLOD < _this._nodePromiseLODs.length; indexLOD++) {
                             _loop_1(indexLOD);
                         }
                         var _loop_2 = function (indexLOD) {
-                            Promise.all(_this._loadMaterialPromises[indexLOD]).then(function () {
+                            var promise = Promise.all(_this._materialPromiseLODs[indexLOD]).then(function () {
+                                if (indexLOD !== 0) {
+                                    _this._loader._parent._endPerformanceCounter("Material LOD " + indexLOD);
+                                }
                                 _this._loader._parent._log("Loaded material LOD " + indexLOD);
                                 _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
+                                if (indexLOD !== _this._materialPromiseLODs.length - 1) {
+                                    _this._loader._parent._startPerformanceCounter("Material LOD " + (indexLOD + 1));
+                                    _this._materialSignalLODs[indexLOD].resolve();
+                                }
                             });
+                            _this._loader._completePromises.push(promise);
                         };
-                        for (var indexLOD = 0; indexLOD < _this._loadMaterialPromises.length; indexLOD++) {
+                        for (var indexLOD = 0; indexLOD < _this._materialPromiseLODs.length; indexLOD++) {
                             _loop_2(indexLOD);
                         }
                     });
@@ -5517,10 +5584,12 @@ var BABYLON;
                 }
                 MSFT_lod.prototype.dispose = function () {
                     _super.prototype.dispose.call(this);
-                    this._loadingNodeLOD = null;
-                    this._loadNodeSignals = {};
-                    this._loadingMaterialLOD = null;
-                    this._loadMaterialSignals = {};
+                    this._nodeIndexLOD = null;
+                    this._nodeSignalLODs.length = 0;
+                    this._nodePromiseLODs.length = 0;
+                    this._materialIndexLOD = null;
+                    this._materialSignalLODs.length = 0;
+                    this._materialPromiseLODs.length = 0;
                     this.onMaterialLODsLoadedObservable.clear();
                     this.onNodeLODsLoadedObservable.clear();
                 };
@@ -5533,10 +5602,8 @@ var BABYLON;
                         var _loop_3 = function (indexLOD) {
                             var nodeLOD = nodeLODs[indexLOD];
                             if (indexLOD !== 0) {
-                                _this._loadingNodeLOD = nodeLOD;
-                                if (!_this._loadNodeSignals[nodeLOD._index]) {
-                                    _this._loadNodeSignals[nodeLOD._index] = new BABYLON.Deferred();
-                                }
+                                _this._nodeIndexLOD = indexLOD;
+                                _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new BABYLON.Deferred();
                             }
                             var promise = _this._loader._loadNodeAsync("#/nodes/" + nodeLOD._index, nodeLOD).then(function () {
                                 if (indexLOD !== 0) {
@@ -5546,23 +5613,15 @@ var BABYLON;
                                         delete previousNodeLOD._babylonMesh;
                                     }
                                 }
-                                if (indexLOD !== nodeLODs.length - 1) {
-                                    var nodeIndex = nodeLODs[indexLOD + 1]._index;
-                                    if (_this._loadNodeSignals[nodeIndex]) {
-                                        _this._loadNodeSignals[nodeIndex].resolve();
-                                        delete _this._loadNodeSignals[nodeIndex];
-                                    }
-                                }
                             });
                             if (indexLOD === 0) {
                                 firstPromise = promise;
                             }
                             else {
-                                _this._loader._completePromises.push(promise);
-                                _this._loadingNodeLOD = null;
+                                _this._nodeIndexLOD = null;
                             }
-                            _this._loadNodePromises[indexLOD] = _this._loadNodePromises[indexLOD] || [];
-                            _this._loadNodePromises[indexLOD].push(promise);
+                            _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || [];
+                            _this._nodePromiseLODs[indexLOD].push(promise);
                         };
                         for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
                             _loop_3(indexLOD);
@@ -5574,7 +5633,7 @@ var BABYLON;
                 MSFT_lod.prototype._loadMaterialAsync = function (context, material, mesh, babylonMesh, babylonDrawMode, assign) {
                     var _this = this;
                     // Don't load material LODs if already loading a node LOD.
-                    if (this._loadingNodeLOD) {
+                    if (this._nodeIndexLOD) {
                         return null;
                     }
                     return this._loadExtensionAsync(context, material, function (extensionContext, extension) {
@@ -5584,10 +5643,7 @@ var BABYLON;
                         var _loop_4 = function (indexLOD) {
                             var materialLOD = materialLODs[indexLOD];
                             if (indexLOD !== 0) {
-                                _this._loadingMaterialLOD = materialLOD;
-                                if (!_this._loadMaterialSignals[materialLOD._index]) {
-                                    _this._loadMaterialSignals[materialLOD._index] = new BABYLON.Deferred();
-                                }
+                                _this._materialIndexLOD = indexLOD;
                             }
                             var promise = _this._loader._loadMaterialAsync("#/materials/" + materialLOD._index, materialLOD, mesh, babylonMesh, babylonDrawMode, indexLOD === 0 ? assign : function () { }).then(function () {
                                 if (indexLOD !== 0) {
@@ -5599,23 +5655,15 @@ var BABYLON;
                                         delete previousBabylonDataLOD[babylonDrawMode];
                                     }
                                 }
-                                if (indexLOD !== materialLODs.length - 1) {
-                                    var materialIndex = materialLODs[indexLOD + 1]._index;
-                                    if (_this._loadMaterialSignals[materialIndex]) {
-                                        _this._loadMaterialSignals[materialIndex].resolve();
-                                        delete _this._loadMaterialSignals[materialIndex];
-                                    }
-                                }
                             });
                             if (indexLOD === 0) {
                                 firstPromise = promise;
                             }
                             else {
-                                _this._loader._completePromises.push(promise);
-                                _this._loadingMaterialLOD = null;
+                                _this._materialIndexLOD = null;
                             }
-                            _this._loadMaterialPromises[indexLOD] = _this._loadMaterialPromises[indexLOD] || [];
-                            _this._loadMaterialPromises[indexLOD].push(promise);
+                            _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || [];
+                            _this._materialPromiseLODs[indexLOD].push(promise);
                         };
                         for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {
                             _loop_4(indexLOD);
@@ -5626,21 +5674,20 @@ var BABYLON;
                 };
                 MSFT_lod.prototype._loadUriAsync = function (context, uri) {
                     var _this = this;
-                    if (this._loadingMaterialLOD || this._loadingNodeLOD) {
-                        if (this._loader._parent.loggingEnabled) {
-                            this._loader._parent._log("deferred");
-                        }
-                    }
                     // Defer the loading of uris if loading a material or node LOD.
-                    if (this._loadingMaterialLOD) {
-                        var index = this._loadingMaterialLOD._index;
-                        return this._loadMaterialSignals[index].promise.then(function () {
+                    if (this._materialIndexLOD !== null) {
+                        this._loader._parent._log("deferred");
+                        var previousIndexLOD = this._materialIndexLOD - 1;
+                        this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new BABYLON.Deferred();
+                        return this._materialSignalLODs[previousIndexLOD].promise.then(function () {
                             return _this._loader._loadUriAsync(context, uri);
                         });
                     }
-                    else if (this._loadingNodeLOD) {
-                        var index = this._loadingNodeLOD._index;
-                        return this._loadNodeSignals[index].promise.then(function () {
+                    else if (this._nodeIndexLOD !== null) {
+                        this._loader._parent._log("deferred");
+                        var previousIndexLOD = this._nodeIndexLOD - 1;
+                        this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new BABYLON.Deferred();
+                        return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () {
                             return _this._loader._loadUriAsync(context, uri);
                         });
                     }

文件差异内容过多而无法显示
+ 4 - 4
dist/preview release/loaders/babylonjs.loaders.min.js


+ 35 - 24
dist/preview release/loaders/babylonjs.loaders.module.d.ts

@@ -246,22 +246,6 @@ declare module BABYLON {
         /** @hidden */
         _normalizeAnimationGroupsToBeginAtZero: boolean;
         /**
-         * Defines if the loader logging is enabled.
-         */
-        loggingEnabled: boolean;
-        /**
-         * Observable raised when the loader logs a message.
-         */
-        readonly onLogObservable: Observable<string>;
-        private _logIndentLevel;
-        private static readonly _logSpaces;
-        /** @hidden */
-        _log(message: string): void;
-        /** @hidden */
-        _logOpen(message: string): void;
-        /** @hidden */
-        _logClose(): void;
-        /**
          * Function called before loading a url referenced by the asset.
          */
         preprocessUrlAsync: (url: string) => Promise<string>;
@@ -340,6 +324,14 @@ declare module BABYLON {
          * The loader state or null if the loader is not active.
          */
         readonly loaderState: Nullable<GLTFLoaderState>;
+        /**
+         * Defines if the loader logging is enabled.
+         */
+        loggingEnabled: boolean;
+        /**
+         * Defines if the loader should capture performance counters.
+         */
+        capturePerformanceCounters: boolean;
         private _loader;
         /**
          * Name of the loader ("gltf")
@@ -411,6 +403,26 @@ declare module BABYLON {
         private static _parseVersion(version);
         private static _compareVersion(a, b);
         private static _decodeBufferToText(buffer);
+        private static readonly _logSpaces;
+        private _logIndentLevel;
+        private _loggingEnabled;
+        /** @hidden */
+        _log: (message: string) => void;
+        /** @hidden */
+        _logOpen(message: string): void;
+        /** @hidden */
+        _logClose(): void;
+        private _logEnabled(message);
+        private _logDisabled(message);
+        private _capturePerformanceCounters;
+        /** @hidden */
+        _startPerformanceCounter: (counterName: string) => void;
+        /** @hidden */
+        _endPerformanceCounter: (counterName: string) => void;
+        private _startPerformanceCounterEnabled(counterName);
+        private _startPerformanceCounterDisabled(counterName);
+        private _endPerformanceCounterEnabled(counterName);
+        private _endPerformanceCounterDisabled(counterName);
     }
 }
 
@@ -1098,8 +1110,8 @@ declare module BABYLON.GLTF2 {
         _parent: GLTFFileLoader;
         _gltf: _ILoaderGLTF;
         _babylonScene: Scene;
+        _readyPromise: Promise<void>;
         _completePromises: Promise<void>[];
-        _onReadyObservable: Observable<IGLTFLoader>;
         private _disposed;
         private _state;
         private _extensions;
@@ -1131,7 +1143,6 @@ declare module BABYLON.GLTF2 {
         private _loadExtensions();
         private _checkExtensions();
         private _createRootNode();
-        private _loadNodesAsync(nodes);
         _loadSceneAsync(context: string, scene: _ILoaderScene): Promise<void>;
         private _forEachPrimitive(node, callback);
         private _getMeshes();
@@ -1312,12 +1323,12 @@ declare module BABYLON.GLTF2.Extensions {
          * Dispose the loader to cancel the loading of the next level of LODs.
          */
         onMaterialLODsLoadedObservable: Observable<number>;
-        private _loadingNodeLOD;
-        private _loadNodeSignals;
-        private _loadNodePromises;
-        private _loadingMaterialLOD;
-        private _loadMaterialSignals;
-        private _loadMaterialPromises;
+        private _nodeIndexLOD;
+        private _nodeSignalLODs;
+        private _nodePromiseLODs;
+        private _materialIndexLOD;
+        private _materialSignalLODs;
+        private _materialPromiseLODs;
         constructor(loader: GLTFLoader);
         dispose(): void;
         protected _loadNodeAsync(context: string, node: _ILoaderNode): Nullable<Promise<void>>;

+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.d.ts

@@ -13,6 +13,7 @@ declare module BABYLON {
         static readonly GreenFireColors: Color3[];
         static readonly RedFireColors: Color3[];
         static readonly BlueFireColors: Color3[];
+        autoGenerateTime: boolean;
         fireColors: Color3[];
         time: number;
         speed: Vector2;

+ 21 - 2
dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.js

@@ -104,6 +104,16 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(FireProceduralTexture.prototype, "autoGenerateTime", {
+            get: function () {
+                return this._autoGenerateTime;
+            },
+            set: function (value) {
+                this._autoGenerateTime = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
             get: function () {
                 return this._fireColors;
@@ -155,6 +165,10 @@ var BABYLON;
         FireProceduralTexture.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
             serializationObject.customType = "BABYLON.FireProceduralTexture";
+            serializationObject.fireColors = [];
+            for (var i = 0; i < this._fireColors.length; i++) {
+                serializationObject.fireColors.push(this._fireColors[i].asArray());
+            }
             return serializationObject;
         };
         /**
@@ -166,11 +180,16 @@ var BABYLON;
          */
         FireProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = BABYLON.SerializationHelper.Parse(function () { return new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
+            var colors = [];
+            for (var i = 0; i < parsedTexture.fireColors.length; i++) {
+                colors.push(BABYLON.Color3.FromArray(parsedTexture.fireColors[i]));
+            }
+            texture.fireColors = colors;
             return texture;
         };
         __decorate([
-            BABYLON.serializeAsColor3()
-        ], FireProceduralTexture.prototype, "fireColors", null);
+            BABYLON.serialize()
+        ], FireProceduralTexture.prototype, "autoGenerateTime", null);
         __decorate([
             BABYLON.serialize()
         ], FireProceduralTexture.prototype, "time", null);

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js


+ 9 - 3
dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.js

@@ -65,6 +65,10 @@ var BABYLON;
         GrassProceduralTexture.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
             serializationObject.customType = "BABYLON.GrassProceduralTexture";
+            serializationObject.grassColors = [];
+            for (var i = 0; i < this._grassColors.length; i++) {
+                serializationObject.grassColors.push(this._grassColors[i].asArray());
+            }
             return serializationObject;
         };
         /**
@@ -76,13 +80,15 @@ var BABYLON;
          */
         GrassProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = BABYLON.SerializationHelper.Parse(function () { return new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
+            var colors = [];
+            for (var i = 0; i < parsedTexture.grassColors.length; i++) {
+                colors.push(BABYLON.Color3.FromArray(parsedTexture.grassColors[i]));
+            }
+            texture.grassColors = colors;
             return texture;
         };
         __decorate([
             BABYLON.serializeAsColor3()
-        ], GrassProceduralTexture.prototype, "grassColors", null);
-        __decorate([
-            BABYLON.serializeAsColor3()
         ], GrassProceduralTexture.prototype, "groundColor", null);
         return GrassProceduralTexture;
     }(BABYLON.ProceduralTexture));

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js


+ 1 - 1
dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.d.ts

@@ -2,7 +2,7 @@
 declare module BABYLON {
     class PerlinNoiseProceduralTexture extends ProceduralTexture {
         time: number;
-        speed: number;
+        timeScale: number;
         translationSpeed: number;
         private _currentTranslation;
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);

+ 3 - 3
dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.js

@@ -22,7 +22,7 @@ var BABYLON;
         function PerlinNoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
             var _this = _super.call(this, name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
             _this.time = 0.0;
-            _this.speed = 1.0;
+            _this.timeScale = 1.0;
             _this.translationSpeed = 1.0;
             _this._currentTranslation = 0;
             _this.updateShaderUniforms();
@@ -36,7 +36,7 @@ var BABYLON;
             }
             var deltaTime = scene.getEngine().getDeltaTime();
             this.time += deltaTime;
-            this.setFloat("time", this.time * this.speed / 1000);
+            this.setFloat("time", this.time * this.timeScale / 1000);
             this._currentTranslation += deltaTime * this.translationSpeed / 1000.0;
             this.setFloat("translationSpeed", this._currentTranslation);
         };
@@ -72,7 +72,7 @@ var BABYLON;
         ], PerlinNoiseProceduralTexture.prototype, "time", void 0);
         __decorate([
             BABYLON.serialize()
-        ], PerlinNoiseProceduralTexture.prototype, "speed", void 0);
+        ], PerlinNoiseProceduralTexture.prototype, "timeScale", void 0);
         __decorate([
             BABYLON.serialize()
         ], PerlinNoiseProceduralTexture.prototype, "translationSpeed", void 0);

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.min.js


+ 2 - 1
dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.d.ts

@@ -38,6 +38,7 @@ declare module BABYLON {
         static readonly GreenFireColors: Color3[];
         static readonly RedFireColors: Color3[];
         static readonly BlueFireColors: Color3[];
+        autoGenerateTime: boolean;
         fireColors: Color3[];
         time: number;
         speed: Vector2;
@@ -261,7 +262,7 @@ declare module BABYLON {
 declare module BABYLON {
     class PerlinNoiseProceduralTexture extends ProceduralTexture {
         time: number;
-        speed: number;
+        timeScale: number;
         translationSpeed: number;
         private _currentTranslation;
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);

+ 33 - 8
dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.js

@@ -190,6 +190,16 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(FireProceduralTexture.prototype, "autoGenerateTime", {
+            get: function () {
+                return this._autoGenerateTime;
+            },
+            set: function (value) {
+                this._autoGenerateTime = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
             get: function () {
                 return this._fireColors;
@@ -241,6 +251,10 @@ var BABYLON;
         FireProceduralTexture.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
             serializationObject.customType = "BABYLON.FireProceduralTexture";
+            serializationObject.fireColors = [];
+            for (var i = 0; i < this._fireColors.length; i++) {
+                serializationObject.fireColors.push(this._fireColors[i].asArray());
+            }
             return serializationObject;
         };
         /**
@@ -252,11 +266,16 @@ var BABYLON;
          */
         FireProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = BABYLON.SerializationHelper.Parse(function () { return new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
+            var colors = [];
+            for (var i = 0; i < parsedTexture.fireColors.length; i++) {
+                colors.push(BABYLON.Color3.FromArray(parsedTexture.fireColors[i]));
+            }
+            texture.fireColors = colors;
             return texture;
         };
         __decorate([
-            BABYLON.serializeAsColor3()
-        ], FireProceduralTexture.prototype, "fireColors", null);
+            BABYLON.serialize()
+        ], FireProceduralTexture.prototype, "autoGenerateTime", null);
         __decorate([
             BABYLON.serialize()
         ], FireProceduralTexture.prototype, "time", null);
@@ -403,6 +422,10 @@ var BABYLON;
         GrassProceduralTexture.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
             serializationObject.customType = "BABYLON.GrassProceduralTexture";
+            serializationObject.grassColors = [];
+            for (var i = 0; i < this._grassColors.length; i++) {
+                serializationObject.grassColors.push(this._grassColors[i].asArray());
+            }
             return serializationObject;
         };
         /**
@@ -414,13 +437,15 @@ var BABYLON;
          */
         GrassProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
             var texture = BABYLON.SerializationHelper.Parse(function () { return new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
+            var colors = [];
+            for (var i = 0; i < parsedTexture.grassColors.length; i++) {
+                colors.push(BABYLON.Color3.FromArray(parsedTexture.grassColors[i]));
+            }
+            texture.grassColors = colors;
             return texture;
         };
         __decorate([
             BABYLON.serializeAsColor3()
-        ], GrassProceduralTexture.prototype, "grassColors", null);
-        __decorate([
-            BABYLON.serializeAsColor3()
         ], GrassProceduralTexture.prototype, "groundColor", null);
         return GrassProceduralTexture;
     }(BABYLON.ProceduralTexture));
@@ -1000,7 +1025,7 @@ var BABYLON;
         function PerlinNoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
             var _this = _super.call(this, name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
             _this.time = 0.0;
-            _this.speed = 1.0;
+            _this.timeScale = 1.0;
             _this.translationSpeed = 1.0;
             _this._currentTranslation = 0;
             _this.updateShaderUniforms();
@@ -1014,7 +1039,7 @@ var BABYLON;
             }
             var deltaTime = scene.getEngine().getDeltaTime();
             this.time += deltaTime;
-            this.setFloat("time", this.time * this.speed / 1000);
+            this.setFloat("time", this.time * this.timeScale / 1000);
             this._currentTranslation += deltaTime * this.translationSpeed / 1000.0;
             this.setFloat("translationSpeed", this._currentTranslation);
         };
@@ -1050,7 +1075,7 @@ var BABYLON;
         ], PerlinNoiseProceduralTexture.prototype, "time", void 0);
         __decorate([
             BABYLON.serialize()
-        ], PerlinNoiseProceduralTexture.prototype, "speed", void 0);
+        ], PerlinNoiseProceduralTexture.prototype, "timeScale", void 0);
         __decorate([
             BABYLON.serialize()
         ], PerlinNoiseProceduralTexture.prototype, "translationSpeed", void 0);

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.min.js


+ 2 - 1
dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.module.d.ts

@@ -43,6 +43,7 @@ declare module BABYLON {
         static readonly GreenFireColors: Color3[];
         static readonly RedFireColors: Color3[];
         static readonly BlueFireColors: Color3[];
+        autoGenerateTime: boolean;
         fireColors: Color3[];
         time: number;
         speed: Vector2;
@@ -266,7 +267,7 @@ declare module BABYLON {
 declare module BABYLON {
     class PerlinNoiseProceduralTexture extends ProceduralTexture {
         time: number;
-        speed: number;
+        timeScale: number;
         translationSpeed: number;
         private _currentTranslation;
         constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);

文件差异内容过多而无法显示
+ 30 - 30
dist/preview release/viewer/babylon.viewer.js


文件差异内容过多而无法显示
+ 69 - 13
dist/preview release/viewer/babylon.viewer.max.js