David Catuhe 7 年 前
コミット
673d2b155b

ファイルの差分が大きいため隠しています
+ 9398 - 9597
dist/preview release/babylon.d.ts


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/preview release/babylon.js


+ 134 - 113
dist/preview release/babylon.max.js

@@ -19864,6 +19864,26 @@ var BABYLON;
         }
         return _OcclusionDataStorage;
     }());
+    /** @hidden */
+    var _FacetDataStorage = /** @class */ (function () {
+        function _FacetDataStorage() {
+            this.facetNb = 0; // facet number
+            this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space  
+            this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
+            this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
+            this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
+            this.bbSize = BABYLON.Vector3.Zero(); // bbox size approximated for facet data
+            this.subDiv = {
+                max: 1,
+                X: 1,
+                Y: 1,
+                Z: 1
+            };
+            this.facetDepthSort = false; // is the facet depth sort to be computed
+            this.facetDepthSortEnabled = false; // is the facet depth sort initialized
+        }
+        return _FacetDataStorage;
+    }());
     /**
      * Class used to store all common mesh properties
      */
@@ -19878,20 +19898,7 @@ var BABYLON;
         function AbstractMesh(name, scene) {
             if (scene === void 0) { scene = null; }
             var _this = _super.call(this, name, scene, false) || this;
-            _this._facetNb = 0; // facet number
-            _this._partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space  
-            _this._partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
-            _this._facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
-            _this._facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
-            _this._bbSize = BABYLON.Vector3.Zero(); // bbox size approximated for facet data
-            _this._subDiv = {
-                max: 1,
-                X: 1,
-                Y: 1,
-                Z: 1
-            };
-            _this._facetDepthSort = false; // is the facet depth sort to be computed
-            _this._facetDepthSortEnabled = false; // is the facet depth sort initialized
+            _this._facetData = new _FacetDataStorage();
             /** Gets ot sets the culling strategy to use to find visible meshes */
             _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
             // Events
@@ -20099,7 +20106,7 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
              */
             get: function () {
-                return this._facetNb;
+                return this._facetData.facetNb;
             },
             enumerable: true,
             configurable: true
@@ -20110,10 +20117,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
              */
             get: function () {
-                return this._partitioningSubdivisions;
+                return this._facetData.partitioningSubdivisions;
             },
             set: function (nb) {
-                this._partitioningSubdivisions = nb;
+                this._facetData.partitioningSubdivisions = nb;
             },
             enumerable: true,
             configurable: true
@@ -20125,10 +20132,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
              */
             get: function () {
-                return this._partitioningBBoxRatio;
+                return this._facetData.partitioningBBoxRatio;
             },
             set: function (ratio) {
-                this._partitioningBBoxRatio = ratio;
+                this._facetData.partitioningBBoxRatio = ratio;
             },
             enumerable: true,
             configurable: true
@@ -20141,10 +20148,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
              */
             get: function () {
-                return this._facetDepthSort;
+                return this._facetData.facetDepthSort;
             },
             set: function (sort) {
-                this._facetDepthSort = sort;
+                this._facetData.facetDepthSort = sort;
             },
             enumerable: true,
             configurable: true
@@ -20157,10 +20164,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
              */
             get: function () {
-                return this._facetDepthSortFrom;
+                return this._facetData.facetDepthSortFrom;
             },
             set: function (location) {
-                this._facetDepthSortFrom = location;
+                this._facetData.facetDepthSortFrom = location;
             },
             enumerable: true,
             configurable: true
@@ -20171,7 +20178,7 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
              */
             get: function () {
-                return this._facetDataEnabled;
+                return this._facetData.facetDataEnabled;
             },
             enumerable: true,
             configurable: true
@@ -21233,7 +21240,7 @@ var BABYLON;
                 }
             }
             // facet data
