David Catuhe 7 anni fa
parent
commit
c83107c8c9

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


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


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


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


File diff suppressed because it is too large
+ 42 - 46
dist/preview release/babylon.no-module.max.js


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


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


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

@@ -2563,13 +2563,15 @@ declare module BABYLON.GUI {
         * @see http://doc.babylonjs.com/how_to/chart3d#mapgraph
         */
     export class MapGraph extends Chart {
+            /** Gets or sets the maximum height of a cylinder */
+            maxCylinderHeight: number;
             /** Gets or sets the offset (in world unit) on X axis to apply to all elements */
             xOffset: number;
             /** Gets or sets the offset (in world unit) on Y axis to apply to all elements */
             yOffset: number;
             /** Gets or sets the tesselation used to build the cylinders */
             cylinderTesselation: number;
-            /** Gets or sets the size of the world map (this will define the width) */
+            /** Gets or sets the size of the world map (this will define the width of the supporting plane) */
             worldMapSize: number;
             updateHoverLabel: (meshLabel: BABYLON.Mesh) => void;
             /**

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


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


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


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

@@ -2786,13 +2786,15 @@ declare module 'babylonjs-gui/3D/charting/mapGraph' {
         * @see http://doc.babylonjs.com/how_to/chart3d#mapgraph
         */
     export class MapGraph extends Chart {
+            /** Gets or sets the maximum height of a cylinder */
+            maxCylinderHeight: number;
             /** Gets or sets the offset (in world unit) on X axis to apply to all elements */
             xOffset: number;
             /** Gets or sets the offset (in world unit) on Y axis to apply to all elements */
             yOffset: number;
             /** Gets or sets the tesselation used to build the cylinders */
             cylinderTesselation: number;
-            /** Gets or sets the size of the world map (this will define the width) */
+            /** Gets or sets the size of the world map (this will define the width of the supporting plane) */
             worldMapSize: number;
             updateHoverLabel: (meshLabel: Mesh) => void;
             /**
@@ -5380,13 +5382,15 @@ declare module BABYLON.GUI {
         * @see http://doc.babylonjs.com/how_to/chart3d#mapgraph
         */
     export class MapGraph extends Chart {
+            /** Gets or sets the maximum height of a cylinder */
+            maxCylinderHeight: number;
             /** Gets or sets the offset (in world unit) on X axis to apply to all elements */
             xOffset: number;
             /** Gets or sets the offset (in world unit) on Y axis to apply to all elements */
             yOffset: number;
             /** Gets or sets the tesselation used to build the cylinders */
             cylinderTesselation: number;
-            /** Gets or sets the size of the world map (this will define the width) */
+            /** Gets or sets the size of the world map (this will define the width of the supporting plane) */
             worldMapSize: number;
             updateHoverLabel: (meshLabel: BABYLON.Mesh) => void;
             /**

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

@@ -1,7 +1,7 @@
 {
-  "errors": 4020,
+  "errors": 4018,
   "babylon.typedoc.json": {
-    "errors": 4020,
+    "errors": 4018,
     "AbstractMesh": {
       "Property": {
         "showBoundingBox": {
@@ -2037,18 +2037,6 @@
             }
           }
         },
-        "isInFrustum": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "frustumPlanes": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "update": {
           "Comments": {
             "MissingText": true

+ 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 suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 1 - 1
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 - 2
src/Culling/babylon.boundingInfo.ts

@@ -82,10 +82,20 @@
             return this;
         }
 
-        public isInFrustum(frustumPlanes: Plane[]): boolean {
-            if (!this.boundingSphere.isInFrustum(frustumPlanes))
+        /**
+         * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.  
+         * @param frustumPlanes defines the frustum to test
+         * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
+         * @returns true if the bounding info is in the frustum planes 
+         */        
+        public isInFrustum(frustumPlanes: Plane[], strategy: number = Scene.CULLINGSTRATEGY_STANDARD): boolean {
+            if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
                 return false;
+            }
 
+            if (strategy == Scene.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY) {
+                return true;
+            }
             return this.boundingBox.isInFrustum(frustumPlanes);
         }
 

+ 3 - 2
src/Mesh/babylon.abstractMesh.ts

@@ -1150,10 +1150,11 @@
          * Returns `true` if the mesh is within the frustum defined by the passed array of planes.  
          * A mesh is in the frustum if its bounding box intersects the frustum
          * @param frustumPlanes defines the frustum to test
+         * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
          * @returns true if the mesh is in the frustum planes 
          */
-        public isInFrustum(frustumPlanes: Plane[]): boolean {
-            return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes);
+        public isInFrustum(frustumPlanes: Plane[], strategy: number = Scene.CULLINGSTRATEGY_STANDARD): boolean {
+            return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, strategy);
         }
 
         /**

+ 7 - 3
src/Mesh/babylon.mesh.ts

@@ -1623,14 +1623,18 @@
         }
 
         /**
-         * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
+         * Returns `true` if the mesh is within the frustum defined by the passed array of planes.  
+         * A mesh is in the frustum if its bounding box intersects the frustum
+         * @param frustumPlanes defines the frustum to test
+         * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
+         * @returns true if the mesh is in the frustum planes 
          */
-        public isInFrustum(frustumPlanes: Plane[]): boolean {
+        public isInFrustum(frustumPlanes: Plane[], strategy: number = Scene.CULLINGSTRATEGY_STANDARD): boolean {
             if (this.delayLoadState === Engine.DELAYLOADSTATE_LOADING) {
                 return false;
             }
 
-            if (!super.isInFrustum(frustumPlanes)) {
+            if (!super.isInFrustum(frustumPlanes, strategy)) {
                 return false;
             }
 

+ 16 - 25
src/babylon.scene.ts

@@ -85,13 +85,17 @@
      */
     export class Scene extends AbstractScene implements IAnimatable {
         // Statics
-        private static _FOGMODE_NONE = 0;
-        private static _FOGMODE_EXP = 1;
-        private static _FOGMODE_EXP2 = 2;
-        private static _FOGMODE_LINEAR = 3;
-
         private static _uniqueIdCounter = 0;
 
+        /** The fog is deactivated */
+        public static readonly FOGMODE_NONE = 0;
+        /** The fog density is following an exponential function */
+        public static readonly FOGMODE_EXP = 1;
+        /** The fog density is following an exponential function faster than FOGMODE_EXP */
+        public static readonly FOGMODE_EXP2 = 2;
+        /** The fog density is following a linear function. */
+        public static readonly FOGMODE_LINEAR = 3;
+
         /**
          * Gets or sets the minimum deltatime when deterministic lock step is enabled
          * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
@@ -103,28 +107,15 @@
          */
         public static MaxDeltaTime = 1000.0;
 
-        /** The fog is deactivated */
-        public static get FOGMODE_NONE(): number {
-            return Scene._FOGMODE_NONE;
-        }
-
-        /** The fog density is following an exponential function */
-        public static get FOGMODE_EXP(): number {
-            return Scene._FOGMODE_EXP;
-        }
-
-        /** The fog density is following an exponential function faster than FOGMODE_EXP */
-        public static get FOGMODE_EXP2(): number {
-            return Scene._FOGMODE_EXP2;
-        }
-
-        /** The fog density is following a linear function. */
-        public static get FOGMODE_LINEAR(): number {
-            return Scene._FOGMODE_LINEAR;
-        }
+        /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
+        public static readonly CULLINGSTRATEGY_STANDARD = 0;
+        /** Culling strategy with bounding sphere only and then frustum culling */
+        public static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
 
         // Members
 
+        /** Gets ot sets the culling strategy to use to find visible meshes */
+        public cullingStrategy = Scene.CULLINGSTRATEGY_STANDARD;
         /**
          * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
          */
@@ -4229,7 +4220,7 @@
 
                 mesh._preActivate();
 
-                if (mesh.isVisible && mesh.visibility > 0 && (mesh.alwaysSelectAsActiveMesh || ((mesh.layerMask & this.activeCamera.layerMask) !== 0 && mesh.isInFrustum(this._frustumPlanes)))) {
+                if (mesh.isVisible && mesh.visibility > 0 && (mesh.alwaysSelectAsActiveMesh || ((mesh.layerMask & this.activeCamera.layerMask) !== 0 && mesh.isInFrustum(this._frustumPlanes, this.cullingStrategy)))) {
                     this._activeMeshes.push(mesh);
                     this.activeCamera._activeMeshes.push(mesh);