Browse Source

Merge pull request #5042 from sebavan/master

Nightly
sebavan 7 years ago
parent
commit
6a944fa5fa

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


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


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


+ 87 - 20
dist/preview release/babylon.max.js

@@ -11515,6 +11515,12 @@ var BABYLON;
                 }
             };
             this._unpackFlipYCached = null;
+            /**
+             * In case you are sharing the context with other applications, it might
+             * be interested to not cache the unpack flip y state to ensure a consistent
+             * value would be set.
+             */
+            this.enableUnpackFlipYCached = true;
             this._boundUniforms = {};
             // Register promises
             BABYLON.PromisePolyfill.Apply();
@@ -14283,7 +14289,6 @@ var BABYLON;
                 return;
             }
             this._currentEffect = null;
-            this._unpackFlipYCached = null;
             this._viewportCached.x = 0;
             this._viewportCached.y = 0;
             this._viewportCached.z = 0;
@@ -14295,6 +14300,7 @@ var BABYLON;
                 this._depthCullingState.reset();
                 this.setDepthFunctionToLessOrEqual();
                 this._alphaState.reset();
+                this._unpackFlipYCached = null;
             }
             this._resetVertexBufferBinding();
             this._cachedIndexBuffer = null;
@@ -14773,8 +14779,10 @@ var BABYLON;
         /** @hidden */
         Engine.prototype._unpackFlipY = function (value) {
             if (this._unpackFlipYCached !== value) {
-                this._unpackFlipYCached = value;
                 this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
+                if (this.enableUnpackFlipYCached) {
+                    this._unpackFlipYCached = value;
+                }
             }
         };
         /** @hidden */
@@ -23689,6 +23697,7 @@ var BABYLON;
         SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
         SceneComponentConstants.NAME_SPRITE = "Sprite";
         SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
+        SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
         SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
         SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
         SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
@@ -23701,6 +23710,7 @@ var BABYLON;
         SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
         SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
         SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
+        SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
         SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
         SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
         SceneComponentConstants.STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER = 2;
@@ -24327,11 +24337,6 @@ var BABYLON;
             */
             _this.proceduralTexturesEnabled = true;
             /**
-             * The list of procedural textures added to the scene
-             * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
-             */
-            _this.proceduralTextures = new Array();
-            /**
              * The list of sound tracks added to the scene
              * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
              */
@@ -24407,6 +24412,11 @@ var BABYLON;
             _this._beforeCameraUpdateStage = BABYLON.Stage.Create();
             /**
              * @hidden
+             * Defines the actions happening before clear the canvas.
+             */
+            _this._beforeClearStage = BABYLON.Stage.Create();
+            /**
+             * @hidden
              * Defines the actions happening before camera updates.
              */
             _this._gatherRenderTargetsStage = BABYLON.Stage.Create();
@@ -27847,16 +27857,9 @@ var BABYLON;
             }
             this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
             this.activeCamera = currentActiveCamera;
-            // Procedural textures
-            if (this.proceduralTexturesEnabled) {
-                BABYLON.Tools.StartPerformanceCounter("Procedural textures", this.proceduralTextures.length > 0);
-                for (var proceduralIndex = 0; proceduralIndex < this.proceduralTextures.length; proceduralIndex++) {
-                    var proceduralTexture = this.proceduralTextures[proceduralIndex];
-                    if (proceduralTexture._shouldRender()) {
-                        proceduralTexture.render();
-                    }
-                }
-                BABYLON.Tools.EndPerformanceCounter("Procedural textures", this.proceduralTextures.length > 0);
+            for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
+                var step = _c[_b];
+                step.action();
             }
             // Clear
             if (this.autoClearDepthAndStencil || this.autoClear) {
@@ -27876,8 +27879,8 @@ var BABYLON;
                 }
             }
             // Collects render targets from external components.
-            for (var _b = 0, _c = this._gatherRenderTargetsStage; _b < _c.length; _b++) {
-                var step = _c[_b];
+            for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
+                var step = _e[_d];
                 step.action(this._renderTargets);
             }
             // Multi-cameras?
@@ -28086,6 +28089,7 @@ var BABYLON;
             this._afterRenderingGroupDrawStage.clear();
             this._afterCameraDrawStage.clear();
             this._beforeCameraUpdateStage.clear();