-            if (this._facetDataEnabled) {
+            if (this._facetData.facetDataEnabled) {
                 this.disableFacetData();
             }
             this.onAfterWorldMatrixUpdateObservable.clear();
@@ -21263,23 +21270,24 @@ var BABYLON;
         // Facet data
         /** @hidden */
         AbstractMesh.prototype._initFacetData = function () {
-            if (!this._facetNormals) {
-                this._facetNormals = new Array();
+            var data = this._facetData;
+            if (!data.facetNormals) {
+                data.facetNormals = new Array();
             }
-            if (!this._facetPositions) {
-                this._facetPositions = new Array();
+            if (!data.facetPositions) {
+                data.facetPositions = new Array();
             }
-            if (!this._facetPartitioning) {
-                this._facetPartitioning = new Array();
+            if (!data.facetPartitioning) {
+                data.facetPartitioning = new Array();
             }
-            this._facetNb = (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] = BABYLON.Vector3.Zero();
-                this._facetPositions[f] = BABYLON.Vector3.Zero();
+            data.facetNb = (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] = BABYLON.Vector3.Zero();
+                data.facetPositions[f] = BABYLON.Vector3.Zero();
             }
-            this._facetDataEnabled = true;
+            data.facetDataEnabled = true;
             return this;
         };
         /**
@@ -21290,21 +21298,22 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.updateFacetData = function () {
-            if (!this._facetDataEnabled) {
+            var data = this._facetData;
+            if (!data.facetDataEnabled) {
                 this._initFacetData();
             }
             var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var indices = this.getIndices();
             var normals = this.getVerticesData(BABYLON.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;
@@ -21315,66 +21324,66 @@ var BABYLON;
                         }
                     }
                     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 : BABYLON.Vector3.Zero();
+                    data.facetDepthSortFrom = (camera) ? camera.position : BABYLON.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);
-                }
-                this._invertedMatrix = BABYLON.Matrix.Identity();
-                this._facetDepthSortOrigin = BABYLON.Vector3.Zero();
-            }
-            this._bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > BABYLON.Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : BABYLON.Epsilon;
-            this._bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > BABYLON.Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : BABYLON.Epsilon;
-            this._bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > BABYLON.Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : BABYLON.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.depthSortedFacets.push(depthSortedFacet);
+                }
+                data.invertedMatrix = BABYLON.Matrix.Identity();
+                data.facetDepthSortOrigin = BABYLON.Vector3.Zero();
+            }
+            data.bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > BABYLON.Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : BABYLON.Epsilon;
+            data.bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > BABYLON.Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : BABYLON.Epsilon;
+            data.bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > BABYLON.Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : BABYLON.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);
-                BABYLON.Vector3.TransformCoordinatesToRef(this._facetDepthSortFrom, this._invertedMatrix, this._facetDepthSortOrigin);
-                this._facetParameters.distanceTo = this._facetDepthSortOrigin;
-            }
-            this._facetParameters.depthSortedFacets = this._depthSortedFacets;
-            BABYLON.VertexData.ComputeNormals(positions, indices, normals, this._facetParameters);
-            if (this._facetDepthSort && this._facetDepthSortEnabled) {
-                this._depthSortedFacets.sort(this._facetDepthSortFunction);
-                var l = (this._depthSortedIndices.length / 3) | 0;
+                this._worldMatrix.invertToRef(data.invertedMatrix);
+                BABYLON.Vector3.TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
+                data.facetParameters.distanceTo = data.facetDepthSortOrigin;
+            }
+            data.facetParameters.depthSortedFacets = data.depthSortedFacets;
+            BABYLON.VertexData.ComputeNormals(positions, indices, normals, data.facetParameters);
+            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;
         };
@@ -21385,10 +21394,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalNormals = function () {
-            if (!this._facetNormals) {
+            if (!this._facetData.facetNormals) {
                 this.updateFacetData();
             }
-            return this._facetNormals;
+            return this._facetData.facetNormals;
         };
         /**
          * Returns the facetLocalPositions array.
@@ -21397,10 +21406,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalPositions = function () {
-            if (!this._facetPositions) {
+            if (!this._facetData.facetPositions) {
                 this.updateFacetData();
             }
-            return this._facetPositions;
+            return this._facetData.facetPositions;
         };
         /**
          * Returns the facetLocalPartioning array
@@ -21408,10 +21417,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalPartitioning = function () {
-            if (!this._facetPartitioning) {
+            if (!this._facetData.facetPartitioning) {
                 this.updateFacetData();
             }
-            return this._facetPartitioning;
+            return this._facetData.facetPartitioning;
         };
         /**
          * Returns the i-th facet position in the world system.
@@ -21472,13 +21481,14 @@ var BABYLON;
          */
         AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
             var bInfo = this.getBoundingInfo();
-            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 data = this._facetData;
+            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];
         };
         /**
          * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
@@ -21578,7 +21588,7 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetDataParameters = function () {
-            return this._facetParameters;
+            return this._facetData.facetParameters;
         };
         /**
          * Disables the feature FacetData and frees the related memory
@@ -21586,13 +21596,13 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.disableFacetData = function () {
-            if (this._facetDataEnabled) {
-                this._facetDataEnabled = false;
-                this._facetPositions = new Array();
-                this._facetNormals = new Array();
-                this._facetPartitioning = new Array();
-                this._facetParameters = null;
-                this._depthSortedIndices = new Uint32Array(0);
+            if (this._facetData.facetDataEnabled) {
+                this._facetData.facetDataEnabled = false;
+                this._facetData.facetPositions = new Array();
+                this._facetData.facetNormals = new Array();
+                this._facetData.facetPartitioning = new Array();
+                this._facetData.facetParameters = null;
+                this._facetData.depthSortedIndices = new Uint32Array(0);
             }
             return this;
         };
@@ -24398,7 +24408,7 @@ var BABYLON;
          */
         function Scene(engine) {
             var _this = _super.call(this) || this;
-            // Members   
+            // Members
             /**
              * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
              */
@@ -24658,21 +24668,25 @@ var 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))
             */
             _this.fogColor = new BABYLON.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)
             */
             _this.fogDensity = 0.1;
             /**
             * Gets or sets the fog start distance to use
             * @see http://doc.babylonjs.com/babylon101/environment#fog
+            * (Default is 0)
             */
             _this.fogStart = 0;
             /**
             * Gets or sets the fog end distance to use
             * @see http://doc.babylonjs.com/babylon101/environment#fog
+            * (Default is 1000)
             */
             _this.fogEnd = 1000.0;
             // Lights
@@ -25152,6 +25166,7 @@ var 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)
             */
             set: function (value) {
                 if (this._fogEnabled === value) {
@@ -25170,6 +25185,12 @@ var 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 |
             */
             set: function (value) {
                 if (this._fogMode === value) {
@@ -26076,7 +26097,7 @@ var BABYLON;
                 _this._processPointerDown(pickResult, evt);
             };
             this._onPointerUp = function (evt) {
-                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.
                 }
                 _this._totalPointersPressed--;
@@ -26636,7 +26657,7 @@ var BABYLON;
             var originalValue = holder.originalValue;
             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;
             }
@@ -26739,7 +26760,7 @@ var BABYLON;
                             var startIndex = 0;
                             var 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);
                                 }

