David Catuhe 7 years ago
parent
commit
9ef7911a44

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


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


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


+ 35 - 2
dist/preview release/babylon.max.js

@@ -12115,6 +12115,20 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
+        Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
+            /**
+             * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
+             * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
+             */
+            get: function () {
+                return this._doNotHandleContextLost;
+            },
+            set: function (value) {
+                this._doNotHandleContextLost = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
             /**
             /**
              * Gets the performance monitor attached to this engine
              * Gets the performance monitor attached to this engine
@@ -28281,6 +28295,25 @@ var BABYLON;
                 this.soundTracks[scIndex].dispose();
                 this.soundTracks[scIndex].dispose();
             }
             }
         };
         };
+        /**
+         * Call this function to reduce memory footprint of the scene.
+         * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
+         */
+        Scene.prototype.clearCachedVertexData = function () {
+            for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
+                var mesh = this.meshes[meshIndex];
+                var geometry = mesh.geometry;
+                if (geometry) {
+                    geometry._indices = [];
+                    for (var vbName in geometry._vertexBuffers) {
+                        if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
+                            continue;
+                        }
+                        geometry._vertexBuffers[vbName]._buffer._data = null;
+                    }
+                }
+            }
+        };
         // Octrees
         // Octrees
         /**
         /**
          * Get the world extend vectors with an optional filter
          * Get the world extend vectors with an optional filter
@@ -39468,11 +39501,11 @@ var BABYLON;
         Geometry.prototype._generatePointsArray = function () {
         Geometry.prototype._generatePointsArray = function () {
             if (this._positions)
             if (this._positions)
                 return true;
                 return true;
-            this._positions = [];
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
-            if (!data) {
+            if (!data || data.length === 0) {
                 return false;
                 return false;
             }
             }
+            this._positions = [];
             for (var index = 0; index < data.length; index += 3) {
             for (var index = 0; index < data.length; index += 3) {
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
             }
             }

+ 35 - 2
dist/preview release/babylon.no-module.max.js

@@ -12082,6 +12082,20 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
+        Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
+            /**
+             * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
+             * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
+             */
+            get: function () {
+                return this._doNotHandleContextLost;
+            },
+            set: function (value) {
+                this._doNotHandleContextLost = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
             /**
             /**
              * Gets the performance monitor attached to this engine
              * Gets the performance monitor attached to this engine
@@ -28248,6 +28262,25 @@ var BABYLON;
                 this.soundTracks[scIndex].dispose();
                 this.soundTracks[scIndex].dispose();
             }
             }
         };
         };
+        /**
+         * Call this function to reduce memory footprint of the scene.
+         * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
+         */
+        Scene.prototype.clearCachedVertexData = function () {
+            for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
+                var mesh = this.meshes[meshIndex];
+                var geometry = mesh.geometry;
+                if (geometry) {
+                    geometry._indices = [];
+                    for (var vbName in geometry._vertexBuffers) {
+                        if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
+                            continue;
+                        }
+                        geometry._vertexBuffers[vbName]._buffer._data = null;
+                    }
+                }
+            }
+        };
         // Octrees
         // Octrees
         /**
         /**
          * Get the world extend vectors with an optional filter
          * Get the world extend vectors with an optional filter
@@ -39435,11 +39468,11 @@ var BABYLON;
         Geometry.prototype._generatePointsArray = function () {
         Geometry.prototype._generatePointsArray = function () {
             if (this._positions)
             if (this._positions)
                 return true;
                 return true;
-            this._positions = [];
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
-            if (!data) {
+            if (!data || data.length === 0) {
                 return false;
                 return false;
             }
             }
+            this._positions = [];
             for (var index = 0; index < data.length; index += 3) {
             for (var index = 0; index < data.length; index += 3) {
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
             }
             }

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


+ 35 - 2
dist/preview release/es6.js

@@ -12082,6 +12082,20 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
+        Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
+            /**
+             * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
+             * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
+             */
+            get: function () {
+                return this._doNotHandleContextLost;
+            },
+            set: function (value) {
+                this._doNotHandleContextLost = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
             /**
             /**
              * Gets the performance monitor attached to this engine
              * Gets the performance monitor attached to this engine
@@ -28248,6 +28262,25 @@ var BABYLON;
                 this.soundTracks[scIndex].dispose();
                 this.soundTracks[scIndex].dispose();
             }
             }
         };
         };
+        /**
+         * Call this function to reduce memory footprint of the scene.
+         * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
+         */
+        Scene.prototype.clearCachedVertexData = function () {
+            for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
+                var mesh = this.meshes[meshIndex];
+                var geometry = mesh.geometry;
+                if (geometry) {
+                    geometry._indices = [];
+                    for (var vbName in geometry._vertexBuffers) {
+                        if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
+                            continue;
+                        }
+                        geometry._vertexBuffers[vbName]._buffer._data = null;
+                    }
+                }
+            }
+        };
         // Octrees
         // Octrees
         /**
         /**
          * Get the world extend vectors with an optional filter
          * Get the world extend vectors with an optional filter
@@ -39435,11 +39468,11 @@ var BABYLON;
         Geometry.prototype._generatePointsArray = function () {
         Geometry.prototype._generatePointsArray = function () {
             if (this._positions)
             if (this._positions)
                 return true;
                 return true;
-            this._positions = [];
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
-            if (!data) {
+            if (!data || data.length === 0) {
                 return false;
                 return false;
             }
             }
+            this._positions = [];
             for (var index = 0; index < data.length; index += 3) {
             for (var index = 0; index < data.length; index += 3) {
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
             }
             }

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


+ 35 - 2
dist/preview release/viewer/babylon.viewer.max.js

@@ -12203,6 +12203,20 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
+        Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
+            /**
+             * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
+             * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
+             */
+            get: function () {
+                return this._doNotHandleContextLost;
+            },
+            set: function (value) {
+                this._doNotHandleContextLost = value;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
         Object.defineProperty(Engine.prototype, "performanceMonitor", {
             /**
             /**
              * Gets the performance monitor attached to this engine
              * Gets the performance monitor attached to this engine
@@ -28369,6 +28383,25 @@ var BABYLON;
                 this.soundTracks[scIndex].dispose();
                 this.soundTracks[scIndex].dispose();
             }
             }
         };
         };
+        /**
+         * Call this function to reduce memory footprint of the scene.
+         * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
+         */
+        Scene.prototype.clearCachedVertexData = function () {
+            for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
+                var mesh = this.meshes[meshIndex];
+                var geometry = mesh.geometry;
+                if (geometry) {
+                    geometry._indices = [];
+                    for (var vbName in geometry._vertexBuffers) {
+                        if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
+                            continue;
+                        }
+                        geometry._vertexBuffers[vbName]._buffer._data = null;
+                    }
+                }
+            }
+        };
         // Octrees
         // Octrees
         /**
         /**
          * Get the world extend vectors with an optional filter
          * Get the world extend vectors with an optional filter
@@ -39556,11 +39589,11 @@ var BABYLON;
         Geometry.prototype._generatePointsArray = function () {
         Geometry.prototype._generatePointsArray = function () {
             if (this._positions)
             if (this._positions)
                 return true;
                 return true;
-            this._positions = [];
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
             var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
-            if (!data) {
+            if (!data || data.length === 0) {
                 return false;
                 return false;
             }
             }
+            this._positions = [];
             for (var index = 0; index < data.length; index += 3) {
             for (var index = 0; index < data.length; index += 3) {
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
                 this._positions.push(BABYLON.Vector3.FromArray(data, index));
             }
             }

+ 12 - 0
src/Engine/babylon.engine.ts

@@ -987,6 +987,18 @@
         private _contextWasLost = false;
         private _contextWasLost = false;
         private _doNotHandleContextLost = false;
         private _doNotHandleContextLost = false;
 
 
+        /**
+         * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
+         * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
+         */
+        public get doNotHandleContextLost(): boolean {
+            return this._doNotHandleContextLost;
+        }
+
+        public set doNotHandleContextLost(value: boolean) {
+            this._doNotHandleContextLost = value;
+        }
+
         // FPS
         // FPS
         private _performanceMonitor = new PerformanceMonitor();
         private _performanceMonitor = new PerformanceMonitor();
         private _fps = 60;
         private _fps = 60;