+            this._beforeClearStage.clear();
             this._gatherRenderTargetsStage.clear();
             this._rebuildGeometryStage.clear();
             this._pointerMoveStage.clear();
@@ -57949,7 +57953,7 @@ var BABYLON;
                 }
                 serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
             }
-            if (particleSystem.noiseTexture && particleSystem.noiseTexture instanceof BABYLON.ProceduralTexture) {
+            if (BABYLON.ProceduralTexture && particleSystem.noiseTexture && particleSystem.noiseTexture instanceof BABYLON.ProceduralTexture) {
                 var noiseTexture = particleSystem.noiseTexture;
                 serializationObject.noiseTexture = noiseTexture.serialize();
             }
@@ -73923,6 +73927,11 @@ var BABYLON;
             _this._fallbackTextureUsed = false;
             _this._cachedDefines = "";
             scene = _this.getScene();
+            var component = scene._getComponent(BABYLON.SceneComponentConstants.NAME_PROCEDURALTEXTURE);
+            if (!component) {
+                component = new BABYLON.ProceduralTextureSceneComponent(scene);
+                scene._addComponent(component);
+            }
             scene.proceduralTextures.push(_this);
             _this._engine = scene.getEngine();
             _this.name = name;
@@ -74250,6 +74259,64 @@ var BABYLON;
 
 //# sourceMappingURL=babylon.proceduralTexture.js.map
 
+var BABYLON;
+(function (BABYLON) {
+    /**
+     * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
+     * in a given scene.
+     */
+    var ProceduralTextureSceneComponent = /** @class */ (function () {
+        /**
+         * Creates a new instance of the component for the given scene
+         * @param scene Defines the scene to register the component in
+         */
+        function ProceduralTextureSceneComponent(scene) {
+            /**
+             * The component name helpfull to identify the component in the list of scene components.
+             */
+            this.name = BABYLON.SceneComponentConstants.NAME_PROCEDURALTEXTURE;
+            this.scene = scene;
+            this.scene.proceduralTextures = new Array();
+            scene.layers = new Array();
+        }
+        /**
+         * Registers the component in a given scene
+         */
+        ProceduralTextureSceneComponent.prototype.register = function () {
+            this.scene._beforeClearStage.registerStep(BABYLON.SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
+        };
+        /**
+         * Rebuilds the elements related to this component in case of
+         * context lost for instance.
+         */
+        ProceduralTextureSceneComponent.prototype.rebuild = function () {
+            // Nothing to do here.
+        };
+        /**
+         * Disposes the component and the associated ressources.
+         */
+        ProceduralTextureSceneComponent.prototype.dispose = function () {
+            // Nothing to do here.
+        };
+        ProceduralTextureSceneComponent.prototype._beforeClear = function () {
+            if (this.scene.proceduralTexturesEnabled) {
+                BABYLON.Tools.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
+                for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
+                    var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
+                    if (proceduralTexture._shouldRender()) {
+                        proceduralTexture.render();
+                    }
+                }
+                BABYLON.Tools.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
+            }
+        };
+        return ProceduralTextureSceneComponent;
+    }());
+    BABYLON.ProceduralTextureSceneComponent = ProceduralTextureSceneComponent;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.proceduralTextureSceneComponent.js.map
+
 
 var BABYLON;
 (function (BABYLON) {

+ 87 - 20
dist/preview release/babylon.no-module.max.js

@@ -11482,6 +11482,12 @@ var BABYLON;
                 }
             };
             this._unpackFlipYCached = null;
+            /**
+             * In case you are sharing the context with other applications, it might
+             * be interested to not cache the unpack flip y state to ensure a consistent
+             * value would be set.
+             */
+            this.enableUnpackFlipYCached = true;
             this._boundUniforms = {};
             // Register promises
             BABYLON.PromisePolyfill.Apply();
@@ -14250,7 +14256,6 @@ var BABYLON;
                 return;
             }
             this._currentEffect = null;
-            this._unpackFlipYCached = null;
             this._viewportCached.x = 0;
             this._viewportCached.y = 0;
             this._viewportCached.z = 0;
@@ -14262,6 +14267,7 @@ var BABYLON;
                 this._depthCullingState.reset();
                 this.setDepthFunctionToLessOrEqual();
                 this._alphaState.reset();
+                this._unpackFlipYCached = null;
             }
             this._resetVertexBufferBinding();
             this._cachedIndexBuffer = null;
@@ -14740,8 +14746,10 @@ var BABYLON;
         /** @hidden */
         Engine.prototype._unpackFlipY = function (value) {
             if (this._unpackFlipYCached !== value) {
-                this._unpackFlipYCached = value;
                 this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
+                if (this.enableUnpackFlipYCached) {
+                    this._unpackFlipYCached = value;
+                }
             }
         };
         /** @hidden */
@@ -23656,6 +23664,7 @@ var BABYLON;
         SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
         SceneComponentConstants.NAME_SPRITE = "Sprite";
         SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
+        SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
         SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
         SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
         SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
@@ -23668,6 +23677,7 @@ var BABYLON;
         SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
         SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
         SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
+        SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
         SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
         SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
         SceneComponentConstants.STEP_AFTERCAMERADRAW_BOUNDINGBOXRENDERER = 2;
@@ -24294,11 +24304,6 @@ var BABYLON;
             */
             _this.proceduralTexturesEnabled = true;
             /**
-             * The list of procedural textures added to the scene
-             * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
-             */
-            _this.proceduralTextures = new Array();
-            /**
              * The list of sound tracks added to the scene
              * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
              */
@@ -24374,6 +24379,11 @@ var BABYLON;
             _this._beforeCameraUpdateStage = BABYLON.Stage.Create();
             /**
              * @hidden
+             * Defines the actions happening before clear the canvas.
+             */
+            _this._beforeClearStage = BABYLON.Stage.Create();
+            /**
+             * @hidden
              * Defines the actions happening before camera updates.
              */
             _this._gatherRenderTargetsStage = BABYLON.Stage.Create();
@@ -27814,16 +27824,9 @@ var BABYLON;
             }
             this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
             this.activeCamera = currentActiveCamera;