+ 134 - 113
dist/preview release/babylon.no-module.max.js

@@ -19831,6 +19831,26 @@ var BABYLON;
         }
         return _OcclusionDataStorage;
     }());
+    /** @hidden */
+    var _FacetDataStorage = /** @class */ (function () {
+        function _FacetDataStorage() {
+            this.facetNb = 0; // facet number
+            this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space  
+            this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
+            this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
+            this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
+            this.bbSize = BABYLON.Vector3.Zero(); // bbox size approximated for facet data
+            this.subDiv = {
+                max: 1,
+                X: 1,
+                Y: 1,
+                Z: 1
+            };
+            this.facetDepthSort = false; // is the facet depth sort to be computed
+            this.facetDepthSortEnabled = false; // is the facet depth sort initialized
+        }
+        return _FacetDataStorage;
+    }());
     /**
      * Class used to store all common mesh properties
      */
@@ -19845,20 +19865,7 @@ var BABYLON;
         function AbstractMesh(name, scene) {
             if (scene === void 0) { scene = null; }
             var _this = _super.call(this, name, scene, false) || this;
-            _this._facetNb = 0; // facet number
-            _this._partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space  
-            _this._partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
-            _this._facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
-            _this._facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
-            _this._bbSize = BABYLON.Vector3.Zero(); // bbox size approximated for facet data
-            _this._subDiv = {
-                max: 1,
-                X: 1,
-                Y: 1,
-                Z: 1
-            };
-            _this._facetDepthSort = false; // is the facet depth sort to be computed
-            _this._facetDepthSortEnabled = false; // is the facet depth sort initialized
+            _this._facetData = new _FacetDataStorage();
             /** Gets ot sets the culling strategy to use to find visible meshes */
             _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
             // Events
@@ -20066,7 +20073,7 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
              */
             get: function () {
-                return this._facetNb;
+                return this._facetData.facetNb;
             },
             enumerable: true,
             configurable: true
@@ -20077,10 +20084,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
              */
             get: function () {
-                return this._partitioningSubdivisions;
+                return this._facetData.partitioningSubdivisions;
             },
             set: function (nb) {
-                this._partitioningSubdivisions = nb;
+                this._facetData.partitioningSubdivisions = nb;
             },
             enumerable: true,
             configurable: true
@@ -20092,10 +20099,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
              */
             get: function () {
-                return this._partitioningBBoxRatio;
+                return this._facetData.partitioningBBoxRatio;
             },
             set: function (ratio) {
-                this._partitioningBBoxRatio = ratio;
+                this._facetData.partitioningBBoxRatio = ratio;
             },
             enumerable: true,
             configurable: true
@@ -20108,10 +20115,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
              */
             get: function () {
-                return this._facetDepthSort;
+                return this._facetData.facetDepthSort;
             },
             set: function (sort) {
-                this._facetDepthSort = sort;
+                this._facetData.facetDepthSort = sort;
             },
             enumerable: true,
             configurable: true
@@ -20124,10 +20131,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
              */
             get: function () {
-                return this._facetDepthSortFrom;
+                return this._facetData.facetDepthSortFrom;
             },
             set: function (location) {
-                this._facetDepthSortFrom = location;
+                this._facetData.facetDepthSortFrom = location;
             },
             enumerable: true,
             configurable: true
@@ -20138,7 +20145,7 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
              */
             get: function () {
-                return this._facetDataEnabled;
+                return this._facetData.facetDataEnabled;
             },
             enumerable: true,
             configurable: true
@@ -21200,7 +21207,7 @@ var BABYLON;
                 }
             }
             // facet data
