David Catuhe 7 éve
szülő
commit
60a67190fe

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 4533 - 4486
Playground/babylon.d.txt


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1733 - 1540
dist/preview release/babylon.d.ts


+ 10 - 0
dist/preview release/gui/babylon.gui.d.ts

@@ -379,6 +379,8 @@ declare module BABYLON.GUI {
             control: BABYLON.Nullable<Control>;
             /** Gets or sets the mesh associated with this point */
             mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
+            /** Resets links */
+            resetLinks(): void;
             /**
                 * Gets a translation vector
                 * @returns the translation vector
@@ -1543,6 +1545,14 @@ declare module BABYLON.GUI {
                 * @param value defines the value or point to remove
                 */
             remove(value: number | MultiLinePoint): void;
+            /**
+                * Resets this object to initial state (no point)
+                */
+            reset(): void;
+            /**
+                * Resets all links
+                */
+            resetLinks(): void;
             /** Gets or sets line width */
             lineWidth: number;
             horizontalAlignment: number;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
dist/preview release/gui/babylon.gui.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js.map


+ 20 - 0
dist/preview release/gui/babylon.gui.module.d.ts

@@ -429,6 +429,8 @@ declare module 'babylonjs-gui/2D/multiLinePoint' {
             control: Nullable<Control>;
             /** Gets or sets the mesh associated with this point */
             mesh: Nullable<AbstractMesh>;
+            /** Resets links */
+            resetLinks(): void;
             /**
                 * Gets a translation vector
                 * @returns the translation vector
@@ -1674,6 +1676,14 @@ declare module 'babylonjs-gui/2D/controls/multiLine' {
                 * @param value defines the value or point to remove
                 */
             remove(value: number | MultiLinePoint): void;
+            /**
+                * Resets this object to initial state (no point)
+                */
+            reset(): void;
+            /**
+                * Resets all links
+                */
+            resetLinks(): void;
             /** Gets or sets line width */
             lineWidth: number;
             horizontalAlignment: number;
@@ -3191,6 +3201,8 @@ declare module BABYLON.GUI {
             control: BABYLON.Nullable<Control>;
             /** Gets or sets the mesh associated with this point */
             mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
+            /** Resets links */
+            resetLinks(): void;
             /**
                 * Gets a translation vector
                 * @returns the translation vector
@@ -4355,6 +4367,14 @@ declare module BABYLON.GUI {
                 * @param value defines the value or point to remove
                 */
             remove(value: number | MultiLinePoint): void;
+            /**
+                * Resets this object to initial state (no point)
+                */
+            reset(): void;
+            /**
+                * Resets all links
+                */
+            resetLinks(): void;
             /** Gets or sets line width */
             lineWidth: number;
             horizontalAlignment: number;

+ 15 - 32
dist/preview release/viewer/babylon.viewer.d.ts

@@ -924,7 +924,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 {
@@ -1558,6 +1558,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 {
@@ -1584,37 +1598,6 @@ declare module BabylonViewer {
     }
 }
 declare module BabylonViewer {
-    /**
-        * The EventManager is in charge of registering user interctions with the viewer.
-        * It is used in the TemplateManager
-        */
-    export class EventManager {
-            constructor(_templateManager: TemplateManager);
-            /**
-                * Register a new callback to a specific template.
-                * The best example for the usage can be found in the DefaultViewer
-                *
-                * @param templateName the templateName to register the event to
-                * @param callback The callback to be executed
-                * @param eventType the type of event to register
-                * @param selector an optional selector. if not defined the parent object in the template will be selected
-                */
-            registerCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
-            /**
-                * This will remove a registered event from the defined template.
-                * Each one of the variables apart from the template name are optional, but one must be provided.
-                *
-                * @param templateName the templateName
-                * @param callback the callback to remove (optional)
-                * @param eventType the event type to remove (optional)
-                * @param selector the selector from which to remove the event (optional)
-                */
-            unregisterCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
-            /**
-                * Dispose the event manager
-                */
-            dispose(): void;
-    }
 }
 declare module BabylonViewer {
     /**

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 2 - 2
dist/preview release/viewer/babylon.viewer.max.js


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

@@ -985,13 +985,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;
 }
 
@@ -1662,6 +1663,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';
@@ -1706,38 +1723,7 @@ declare module 'babylonjs-viewer/configuration/interfaces/environmentMapConfigur
 }
 
 declare module 'babylonjs-viewer/templating/eventManager' {
-    import { EventCallback, TemplateManager } from "babylonjs-viewer/templating/templateManager";
-    /**
-        * The EventManager is in charge of registering user interctions with the viewer.
-        * It is used in the TemplateManager
-        */
-    export class EventManager {
-            constructor(_templateManager: TemplateManager);
-            /**
-                * Register a new callback to a specific template.
-                * The best example for the usage can be found in the DefaultViewer
-                *
-                * @param templateName the templateName to register the event to
-                * @param callback The callback to be executed
-                * @param eventType the type of event to register
-                * @param selector an optional selector. if not defined the parent object in the template will be selected
-                */
-            registerCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
-            /**
-                * This will remove a registered event from the defined template.
-                * Each one of the variables apart from the template name are optional, but one must be provided.
-                *
-                * @param templateName the templateName
-                * @param callback the callback to remove (optional)
-                * @param eventType the event type to remove (optional)
-                * @param selector the selector from which to remove the event (optional)
-                */
-            unregisterCallback(templateName: string, callback: (eventData: EventCallback) => void, eventType?: string, selector?: string): void;
-            /**
-                * Dispose the event manager
-                */
-            dispose(): void;
-    }
+    
 }
 
 declare module 'babylonjs-viewer/labs/viewerLabs' {

+ 0 - 1
dist/preview release/what's new.md

@@ -116,7 +116,6 @@
 - Added HDR support to ReflectionProbe ([Deltakosh](https://github.com/deltakosh))
 - Added ACES ToneMapping to the image processing to help getting more parity with other engines ([sebavan](http://www.github.com/sebavan))
 - Added Image Processing to the particle system to allow consistency in one pass forward rendering scenes ([sebavan](http://www.github.com/sebavan))
-- Added Video Recorder [Issue 4708](https://github.com/BabylonJS/Babylon.js/issues/4708) ([sebavan](http://www.github.com/sebavan))
 - Added support for main WebGL2 texture formats ([PeapBoy](https://github.com/NicolasBuecher))
 - Added fadeInOutBehavior and tooltipText for holographic buttons ([TrevorDev](https://github.com/TrevorDev))
 - StartDrag method added to pointerDragBehavior used to simulate the start of a drag ([TrevorDev](https://github.com/TrevorDev))

+ 19 - 3
gui/src/2D/controls/multiLine.ts

@@ -127,6 +127,24 @@ export class MultiLine extends Control {
         this._points.splice(index, 1);
     }
 
+    /**
+     * Resets this object to initial state (no point)
+     */
+    public reset(): void {
+        while (this._points.length > 0) {
+            this.remove(this._points.length - 1);
+        }
+    }
+
+    /**
+     * Resets all links
+     */
+    public resetLinks(): void {
+        this._points.forEach(point => {
+            if (point != null) point.resetLinks();
+        });
+    }
+
     /** Gets or sets line width */
     public get lineWidth(): number {
         return this._lineWidth;
@@ -239,9 +257,7 @@ export class MultiLine extends Control {
     }
 
     public dispose(): void {
-        while (this._points.length > 0) {
-            this.remove(this._points.length - 1);
-        }
+        this.reset();
 
         super.dispose();
     }

+ 7 - 2
gui/src/2D/multiLinePoint.ts

@@ -114,6 +114,12 @@ export class MultiLinePoint {
         this._multiLine._markAsDirty();
     }
 
+    /** Resets links */
+    public resetLinks(): void {
+        this.control = null;
+        this.mesh = null;
+    }
+
     /** 
      * Gets a translation vector
      * @returns the translation vector
@@ -143,8 +149,7 @@ export class MultiLinePoint {
 
     /** Release associated resources */
     public dispose(): void {
-        this.control = null;
-        this.mesh = null;
+        this.resetLinks();
     }
 
 }

+ 129 - 119
src/Mesh/babylon.abstractMesh.ts

@@ -1,4 +1,5 @@
 module BABYLON {
+<<<<<<< HEAD
 
     /** @hidden */
     class _OcclusionDataStorage {
@@ -10,6 +11,36 @@
 
         /** @hidden */
         public isOcclusionQueryInProgress = false;
+=======
+    /** @hidden */
+    class _FacetDataStorage {
+        // facetData private properties
+        public facetPositions: Vector3[];             // facet local positions
+        public facetNormals: Vector3[];               // facet local normals
+        public facetPartitioning: number[][];         // partitioning array of facet index arrays
+        public facetNb: number = 0;                   // facet number
+        public partitioningSubdivisions: number = 10; // number of subdivisions per axis in the partioning space  
+        public partitioningBBoxRatio: number = 1.01;  // the partioning array space is by default 1% bigger than the bounding box
+        public facetDataEnabled: boolean = false;     // is the facet data feature enabled on this mesh ?
+        public facetParameters: any = {};             // keep a reference to the object parameters to avoid memory re-allocation
+        public bbSize: Vector3 = Vector3.Zero();      // bbox size approximated for facet data
+        public subDiv = {                             // actual number of subdivisions per axis for ComputeNormals()
+            max: 1,
+            X: 1,
+            Y: 1,
+            Z: 1
+        };
+
+        public facetDepthSort: boolean = false;                           // is the facet depth sort to be computed
+        public facetDepthSortEnabled: boolean = false;                    // is the facet depth sort initialized
+        public depthSortedIndices: IndicesArray;                          // copy of the indices array to store them once sorted
+        public depthSortedFacets: { ind: number, sqDistance: number }[];    // array of depth sorted facets
+        public facetDepthSortFunction: (f1: { ind: number, sqDistance: number }, f2: { ind: number, sqDistance: number }) => number;  // facet depth sort function
+        public facetDepthSortFrom: Vector3;                               // location where to depth sort from
+        public facetDepthSortOrigin: Vector3;                             // same as facetDepthSortFrom but expressed in the mesh local space
+        
+        public invertedMatrix: Matrix; // Inverted world matrix.
+>>>>>>> master
     }
 
     /**
@@ -59,31 +90,7 @@
             return TransformNode.BILLBOARDMODE_ALL;
         }
 
-        // facetData private properties
-        private _facetPositions: Vector3[];             // facet local positions
-        private _facetNormals: Vector3[];               // facet local normals
-        private _facetPartitioning: number[][];         // partitioning array of facet index arrays
-        private _facetNb: number = 0;                   // facet number
-        private _partitioningSubdivisions: number = 10; // number of subdivisions per axis in the partioning space  
-        private _partitioningBBoxRatio: number = 1.01;  // the partioning array space is by default 1% bigger than the bounding box
-        private _facetDataEnabled: boolean = false;     // is the facet data feature enabled on this mesh ?
-        private _facetParameters: any = {};             // keep a reference to the object parameters to avoid memory re-allocation
-        private _bbSize: Vector3 = Vector3.Zero();      // bbox size approximated for facet data
-        private _subDiv = {                             // actual number of subdivisions per axis for ComputeNormals()
-            max: 1,
-            X: 1,
-            Y: 1,
-            Z: 1
-        };
-
-        private _facetDepthSort: boolean = false;                           // is the facet depth sort to be computed
-        private _facetDepthSortEnabled: boolean = false;                    // is the facet depth sort initialized
-        private _depthSortedIndices: IndicesArray;                          // copy of the indices array to store them once sorted
-        private _depthSortedFacets: { ind: number, sqDistance: number }[];    // array of depth sorted facets
-        private _facetDepthSortFunction: (f1: { ind: number, sqDistance: number }, f2: { ind: number, sqDistance: number }) => number;  // facet depth sort function
-        private _facetDepthSortFrom: Vector3;                               // location where to depth sort from
-        private _facetDepthSortOrigin: Vector3;                             // same as facetDepthSortFrom but expressed in the mesh local space
-        private _invertedMatrix: Matrix;                                    // Mesh inverted World Matrix
+        private _facetData = new _FacetDataStorage();
 
         /** Gets ot sets the culling strategy to use to find visible meshes */
         public cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
@@ -93,17 +100,17 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
          */
         public get facetNb(): number {
-            return this._facetNb;
+            return this._facetData.facetNb;
         }
         /**
          * Gets or set the number (integer) of subdivisions per axis in the partioning space
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
          */
         public get partitioningSubdivisions(): number {
-            return this._partitioningSubdivisions;
+            return this._facetData.partitioningSubdivisions;
         }
         public set partitioningSubdivisions(nb: number) {
-            this._partitioningSubdivisions = nb;
+            this._facetData.partitioningSubdivisions = nb;
         }
         /**
          * The ratio (float) to apply to the bouding box size to set to the partioning space.  
@@ -111,10 +118,10 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
          */
         public get partitioningBBoxRatio(): number {
-            return this._partitioningBBoxRatio;
+            return this._facetData.partitioningBBoxRatio;
         }
         public set partitioningBBoxRatio(ratio: number) {
-            this._partitioningBBoxRatio = ratio;
+            this._facetData.partitioningBBoxRatio = ratio;
         }
 
         /**
@@ -124,10 +131,10 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
          */
         public get mustDepthSortFacets(): boolean {
-            return this._facetDepthSort;
+            return this._facetData.facetDepthSort;
         }
         public set mustDepthSortFacets(sort: boolean) {
-            this._facetDepthSort = sort;
+            this._facetData.facetDepthSort = sort;
         }
 
         /**
@@ -137,10 +144,10 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
          */
         public get facetDepthSortFrom(): Vector3 {
-            return this._facetDepthSortFrom;
+            return this._facetData.facetDepthSortFrom;
         }
         public set facetDepthSortFrom(location: Vector3) {
-            this._facetDepthSortFrom = location;
+            this._facetData.facetDepthSortFrom = location;
         }
 
         /**
@@ -148,7 +155,7 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
          */
         public get isFacetDataEnabled(): boolean {
-            return this._facetDataEnabled;
+            return this._facetData.facetDataEnabled;
         }
 
         /** @hidden */
@@ -1519,7 +1526,7 @@
             }
 
             // facet data
-            if (this._facetDataEnabled) {
+            if (this._facetData.facetDataEnabled) {
                 this.disableFacetData();
             }
 
@@ -1554,23 +1561,24 @@
         // Facet data
         /** @hidden */
         private _initFacetData(): AbstractMesh {
-            if (!this._facetNormals) {
-                this._facetNormals = new Array<Vector3>();
+            const data = this._facetData;
+            if (!data.facetNormals) {
+                data.facetNormals = new Array<Vector3>();
             }
-            if (!this._facetPositions) {
-                this._facetPositions = new Array<Vector3>();
+            if (!data.facetPositions) {
+                data.facetPositions = new Array<Vector3>();
             }
-            if (!this._facetPartitioning) {
-                this._facetPartitioning = new Array<number[]>();
+            if (!data.facetPartitioning) {
+                data.facetPartitioning = new Array<number[]>();
             }
-            this._facetNb = ((<IndicesArray>this.getIndices()).length / 3) | 0;
-            this._partitioningSubdivisions = (this._partitioningSubdivisions) ? this._partitioningSubdivisions : 10;   // default nb of partitioning subdivisions = 10
-            this._partitioningBBoxRatio = (this._partitioningBBoxRatio) ? this._partitioningBBoxRatio : 1.01;          // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
-            for (var f = 0; f < this._facetNb; f++) {
-                this._facetNormals[f] = Vector3.Zero();
-                this._facetPositions[f] = Vector3.Zero();
+            data.facetNb = ((<IndicesArray>this.getIndices()).length / 3) | 0;
+            data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10;   // default nb of partitioning subdivisions = 10
+            data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01;          // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
+            for (var f = 0; f < data.facetNb; f++) {
+                data.facetNormals[f] = Vector3.Zero();
+                data.facetPositions[f] = Vector3.Zero();
             }
-            this._facetDataEnabled = true;
+            data.facetDataEnabled = true;
             return this;
         }
 
@@ -1582,7 +1590,8 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         public updateFacetData(): AbstractMesh {
-            if (!this._facetDataEnabled) {
+            const data = this._facetData;
+            if (!data.facetDataEnabled) {
                 this._initFacetData();
             }
             var positions = this.getVerticesData(VertexBuffer.PositionKind);
@@ -1590,14 +1599,14 @@
             var normals = this.getVerticesData(VertexBuffer.NormalKind);
             var bInfo = this.getBoundingInfo();
 
-            if (this._facetDepthSort && !this._facetDepthSortEnabled) {
+            if (data.facetDepthSort && !data.facetDepthSortEnabled) {
                 // init arrays, matrix and sort function on first call
-                this._facetDepthSortEnabled = true;
+                data.facetDepthSortEnabled = true;
                 if (indices instanceof Uint16Array) {
-                    this._depthSortedIndices = new Uint16Array(indices!);
+                    data.depthSortedIndices = new Uint16Array(indices!);
                 }
                 else if (indices instanceof Uint32Array) {
-                    this._depthSortedIndices = new Uint32Array(indices!);
+                    data.depthSortedIndices = new Uint32Array(indices!);
                 }
                 else {
                     var needs32bits = false;
@@ -1608,68 +1617,68 @@
                         }
                     }
                     if (needs32bits) {
-                        this._depthSortedIndices = new Uint32Array(indices!);
+                        data.depthSortedIndices = new Uint32Array(indices!);
                     }
                     else {
-                        this._depthSortedIndices = new Uint16Array(indices!);
+                        data.depthSortedIndices = new Uint16Array(indices!);
                     }
                 }
-                this._facetDepthSortFunction = function (f1, f2) {
+                data.facetDepthSortFunction = function (f1, f2) {
                     return (f2.sqDistance - f1.sqDistance);
                 };
-                if (!this._facetDepthSortFrom) {
+                if (!data.facetDepthSortFrom) {
                     var camera = this.getScene().activeCamera;
-                    this._facetDepthSortFrom = (camera) ? camera.position : Vector3.Zero();
+                    data.facetDepthSortFrom = (camera) ? camera.position : Vector3.Zero();
                 }
-                this._depthSortedFacets = [];
-                for (var f = 0; f < this._facetNb; f++) {
+                data.depthSortedFacets = [];
+                for (var f = 0; f < data.facetNb; f++) {
                     var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
-                    this._depthSortedFacets.push(depthSortedFacet);
+                    data.depthSortedFacets.push(depthSortedFacet);
                 }
-                this._invertedMatrix = Matrix.Identity();
-                this._facetDepthSortOrigin = Vector3.Zero();
-            }
-
-            this._bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : Epsilon;
-            this._bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : Epsilon;
-            this._bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : Epsilon;
-            var bbSizeMax = (this._bbSize.x > this._bbSize.y) ? this._bbSize.x : this._bbSize.y;
-            bbSizeMax = (bbSizeMax > this._bbSize.z) ? bbSizeMax : this._bbSize.z;
-            this._subDiv.max = this._partitioningSubdivisions;
-            this._subDiv.X = Math.floor(this._subDiv.max * this._bbSize.x / bbSizeMax);   // adjust the number of subdivisions per axis
-            this._subDiv.Y = Math.floor(this._subDiv.max * this._bbSize.y / bbSizeMax);   // according to each bbox size per axis
-            this._subDiv.Z = Math.floor(this._subDiv.max * this._bbSize.z / bbSizeMax);
-            this._subDiv.X = this._subDiv.X < 1 ? 1 : this._subDiv.X;                     // at least one subdivision
-            this._subDiv.Y = this._subDiv.Y < 1 ? 1 : this._subDiv.Y;
-            this._subDiv.Z = this._subDiv.Z < 1 ? 1 : this._subDiv.Z;
+                data.invertedMatrix = Matrix.Identity();
+                data.facetDepthSortOrigin = Vector3.Zero();
+            }
+
+            data.bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : Epsilon;
+            data.bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : Epsilon;
+            data.bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : Epsilon;
+            var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
+            bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
+            data.subDiv.max = data.partitioningSubdivisions;
+            data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax);   // adjust the number of subdivisions per axis
+            data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax);   // according to each bbox size per axis
+            data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
+            data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X;                     // at least one subdivision
+            data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
+            data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
             // set the parameters for ComputeNormals()
-            this._facetParameters.facetNormals = this.getFacetLocalNormals();
-            this._facetParameters.facetPositions = this.getFacetLocalPositions();
-            this._facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
-            this._facetParameters.bInfo = bInfo;
-            this._facetParameters.bbSize = this._bbSize;
-            this._facetParameters.subDiv = this._subDiv;
-            this._facetParameters.ratio = this.partitioningBBoxRatio;
-            this._facetParameters.depthSort = this._facetDepthSort;
-            if (this._facetDepthSort && this._facetDepthSortEnabled) {
+            data.facetParameters.facetNormals = this.getFacetLocalNormals();
+            data.facetParameters.facetPositions = this.getFacetLocalPositions();
+            data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
+            data.facetParameters.bInfo = bInfo;
+            data.facetParameters.bbSize = data.bbSize;
+            data.facetParameters.subDiv = data.subDiv;
+            data.facetParameters.ratio = this.partitioningBBoxRatio;
+            data.facetParameters.depthSort = data.facetDepthSort;
+            if (data.facetDepthSort && data.facetDepthSortEnabled) {
                 this.computeWorldMatrix(true);
-                this._worldMatrix.invertToRef(this._invertedMatrix);
-                Vector3.TransformCoordinatesToRef(this._facetDepthSortFrom, this._invertedMatrix, this._facetDepthSortOrigin);
-                this._facetParameters.distanceTo = this._facetDepthSortOrigin;
+                this._worldMatrix.invertToRef(data.invertedMatrix);
+                Vector3.TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
+                data.facetParameters.distanceTo = data.facetDepthSortOrigin;
             }
-            this._facetParameters.depthSortedFacets = this._depthSortedFacets;
-            VertexData.ComputeNormals(positions, indices, normals, this._facetParameters);
+            data.facetParameters.depthSortedFacets = data.depthSortedFacets;
+            VertexData.ComputeNormals(positions, indices, normals, data.facetParameters);
 
-            if (this._facetDepthSort && this._facetDepthSortEnabled) {
-                this._depthSortedFacets.sort(this._facetDepthSortFunction);
-                var l = (this._depthSortedIndices.length / 3) | 0;
+            if (data.facetDepthSort && data.facetDepthSortEnabled) {
+                data.depthSortedFacets.sort(data.facetDepthSortFunction);
+                var l = (data.depthSortedIndices.length / 3) | 0;
                 for (var f = 0; f < l; f++) {
-                    var sind = this._depthSortedFacets[f].ind;
-                    this._depthSortedIndices[f * 3] = indices![sind];
-                    this._depthSortedIndices[f * 3 + 1] = indices![sind + 1];
-                    this._depthSortedIndices[f * 3 + 2] = indices![sind + 2];
+                    var sind = data.depthSortedFacets[f].ind;
+                    data.depthSortedIndices[f * 3] = indices![sind];
+                    data.depthSortedIndices[f * 3 + 1] = indices![sind + 1];
+                    data.depthSortedIndices[f * 3 + 2] = indices![sind + 2];
                 }
-                this.updateIndices(this._depthSortedIndices);
+                this.updateIndices(data.depthSortedIndices);
             }
 
             return this;
@@ -1682,10 +1691,10 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         public getFacetLocalNormals(): Vector3[] {
-            if (!this._facetNormals) {
+            if (!this._facetData.facetNormals) {
                 this.updateFacetData();
             }
-            return this._facetNormals;
+            return this._facetData.facetNormals;
         }
 
         /**
@@ -1695,10 +1704,10 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata 
          */
         public getFacetLocalPositions(): Vector3[] {
-            if (!this._facetPositions) {
+            if (!this._facetData.facetPositions) {
                 this.updateFacetData();
             }
-            return this._facetPositions;
+            return this._facetData.facetPositions;
         }
 
         /**
@@ -1707,10 +1716,10 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata 
          */
         public getFacetLocalPartitioning(): number[][] {
-            if (!this._facetPartitioning) {
+            if (!this._facetData.facetPartitioning) {
                 this.updateFacetData();
             }
-            return this._facetPartitioning;
+            return this._facetData.facetPartitioning;
         }
 
         /**
@@ -1776,14 +1785,15 @@
          */
         public getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]> {
             var bInfo = this.getBoundingInfo();
+            const data = this._facetData;
 
-            var ox = Math.floor((x - bInfo.minimum.x * this._partitioningBBoxRatio) * this._subDiv.X * this._partitioningBBoxRatio / this._bbSize.x);
-            var oy = Math.floor((y - bInfo.minimum.y * this._partitioningBBoxRatio) * this._subDiv.Y * this._partitioningBBoxRatio / this._bbSize.y);
-            var oz = Math.floor((z - bInfo.minimum.z * this._partitioningBBoxRatio) * this._subDiv.Z * this._partitioningBBoxRatio / this._bbSize.z);
-            if (ox < 0 || ox > this._subDiv.max || oy < 0 || oy > this._subDiv.max || oz < 0 || oz > this._subDiv.max) {
+            var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
+            var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
+            var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
+            if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
                 return null;
             }
-            return this._facetPartitioning[ox + this._subDiv.max * oy + this._subDiv.max * this._subDiv.max * oz];
+            return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
         }
 
         /** 
@@ -1884,7 +1894,7 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata 
          */
         public getFacetDataParameters(): any {
-            return this._facetParameters;
+            return this._facetData.facetParameters;
         }
 
         /** 
@@ -1893,13 +1903,13 @@
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata 
          */
         public disableFacetData(): AbstractMesh {
-            if (this._facetDataEnabled) {
-                this._facetDataEnabled = false;
-                this._facetPositions = new Array<Vector3>();
-                this._facetNormals = new Array<Vector3>();
-                this._facetPartitioning = new Array<number[]>();
-                this._facetParameters = null;
-                this._depthSortedIndices = new Uint32Array(0);
+            if (this._facetData.facetDataEnabled) {
+                this._facetData.facetDataEnabled = false;
+                this._facetData.facetPositions = new Array<Vector3>();
+                this._facetData.facetNormals = new Array<Vector3>();
+                this._facetData.facetPartitioning = new Array<number[]>();
+                this._facetData.facetParameters = null;
+                this._facetData.depthSortedIndices = new Uint32Array(0);
             }
             return this;
         }

+ 54 - 43
src/babylon.scene.ts

@@ -3,7 +3,7 @@ module BABYLON {
      * Define an interface for all classes that will hold resources
      */
     export interface IDisposable {
-        /** 
+        /**
          * Releases all held resources
          */
         dispose(): void;
@@ -91,7 +91,7 @@ module BABYLON {
          */
         public static MaxDeltaTime = 1000.0;
 
-        // Members   
+        // Members
 
         /**
          * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
@@ -439,7 +439,7 @@ module BABYLON {
         * An event triggered when a mesh is removed
         */
         public onMeshRemovedObservable = new Observable<AbstractMesh>();
-        
+
         /**
         * An event triggered when a material is created
         */
@@ -449,7 +449,7 @@ module BABYLON {
         * An event triggered when a material is removed
         */
         public onMaterialRemovedObservable = new Observable<Material>();
-        
+
         /**
         * An event triggered when a texture is created
         */
@@ -658,6 +658,7 @@ module BABYLON {
         /**
         * Gets or sets a boolean indicating if fog is enabled on this scene
         * @see http://doc.babylonjs.com/babylon101/environment#fog
+        * (Default is true)
         */
         public set fogEnabled(value: boolean) {
             if (this._fogEnabled === value) {
@@ -674,6 +675,12 @@ module BABYLON {
         /**
         * Gets or sets the fog mode to use
         * @see http://doc.babylonjs.com/babylon101/environment#fog
+        * | mode | value |
+        * | --- | --- |
+        * | FOGMODE_NONE | 0 |
+        * | FOGMODE_EXP | 1 |
+        * | FOGMODE_EXP2 | 2 |
+        * | FOGMODE_LINEAR | 3 |
         */
         public set fogMode(value: number) {
             if (this._fogMode === value) {
@@ -689,21 +696,25 @@ module BABYLON {
         /**
         * Gets or sets the fog color to use
         * @see http://doc.babylonjs.com/babylon101/environment#fog
+        * (Default is Color3(0.2, 0.2, 0.3))
         */
         public fogColor = new Color3(0.2, 0.2, 0.3);
         /**
         * Gets or sets the fog density to use
         * @see http://doc.babylonjs.com/babylon101/environment#fog
+        * (Default is 0.1)
         */
         public fogDensity = 0.1;
         /**
         * Gets or sets the fog start distance to use
         * @see http://doc.babylonjs.com/babylon101/environment#fog
+        * (Default is 0)
         */
         public fogStart = 0;
         /**
         * Gets or sets the fog end distance to use
         * @see http://doc.babylonjs.com/babylon101/environment#fog
+        * (Default is 1000)
         */
         public fogEnd = 1000.0;
 
@@ -821,7 +832,7 @@ module BABYLON {
         private _workerCollisions: boolean;
         /** @hidden */
         public collisionCoordinator: ICollisionCoordinator;
-        /** 
+        /**
          * Defines the gravity applied to this scene (used only for collisions)
          * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
          */
@@ -1031,7 +1042,7 @@ module BABYLON {
         /**
          * @hidden
          * Add a component to the scene.
-         * Note that the ccomponent could be registered on th next frame if this is called after 
+         * Note that the ccomponent could be registered on th next frame if this is called after
          * the register component stage.
          * @param component Defines the component to add to the scene
          */
@@ -1278,7 +1289,7 @@ module BABYLON {
             return this._pointerY;
         }
 
-        /** 
+        /**
          * Gets the cached material (ie. the latest rendered one)
          * @returns the cached material
          */
@@ -1286,7 +1297,7 @@ module BABYLON {
             return this._cachedMaterial;
         }
 
-        /** 
+        /**
          * Gets the cached effect (ie. the latest rendered one)
          * @returns the cached effect
          */
@@ -1294,7 +1305,7 @@ module BABYLON {
             return this._cachedEffect;
         }
 
-        /** 
+        /**
          * Gets the cached visibility state (ie. the latest rendered one)
          * @returns the cached visibility state
          */
@@ -1313,7 +1324,7 @@ module BABYLON {
             return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
         }
 
-        /** 
+        /**
          * Gets the engine associated with the scene
          * @returns an Engine
          */
@@ -1321,7 +1332,7 @@ module BABYLON {
             return this._engine;
         }
 
-        /** 
+        /**
          * Gets the total number of vertices rendered per frame
          * @returns the total number of vertices rendered per frame
          */
@@ -1337,9 +1348,9 @@ module BABYLON {
             return this._totalVertices;
         }
 
-        /** 
+        /**
          * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
-         * @returns the total number of active indices rendered per frame         
+         * @returns the total number of active indices rendered per frame
          */
         public getActiveIndices(): number {
             return this._activeIndices.current;
@@ -1353,9 +1364,9 @@ module BABYLON {
             return this._activeIndices;
         }
 
-        /** 
+        /**
          * Gets the total number of active particles rendered per frame
-         * @returns the total number of active particles rendered per frame         
+         * @returns the total number of active particles rendered per frame
          */
         public getActiveParticles(): number {
             return this._activeParticles.current;
@@ -1369,9 +1380,9 @@ module BABYLON {
             return this._activeParticles;
         }
 
-        /** 
+        /**
          * Gets the total number of active bones rendered per frame
-         * @returns the total number of active bones rendered per frame         
+         * @returns the total number of active bones rendered per frame
          */
         public getActiveBones(): number {
             return this._activeBones.current;
@@ -1421,9 +1432,9 @@ module BABYLON {
             return null;
         }
 
-        /** 
+        /**
          * Gets the array of active meshes
-         * @returns an array of AbstractMesh 
+         * @returns an array of AbstractMesh
          */
         public getActiveMeshes(): SmartArray<AbstractMesh> {
             return this._activeMeshes;
@@ -1471,7 +1482,7 @@ module BABYLON {
             return null;
         }
 
-        /** 
+        /**
          * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
          * @returns a number
          */
@@ -1479,7 +1490,7 @@ module BABYLON {
             return this._animationRatio !== undefined ? this._animationRatio : 1;
         }
 
-        /** 
+        /**
          * Gets an unique Id for the current render phase
          * @returns a number
          */
@@ -1487,7 +1498,7 @@ module BABYLON {
             return this._renderId;
         }
 
-        /** 
+        /**
          * Gets an unique Id for the current frame
          * @returns a number
          */
@@ -1998,7 +2009,7 @@ module BABYLON {
             };
 
             this._onPointerUp = (evt: PointerEvent) => {
-                if (this._totalPointersPressed === 0) {  // We are attaching the pointer up to windows because of a bug in FF                    
+                if (this._totalPointersPressed === 0) {  // We are attaching the pointer up to windows because of a bug in FF
                     return;                             // So we need to test it the pointer down was pressed before.
                 }
 
@@ -2334,7 +2345,7 @@ module BABYLON {
             }
         }
 
-        /** 
+        /**
          * Returns the number of items waiting to be loaded
          * @returns the number of items waiting to be loaded
          */
@@ -2635,7 +2646,7 @@ module BABYLON {
 
             var scale = 1;
             if (holder.totalWeight < 1.0) {
-                // We need to mix the original value in                     
+                // We need to mix the original value in
                 originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
                 scale = 1.0 - holder.totalWeight;
             } else {
@@ -2758,7 +2769,7 @@ module BABYLON {
                             let normalizer = 1.0;
 
                             if (holder.totalWeight < 1.0) {
-                                // We need to mix the original value in     
+                                // We need to mix the original value in
                                 if (originalValue.scale) {
                                     finalValue = originalValue.scale(1.0 - holder.totalWeight);
                                 } else {
@@ -2806,7 +2817,7 @@ module BABYLON {
             this._useAlternateCameraConfiguration = active;
         }
 
-        /** 
+        /**
          * Gets the current view matrix
          * @returns a Matrix
          */
@@ -2814,7 +2825,7 @@ module BABYLON {
             return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
         }
 
-        /** 
+        /**
          * Gets the current projection matrix
          * @returns a Matrix
          */
@@ -2822,7 +2833,7 @@ module BABYLON {
             return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
         }
 
-        /** 
+        /**
          * Gets the current transform matrix
          * @returns a Matrix made of View * Projection
          */
@@ -2830,7 +2841,7 @@ module BABYLON {
             return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
         }
 
-        /** 
+        /**
          * Sets the current transform matrix
          * @param view defines the View matrix to use
          * @param projection defines the Projection matrix to use
@@ -2903,7 +2914,7 @@ module BABYLON {
             return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
         }
 
-        /** 
+        /**
          * Gets an unique (relatively to the current scene) Id
          * @returns an unique number for the scene
          */
@@ -3129,7 +3140,7 @@ module BABYLON {
                 this.materials.splice(index, 1);
             }
             this.onMaterialRemovedObservable.notifyObservers(toRemove);
-            
+
             return index;
         }
 
@@ -3157,7 +3168,7 @@ module BABYLON {
                 this.textures.splice(index, 1);
             }
             this.onTextureRemovedObservable.notifyObservers(toRemove);
-            
+
             return index;
         }
 
@@ -3180,7 +3191,7 @@ module BABYLON {
             this.onNewLightAddedObservable.notifyObservers(newLight);
         }
 
-        /** 
+        /**
          * Sorts the list list based on light priorities
          */
         public sortLightsByPriority(): void {
@@ -3580,7 +3591,7 @@ module BABYLON {
             return false;
         }
 
-        /** 
+        /**
          * Gets the list of geometries attached to the scene
          * @returns an array of Geometry
          */
@@ -4064,7 +4075,7 @@ module BABYLON {
 
             // Determine mesh candidates
             const meshes = this.getActiveMeshCandidates();
-            
+
             // Check each mesh
             const len = meshes.length;
             for (let i = 0; i < len; i++) {
@@ -4366,7 +4377,7 @@ module BABYLON {
             return 1000.0 / 60.0; // frame time in ms
         }
 
-        /** 
+        /**
          * Render the scene
          * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
          */
@@ -4579,7 +4590,7 @@ module BABYLON {
             this._activeParticles.addCount(0, true);
         }
 
-        /** 
+        /**
          * Freeze all materials
          * A frozen material will not be updatable but should be faster to render
          */
@@ -4589,7 +4600,7 @@ module BABYLON {
             }
         }
 
-        /** 
+        /**
          * Unfreeze all materials
          * A frozen material will not be updatable but should be faster to render
          */
@@ -4599,7 +4610,7 @@ module BABYLON {
             }
         }
 
-        /** 
+        /**
          * Releases all held ressources
          */
         public dispose(): void {
@@ -4831,7 +4842,7 @@ module BABYLON {
 
         /**
          * Get the world extend vectors with an optional filter
-         * 
+         *
          * @param filterPredicate the predicate - which meshes should be included when calculating the world size
          * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
          */
@@ -5132,14 +5143,14 @@ module BABYLON {
             }
         }
 
-        /** 
+        /**
          * Gets the mesh under the pointer
          * @returns a Mesh or null if no mesh is under the pointer
          */
         public getPointerOverMesh(): Nullable<AbstractMesh> {
             return this._pointerOverMesh;
         }
-     
+
         // Misc.
         /** @hidden */
         public _rebuildGeometries(): void {