-            // Procedural textures
-            if (this.proceduralTexturesEnabled) {
-                BABYLON.Tools.StartPerformanceCounter("Procedural textures", this.proceduralTextures.length > 0);
-                for (var proceduralIndex = 0; proceduralIndex < this.proceduralTextures.length; proceduralIndex++) {
-                    var proceduralTexture = this.proceduralTextures[proceduralIndex];
-                    if (proceduralTexture._shouldRender()) {
-                        proceduralTexture.render();
-                    }
-                }
-                BABYLON.Tools.EndPerformanceCounter("Procedural textures", this.proceduralTextures.length > 0);
+            for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
+                var step = _c[_b];
+                step.action();
             }
             // Clear
             if (this.autoClearDepthAndStencil || this.autoClear) {
@@ -27843,8 +27846,8 @@ var BABYLON;
                 }
             }
             // Collects render targets from external components.
-            for (var _b = 0, _c = this._gatherRenderTargetsStage; _b < _c.length; _b++) {
-                var step = _c[_b];
+            for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
+                var step = _e[_d];
                 step.action(this._renderTargets);
             }
             // Multi-cameras?
@@ -28053,6 +28056,7 @@ var BABYLON;
             this._afterRenderingGroupDrawStage.clear();
             this._afterCameraDrawStage.clear();
             this._beforeCameraUpdateStage.clear();
+            this._beforeClearStage.clear();
             this._gatherRenderTargetsStage.clear();
             this._rebuildGeometryStage.clear();
             this._pointerMoveStage.clear();
@@ -57916,7 +57920,7 @@ var BABYLON;
                 }
                 serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
             }