-            if (this._facetDataEnabled) {
+            if (this._facetData.facetDataEnabled) {
                 this.disableFacetData();
             }
             this.onAfterWorldMatrixUpdateObservable.clear();
@@ -21230,23 +21237,24 @@ var BABYLON;
         // Facet data
         /** @hidden */
         AbstractMesh.prototype._initFacetData = function () {
-            if (!this._facetNormals) {
-                this._facetNormals = new Array();
+            var data = this._facetData;
+            if (!data.facetNormals) {
+                data.facetNormals = new Array();
             }
-            if (!this._facetPositions) {
-                this._facetPositions = new Array();
+            if (!data.facetPositions) {
+                data.facetPositions = new Array();
             }
-            if (!this._facetPartitioning) {
-                this._facetPartitioning = new Array();
+            if (!data.facetPartitioning) {
+                data.facetPartitioning = new Array();
             }
-            this._facetNb = (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] = BABYLON.Vector3.Zero();
-                this._facetPositions[f] = BABYLON.Vector3.Zero();
+            data.facetNb = (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] = BABYLON.Vector3.Zero();
+                data.facetPositions[f] = BABYLON.Vector3.Zero();
             }
-            this._facetDataEnabled = true;
+            data.facetDataEnabled = true;
             return this;
         };
         /**
@@ -21257,21 +21265,22 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.updateFacetData = function () {
-            if (!this._facetDataEnabled) {
+            var data = this._facetData;
+            if (!data.facetDataEnabled) {
                 this._initFacetData();
             }
             var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var indices = this.getIndices();
             var normals = this.getVerticesData(BABYLON.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;
@@ -21282,66 +21291,66 @@ var BABYLON;
                         }
                     }
                     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 : BABYLON.Vector3.Zero();
+                    data.facetDepthSortFrom = (camera) ? camera.position : BABYLON.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);
-                }
-                this._invertedMatrix = BABYLON.Matrix.Identity();
-                this._facetDepthSortOrigin = BABYLON.Vector3.Zero();
-            }
-            this._bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > BABYLON.Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : BABYLON.Epsilon;
-            this._bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > BABYLON.Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : BABYLON.Epsilon;
-            this._bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > BABYLON.Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : BABYLON.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.depthSortedFacets.push(depthSortedFacet);
+                }
+                data.invertedMatrix = BABYLON.Matrix.Identity();
+                data.facetDepthSortOrigin = BABYLON.Vector3.Zero();
+            }
+            data.bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > BABYLON.Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : BABYLON.Epsilon;
+            data.bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > BABYLON.Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : BABYLON.Epsilon;
+            data.bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > BABYLON.Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : BABYLON.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);
-                BABYLON.Vector3.TransformCoordinatesToRef(this._facetDepthSortFrom, this._invertedMatrix, this._facetDepthSortOrigin);
-                this._facetParameters.distanceTo = this._facetDepthSortOrigin;
-            }
-            this._facetParameters.depthSortedFacets = this._depthSortedFacets;
-            BABYLON.VertexData.ComputeNormals(positions, indices, normals, this._facetParameters);
-            if (this._facetDepthSort && this._facetDepthSortEnabled) {
-                this._depthSortedFacets.sort(this._facetDepthSortFunction);
-                var l = (this._depthSortedIndices.length / 3) | 0;
+                this._worldMatrix.invertToRef(data.invertedMatrix);
+                BABYLON.Vector3.TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
+                data.facetParameters.distanceTo = data.facetDepthSortOrigin;
+            }
+            data.facetParameters.depthSortedFacets = data.depthSortedFacets;
+            BABYLON.VertexData.ComputeNormals(positions, indices, normals, data.facetParameters);
+            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;
         };
@@ -21352,10 +21361,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalNormals = function () {
-            if (!this._facetNormals) {
+            if (!this._facetData.facetNormals) {
                 this.updateFacetData();
             }
-            return this._facetNormals;
+            return this._facetData.facetNormals;
         };
         /**
          * Returns the facetLocalPositions array.
@@ -21364,10 +21373,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalPositions = function () {
-            if (!this._facetPositions) {
+            if (!this._facetData.facetPositions) {
                 this.updateFacetData();
             }
-            return this._facetPositions;
+            return this._facetData.facetPositions;
         };
         /**
          * Returns the facetLocalPartioning array
@@ -21375,10 +21384,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalPartitioning = function () {
-            if (!this._facetPartitioning) {
+            if (!this._facetData.facetPartitioning) {
                 this.updateFacetData();
             }
-            return this._facetPartitioning;
+            return this._facetData.facetPartitioning;
         };
         /**
          * Returns the i-th facet position in the world system.
@@ -21439,13 +21448,14 @@ var BABYLON;
          */
         AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
             var bInfo = this.getBoundingInfo();
-            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 data = this._facetData;
+            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];
         };
         /**
          * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
@@ -21545,7 +21555,7 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetDataParameters = function () {
-            return this._facetParameters;
+            return this._facetData.facetParameters;
         };
         /**
          * Disables the feature FacetData and frees the related memory
@@ -21553,13 +21563,13 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.disableFacetData = function () {
-            if (this._facetDataEnabled) {
-                this._facetDataEnabled = false;
-                this._facetPositions = new Array();
-                this._facetNormals = new Array();
-                this._facetPartitioning = new Array();
-                this._facetParameters = null;
-                this._depthSortedIndices = new Uint32Array(0);
+            if (this._facetData.facetDataEnabled) {
+                this._facetData.facetDataEnabled = false;
+                this._facetData.facetPositions = new Array();
+                this._facetData.facetNormals = new Array();
+                this._facetData.facetPartitioning = new Array();
+                this._facetData.facetParameters = null;
+                this._facetData.depthSortedIndices = new Uint32Array(0);
             }
             return this;
         };
@@ -24365,7 +24375,7 @@ var BABYLON;
          */
         function Scene(engine) {
             var _this = _super.call(this) || this;
-            // Members   
+            // Members
             /**
              * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
              */
@@ -24625,21 +24635,25 @@ var 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))
             */
             _this.fogColor = new BABYLON.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)
             */
             _this.fogDensity = 0.1;
             /**
             * Gets or sets the fog start distance to use
             * @see http://doc.babylonjs.com/babylon101/environment#fog
+            * (Default is 0)
             */
             _this.fogStart = 0;
             /**
             * Gets or sets the fog end distance to use
             * @see http://doc.babylonjs.com/babylon101/environment#fog
+            * (Default is 1000)
             */
             _this.fogEnd = 1000.0;
             // Lights
