@loaders.gl/tiles 4.0.0-alpha.9 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/dist.min.js +149 -81
  2. package/dist/es5/tileset/tileset-3d.js +5 -1
  3. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  4. package/dist/es5/tileset/tileset-traverser.js +1 -1
  5. package/dist/es5/tileset/tileset-traverser.js.map +1 -1
  6. package/dist/esm/tileset/tileset-3d.js +5 -1
  7. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  8. package/dist/esm/tileset/tileset-traverser.js +1 -1
  9. package/dist/esm/tileset/tileset-traverser.js.map +1 -1
  10. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  11. package/package.json +4 -4
  12. package/src/tileset/tileset-3d.ts +7 -1
  13. package/src/tileset/tileset-traverser.ts +1 -1
  14. package/dist/bundle.js +0 -5
  15. package/dist/constants.js +0 -39
  16. package/dist/index.js +0 -26
  17. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js +0 -54
  18. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js +0 -47
  19. package/dist/tileset/format-i3s/i3s-tile-manager.js +0 -80
  20. package/dist/tileset/format-i3s/i3s-tileset-traverser.js +0 -92
  21. package/dist/tileset/helpers/3d-tiles-options.js +0 -9
  22. package/dist/tileset/helpers/bounding-volume.js +0 -293
  23. package/dist/tileset/helpers/frame-state.js +0 -133
  24. package/dist/tileset/helpers/i3s-lod.js +0 -85
  25. package/dist/tileset/helpers/tiles-3d-lod.js +0 -117
  26. package/dist/tileset/helpers/transform-utils.js +0 -53
  27. package/dist/tileset/helpers/zoom.js +0 -89
  28. package/dist/tileset/tile-3d.js +0 -610
  29. package/dist/tileset/tileset-3d.js +0 -715
  30. package/dist/tileset/tileset-cache.js +0 -72
  31. package/dist/tileset/tileset-traverser.js +0 -300
  32. package/dist/types.js +0 -2
  33. package/dist/utils/doubly-linked-list-node.js +0 -18
  34. package/dist/utils/doubly-linked-list.js +0 -97
  35. package/dist/utils/managed-array.js +0 -152