-            if (particleSystem.noiseTexture && particleSystem.noiseTexture instanceof BABYLON.ProceduralTexture) {
+            if (BABYLON.ProceduralTexture && particleSystem.noiseTexture && particleSystem.noiseTexture instanceof BABYLON.ProceduralTexture) {
                 var noiseTexture = particleSystem.noiseTexture;
                 serializationObject.noiseTexture = noiseTexture.serialize();
             }
@@ -73890,6 +73894,11 @@ var BABYLON;
             _this._fallbackTextureUsed = false;
             _this._cachedDefines = "";
             scene = _this.getScene();
+            var component = scene._getComponent(BABYLON.SceneComponentConstants.NAME_PROCEDURALTEXTURE);
+            if (!component) {
+                component = new BABYLON.ProceduralTextureSceneComponent(scene);
+                scene._addComponent(component);
+            }
             scene.proceduralTextures.push(_this);
             _this._engine = scene.getEngine();
             _this.name = name;
@@ -74217,6 +74226,64 @@ var BABYLON;
 
 //# sourceMappingURL=babylon.proceduralTexture.js.map
 
+var BABYLON;
+(function (BABYLON) {
+    /**
+     * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
+     * in a given scene.
+     */
+    var ProceduralTextureSceneComponent = /** @class */ (function () {
+        /**
+         * Creates a new instance of the component for the given scene
+         * @param scene Defines the scene to register the component in
+         */
+        function ProceduralTextureSceneComponent(scene) {
+            /**
+             * The component name helpfull to identify the component in the list of scene components.
+             */
+            this.name = BABYLON.SceneComponentConstants.NAME_PROCEDURALTEXTURE;
+            this.scene = scene;
+            this.scene.proceduralTextures = new Array();
+            scene.layers = new Array();
+        }
+        /**
+         * Registers the component in a given scene
+         */
+        ProceduralTextureSceneComponent.prototype.register = function () {
+            this.scene._beforeClearStage.registerStep(BABYLON.SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
+        };
+        /**
+         * Rebuilds the elements related to this component in case of
+         * context lost for instance.
+         */
+        ProceduralTextureSceneComponent.prototype.rebuild = function () {
+            // Nothing to do here.
+        };
+        /**
+         * Disposes the component and the associated ressources.
+         */
+        ProceduralTextureSceneComponent.prototype.dispose = function () {
+            // Nothing to do here.
+        };
+        ProceduralTextureSceneComponent.prototype._beforeClear = function () {
+            if (this.scene.proceduralTexturesEnabled) {
+                BABYLON.Tools.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
+                for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
+                    var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
+                    if (proceduralTexture._shouldRender()) {
+                        proceduralTexture.render();
+                    }
+                }
+                BABYLON.Tools.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
+            }
+        };
+        return ProceduralTextureSceneComponent;
+    }());
+    BABYLON.ProceduralTextureSceneComponent = ProceduralTextureSceneComponent;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.proceduralTextureSceneComponent.js.map
+
 
 var BABYLON;
 (function (BABYLON) {

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


File diff suppressed because it is too large
+ 89 - 22
dist/preview release/es6.js


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


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js.map


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

@@ -1,7 +1,7 @@
 {
-  "errors": 3962,
+  "errors": 3950,
   "babylon.typedoc.json": {
-    "errors": 3962,
+    "errors": 3950,
     "AnimationGroup": {
       "Constructor": {
         "new AnimationGroup": {
@@ -4638,13 +4638,6 @@
             "MissingText": true
           }
         }
-      },
-      "Method": {
-        "render": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
       }
     },
     "ElasticEase": {
@@ -9629,75 +9622,6 @@
         }
       }
     },
-    "OutlineRenderer": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new OutlineRenderer": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "scene": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "zOffset": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "isReady": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "subMesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "useInstances": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "render": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "subMesh": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "batch": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "useOverlay": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "PBRBaseSimpleMaterial": {
       "Property": {
         "lightmapTexture": {

+ 7 - 0
dist/preview release/viewer/babylon.viewer.d.ts

@@ -919,6 +919,13 @@ declare module BabylonViewer {
     }
 }
 declare module BabylonViewer {
+    /**
+      *
+      * @param name the name of the custom optimizer configuration
+      * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
+      */
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 declare module BabylonViewer {
     /**

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


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


+ 8 - 1
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -985,7 +985,14 @@ declare module 'babylonjs-viewer/templating/viewerTemplatePlugin' {
 }
 
 declare module 'babylonjs-viewer/optimizer/custom' {
-    
+    import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
+    /**
+      *
+      * @param name the name of the custom optimizer configuration
+      * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
+      */
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 
 declare module 'babylonjs-viewer/initializer' {