@@ -25119,6 +25133,7 @@ var 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)
             */
             set: function (value) {
                 if (this._fogEnabled === value) {
@@ -25137,6 +25152,12 @@ var 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 |
             */
             set: function (value) {
                 if (this._fogMode === value) {
@@ -26043,7 +26064,7 @@ var BABYLON;
                 _this._processPointerDown(pickResult, evt);
             };
             this._onPointerUp = function (evt) {
-                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.
                 }
                 _this._totalPointersPressed--;
@@ -26603,7 +26624,7 @@ var BABYLON;
             var originalValue = holder.originalValue;
             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;
             }
@@ -26706,7 +26727,7 @@ var BABYLON;
                             var startIndex = 0;
                             var 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);
                                 }

ファイルの差分が大きいため隠しています
+ 1 - 1
dist/preview release/babylon.worker.js


+ 134 - 113
dist/preview release/es6.js

@@ -19831,6 +19831,26 @@ var BABYLON;
         }
         return _OcclusionDataStorage;
     }());
+    /** @hidden */
+    var _FacetDataStorage = /** @class */ (function () {
+        function _FacetDataStorage() {
+            this.facetNb = 0; // facet number
+            this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space  
+            this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
+            this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
+            this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
+            this.bbSize = BABYLON.Vector3.Zero(); // bbox size approximated for facet data
+            this.subDiv = {
+                max: 1,
+                X: 1,
+                Y: 1,
+                Z: 1
+            };
+            this.facetDepthSort = false; // is the facet depth sort to be computed
+            this.facetDepthSortEnabled = false; // is the facet depth sort initialized
+        }
+        return _FacetDataStorage;
+    }());
     /**
      * Class used to store all common mesh properties
      */
@@ -19845,20 +19865,7 @@ var BABYLON;
         function AbstractMesh(name, scene) {
             if (scene === void 0) { scene = null; }
             var _this = _super.call(this, name, scene, false) || this;
-            _this._facetNb = 0; // facet number
-            _this._partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space  
-            _this._partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
-            _this._facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
-            _this._facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
-            _this._bbSize = BABYLON.Vector3.Zero(); // bbox size approximated for facet data
-            _this._subDiv = {
-                max: 1,
-                X: 1,
-                Y: 1,
-                Z: 1
-            };
-            _this._facetDepthSort = false; // is the facet depth sort to be computed
-            _this._facetDepthSortEnabled = false; // is the facet depth sort initialized
+            _this._facetData = new _FacetDataStorage();
             /** Gets ot sets the culling strategy to use to find visible meshes */
             _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
             // Events
@@ -20066,7 +20073,7 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
              */
             get: function () {
-                return this._facetNb;
+                return this._facetData.facetNb;
             },
             enumerable: true,
             configurable: true
@@ -20077,10 +20084,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
              */
             get: function () {
-                return this._partitioningSubdivisions;
+                return this._facetData.partitioningSubdivisions;
             },
             set: function (nb) {
-                this._partitioningSubdivisions = nb;
+                this._facetData.partitioningSubdivisions = nb;
             },
             enumerable: true,
             configurable: true
@@ -20092,10 +20099,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
              */
             get: function () {
-                return this._partitioningBBoxRatio;
+                return this._facetData.partitioningBBoxRatio;
             },
             set: function (ratio) {
-                this._partitioningBBoxRatio = ratio;
+                this._facetData.partitioningBBoxRatio = ratio;
             },
             enumerable: true,
             configurable: true
@@ -20108,10 +20115,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
              */
             get: function () {
-                return this._facetDepthSort;
+                return this._facetData.facetDepthSort;
             },
             set: function (sort) {
-                this._facetDepthSort = sort;
+                this._facetData.facetDepthSort = sort;
             },
             enumerable: true,
             configurable: true
@@ -20124,10 +20131,10 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
              */
             get: function () {
-                return this._facetDepthSortFrom;
+                return this._facetData.facetDepthSortFrom;
             },
             set: function (location) {
-                this._facetDepthSortFrom = location;
+                this._facetData.facetDepthSortFrom = location;
             },
             enumerable: true,
             configurable: true
@@ -20138,7 +20145,7 @@ var BABYLON;
              * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
              */
             get: function () {
-                return this._facetDataEnabled;
+                return this._facetData.facetDataEnabled;
             },
             enumerable: true,
             configurable: true
@@ -21200,7 +21207,7 @@ var BABYLON;
                 }
             }
             // facet data
