Explorar o código

Merge remote-tracking branch 'BabylonJS/master'

MackeyK24 %!s(int64=8) %!d(string=hai) anos
pai
achega
a8eba31d48

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 788 - 781
dist/preview release/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 18 - 18
dist/preview release/babylon.js


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

@@ -24864,13 +24864,18 @@ var BABYLON;
         Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
             var _this = this;
             var subMesh = new BABYLON.BaseSubMesh();
-            var engine = this.getScene().getEngine();
+            var scene = this.getScene();
+            var engine = scene.getEngine();
             var checkReady = function () {
                 if (subMesh._materialDefines) {
                     subMesh._materialDefines._renderId = -1;
                 }
                 var alphaTestState = engine.getAlphaTesting();
+                var clipPlaneState = scene.clipPlane;
                 engine.setAlphaTesting(options ? options.alphaTest : _this.needAlphaTesting());
+                if (options.clipPlane) {
+                    scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
+                }
                 if (_this.isReadyForSubMesh(mesh, subMesh)) {
                     if (onCompiled) {
                         onCompiled(_this);
@@ -24880,6 +24885,9 @@ var BABYLON;
                     setTimeout(checkReady, 16);
                 }
                 engine.setAlphaTesting(alphaTestState);
+                if (options.clipPlane) {
+                    scene.clipPlane = clipPlaneState;
+                }
             };
             checkReady();
         };
@@ -48797,10 +48805,16 @@ var BABYLON;
         MultiMaterial.prototype.getClassName = function () {
             return "MultiMaterial";
         };
