Jelajahi Sumber

Added new blockMaterialDirtyMechanism flag to scene

David Catuhe 7 tahun lalu
induk
melakukan
4ee742c26a

File diff ditekan karena terlalu besar
+ 2111 - 2109
Playground/babylon.d.txt


File diff ditekan karena terlalu besar
+ 4888 - 4884
dist/preview release/babylon.d.ts


File diff ditekan karena terlalu besar
+ 1 - 1
dist/preview release/babylon.js


File diff ditekan karena terlalu besar
+ 20 - 2
dist/preview release/babylon.max.js


File diff ditekan karena terlalu besar
+ 20 - 2
dist/preview release/babylon.no-module.max.js


File diff ditekan karena terlalu besar
+ 1 - 1
dist/preview release/babylon.worker.js


File diff ditekan karena terlalu besar
+ 20 - 2
dist/preview release/es6.js


+ 1 - 1
dist/preview release/gui/babylon.gui.d.ts

@@ -1287,7 +1287,7 @@ declare module BABYLON.GUI {
     /**
         * Class used to create 2D images
         */
-    class GUIImage extends Control {
+    export class Image extends Control {
             name?: string | undefined;
             /**
                 * Gets or sets the left coordinate in the source image

File diff ditekan karena terlalu besar
+ 1 - 1
dist/preview release/gui/babylon.gui.js


File diff ditekan karena terlalu besar
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


File diff ditekan karena terlalu besar
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js.map


+ 2 - 3
dist/preview release/gui/babylon.gui.module.d.ts

@@ -1406,7 +1406,7 @@ declare module 'babylonjs-gui/2D/controls/image' {
     /**
         * Class used to create 2D images
         */
-    class GUIImage extends Control {
+    export class Image extends Control {
             name?: string | undefined;
             /**
                 * Gets or sets the left coordinate in the source image
@@ -1473,7 +1473,6 @@ declare module 'babylonjs-gui/2D/controls/image' {
             /** STRETCH_EXTEND */
             static readonly STRETCH_EXTEND: number;
     }
-    export { GUIImage as Image };
 }
 
 declare module 'babylonjs-gui/2D/controls/inputText' {
@@ -4106,7 +4105,7 @@ declare module BABYLON.GUI {
     /**
         * Class used to create 2D images
         */
-    class GUIImage extends Control {
+    export class Image extends Control {
             name?: string | undefined;
             /**
                 * Gets or sets the left coordinate in the source image

+ 19 - 5
dist/preview release/viewer/babylon.viewer.d.ts

@@ -168,11 +168,11 @@ declare module BabylonViewer {
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
                 * Hide the overlay screen.
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
                 * show the viewer (in case it was hidden)
                 *
@@ -189,11 +189,11 @@ declare module BabylonViewer {
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
                 * Hide the loading screen
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
@@ -916,7 +916,7 @@ 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 getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 declare module BabylonViewer {
@@ -1542,6 +1542,20 @@ declare module BabylonViewer {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 declare module BabylonViewer {
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+declare module BabylonViewer {
 }
 declare module BabylonViewer {
     export interface IEnvironmentMapConfiguration {

File diff ditekan karena terlalu besar
+ 2 - 2
dist/preview release/viewer/babylon.viewer.js


File diff ditekan karena terlalu besar
+ 2 - 2
dist/preview release/viewer/babylon.viewer.max.js


+ 22 - 5
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -200,11 +200,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
                 * Hide the overlay screen.
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
                 * show the viewer (in case it was hidden)
                 *
@@ -221,11 +221,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
                 * Hide the loading screen
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
@@ -977,13 +977,14 @@ declare module 'babylonjs-viewer/templating/viewerTemplatePlugin' {
 }
 
 declare module 'babylonjs-viewer/optimizer/custom' {
+    import { extendedUpgrade } from "babylonjs-viewer/optimizer/custom/extended";
     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 getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 
@@ -1646,6 +1647,22 @@ declare module 'babylonjs-viewer/loader/plugins' {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 
+declare module 'babylonjs-viewer/optimizer/custom/extended' {
+    import { SceneManager } from 'babylonjs-viewer/managers/sceneManager';
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+
 declare module 'babylonjs-viewer/configuration/interfaces' {
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';

+ 12 - 30
gui/src/2D/controls/image.ts

@@ -5,12 +5,12 @@ import { Measure } from "../measure";
 /**
  * Class used to create 2D images
  */
-class GUIImage extends Control {
+export class Image extends Control {
     private _domImage: HTMLImageElement;
     private _imageWidth: number;
     private _imageHeight: number;
     private _loaded = false;
-    private _stretch = GUIImage.STRETCH_FILL;
+    private _stretch = Image.STRETCH_FILL;
     private _source: Nullable<string>;
     private _autoScale = false;
 
@@ -169,7 +169,7 @@ class GUIImage extends Control {
         this._loaded = false;
         this._source = value;
 
-        this._domImage = new Image();
+        this._domImage = document.createElement("img");
 
         this._domImage.onload = () => {
             this._onImageLoaded();
@@ -286,15 +286,15 @@ class GUIImage extends Control {
         if (this._processMeasures(parentMeasure, context)) {
             if (this._loaded) {
                 switch (this._stretch) {
-                    case GUIImage.STRETCH_NONE:
+                    case Image.STRETCH_NONE:
                         context.drawImage(this._domImage, x, y, width, height,
                             this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
                         break;
-                    case GUIImage.STRETCH_FILL:
+                    case Image.STRETCH_FILL:
                         context.drawImage(this._domImage, x, y, width, height,
                             this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
                         break;
-                    case GUIImage.STRETCH_UNIFORM:
+                    case Image.STRETCH_UNIFORM:
                         var hRatio = this._currentMeasure.width / width;
                         var vRatio = this._currentMeasure.height / height;
                         var ratio = Math.min(hRatio, vRatio);
@@ -304,7 +304,7 @@ class GUIImage extends Control {
                         context.drawImage(this._domImage, x, y, width, height,
                             this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
                         break;
-                    case GUIImage.STRETCH_EXTEND:
+                    case Image.STRETCH_EXTEND:
                         context.drawImage(this._domImage, x, y, width, height,
                             this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
                         if (this._autoScale) {
@@ -322,30 +322,12 @@ class GUIImage extends Control {
     }
 
     // Static
-    private static _STRETCH_NONE = 0;
-    private static _STRETCH_FILL = 1;
-    private static _STRETCH_UNIFORM = 2;
-    private static _STRETCH_EXTEND = 3;
-
     /** STRETCH_NONE */
-    public static get STRETCH_NONE(): number {
-        return GUIImage._STRETCH_NONE;
-    }
-
+    public static readonly STRETCH_NONE = 0;
     /** STRETCH_FILL */
-    public static get STRETCH_FILL(): number {
-        return GUIImage._STRETCH_FILL;
-    }
-
+    public static readonly STRETCH_FILL = 1;
     /** STRETCH_UNIFORM */
-    public static get STRETCH_UNIFORM(): number {
-        return GUIImage._STRETCH_UNIFORM;
-    }
-
+    public static readonly STRETCH_UNIFORM = 2;
     /** STRETCH_EXTEND */
-    public static get STRETCH_EXTEND(): number {
-        return GUIImage._STRETCH_EXTEND;
-    }
-}
-
-export { GUIImage as Image };
+    public static readonly STRETCH_EXTEND = 3;
+}

+ 7 - 0
src/babylon.scene.ts

@@ -5993,12 +5993,19 @@
             return this._renderingManager.getAutoClearDepthStencilSetup(index);
         }
 
+        /** Gets or sets a boolean blocking all the call to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
+        public blockMaterialDirtyMechanism = false;
+
         /**
          * Will flag all materials as dirty to trigger new shader compilation
          * @param flag defines the flag used to specify which material part must be marked as dirty
          * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
          */
         public markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void {
+            if (this.blockMaterialDirtyMechanism) {
+                return;
+            }
+
             for (var material of this.materials) {
                 if (predicate && !predicate(material)) {
                     continue;