-            if (this._facetDataEnabled) {
+            if (this._facetData.facetDataEnabled) {
                 this.disableFacetData();
             }
             this.onAfterWorldMatrixUpdateObservable.clear();
@@ -21230,23 +21237,24 @@ var BABYLON;
         // Facet data
         /** @hidden */
         AbstractMesh.prototype._initFacetData = function () {
-            if (!this._facetNormals) {
-                this._facetNormals = new Array();
+            var data = this._facetData;
+            if (!data.facetNormals) {
+                data.facetNormals = new Array();
             }
-            if (!this._facetPositions) {
-                this._facetPositions = new Array();
+            if (!data.facetPositions) {
+                data.facetPositions = new Array();
             }
-            if (!this._facetPartitioning) {
-                this._facetPartitioning = new Array();
+            if (!data.facetPartitioning) {
+                data.facetPartitioning = new Array();
             }
-            this._facetNb = (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] = BABYLON.Vector3.Zero();
-                this._facetPositions[f] = BABYLON.Vector3.Zero();
+            data.facetNb = (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] = BABYLON.Vector3.Zero();
+                data.facetPositions[f] = BABYLON.Vector3.Zero();
             }
-            this._facetDataEnabled = true;
+            data.facetDataEnabled = true;
             return this;
         };
         /**
@@ -21257,21 +21265,22 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.updateFacetData = function () {
-            if (!this._facetDataEnabled) {
+            var data = this._facetData;
+            if (!data.facetDataEnabled) {
                 this._initFacetData();
             }
             var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var indices = this.getIndices();
             var normals = this.getVerticesData(BABYLON.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;
@@ -21282,66 +21291,66 @@ var BABYLON;
                         }
                     }
                     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 : BABYLON.Vector3.Zero();
+                    data.facetDepthSortFrom = (camera) ? camera.position : BABYLON.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);
-                }
-                this._invertedMatrix = BABYLON.Matrix.Identity();
-                this._facetDepthSortOrigin = BABYLON.Vector3.Zero();
-            }
-            this._bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > BABYLON.Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : BABYLON.Epsilon;
-            this._bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > BABYLON.Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : BABYLON.Epsilon;
-            this._bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > BABYLON.Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : BABYLON.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.depthSortedFacets.push(depthSortedFacet);
+                }
+                data.invertedMatrix = BABYLON.Matrix.Identity();
+                data.facetDepthSortOrigin = BABYLON.Vector3.Zero();
+            }
+            data.bbSize.x = (bInfo.maximum.x - bInfo.minimum.x > BABYLON.Epsilon) ? bInfo.maximum.x - bInfo.minimum.x : BABYLON.Epsilon;
+            data.bbSize.y = (bInfo.maximum.y - bInfo.minimum.y > BABYLON.Epsilon) ? bInfo.maximum.y - bInfo.minimum.y : BABYLON.Epsilon;
+            data.bbSize.z = (bInfo.maximum.z - bInfo.minimum.z > BABYLON.Epsilon) ? bInfo.maximum.z - bInfo.minimum.z : BABYLON.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);
-                BABYLON.Vector3.TransformCoordinatesToRef(this._facetDepthSortFrom, this._invertedMatrix, this._facetDepthSortOrigin);
-                this._facetParameters.distanceTo = this._facetDepthSortOrigin;
-            }
-            this._facetParameters.depthSortedFacets = this._depthSortedFacets;
-            BABYLON.VertexData.ComputeNormals(positions, indices, normals, this._facetParameters);
-            if (this._facetDepthSort && this._facetDepthSortEnabled) {
-                this._depthSortedFacets.sort(this._facetDepthSortFunction);
-                var l = (this._depthSortedIndices.length / 3) | 0;
+                this._worldMatrix.invertToRef(data.invertedMatrix);
+                BABYLON.Vector3.TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
+                data.facetParameters.distanceTo = data.facetDepthSortOrigin;
+            }
+            data.facetParameters.depthSortedFacets = data.depthSortedFacets;
+            BABYLON.VertexData.ComputeNormals(positions, indices, normals, data.facetParameters);
+            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;
         };
@@ -21352,10 +21361,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalNormals = function () {
-            if (!this._facetNormals) {
+            if (!this._facetData.facetNormals) {
                 this.updateFacetData();
             }
-            return this._facetNormals;
+            return this._facetData.facetNormals;
         };
         /**
          * Returns the facetLocalPositions array.
@@ -21364,10 +21373,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalPositions = function () {
-            if (!this._facetPositions) {
+            if (!this._facetData.facetPositions) {
                 this.updateFacetData();
             }
-            return this._facetPositions;
+            return this._facetData.facetPositions;
         };
         /**
          * Returns the facetLocalPartioning array
@@ -21375,10 +21384,10 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetLocalPartitioning = function () {
-            if (!this._facetPartitioning) {
+            if (!this._facetData.facetPartitioning) {
                 this.updateFacetData();
             }
-            return this._facetPartitioning;
+            return this._facetData.facetPartitioning;
         };
         /**
          * Returns the i-th facet position in the world system.
@@ -21439,13 +21448,14 @@ var BABYLON;
          */
         AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
             var bInfo = this.getBoundingInfo();
-            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 data = this._facetData;
+            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];
         };
         /**
          * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
@@ -21545,7 +21555,7 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.getFacetDataParameters = function () {
-            return this._facetParameters;
+            return this._facetData.facetParameters;
         };
         /**
          * Disables the feature FacetData and frees the related memory
@@ -21553,13 +21563,13 @@ var BABYLON;
          * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
          */
         AbstractMesh.prototype.disableFacetData = function () {
-            if (this._facetDataEnabled) {
-                this._facetDataEnabled = false;
-                this._facetPositions = new Array();
-                this._facetNormals = new Array();
-                this._facetPartitioning = new Array();
-                this._facetParameters = null;
-                this._depthSortedIndices = new Uint32Array(0);
+            if (this._facetData.facetDataEnabled) {
+                this._facetData.facetDataEnabled = false;
+                this._facetData.facetPositions = new Array();
+                this._facetData.facetNormals = new Array();
+                this._facetData.facetPartitioning = new Array();
+                this._facetData.facetParameters = null;
+                this._facetData.depthSortedIndices = new Uint32Array(0);
             }
             return this;
         };
@@ -24365,7 +24375,7 @@ var BABYLON;
          */
         function Scene(engine) {
             var _this = _super.call(this) || this;
-            // Members   
+            // Members
             /**
              * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
              */
@@ -24625,21 +24635,25 @@ var 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))
             */
             _this.fogColor = new BABYLON.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)
             */
             _this.fogDensity = 0.1;
             /**
             * Gets or sets the fog start distance to use
             * @see http://doc.babylonjs.com/babylon101/environment#fog
+            * (Default is 0)
             */
             _this.fogStart = 0;
             /**
             * Gets or sets the fog end distance to use
             * @see http://doc.babylonjs.com/babylon101/environment#fog
+            * (Default is 1000)
             */
             _this.fogEnd = 1000.0;
             // Lights