-        MultiMaterial.prototype.isReady = function (mesh) {
+        MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
             for (var index = 0; index < this.subMaterials.length; index++) {
                 var subMaterial = this.subMaterials[index];
                 if (subMaterial) {
+                    if (this.subMaterials[index].isReadyForSubMesh) {
+                        if (!this.subMaterials[index].isReadyForSubMesh(mesh, subMesh, useInstances)) {
+                            return false;
+                        }
+                        continue;
+                    }
                     if (!this.subMaterials[index].isReady(mesh)) {
                         return false;
                     }
@@ -52957,8 +52971,10 @@ var BABYLON;
          * @param {BABYLON.Scene} scene - The scene linked to this pipeline
          * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
+         * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
          */
-        function DefaultRenderingPipeline(name, hdr, scene, cameras) {
+        function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
+            if (automaticBuild === void 0) { automaticBuild = true; }
             var _this = _super.call(this, scene.getEngine(), name) || this;
             _this.PassPostProcessId = "PassPostProcessEffect";
             _this.HighLightsPostProcessId = "HighLightsPostProcessEffect";
@@ -52975,6 +52991,7 @@ var BABYLON;
             _this._fxaaEnabled = false;
             _this._imageProcessingEnabled = true;
             _this._bloomScale = 0.6;
+            _this._buildAllowed = true;
             /**
              * Specifies the size of the bloom blur kernel, relative to the final output size
              */
@@ -52984,6 +53001,7 @@ var BABYLON;
              */
             _this._bloomWeight = 0.15;
             _this._cameras = cameras || [];
+            _this._buildAllowed = automaticBuild;
             // Initialize
             _this._scene = scene;
             var caps = _this._scene.getEngine().getCaps();
@@ -53077,8 +53095,20 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        /**
+         * Force the compilation of the entire pipeline.
+         */
+        DefaultRenderingPipeline.prototype.prepare = function () {
+            var previousState = this._buildAllowed;
+            this._buildAllowed = true;
+            this._buildPipeline();
+            this._buildAllowed = previousState;
+        };
         DefaultRenderingPipeline.prototype._buildPipeline = function () {
             var _this = this;
+            if (!this._buildAllowed) {
+                return;
+            }
             var engine = this._scene.getEngine();
             this._disposePostProcesses();
             this._reset();
@@ -54039,9 +54069,8 @@ var BABYLON;
                 EXPOSURE: false,
             };
             // Setup the default processing configuration to the scene.
-            _this._attachImageProcessingConfiguration(null);
+            _this._attachImageProcessingConfiguration(null, true);
             _this.imageProcessingConfiguration.applyByPostProcess = true;
-            _this._updateParameters();
             _this.onApply = function (effect) {
                 _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
             };
@@ -54069,8 +54098,9 @@ var BABYLON;
          * Attaches a new image processing configuration to the PBR Material.
          * @param configuration
          */
-        ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration) {
+        ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
             var _this = this;
+            if (doNotBuild === void 0) { doNotBuild = false; }
             if (configuration === this._imageProcessingConfiguration) {
                 return;
             }
@@ -54092,7 +54122,9 @@ var BABYLON;
                 _this._updateParameters();
             });
             // Ensure the effect will be rebuilt.
-            this._updateParameters();
+            if (!doNotBuild) {
+                this._updateParameters();
+            }
         };
         Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
             /**

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 788 - 781
dist/preview release/babylon.module.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 18 - 18
dist/preview release/babylon.worker.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 4127 - 4120
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 16 - 16
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


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

@@ -24864,13 +24864,18 @@ var BABYLON;
         Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
             var _this = this;
             var subMesh = new BABYLON.BaseSubMesh();
-            var engine = this.getScene().getEngine();
+            var scene = this.getScene();
+            var engine = scene.getEngine();
             var checkReady = function () {
                 if (subMesh._materialDefines) {
                     subMesh._materialDefines._renderId = -1;
                 }
                 var alphaTestState = engine.getAlphaTesting();
+                var clipPlaneState = scene.clipPlane;
                 engine.setAlphaTesting(options ? options.alphaTest : _this.needAlphaTesting());
+                if (options.clipPlane) {
+                    scene.clipPlane = new BABYLON.Plane(0, 0, 0, 1);
+                }
                 if (_this.isReadyForSubMesh(mesh, subMesh)) {
                     if (onCompiled) {
                         onCompiled(_this);
@@ -24880,6 +24885,9 @@ var BABYLON;
                     setTimeout(checkReady, 16);
                 }
                 engine.setAlphaTesting(alphaTestState);
+                if (options.clipPlane) {
+                    scene.clipPlane = clipPlaneState;
+                }
             };
             checkReady();
         };
@@ -35825,10 +35833,16 @@ var BABYLON;
         MultiMaterial.prototype.getClassName = function () {
             return "MultiMaterial";
         };
-        MultiMaterial.prototype.isReady = function (mesh) {
+        MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
             for (var index = 0; index < this.subMaterials.length; index++) {
                 var subMaterial = this.subMaterials[index];
                 if (subMaterial) {
+                    if (this.subMaterials[index].isReadyForSubMesh) {
+                        if (!this.subMaterials[index].isReadyForSubMesh(mesh, subMesh, useInstances)) {
+                            return false;
+                        }
+                        continue;
+                    }
                     if (!this.subMaterials[index].isReady(mesh)) {
                         return false;
                     }
@@ -40208,9 +40222,8 @@ var BABYLON;
                 EXPOSURE: false,
             };
             // Setup the default processing configuration to the scene.
-            _this._attachImageProcessingConfiguration(null);
+            _this._attachImageProcessingConfiguration(null, true);
             _this.imageProcessingConfiguration.applyByPostProcess = true;
-            _this._updateParameters();
             _this.onApply = function (effect) {
                 _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
             };
@@ -40238,8 +40251,9 @@ var BABYLON;
          * Attaches a new image processing configuration to the PBR Material.
          * @param configuration
          */
-        ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration) {
+        ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
             var _this = this;
+            if (doNotBuild === void 0) { doNotBuild = false; }
             if (configuration === this._imageProcessingConfiguration) {
                 return;
             }
@@ -40261,7 +40275,9 @@ var BABYLON;
                 _this._updateParameters();
             });
             // Ensure the effect will be rebuilt.
-            this._updateParameters();
+            if (!doNotBuild) {
+                this._updateParameters();
+            }
         };
         Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
             /**
@@ -41729,8 +41745,10 @@ var BABYLON;
          * @param {BABYLON.Scene} scene - The scene linked to this pipeline
          * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
+         * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
          */