@@ -1,72 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TilesetCache = void 0;
5
- const doubly_linked_list_1 = require("../utils/doubly-linked-list");
6
- /**
7
- * Stores tiles with content loaded.
8
- * @private
9
- */
10
- class TilesetCache {
11
- constructor() {
12
- // [head, sentinel) -> tiles that weren't selected this frame and may be removed from the cache
13
- // (sentinel, tail] -> tiles that were selected this frame
14
- this._list = new doubly_linked_list_1.DoublyLinkedList();
15
- this._sentinel = this._list.add('sentinel');
16
- this._trimTiles = false;
17
- }
18
- reset() {
19
- // Move sentinel node to the tail so, at the start of the frame, all tiles
20
- // may be potentially replaced. Tiles are moved to the right of the sentinel
21
- // when they are selected so they will not be replaced.
22
- this._list.splice(this._list.tail, this._sentinel);
23
- }
24
- touch(tile) {
25
- const node = tile._cacheNode;
26
- if (node) {
27
- this._list.splice(this._sentinel, node);
28
- }
29
- }
30
- add(tileset, tile, addCallback) {
31
- if (!tile._cacheNode) {
32
- tile._cacheNode = this._list.add(tile);
33
- if (addCallback) {
34
- addCallback(tileset, tile);
35
- }
36
- }
37
- }
38
- unloadTile(tileset, tile, unloadCallback) {
39
- const node = tile._cacheNode;
40
- if (!node) {
41
- return;
42
- }
43
- this._list.remove(node);
44
- tile._cacheNode = null;
45
- if (unloadCallback) {
46
- unloadCallback(tileset, tile);
47
- }
48
- }
49
- unloadTiles(tileset, unloadCallback) {
50
- const trimTiles = this._trimTiles;
51
- this._trimTiles = false;
52
- const list = this._list;
53
- const maximumMemoryUsageInBytes = tileset.maximumMemoryUsage * 1024 * 1024;
54
- // Traverse the list only to the sentinel since tiles/nodes to the
55
- // right of the sentinel were used this frame.
56
- // The sub-list to the left of the sentinel is ordered from LRU to MRU.
57
- const sentinel = this._sentinel;
58
- let node = list.head;
59
- while (node !== sentinel &&
60
- (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)) {
61
- // @ts-expect-error
62
- const tile = node.item;
63
- // @ts-expect-error
64
- node = node.next;
65
- this.unloadTile(tileset, tile, unloadCallback);
66
- }
67
- }
68
- trim() {
69
- this._trimTiles = true;
70
- }
71
- }
72
- exports.TilesetCache = TilesetCache;
@@ -1,300 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.TilesetTraverser = exports.DEFAULT_PROPS = void 0;
5
- const managed_array_1 = require("../utils/managed-array");
6
- const constants_1 = require("../constants");
7
- exports.DEFAULT_PROPS = {
8
- loadSiblings: false,
9
- skipLevelOfDetail: false,
10
- maximumScreenSpaceError: 2,
11
- updateTransforms: true,
12
- onTraversalEnd: () => { },
13
- viewportTraversersMap: {},
14
- basePath: ''
15
- };
16
- class TilesetTraverser {
17
- // RESULT
18
- traversalFinished(frameState) {
19
- return true;
20
- }
21
- // TODO nested props
22
- constructor(options) {
23
- // fulfill in traverse call
24
- this.root = null;
25
- // tiles should be rendered
26
- this.selectedTiles = {};
27
- // tiles should be loaded from server
28
- this.requestedTiles = {};
29
- // tiles does not have render content
30
- this.emptyTiles = {};
31
- this.lastUpdate = new Date().getTime();
32
- this.updateDebounceTime = 1000;
33
- /** temporary storage to hold the traversed tiles during a traversal */
34
- this._traversalStack = new managed_array_1.ManagedArray();
35
- this._emptyTraversalStack = new managed_array_1.ManagedArray();
36
- /** set in every traverse cycle */
37
- this._frameNumber = null;
38
- this.options = { ...exports.DEFAULT_PROPS, ...options };
39
- }
40
- // tiles should be visible
41
- traverse(root, frameState, options) {
42
- this.root = root; // for root screen space error
43
- this.options = { ...this.options, ...options };
44
- // reset result
45
- this.reset();
46
- // update tile (visibility and expiration)
47
- this.updateTile(root, frameState);
48
- this._frameNumber = frameState.frameNumber;
49
- this.executeTraversal(root, frameState);
50
- }
51
- reset() {
52
- this.requestedTiles = {};
53
- this.selectedTiles = {};
54
- this.emptyTiles = {};
55
- this._traversalStack.reset();
56
- this._emptyTraversalStack.reset();
57
- }
58
- /**
59
- * Execute traverse
60
- * Depth-first traversal that traverses all visible tiles and marks tiles for selection.
61
- * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
62
- * This is the traditional replacement refinement approach and is called the base traversal.
63
- * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
64
- * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
65
- * and rendering children and parent tiles simultaneously.
66
- */
67
- /* eslint-disable-next-line complexity, max-statements */
68
- executeTraversal(root, frameState) {
69
- // stack to store traversed tiles, only visible tiles should be added to stack
70
- // visible: visible in the current view frustum
71
- const stack = this._traversalStack;
72
- root._selectionDepth = 1;
73
- stack.push(root);
74
- while (stack.length > 0) {
75
- // 1. pop tile
76
- const tile = stack.pop();
77
- // 2. check if tile needs to be refine, needs refine if a tile's LoD is not sufficient and tile has available children (available content)
78
- let shouldRefine = false;
79
- if (this.canTraverse(tile, frameState)) {
80
- this.updateChildTiles(tile, frameState);
81
- shouldRefine = this.updateAndPushChildren(tile, frameState, stack, tile.hasRenderContent ? tile._selectionDepth + 1 : tile._selectionDepth);
82
- }
83
- // 3. decide if should render (select) this tile
84
- // - tile does not have render content
85
- // - tile has render content and tile is `add` type (pointcloud)
86
- // - tile has render content and tile is `replace` type (photogrammetry) and can't refine any further
87
- const parent = tile.parent;
88
- const parentRefines = Boolean(!parent || parent._shouldRefine);
89
- const stoppedRefining = !shouldRefine;
90
- if (!tile.hasRenderContent) {
91
- this.emptyTiles[tile.id] = tile;
92
- this.loadTile(tile, frameState);
93
- if (stoppedRefining) {
94
- this.selectTile(tile, frameState);
95
- }
96
- // additive tiles
97
- }
98
- else if (tile.refine === constants_1.TILE_REFINEMENT.ADD) {
99
- // Additive tiles are always loaded and selected
100
- this.loadTile(tile, frameState);
101
- this.selectTile(tile, frameState);
102
- // replace tiles
103
- }
104
- else if (tile.refine === constants_1.TILE_REFINEMENT.REPLACE) {
105
- // Always load tiles in the base traversal
106
- // Select tiles that can't refine further
107
- this.loadTile(tile, frameState);
108
- if (stoppedRefining) {
109
- this.selectTile(tile, frameState);
110
- }
111
- }
112
- // 3. update cache, most recent touched tiles have higher priority to be fetched from server
113
- this.touchTile(tile, frameState);
114
- // 4. update tile refine prop and parent refinement status to trickle down to the descendants
115
- tile._shouldRefine = shouldRefine && parentRefines;
116
- }
117
- const newTime = new Date().getTime();
118
- if (this.traversalFinished(frameState) || newTime - this.lastUpdate > this.updateDebounceTime) {
119
- this.lastUpdate = newTime;
120
- this.options.onTraversalEnd(frameState);
121
- }
122
- }
123
- updateChildTiles(tile, frameState) {
124
- const children = tile.children;
125
- for (const child of children) {
126
- this.updateTile(child, frameState);
127
- }
128
- }
129
- /* eslint-disable complexity, max-statements */
130
- updateAndPushChildren(tile, frameState, stack, depth) {
131
- const { loadSiblings, skipLevelOfDetail } = this.options;
132
- const children = tile.children;
133
- // sort children tiles
134
- children.sort(this.compareDistanceToCamera.bind(this));
135
- // For traditional replacement refinement only refine if all children are loaded.
136
- // Empty tiles are exempt since it looks better if children stream in as they are loaded to fill the empty space.
137
- const checkRefines = tile.refine === constants_1.TILE_REFINEMENT.REPLACE && tile.hasRenderContent && !skipLevelOfDetail;
138
- let hasVisibleChild = false;
139
- let refines = true;
140
- for (const child of children) {
141
- child._selectionDepth = depth;
142
- if (child.isVisibleAndInRequestVolume) {
143
- if (stack.find(child)) {
144
- stack.delete(child);
145
- }
146
- stack.push(child);
147
- hasVisibleChild = true;
148
- }
149
- else if (checkRefines || loadSiblings) {
150
- // Keep non-visible children loaded since they are still needed before the parent can refine.
151
- // Or loadSiblings is true so always load tiles regardless of visibility.
152
- this.loadTile(child, frameState);
153
- this.touchTile(child, frameState);
154
- }
155
- if (checkRefines) {
156
- let childRefines;
157
- if (!child._inRequestVolume) {
158
- childRefines = false;
159
- }
160
- else if (!child.hasRenderContent) {
161
- childRefines = this.executeEmptyTraversal(child, frameState);
162
- }
163
- else {
164
- childRefines = child.contentAvailable;
165
- }
166
- refines = refines && childRefines;
167
- if (!refines) {
168
- return false;
169
- }
170
- }
171
- }
172
- if (!hasVisibleChild) {
173
- refines = false;
174
- }
175
- return refines;
176
- }
177
- /* eslint-enable complexity, max-statements */
178
- updateTile(tile, frameState) {
179
- this.updateTileVisibility(tile, frameState);
180
- }
181
- // tile to render in the browser
182
- selectTile(tile, frameState) {
183
- if (this.shouldSelectTile(tile)) {
184
- // The tile can be selected right away and does not require traverseAndSelect
185
- tile._selectedFrame = frameState.frameNumber;
186
- this.selectedTiles[tile.id] = tile;
187
- }
188
- }
189
- // tile to load from server
190
- loadTile(tile, frameState) {
191
- if (this.shouldLoadTile(tile)) {
192
- tile._requestedFrame = frameState.frameNumber;
193
- tile._priority = tile._getPriority();
194
- this.requestedTiles[tile.id] = tile;
195
- }
196
- }
197
- // cache tile
198
- touchTile(tile, frameState) {
199
- tile.tileset._cache.touch(tile);
200
- tile._touchedFrame = frameState.frameNumber;
201
- }
202
- // tile should be visible
203
- // tile should have children
204
- // tile LoD (level of detail) is not sufficient under current viewport
205
- canTraverse(tile, frameState, useParentMetric = false, ignoreVisibility = false) {
206
- if (!tile.hasChildren) {
207
- return false;
208
- }
209
- // cesium specific
210
- if (tile.hasTilesetContent) {
211
- // Traverse external this to visit its root tile
212
- // Don't traverse if the subtree is expired because it will be destroyed
213
- return !tile.contentExpired;
214
- }
215
- if (!ignoreVisibility && !tile.isVisibleAndInRequestVolume) {
216
- return false;
217
- }
218
- return this.shouldRefine(tile, frameState, useParentMetric);
219
- }
220
- shouldLoadTile(tile) {
221
- // if request tile is in current frame
222
- // and has unexpired render content
223
- return tile.hasUnloadedContent || tile.contentExpired;
224
- }
225
- shouldSelectTile(tile) {
226
- // if select tile is in current frame
227
- // and content available
228
- return tile.contentAvailable && !this.options.skipLevelOfDetail;
229
- }
230
- /** Decide if tile LoD (level of detail) is not sufficient under current viewport */
231
- shouldRefine(tile, frameState, useParentMetric = false) {
232
- let screenSpaceError = tile._screenSpaceError;
233
- if (useParentMetric) {
234
- screenSpaceError = tile.getScreenSpaceError(frameState, true);
235
- }
236
- return screenSpaceError > this.options.maximumScreenSpaceError;
237
- }
238
- updateTileVisibility(tile, frameState) {
239
- const viewportIds = [];
240
- if (this.options.viewportTraversersMap) {
241
- for (const key in this.options.viewportTraversersMap) {
242
- const value = this.options.viewportTraversersMap[key];
243
- if (value === frameState.viewport.id) {
244
- viewportIds.push(key);
245
- }
246
- }
247
- }
248
- else {
249
- viewportIds.push(frameState.viewport.id);
250
- }
251
- tile.updateVisibility(frameState, viewportIds);
252
- }
253
- // UTILITIES
254
- compareDistanceToCamera(b, a) {
255
- return b._distanceToCamera - a._distanceToCamera;
256
- }
257
- anyChildrenVisible(tile, frameState) {
258
- let anyVisible = false;
259
- for (const child of tile.children) {
260
- // @ts-expect-error
261
- child.updateVisibility(frameState);
262
- // @ts-expect-error
263
- anyVisible = anyVisible || child.isVisibleAndInRequestVolume;
264
- }
265
- return anyVisible;
266
- }
267
- // Depth-first traversal that checks if all nearest descendants with content are loaded.
268
- // Ignores visibility.
269
- executeEmptyTraversal(root, frameState) {
270
- let allDescendantsLoaded = true;
271
- const stack = this._emptyTraversalStack;
272
- stack.push(root);
273
- while (stack.length > 0 && allDescendantsLoaded) {
274
- const tile = stack.pop();
275
- this.updateTile(tile, frameState);
276
- if (!tile.isVisibleAndInRequestVolume) {
277
- // Load tiles that aren't visible since they are still needed for the parent to refine
278
- this.loadTile(tile, frameState);
279
- }
280
- this.touchTile(tile, frameState);
281
- // Only traverse if the tile is empty - traversal stop at descendants with content
282
- const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, true);
283
- if (traverse) {
284
- const children = tile.children;
285
- for (const child of children) {
286
- // eslint-disable-next-line max-depth
287
- if (stack.find(child)) {
288
- stack.delete(child);
289
- }
290
- stack.push(child);
291
- }
292
- }
293
- else if (!tile.contentAvailable) {
294
- allDescendantsLoaded = false;
295
- }
296
- }
297
- return allDescendantsLoaded;
298
- }
299
- }
300
- exports.TilesetTraverser = TilesetTraverser;
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.DoublyLinkedListNode = void 0;
5
- // This file is derived from the Cesium code base under Apache 2 license
6
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
7
- /**
8
- * Doubly linked list node
9
- * @private
10
- */
11
- class DoublyLinkedListNode {
12
- constructor(item, previous, next) {
13
- this.item = item;
14
- this.previous = previous;
15
- this.next = next;
16
- }
17
- }
18
- exports.DoublyLinkedListNode = DoublyLinkedListNode;
@@ -1,97 +0,0 @@
1
- "use strict";
2
- // This file is derived from the Cesium code base under Apache 2 license
3
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.DoublyLinkedList = void 0;
6
- const doubly_linked_list_node_1 = require("./doubly-linked-list-node");
7
- /**
8
- * Doubly linked list
9
- * @private
10
- */
11
- class DoublyLinkedList {
12
- constructor() {
13
- this.head = null;
14
- this.tail = null;
15
- this._length = 0;
16
- }
17
- get length() {
18
- return this._length;
19
- }
20
- /**
21
- * Adds the item to the end of the list
22
- * @param {*} [item]
23
- * @return {DoublyLinkedListNode}
24
- */
25
- add(item) {
26
- const node = new doubly_linked_list_node_1.DoublyLinkedListNode(item, this.tail, null);
27
- if (this.tail) {
28
- this.tail.next = node;
29
- this.tail = node;
30
- }
31
- else {
32
- this.head = node;
33
- this.tail = node;
34
- }
35
- ++this._length;
36
- return node;
37
- }
38
- /**
39
- * Removes the given node from the list
40
- * @param {DoublyLinkedListNode} node
41
- */
42
- remove(node) {
43
- if (!node) {
44
- return;
45
- }
46
- if (node.previous && node.next) {
47
- node.previous.next = node.next;
48
- node.next.previous = node.previous;
49
- }
50
- else if (node.previous) {
51
- // Remove last node
52
- node.previous.next = null;
53
- this.tail = node.previous;
54
- }
55
- else if (node.next) {
56
- // Remove first node
57
- node.next.previous = null;
58
- this.head = node.next;
59
- }
60
- else {
61
- // Remove last node in the linked list
62
- this.head = null;
63
- this.tail = null;
64
- }
65
- node.next = null;
66
- node.previous = null;
67
- --this._length;
68
- }
69
- /**
70
- * Moves nextNode after node
71
- * @param {DoublyLinkedListNode} node
72
- * @param {DoublyLinkedListNode} nextNode
73
- */
74
- splice(node, nextNode) {
75
- if (node === nextNode) {
76
- return;
77
- }
78
- // Remove nextNode, then insert after node
79
- this.remove(nextNode);
80
- this._insert(node, nextNode);
81
- }
82
- _insert(node, nextNode) {
83
- const oldNodeNext = node.next;
84
- node.next = nextNode;
85
- // nextNode is the new tail
86
- if (this.tail === node) {
87
- this.tail = nextNode;
88
- }
89
- else {
90
- oldNodeNext.previous = nextNode;
91
- }
92
- nextNode.next = oldNodeNext;
93
- nextNode.previous = node;
94
- ++this._length;
95
- }
96
- }
97
- exports.DoublyLinkedList = DoublyLinkedList;
@@ -1,152 +0,0 @@
1
- "use strict";
2
- // This file is derived from the Cesium code base under Apache 2 license
3
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.ManagedArray = void 0;
6
- const loader_utils_1 = require("@loaders.gl/loader-utils");
7
- /**
8
- * A wrapper around arrays so that the internal length of the array can be manually managed.
9
- *
10
- * @alias ManagedArray
11
- * @constructor
12
- * @private
13
- *
14
- * @param {Number} [length=0] The initial length of the array.
15
- */
16
- class ManagedArray {
17
- constructor(length = 0) {
18
- this._map = new Map();
19
- this._array = new Array(length);
20
- this._length = length;
21
- }
22
- /**
23
- * Gets or sets the length of the array.
24
- * If the set length is greater than the length of the internal array, the internal array is resized.
25
- *
26
- * @memberof ManagedArray.prototype
27
- * @type Number
28
- */
29
- get length() {
30
- return this._length;
31
- }
32
- set length(length) {
33
- this._length = length;
34
- if (length > this._array.length) {
35
- this._array.length = length;
36
- }
37
- }
38
- /**
39
- * Gets the internal array.
40
- *
41
- * @memberof ManagedArray.prototype
42
- * @type Array
43
- * @readonly
44
- */
45
- get values() {
46
- return this._array;
47
- }
48
- /**
49
- * Gets the element at an index.
50
- *
51
- * @param {Number} index The index to get.
52
- */
53
- get(index) {
54
- (0, loader_utils_1.assert)(index < this._array.length);
55
- return this._array[index];
56
- }
57
- /**
58
- * Sets the element at an index. Resizes the array if index is greater than the length of the array.
59
- *
60
- * @param {Number} index The index to set.
61
- * @param {*} element The element to set at index.
62
- */
63
- set(index, element) {
64
- (0, loader_utils_1.assert)(index >= 0);
65
- if (index >= this.length) {
66
- this.length = index + 1;
67
- }
68
- if (this._map.has(this._array[index])) {
69
- this._map.delete(this._array[index]);
70
- }
71
- this._array[index] = element;
72
- this._map.set(element, index);
73
- }
74
- delete(element) {
75
- const index = this._map.get(element);
76
- if (index >= 0) {
77
- this._array.splice(index, 1);
78
- this._map.delete(element);
79
- this.length--;
80
- }
81
- }
82
- /**
83
- * Returns the last element in the array without modifying the array.
84
- *
85
- * @returns {*} The last element in the array.
86
- */
87
- peek() {
88
- return this._array[this._length - 1];
89
- }
90
- /**
91
- * Push an element into the array.
92
- *
93
- * @param {*} element The element to push.
94
- */
95
- push(element) {
96
- if (!this._map.has(element)) {
97
- const index = this.length++;
98
- this._array[index] = element;
99
- this._map.set(element, index);
100
- }
101
- }
102
- /**
103
- * Pop an element from the array.
104
- *
105
- * @returns {*} The last element in the array.
106
- */
107
- pop() {
108
- const element = this._array[--this.length];
109
- this._map.delete(element);
110
- return element;
111
- }
112
- /**
113
- * Resize the internal array if length > _array.length.
114
- *
115
- * @param {Number} length The length.
116
- */
117
- reserve(length) {
118
- (0, loader_utils_1.assert)(length >= 0);
119
- if (length > this._array.length) {
120
- this._array.length = length;
121
- }
122
- }
123
- /**
124
- * Resize the array.
125
- *
126
- * @param {Number} length The length.
127
- */
128
- resize(length) {
129
- (0, loader_utils_1.assert)(length >= 0);
130
- this.length = length;
131
- }
132
- /**
133
- * Trim the internal array to the specified length. Defaults to the current length.
134
- *
135
- * @param {Number} [length] The length.
136
- */
137
- trim(length) {
138
- if (length === null || length === undefined) {
139
- length = this.length;
140
- }
141
- this._array.length = length;
142
- }
143
- reset() {
144
- this._array = [];
145
- this._map = new Map();
146
- this._length = 0;
147
- }
148
- find(target) {
149
- return this._map.has(target);
150
- }
151
- }
152
- exports.ManagedArray = ManagedArray;