@@ -25119,6 +25133,7 @@ var 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)
             */
             set: function (value) {
                 if (this._fogEnabled === value) {
@@ -25137,6 +25152,12 @@ var 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 |
             */
             set: function (value) {
                 if (this._fogMode === value) {
@@ -26043,7 +26064,7 @@ var BABYLON;
                 _this._processPointerDown(pickResult, evt);
             };
             this._onPointerUp = function (evt) {
-                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.
                 }
                 _this._totalPointersPressed--;
@@ -26603,7 +26624,7 @@ var BABYLON;
             var originalValue = holder.originalValue;
             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;
             }
@@ -26706,7 +26727,7 @@ var BABYLON;
                             var startIndex = 0;
                             var 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);
                                 }

+ 145 - 10
src/Engine/Extensions/babylon.engine.occlusionQuery.ts

@@ -1,4 +1,25 @@
 module BABYLON {
+    /** @hidden */
+    class _OcclusionDataStorage {
+        /** @hidden */
+        public occlusionInternalRetryCounter = 0;
+
+        /** @hidden */
+        public isOcclusionQueryInProgress = false;
+
+        /** @hidden */
+        public isOccluded = false;
+
+        /** @hidden */
+        public occlusionRetryCount = -1;
+
+        /** @hidden */
+        public occlusionType = AbstractMesh.OCCLUSION_TYPE_NONE;
+
+        /** @hidden */
+        public occlusionQueryAlgorithmType = AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
+    }
+
     export interface Engine {       
         /**
          * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
@@ -248,25 +269,138 @@ module BABYLON {
         return algorithmType === AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
     }
 
+    export interface AbstractMesh {
+        /**
+         * Backing filed 
+         * @hidden 
+         */
+        __occlusionDataStorage: _OcclusionDataStorage;
+
+        /**
+         * Access property
+         * @hidden
+         */
+        _occlusionDataStorage: _OcclusionDataStorage;
+
+        /**
+        * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
+        * The default value is -1 which means don't break the query and wait till the result
+        * @see http://doc.babylonjs.com/features/occlusionquery
+        */
+        occlusionRetryCount: number;
+
+        /**
+         * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
+         * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
+         * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
+         * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
+         * @see http://doc.babylonjs.com/features/occlusionquery
+         */
+        occlusionType: number;
+
+        /**
+        * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
+        * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
+        * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
+        * @see http://doc.babylonjs.com/features/occlusionquery
+        */
+        occlusionQueryAlgorithmType: number; 
+
+        /**
+        * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
+        * @see http://doc.babylonjs.com/features/occlusionquery
+        */
+       isOccluded: boolean;
+
+        /**
+         * Flag to check the progress status of the query
+         * @see http://doc.babylonjs.com/features/occlusionquery
+         */
+        isOcclusionQueryInProgress: boolean;
+    }
+
+    Object.defineProperty(AbstractMesh.prototype, "isOcclusionQueryInProgress", {
+        get: function (this:AbstractMesh) {
+            return this._occlusionDataStorage.isOcclusionQueryInProgress;
+        },
+        enumerable: false,
+        configurable: true
+    });  
+
+    Object.defineProperty(AbstractMesh.prototype, "_occlusionDataStorage", {
+        get: function (this:AbstractMesh) {
+            if (!this.__occlusionDataStorage) {
+                this.__occlusionDataStorage = new _OcclusionDataStorage();
+            }
+            return this.__occlusionDataStorage;
+        },
+        enumerable: false,
+        configurable: true
+    });     
+
+    Object.defineProperty(AbstractMesh.prototype, "isOccluded", {
+        get: function (this:AbstractMesh) {
+            return this._occlusionDataStorage.isOccluded;
+        },
+        set: function(this:AbstractMesh, value: boolean) {
+            this._occlusionDataStorage.isOccluded = value;
+        },
+        enumerable: true,
+        configurable: true
+    });     
+
+    Object.defineProperty(AbstractMesh.prototype, "occlusionQueryAlgorithmType", {
+        get: function (this:AbstractMesh) {
+            return this._occlusionDataStorage.occlusionQueryAlgorithmType;
+        },
+        set: function(this:AbstractMesh, value: number) {
+            this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
+        },
+        enumerable: true,
+        configurable: true
+    });  
+
+    Object.defineProperty(AbstractMesh.prototype, "occlusionType", {
+        get: function (this:AbstractMesh) {
+            return this._occlusionDataStorage.occlusionType;
+        },
+        set: function(this:AbstractMesh, value: number) {
+            this._occlusionDataStorage.occlusionType = value;
+        },
+        enumerable: true,
+        configurable: true
+    });    
+
+    Object.defineProperty(AbstractMesh.prototype, "occlusionRetryCount", {
+        get: function (this:AbstractMesh) {
+            return this._occlusionDataStorage.occlusionRetryCount;
+        },
+        set: function(this:AbstractMesh, value: number) {
+            this._occlusionDataStorage.occlusionRetryCount = value;
+        },
+        enumerable: true,
+        configurable: true
+    });
+
     // We also need to update AbstractMesh as there is a portion of the code there
     AbstractMesh.prototype._checkOcclusionQuery = function() {
         let dataStorage = this._occlusionDataStorage;
 
-        if (this.occlusionType === AbstractMesh.OCCLUSION_TYPE_NONE) {
+        if (dataStorage.occlusionType === AbstractMesh.OCCLUSION_TYPE_NONE) {
             dataStorage.isOccluded = false;
-            return;
+            return false;
         }
 
         var engine = this.getEngine();
 
         if (engine.webGLVersion < 2) {
             dataStorage.isOccluded = false;
-            return;
+            return false;
         }
 
         if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
             dataStorage.isOccluded = false;
-            return;
+            return false;
         }
 
         if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
@@ -283,18 +417,17 @@ module BABYLON {
 
                 dataStorage.occlusionInternalRetryCounter++;
 
-                if (this.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > this.occlusionRetryCount) {
+                if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
                     dataStorage.isOcclusionQueryInProgress = false;
                     dataStorage.occlusionInternalRetryCounter = 0;
 
                     // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
                     // if strict continue the last state of the object.
-                    dataStorage.isOccluded = this.occlusionType === AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
+                    dataStorage.isOccluded = dataStorage.occlusionType === AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
                 }
                 else {
-                    return;
+                    return false;
                 }
-
             }
         }
 
@@ -306,10 +439,12 @@ module BABYLON {
                 this._occlusionQuery = engine.createQuery();
             }
 
-            engine.beginOcclusionQuery(this.occlusionQueryAlgorithmType, this._occlusionQuery);
+            engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
             occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
-            engine.endOcclusionQuery(this.occlusionQueryAlgorithmType);
+            engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
             this._occlusionDataStorage.isOcclusionQueryInProgress = true;
         }