-        function DefaultRenderingPipeline(name, hdr, scene, cameras) {
+        function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
+            if (automaticBuild === void 0) { automaticBuild = true; }
             var _this = _super.call(this, scene.getEngine(), name) || this;
             _this.PassPostProcessId = "PassPostProcessEffect";
             _this.HighLightsPostProcessId = "HighLightsPostProcessEffect";
@@ -41747,6 +41765,7 @@ var BABYLON;
             _this._fxaaEnabled = false;
             _this._imageProcessingEnabled = true;
             _this._bloomScale = 0.6;
+            _this._buildAllowed = true;
             /**
              * Specifies the size of the bloom blur kernel, relative to the final output size
              */
@@ -41756,6 +41775,7 @@ var BABYLON;
              */
             _this._bloomWeight = 0.15;
             _this._cameras = cameras || [];
+            _this._buildAllowed = automaticBuild;
             // Initialize
             _this._scene = scene;
             var caps = _this._scene.getEngine().getCaps();
@@ -41849,8 +41869,20 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        /**
+         * Force the compilation of the entire pipeline.
+         */
+        DefaultRenderingPipeline.prototype.prepare = function () {
+            var previousState = this._buildAllowed;
+            this._buildAllowed = true;
+            this._buildPipeline();
+            this._buildAllowed = previousState;
+        };
         DefaultRenderingPipeline.prototype._buildPipeline = function () {
             var _this = this;
+            if (!this._buildAllowed) {
+                return;
+            }
             var engine = this._scene.getEngine();
             this._disposePostProcesses();
             this._reset();
@@ -52155,11 +52187,13 @@ var BABYLON;
                                         if (isNew && _this._parent.onMaterialLoaded) {
                                             _this._parent.onMaterialLoaded(babylonMaterial);
                                         }
-                                        _this.addPendingData(material);
-                                        babylonMaterial.forceCompilation(babylonMesh, function (babylonMaterial) {
-                                            babylonMultiMaterial.subMaterials[i] = babylonMaterial;
-                                            _this.removePendingData(material);
-                                        });
+                                        // Note: Removing force compilation from loader as this will be delegated to users as they
+                                        // may want to add more options to the material before compiling it
+                                        //this.addPendingData(material);
+                                        //babylonMaterial.forceCompilation(babylonMesh, babylonMaterial => {
+                                        babylonMultiMaterial.subMaterials[i] = babylonMaterial;
+                                        //    this.removePendingData(material);
+                                        //});
                                     });
                                 }
                             }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 4127 - 4120
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 7 - 5
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -642,11 +642,13 @@ var BABYLON;
                                         if (isNew && _this._parent.onMaterialLoaded) {
                                             _this._parent.onMaterialLoaded(babylonMaterial);
                                         }
-                                        _this.addPendingData(material);
-                                        babylonMaterial.forceCompilation(babylonMesh, function (babylonMaterial) {
-                                            babylonMultiMaterial.subMaterials[i] = babylonMaterial;
-                                            _this.removePendingData(material);
-                                        });
+                                        // Note: Removing force compilation from loader as this will be delegated to users as they
+                                        // may want to add more options to the material before compiling it
+                                        //this.addPendingData(material);
+                                        //babylonMaterial.forceCompilation(babylonMesh, babylonMaterial => {
+                                        babylonMultiMaterial.subMaterials[i] = babylonMaterial;
+                                        //    this.removePendingData(material);
+                                        //});
                                     });
                                 }
                             }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 7 - 5
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2800,11 +2800,13 @@ var BABYLON;
                                         if (isNew && _this._parent.onMaterialLoaded) {
                                             _this._parent.onMaterialLoaded(babylonMaterial);
                                         }
-                                        _this.addPendingData(material);
-                                        babylonMaterial.forceCompilation(babylonMesh, function (babylonMaterial) {
-                                            babylonMultiMaterial.subMaterials[i] = babylonMaterial;
-                                            _this.removePendingData(material);
-                                        });
+                                        // Note: Removing force compilation from loader as this will be delegated to users as they
+                                        // may want to add more options to the material before compiling it
+                                        //this.addPendingData(material);
+                                        //babylonMaterial.forceCompilation(babylonMesh, babylonMaterial => {
+                                        babylonMultiMaterial.subMaterials[i] = babylonMaterial;
+                                        //    this.removePendingData(material);
+                                        //});
                                     });
                                 }
                             }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 6 - 4
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -407,11 +407,13 @@ module BABYLON.GLTF2 {
                                         this._parent.onMaterialLoaded(babylonMaterial);
                                     }
 
-                                    this.addPendingData(material);
-                                    babylonMaterial.forceCompilation(babylonMesh, babylonMaterial => {
+                                    // Note: Removing force compilation from loader as this will be delegated to users as they
+                                    // may want to add more options to the material before compiling it
+                                    //this.addPendingData(material);
+                                    //babylonMaterial.forceCompilation(babylonMesh, babylonMaterial => {
                                         babylonMultiMaterial.subMaterials[i] = babylonMaterial;
-                                        this.removePendingData(material);
-                                    });
+                                    //    this.removePendingData(material);
+                                    //});
                                 });
                             }
                         }

+ 13 - 2
src/Materials/babylon.material.ts

@@ -517,9 +517,10 @@
         }
 
         // Force shader compilation including textures ready check
