12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import defined from "../Core/defined.js";
- import DoublyLinkedList from "../Core/DoublyLinkedList.js";
- function Cesium3DTilesetCache() {
-
-
- this._list = new DoublyLinkedList();
- this._sentinel = this._list.add();
- this._trimTiles = false;
- }
- Cesium3DTilesetCache.prototype.reset = function () {
-
-
-
- this._list.splice(this._list.tail, this._sentinel);
- };
- Cesium3DTilesetCache.prototype.touch = function (tile) {
- var node = tile.cacheNode;
- if (defined(node)) {
- this._list.splice(this._sentinel, node);
- }
- };
- Cesium3DTilesetCache.prototype.add = function (tile) {
- if (!defined(tile.cacheNode)) {
- tile.cacheNode = this._list.add(tile);
- }
- };
- Cesium3DTilesetCache.prototype.unloadTile = function (
- tileset,
- tile,
- unloadCallback
- ) {
- var node = tile.cacheNode;
- if (!defined(node)) {
- return;
- }
- this._list.remove(node);
- tile.cacheNode = undefined;
- unloadCallback(tileset, tile);
- };
- Cesium3DTilesetCache.prototype.unloadTiles = function (
- tileset,
- unloadCallback
- ) {
- var trimTiles = this._trimTiles;
- this._trimTiles = false;
- var list = this._list;
- var maximumMemoryUsageInBytes = tileset.maximumMemoryUsage * 1024 * 1024;
-
-
-
-
- var sentinel = this._sentinel;
- var node = list.head;
- while (
- node !== sentinel &&
- (tileset.totalMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)
- ) {
- var tile = node.item;
- node = node.next;
- this.unloadTile(tileset, tile, unloadCallback);
- }
- };
- Cesium3DTilesetCache.prototype.trim = function () {
- this._trimTiles = true;
- };
- export default Cesium3DTilesetCache;
|