+
+        return dataStorage.isOccluded;
     } 
 }

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

@@ -1,17 +1,4 @@
 module BABYLON {
-<<<<<<< HEAD
-
-    /** @hidden */
-    class _OcclusionDataStorage {
-        /** @hidden */
-        public occlusionInternalRetryCounter = 0;
-
-        /** @hidden */
-        public isOccluded = false;
-
-        /** @hidden */
-        public isOcclusionQueryInProgress = false;
-=======
     /** @hidden */
     class _FacetDataStorage {
         // facetData private properties
@@ -40,7 +27,6 @@
         public facetDepthSortOrigin: Vector3;                             // same as facetDepthSortFrom but expressed in the mesh local space
         
         public invertedMatrix: Matrix; // Inverted world matrix.
->>>>>>> master
     }
 
     /**
@@ -210,53 +196,6 @@
          */
         public definedFacingForward = true; 
 
-        /**
-        * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
-        * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
-        * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
-        * @see http://doc.babylonjs.com/features/occlusionquery
-        */
-        public occlusionQueryAlgorithmType = AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
-
-        /**
-         * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
-         * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
-         * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
-         * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
-         * @see http://doc.babylonjs.com/features/occlusionquery
-         */
-        public occlusionType = AbstractMesh.OCCLUSION_TYPE_NONE;
-
-        /**
-        * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
-        * The default value is -1 which means don't break the query and wait till the result
-        * @see http://doc.babylonjs.com/features/occlusionquery
-        */
-        public occlusionRetryCount = -1;
-
-        /** @hidden */
-        public _occlusionDataStorage: _OcclusionDataStorage;
-
-        /**
-        * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
-        * @see http://doc.babylonjs.com/features/occlusionquery
-        */
-        public get isOccluded(): boolean {
-            return this._occlusionDataStorage.isOccluded;
-        }
-
-        public set isOccluded(value: boolean) {
-            this._occlusionDataStorage.isOccluded = value;
-        }
-
-        /**
-         * Flag to check the progress status of the query
-         * @see http://doc.babylonjs.com/features/occlusionquery
-         */
-        public get isOcclusionQueryInProgress(): boolean {
-            return this._occlusionDataStorage.isOcclusionQueryInProgress;
-        }
-
         /** @hidden */
         public _occlusionQuery: Nullable<WebGLQuery>;
 
@@ -1498,7 +1437,7 @@
             // Query
             let engine = this.getScene().getEngine();
             if (this._occlusionQuery) {
-                this._occlusionDataStorage.isOcclusionQueryInProgress = false;
+                this.isOcclusionQueryInProgress = false;
                 engine.deleteQuery(this._occlusionQuery);
                 this._occlusionQuery = null;
             }
@@ -1969,8 +1908,8 @@
         }
 
         /** @hidden */
-        public _checkOcclusionQuery() { // Will be replaced by correct code if Occlusion queries are referenced
-            this._occlusionDataStorage.isOccluded = false;
+        public _checkOcclusionQuery(): boolean { // Will be replaced by correct code if Occlusion queries are referenced
+            return false;
         }
     }
 }

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

@@ -1480,9 +1480,7 @@
          * @returns the current mesh
          */
         public render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh {
-
-            this._checkOcclusionQuery();
-            if (this._occlusionDataStorage.isOccluded) {
+            if (this._checkOcclusionQuery()) {
                 return this;
             }