-        public forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { alphaTest: boolean }): void {
+        public forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { alphaTest: boolean, clipPlane: boolean }): void {
             var subMesh = new BaseSubMesh();
-            var engine = this.getScene().getEngine();
+            var scene = this.getScene();
+            var engine = scene.getEngine();
 
             var checkReady = () => {
                 if (subMesh._materialDefines) {
@@ -527,8 +528,14 @@
                 }
 
                 var alphaTestState = engine.getAlphaTesting();
+                var clipPlaneState = scene.clipPlane;
+
                 engine.setAlphaTesting(options ? options.alphaTest : this.needAlphaTesting());
 
+                if (options.clipPlane) {
+                    scene.clipPlane = new Plane(0, 0, 0, 1);
+                }
+
                 if (this.isReadyForSubMesh(mesh, subMesh)) {
                     if (onCompiled) {
                         onCompiled(this);
@@ -539,6 +546,10 @@
                 }
 
                 engine.setAlphaTesting(alphaTestState);
+
+                if (options.clipPlane) {
+                    scene.clipPlane = clipPlaneState;
+                }
             };
 
             checkReady();

+ 8 - 1
src/Materials/babylon.multiMaterial.ts

@@ -56,10 +56,17 @@
             return "MultiMaterial";
         }
 
-        public isReady(mesh?: AbstractMesh): boolean {
+        public isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean {
             for (var index = 0; index < this.subMaterials.length; index++) {
                 var subMaterial = this.subMaterials[index];
                 if (subMaterial) {
+                    if (this.subMaterials[index].isReadyForSubMesh) {
+                        if (!this.subMaterials[index].isReadyForSubMesh(mesh, subMesh, useInstances)) {
+                            return false;
+                        }
+                        continue;
+                    }
+
                     if (!this.subMaterials[index].isReady(mesh)) {
                         return false;
                     }

+ 20 - 1
src/PostProcess/RenderPipeline/Pipelines/babylon.defaultRenderingPipeline.ts

@@ -31,6 +31,8 @@
         private _defaultPipelineTextureType: number;
         private _bloomScale: number = 0.6;
 
+        private _buildAllowed = true;
+
         /**
 		 * Specifies the size of the bloom blur kernel, relative to the final output size
 		 */
@@ -124,11 +126,14 @@
          * @param {BABYLON.Scene} scene - The scene linked to this pipeline
          * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
          * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
+         * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
          */
-        constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[]) {
+        constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild = true) {
             super(scene.getEngine(), name);
             this._cameras = cameras || [];
 
+            this._buildAllowed = automaticBuild;
+
             // Initialize
             this._scene = scene;
             var caps = this._scene.getEngine().getCaps();
@@ -152,7 +157,21 @@
             this._buildPipeline();
         }
 
+        /**
+         * Force the compilation of the entire pipeline.
+         */
+        public prepare(): void {
+            let previousState = this._buildAllowed;
+            this._buildAllowed = true;
+            this._buildPipeline();
+            this._buildAllowed = previousState;
+        }
+
         private _buildPipeline() {
+            if (!this._buildAllowed) {
+                return;
+            }
+
             var engine = this._scene.getEngine();
 
             this._disposePostProcesses();

+ 5 - 5
src/PostProcess/babylon.imageProcessingPostProcess.ts

@@ -31,7 +31,7 @@
          * Attaches a new image processing configuration to the PBR Material.
          * @param configuration 
          */
-        protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void {
+        protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration, doNotBuild = false): void {
             if (configuration === this._imageProcessingConfiguration) {
                 return;
             }
@@ -57,7 +57,9 @@
             });
 
             // Ensure the effect will be rebuilt.
-            this._updateParameters();
+            if (!doNotBuild) {
+                this._updateParameters();
+            }
         }
 
         /**
@@ -301,12 +303,10 @@
                                             null, textureType, "postprocess", null, true);
 
             // Setup the default processing configuration to the scene.
-            this._attachImageProcessingConfiguration(null);
+            this._attachImageProcessingConfiguration(null, true);
 
             this.imageProcessingConfiguration.applyByPostProcess = true;
 
-            this._updateParameters();
-
             this.onApply = (effect: Effect) => {
                 this.imageProcessingConfiguration.bind(effect, this.aspectRatio);
             };

BIN=BIN
tests/validation/ReferenceImages/Espilit.png


+ 3 - 1
tests/validation/config.json

@@ -14,7 +14,8 @@
       "referenceImage": "WCafe.png"
     },
     {
-      "title": "Espilit",
+      "title": "Espilit",      
+      "renderCount": 10,
       "sceneFolder": "/Scenes/Espilit/",
       "sceneFilename": "Espilit.binary.babylon",
       "referenceImage": "Espilit.png"
@@ -174,6 +175,7 @@
     },
      {
       "title": "PBR glossy",
+      "renderCount": 10,
       "scriptToRun": "/Demos/PBRGlossy/index.js",
       "functionToCall": "CreatePBRGlossyScene",
       "referenceImage": "pbrglossy.png"