@loaders.gl/tiles 4.0.0-beta.3 → 4.0.0-beta.5

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.
package/dist/dist.dev.js CHANGED
@@ -4949,14 +4949,11 @@ var __exports__ = (() => {
4949
4949
  var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
4950
4950
  var DEFAULT_PROPS = {
4951
4951
  id: "request-scheduler",
4952
- // Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing
4953
4952
  throttleRequests: true,
4954
- // The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit.
4955
4953
  maxRequests: 6
4956
4954
  };
4957
4955
  var RequestScheduler = class {
4958
4956
  activeRequestCount = 0;
4959
- /** Tracks the number of active requests and prioritizes/cancels queued requests. */
4960
4957
  requestQueue = [];
4961
4958
  requestMap = /* @__PURE__ */ new Map();
4962
4959
  deferredUpdate = null;
@@ -4974,22 +4971,6 @@ var __exports__ = (() => {
4974
4971
  this.stats.get(STAT_QUEUED_REQUESTS_EVER);
4975
4972
  this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
4976
4973
  }
4977
- /**
4978
- * Called by an application that wants to issue a request, without having it deeply queued by the browser
4979
- *
4980
- * When the returned promise resolved, it is OK for the application to issue a request.
4981
- * The promise resolves to an object that contains a `done` method.
4982
- * When the application's request has completed (or failed), the application must call the `done` function
4983
- *
4984
- * @param handle
4985
- * @param getPriority will be called when request "slots" open up,
4986
- * allowing the caller to update priority or cancel the request
4987
- * Highest priority executes first, priority < 0 cancels the request
4988
- * @returns a promise
4989
- * - resolves to a object (with a `done` field) when the request can be issued without queueing,
4990
- * - resolves to `null` if the request has been cancelled (by the callback return < 0).
4991
- * In this case the application should not issue the request
4992
- */
4993
4974
  scheduleRequest(handle, getPriority = () => 0) {
4994
4975
  if (!this.props.throttleRequests) {
4995
4976
  return Promise.resolve({
@@ -5014,7 +4995,6 @@ var __exports__ = (() => {
5014
4995
  this._issueNewRequests();
5015
4996
  return promise;
5016
4997
  }
5017
- // PRIVATE
5018
4998
  _issueRequest(request) {
5019
4999
  const {
5020
5000
  handle,
@@ -5036,13 +5016,11 @@ var __exports__ = (() => {
5036
5016
  done
5037
5017
  });
5038
5018
  }
5039
- /** We check requests asynchronously, to prevent multiple updates */
5040
5019
  _issueNewRequests() {
5041
5020
  if (!this.deferredUpdate) {
5042
5021
  this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);
5043
5022
  }
5044
5023
  }
5045
- /** Refresh all requests */
5046
5024
  _issueNewRequestsAsync() {
5047
5025
  this.deferredUpdate = null;
5048
5026
  const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
@@ -5057,7 +5035,6 @@ var __exports__ = (() => {
5057
5035
  }
5058
5036
  }
5059
5037
  }
5060
- /** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
5061
5038
  _updateAllRequests() {
5062
5039
  const requestQueue = this.requestQueue;
5063
5040
  for (let i = 0; i < requestQueue.length; ++i) {
@@ -5070,7 +5047,6 @@ var __exports__ = (() => {
5070
5047
  }
5071
5048
  requestQueue.sort((a, b) => a.priority - b.priority);
5072
5049
  }
5073
- /** Update a single request by calling the callback */
5074
5050
  _updateRequest(request) {
5075
5051
  request.priority = request.getPriority(request.handle);
5076
5052
  if (request.priority < 0) {
@@ -5241,11 +5217,6 @@ var __exports__ = (() => {
5241
5217
  get length() {
5242
5218
  return this._length;
5243
5219
  }
5244
- /**
5245
- * Adds the item to the end of the list
5246
- * @param {*} [item]
5247
- * @return {DoublyLinkedListNode}
5248
- */
5249
5220
  add(item) {
5250
5221
  const node = new DoublyLinkedListNode(item, this.tail, null);
5251
5222
  if (this.tail) {
@@ -5258,10 +5229,6 @@ var __exports__ = (() => {
5258
5229
  ++this._length;
5259
5230
  return node;
5260
5231
  }
5261
- /**
5262
- * Removes the given node from the list
5263
- * @param {DoublyLinkedListNode} node
5264
- */
5265
5232
  remove(node) {
5266
5233
  if (!node) {
5267
5234
  return;
@@ -5283,11 +5250,6 @@ var __exports__ = (() => {
5283
5250
  node.previous = null;
5284
5251
  --this._length;
5285
5252
  }
5286
- /**
5287
- * Moves nextNode after node
5288
- * @param {DoublyLinkedListNode} node
5289
- * @param {DoublyLinkedListNode} nextNode
5290
- */
5291
5253
  splice(node, nextNode) {
5292
5254
  if (node === nextNode) {
5293
5255
  return;
@@ -5877,14 +5839,8 @@ var __exports__ = (() => {
5877
5839
  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
5878
5840
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
5879
5841
  const cameraPositionCartesian2 = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
5880
- const cameraDirectionCartesian = new Vector3(
5881
- // @ts-ignore
5882
- enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))
5883
- ).normalize();
5884
- const cameraUpCartesian = new Vector3(
5885
- // @ts-ignore
5886
- enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))
5887
- ).normalize();
5842
+ const cameraDirectionCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))).normalize();
5843
+ const cameraUpCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))).normalize();
5888
5844
  commonSpacePlanesToWGS84(viewport);
5889
5845
  const ViewportClass = viewport.constructor;
5890
5846
  const {
@@ -5914,9 +5870,7 @@ var __exports__ = (() => {
5914
5870
  height,
5915
5871
  cullingVolume,
5916
5872
  frameNumber,
5917
- // TODO: This can be the same between updates, what number is unique for between updates?
5918
5873
  sseDenominator: 1.15
5919
- // Assumes fovy = 60 degrees
5920
5874
  };
5921
5875
  }
5922
5876
  function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
@@ -5960,11 +5914,7 @@ var __exports__ = (() => {
5960
5914
  const plane = frustumPlanes[dir];
5961
5915
  const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition3);
5962
5916
  const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition3);
5963
- cullingVolume.planes[i++].fromPointNormal(
5964
- cartesianPos,
5965
- // Want the normal to point into the frustum since that's what culling expects
5966
- scratchVector8.copy(nearCenterCartesian).subtract(cartesianPos)
5967
- );
5917
+ cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector8.copy(nearCenterCartesian).subtract(cartesianPos));
5968
5918
  }
5969
5919
  }
5970
5920
  function closestPointOnPlane(plane, refPoint, out = new Vector3()) {
@@ -6036,36 +5986,30 @@ var __exports__ = (() => {
6036
5986
  // src/constants.ts
6037
5987
  var TILE_CONTENT_STATE = {
6038
5988
  UNLOADED: 0,
6039
- // Has never been requested
6040
5989
  LOADING: 1,
6041
- // Is waiting on a pending request
6042
5990
  PROCESSING: 2,
6043
- // Request received. Contents are being processed for rendering. Depending on the content, it might make its own requests for external data.
6044
5991
  READY: 3,
6045
- // Ready to render.
6046
5992
  EXPIRED: 4,
6047
- // Is expired and will be unloaded once new content is loaded.
6048
5993
  FAILED: 5
6049
- // Request failed.
6050
5994
  };
6051
- var TILE_REFINEMENT = /* @__PURE__ */ function(TILE_REFINEMENT2) {
5995
+ var TILE_REFINEMENT = function(TILE_REFINEMENT2) {
6052
5996
  TILE_REFINEMENT2[TILE_REFINEMENT2["ADD"] = 1] = "ADD";
6053
5997
  TILE_REFINEMENT2[TILE_REFINEMENT2["REPLACE"] = 2] = "REPLACE";
6054
5998
  return TILE_REFINEMENT2;
6055
5999
  }({});
6056
- var TILE_TYPE = /* @__PURE__ */ function(TILE_TYPE2) {
6000
+ var TILE_TYPE = function(TILE_TYPE2) {
6057
6001
  TILE_TYPE2["EMPTY"] = "empty";
6058
6002
  TILE_TYPE2["SCENEGRAPH"] = "scenegraph";
6059
6003
  TILE_TYPE2["POINTCLOUD"] = "pointcloud";
6060
6004
  TILE_TYPE2["MESH"] = "mesh";
6061
6005
  return TILE_TYPE2;
6062
6006
  }({});
6063
- var TILESET_TYPE = /* @__PURE__ */ function(TILESET_TYPE2) {
6007
+ var TILESET_TYPE = function(TILESET_TYPE2) {
6064
6008
  TILESET_TYPE2["I3S"] = "I3S";
6065
6009
  TILESET_TYPE2["TILES3D"] = "TILES3D";
6066
6010
  return TILESET_TYPE2;
6067
6011
  }({});
6068
- var LOD_METRIC_TYPE = /* @__PURE__ */ function(LOD_METRIC_TYPE2) {
6012
+ var LOD_METRIC_TYPE = function(LOD_METRIC_TYPE2) {
6069
6013
  LOD_METRIC_TYPE2["GEOMETRIC_ERROR"] = "geometricError";
6070
6014
  LOD_METRIC_TYPE2["MAX_SCREEN_THRESHOLD"] = "maxScreenThreshold";
6071
6015
  return LOD_METRIC_TYPE2;
@@ -6344,13 +6288,6 @@ var __exports__ = (() => {
6344
6288
  this._array = new Array(length4);
6345
6289
  this._length = length4;
6346
6290
  }
6347
- /**
6348
- * Gets or sets the length of the array.
6349
- * If the set length is greater than the length of the internal array, the internal array is resized.
6350
- *
6351
- * @memberof ManagedArray.prototype
6352
- * @type Number
6353
- */
6354
6291
  get length() {
6355
6292
  return this._length;
6356
6293
  }
@@ -6360,31 +6297,13 @@ var __exports__ = (() => {
6360
6297
  this._array.length = length4;
6361
6298
  }
6362
6299
  }
6363
- /**
6364
- * Gets the internal array.
6365
- *
6366
- * @memberof ManagedArray.prototype
6367
- * @type Array
6368
- * @readonly
6369
- */
6370
6300
  get values() {
6371
6301
  return this._array;
6372
6302
  }
6373
- /**
6374
- * Gets the element at an index.
6375
- *
6376
- * @param {Number} index The index to get.
6377
- */
6378
6303
  get(index) {
6379
6304
  assert2(index < this._array.length);
6380
6305
  return this._array[index];
6381
6306
  }
6382
- /**
6383
- * Sets the element at an index. Resizes the array if index is greater than the length of the array.
6384
- *
6385
- * @param {Number} index The index to set.
6386
- * @param {*} element The element to set at index.
6387
- */
6388
6307
  set(index, element) {
6389
6308
  assert2(index >= 0);
6390
6309
  if (index >= this.length) {
@@ -6404,19 +6323,9 @@ var __exports__ = (() => {
6404
6323
  this.length--;
6405
6324
  }
6406
6325
  }
6407
- /**
6408
- * Returns the last element in the array without modifying the array.
6409
- *
6410
- * @returns {*} The last element in the array.
6411
- */
6412
6326
  peek() {
6413
6327
  return this._array[this._length - 1];
6414
6328
  }
6415
- /**
6416
- * Push an element into the array.
6417
- *
6418
- * @param {*} element The element to push.
6419
- */
6420
6329
  push(element) {
6421
6330
  if (!this._map.has(element)) {
6422
6331
  const index = this.length++;
@@ -6424,41 +6333,21 @@ var __exports__ = (() => {
6424
6333
  this._map.set(element, index);
6425
6334
  }
6426
6335
  }
6427
- /**
6428
- * Pop an element from the array.
6429
- *
6430
- * @returns {*} The last element in the array.
6431
- */
6432
6336
  pop() {
6433
6337
  const element = this._array[--this.length];
6434
6338
  this._map.delete(element);
6435
6339
  return element;
6436
6340
  }
6437
- /**
6438
- * Resize the internal array if length > _array.length.
6439
- *
6440
- * @param {Number} length The length.
6441
- */
6442
6341
  reserve(length4) {
6443
6342
  assert2(length4 >= 0);
6444
6343
  if (length4 > this._array.length) {
6445
6344
  this._array.length = length4;
6446
6345
  }
6447
6346
  }
6448
- /**
6449
- * Resize the array.
6450
- *
6451
- * @param {Number} length The length.
6452
- */
6453
6347
  resize(length4) {
6454
6348
  assert2(length4 >= 0);
6455
6349
  this.length = length4;
6456
6350
  }
6457
- /**
6458
- * Trim the internal array to the specified length. Defaults to the current length.
6459
- *
6460
- * @param {Number} [length] The length.
6461
- */
6462
6351
  trim(length4) {
6463
6352
  if (length4 === null || length4 === void 0) {
6464
6353
  length4 = this.length;
@@ -6487,33 +6376,24 @@ var __exports__ = (() => {
6487
6376
  basePath: ""
6488
6377
  };
6489
6378
  var TilesetTraverser = class {
6490
- // fulfill in traverse call
6491
6379
  root = null;
6492
- // tiles should be rendered
6493
6380
  selectedTiles = {};
6494
- // tiles should be loaded from server
6495
6381
  requestedTiles = {};
6496
- // tiles does not have render content
6497
6382
  emptyTiles = {};
6498
6383
  lastUpdate = new Date().getTime();
6499
6384
  updateDebounceTime = 1e3;
6500
- /** temporary storage to hold the traversed tiles during a traversal */
6501
6385
  _traversalStack = new ManagedArray();
6502
6386
  _emptyTraversalStack = new ManagedArray();
6503
- /** set in every traverse cycle */
6504
6387
  _frameNumber = null;
6505
- // RESULT
6506
6388
  traversalFinished(frameState) {
6507
6389
  return true;
6508
6390
  }
6509
- // TODO nested props
6510
6391
  constructor(options) {
6511
6392
  this.options = {
6512
6393
  ...DEFAULT_PROPS2,
6513
6394
  ...options
6514
6395
  };
6515
6396
  }
6516
- // tiles should be visible
6517
6397
  traverse(root, frameState, options) {
6518
6398
  this.root = root;
6519
6399
  this.options = {
@@ -6532,16 +6412,6 @@ var __exports__ = (() => {
6532
6412
  this._traversalStack.reset();
6533
6413
  this._emptyTraversalStack.reset();
6534
6414
  }
6535
- /**
6536
- * Execute traverse
6537
- * Depth-first traversal that traverses all visible tiles and marks tiles for selection.
6538
- * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
6539
- * This is the traditional replacement refinement approach and is called the base traversal.
6540
- * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
6541
- * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
6542
- * and rendering children and parent tiles simultaneously.
6543
- */
6544
- /* eslint-disable-next-line complexity, max-statements */
6545
6415
  executeTraversal(root, frameState) {
6546
6416
  const stack = this._traversalStack;
6547
6417
  root._selectionDepth = 1;
@@ -6586,7 +6456,6 @@ var __exports__ = (() => {
6586
6456
  this.updateTile(child, frameState);
6587
6457
  }
6588
6458
  }
6589
- /* eslint-disable complexity, max-statements */
6590
6459
  updateAndPushChildren(tile, frameState, stack, depth) {
6591
6460
  const {
6592
6461
  loadSiblings,
@@ -6629,18 +6498,15 @@ var __exports__ = (() => {
6629
6498
  }
6630
6499
  return refines;
6631
6500
  }
6632
- /* eslint-enable complexity, max-statements */
6633
6501
  updateTile(tile, frameState) {
6634
6502
  this.updateTileVisibility(tile, frameState);
6635
6503
  }
6636
- // tile to render in the browser
6637
6504
  selectTile(tile, frameState) {
6638
6505
  if (this.shouldSelectTile(tile)) {
6639
6506
  tile._selectedFrame = frameState.frameNumber;
6640
6507
  this.selectedTiles[tile.id] = tile;
6641
6508
  }
6642
6509
  }
6643
- // tile to load from server
6644
6510
  loadTile(tile, frameState) {
6645
6511
  if (this.shouldLoadTile(tile)) {
6646
6512
  tile._requestedFrame = frameState.frameNumber;
@@ -6648,14 +6514,10 @@ var __exports__ = (() => {
6648
6514
  this.requestedTiles[tile.id] = tile;
6649
6515
  }
6650
6516
  }
6651
- // cache tile
6652
6517
  touchTile(tile, frameState) {
6653
6518
  tile.tileset._cache.touch(tile);
6654
6519
  tile._touchedFrame = frameState.frameNumber;
6655
6520
  }
6656
- // tile should be visible
6657
- // tile should have children
6658
- // tile LoD (level of detail) is not sufficient under current viewport
6659
6521
  canTraverse(tile, frameState, useParentMetric = false, ignoreVisibility = false) {
6660
6522
  if (!tile.hasChildren) {
6661
6523
  return false;
@@ -6674,7 +6536,6 @@ var __exports__ = (() => {
6674
6536
  shouldSelectTile(tile) {
6675
6537
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
6676
6538
  }
6677
- /** Decide if tile LoD (level of detail) is not sufficient under current viewport */
6678
6539
  shouldRefine(tile, frameState, useParentMetric = false) {
6679
6540
  let screenSpaceError = tile._screenSpaceError;
6680
6541
  if (useParentMetric) {
@@ -6696,7 +6557,6 @@ var __exports__ = (() => {
6696
6557
  }
6697
6558
  tile.updateVisibility(frameState, viewportIds);
6698
6559
  }
6699
- // UTILITIES
6700
6560
  compareDistanceToCamera(b, a) {
6701
6561
  return b._distanceToCamera - a._distanceToCamera;
6702
6562
  }
@@ -6708,8 +6568,6 @@ var __exports__ = (() => {
6708
6568
  }
6709
6569
  return anyVisible;
6710
6570
  }
6711
- // Depth-first traversal that checks if all nearest descendants with content are loaded.
6712
- // Ignores visibility.
6713
6571
  executeEmptyTraversal(root, frameState) {
6714
6572
  let allDescendantsLoaded = true;
6715
6573
  const stack = this._emptyTraversalStack;
@@ -6744,46 +6602,31 @@ var __exports__ = (() => {
6744
6602
  return x !== void 0 && x !== null;
6745
6603
  }
6746
6604
  var Tile3D = class {
6747
- /* Specifies the type of refine that is used when traversing this tile for rendering. */
6748
- /** Different refinement algorithms used by I3S and 3D tiles */
6749
6605
  lodMetricType = "geometricError";
6750
- /** The error, in meters, introduced if this tile is rendered and its children are not. */
6751
6606
  lodMetricValue = 0;
6752
- /** @todo math.gl is not exporting BoundingVolume base type? */
6753
6607
  boundingVolume = null;
6754
- /**
6755
- * The tile's content. This represents the actual tile's payload,
6756
- * not the content's metadata in the tileset JSON file.
6757
- */
6758
6608
  content = null;
6759
6609
  contentState = TILE_CONTENT_STATE.UNLOADED;
6760
6610
  gpuMemoryUsageInBytes = 0;
6761
- /** The tile's children - an array of Tile3D objects. */
6762
6611
  children = [];
6763
6612
  depth = 0;
6764
6613
  viewportIds = [];
6765
6614
  transform = new Matrix4();
6766
6615
  extensions = null;
6767
- /** TODO Cesium 3d tiles specific */
6768
6616
  implicitTiling = null;
6769
- /** Container to store application specific data */
6770
6617
  userData = {};
6771
6618
  hasEmptyContent = false;
6772
6619
  hasTilesetContent = false;
6773
6620
  traverser = new TilesetTraverser({});
6774
- /** Used by TilesetCache */
6775
6621
  _cacheNode = null;
6776
6622
  _frameNumber = null;
6777
- // TODO Cesium 3d tiles specific
6778
6623
  _expireDate = null;
6779
6624
  _expiredContent = null;
6780
6625
  _boundingBox = void 0;
6781
- /** updated every frame for tree traversal and rendering optimizations: */
6782
6626
  _distanceToCamera = 0;
6783
6627
  _screenSpaceError = 0;
6784
6628
  _visible = void 0;
6785
6629
  _initialTransform = new Matrix4();
6786
- // Used by traverser, cannot be marked private
6787
6630
  _priority = 0;
6788
6631
  _selectedFrame = 0;
6789
6632
  _requestedFrame = 0;
@@ -6795,17 +6638,6 @@ var __exports__ = (() => {
6795
6638
  _visitedFrame = 0;
6796
6639
  _inRequestVolume = false;
6797
6640
  _lodJudge = null;
6798
- // TODO i3s specific, needs to remove
6799
- /**
6800
- * @constructs
6801
- * Create a Tile3D instance
6802
- * @param tileset - Tileset3D instance
6803
- * @param header - tile header - JSON loaded from a dataset
6804
- * @param parentHeader - parent Tile3D instance
6805
- * @param extendedId - optional ID to separate copies of a tile for different viewports.
6806
- * const extendedId = `${tile.id}-${frameState.viewport.id}`;
6807
- */
6808
- // eslint-disable-next-line max-statements
6809
6641
  constructor(tileset, header, parentHeader, extendedId = "") {
6810
6642
  this.header = header;
6811
6643
  this.tileset = tileset;
@@ -6837,74 +6669,42 @@ var __exports__ = (() => {
6837
6669
  get isVisibleAndInRequestVolume() {
6838
6670
  return this._visible && this._inRequestVolume;
6839
6671
  }
6840
- /** Returns true if tile is not an empty tile and not an external tileset */
6841
6672
  get hasRenderContent() {
6842
6673
  return !this.hasEmptyContent && !this.hasTilesetContent;
6843
6674
  }
6844
- /** Returns true if tile has children */
6845
6675
  get hasChildren() {
6846
6676
  return this.children.length > 0 || this.header.children && this.header.children.length > 0;
6847
6677
  }
6848
- /**
6849
- * Determines if the tile's content is ready. This is automatically `true` for
6850
- * tiles with empty content.
6851
- */
6852
6678
  get contentReady() {
6853
6679
  return this.contentState === TILE_CONTENT_STATE.READY || this.hasEmptyContent;
6854
6680
  }
6855
- /**
6856
- * Determines if the tile has available content to render. `true` if the tile's
6857
- * content is ready or if it has expired content this renders while new content loads; otherwise,
6858
- */
6859
6681
  get contentAvailable() {
6860
6682
  return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
6861
6683
  }
6862
- /** Returns true if tile has renderable content but it's unloaded */
6863
6684
  get hasUnloadedContent() {
6864
6685
  return this.hasRenderContent && this.contentUnloaded;
6865
6686
  }
6866
- /**
6867
- * Determines if the tile's content has not be requested. `true` if tile's
6868
- * content has not be requested; otherwise, `false`.
6869
- */
6870
6687
  get contentUnloaded() {
6871
6688
  return this.contentState === TILE_CONTENT_STATE.UNLOADED;
6872
6689
  }
6873
- /**
6874
- * Determines if the tile's content is expired. `true` if tile's
6875
- * content is expired; otherwise, `false`.
6876
- */
6877
6690
  get contentExpired() {
6878
6691
  return this.contentState === TILE_CONTENT_STATE.EXPIRED;
6879
6692
  }
6880
- // Determines if the tile's content failed to load. `true` if the tile's
6881
- // content failed to load; otherwise, `false`.
6882
6693
  get contentFailed() {
6883
6694
  return this.contentState === TILE_CONTENT_STATE.FAILED;
6884
6695
  }
6885
- /**
6886
- * Distance from the tile's bounding volume center to the camera
6887
- */
6888
6696
  get distanceToCamera() {
6889
6697
  return this._distanceToCamera;
6890
6698
  }
6891
- /**
6892
- * Screen space error for LOD selection
6893
- */
6894
6699
  get screenSpaceError() {
6895
6700
  return this._screenSpaceError;
6896
6701
  }
6897
- /**
6898
- * Get bounding box in cartographic coordinates
6899
- * @returns [min, max] each in [longitude, latitude, altitude]
6900
- */
6901
6702
  get boundingBox() {
6902
6703
  if (!this._boundingBox) {
6903
6704
  this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);
6904
6705
  }
6905
6706
  return this._boundingBox;
6906
6707
  }
6907
- /** Get the tile's screen space error. */
6908
6708
  getScreenSpaceError(frameState, useParentLodMetric) {
6909
6709
  switch (this.tileset.type) {
6910
6710
  case TILESET_TYPE.I3S:
@@ -6915,24 +6715,12 @@ var __exports__ = (() => {
6915
6715
  throw new Error("Unsupported tileset type");
6916
6716
  }
6917
6717
  }
6918
- /**
6919
- * Make tile unselected than means it won't be shown
6920
- * but it can be still loaded in memory
6921
- */
6922
6718
  unselect() {
6923
6719
  this._selectedFrame = 0;
6924
6720
  }
6925
- /**
6926
- * Memory usage of tile on GPU
6927
- */
6928
6721
  _getGpuMemoryUsageInBytes() {
6929
6722
  return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
6930
6723
  }
6931
- /*
6932
- * If skipLevelOfDetail is off try to load child tiles as soon as possible so that their parent can refine sooner.
6933
- * Tiles are prioritized by screen space error.
6934
- */
6935
- // eslint-disable-next-line complexity
6936
6724
  _getPriority() {
6937
6725
  const traverser = this.tileset._traverser;
6938
6726
  const {
@@ -6954,11 +6742,6 @@ var __exports__ = (() => {
6954
6742
  const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0;
6955
6743
  return Math.max(rootScreenSpaceError - screenSpaceError, 0);
6956
6744
  }
6957
- /**
6958
- * Requests the tile's content.
6959
- * The request may not be made if the Request Scheduler can't prioritize it.
6960
- */
6961
- // eslint-disable-next-line max-statements, complexity
6962
6745
  async loadContent() {
6963
6746
  if (this.hasEmptyContent) {
6964
6747
  return false;
@@ -6982,7 +6765,6 @@ var __exports__ = (() => {
6982
6765
  const options = {
6983
6766
  ...this.tileset.loadOptions,
6984
6767
  [loader.id]: {
6985
- // @ts-expect-error
6986
6768
  ...this.tileset.loadOptions[loader.id],
6987
6769
  isTileset: this.type === "json",
6988
6770
  ...this._getLoaderSpecificOptions(loader.id)
@@ -7005,7 +6787,6 @@ var __exports__ = (() => {
7005
6787
  requestToken.done();
7006
6788
  }
7007
6789
  }
7008
- // Unloads the tile's content.
7009
6790
  unloadContent() {
7010
6791
  if (this.content && this.content.destroy) {
7011
6792
  this.content.destroy();
@@ -7018,12 +6799,6 @@ var __exports__ = (() => {
7018
6799
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
7019
6800
  return true;
7020
6801
  }
7021
- /**
7022
- * Update the tile's visibility
7023
- * @param {Object} frameState - frame state for tile culling
7024
- * @param {string[]} viewportIds - a list of viewport ids that show this tile
7025
- * @return {void}
7026
- */
7027
6802
  updateVisibility(frameState, viewportIds) {
7028
6803
  if (this._frameNumber === frameState.frameNumber) {
7029
6804
  return;
@@ -7042,10 +6817,6 @@ var __exports__ = (() => {
7042
6817
  this._frameNumber = frameState.frameNumber;
7043
6818
  this.viewportIds = viewportIds;
7044
6819
  }
7045
- // Determines whether the tile's bounding volume intersects the culling volume.
7046
- // @param {FrameState} frameState The frame state.
7047
- // @param {Number} parentVisibilityPlaneMask The parent's plane mask to speed up the visibility check.
7048
- // @returns {Number} A plane mask as described above in {@link CullingVolume#computeVisibilityWithPlaneMask}.
7049
6820
  visibility(frameState, parentVisibilityPlaneMask) {
7050
6821
  const {
7051
6822
  cullingVolume: cullingVolume2
@@ -7055,27 +6826,13 @@ var __exports__ = (() => {
7055
6826
  } = this;
7056
6827
  return cullingVolume2.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
7057
6828
  }
7058
- // Assuming the tile's bounding volume intersects the culling volume, determines
7059
- // whether the tile's content's bounding volume intersects the culling volume.
7060
- // @param {FrameState} frameState The frame state.
7061
- // @returns {Intersect} The result of the intersection: the tile's content is completely outside, completely inside, or intersecting the culling volume.
7062
6829
  contentVisibility() {
7063
6830
  return true;
7064
6831
  }
7065
- /**
7066
- * Computes the (potentially approximate) distance from the closest point of the tile's bounding volume to the camera.
7067
- * @param frameState The frame state.
7068
- * @returns {Number} The distance, in meters, or zero if the camera is inside the bounding volume.
7069
- */
7070
6832
  distanceToTile(frameState) {
7071
6833
  const boundingVolume = this.boundingVolume;
7072
6834
  return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
7073
6835
  }
7074
- /**
7075
- * Computes the tile's camera-space z-depth.
7076
- * @param frameState The frame state.
7077
- * @returns The distance, in meters.
7078
- */
7079
6836
  cameraSpaceZDepth({
7080
6837
  camera
7081
6838
  }) {
@@ -7083,17 +6840,10 @@ var __exports__ = (() => {
7083
6840
  scratchVector10.subVectors(boundingVolume.center, camera.position);
7084
6841
  return camera.direction.dot(scratchVector10);
7085
6842
  }
7086
- /**
7087
- * Checks if the camera is inside the viewer request volume.
7088
- * @param {FrameState} frameState The frame state.
7089
- * @returns {Boolean} Whether the camera is inside the volume.
7090
- */
7091
6843
  insideViewerRequestVolume(frameState) {
7092
6844
  const viewerRequestVolume = this._viewerRequestVolume;
7093
6845
  return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
7094
6846
  }
7095
- // TODO Cesium specific
7096
- // Update whether the tile has expired.
7097
6847
  updateExpiration() {
7098
6848
  if (defined2(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
7099
6849
  const now = Date.now();
@@ -7106,7 +6856,6 @@ var __exports__ = (() => {
7106
6856
  get extras() {
7107
6857
  return this.header.extras;
7108
6858
  }
7109
- // INTERNAL METHODS
7110
6859
  _initializeLodMetric(header) {
7111
6860
  if ("lodMetricType" in header) {
7112
6861
  this.lodMetricType = header.lodMetricType;
@@ -7148,7 +6897,6 @@ var __exports__ = (() => {
7148
6897
  this.hasEmptyContent = false;
7149
6898
  }
7150
6899
  }
7151
- // TODO - remove anything not related to basic visibility detection
7152
6900
  _initializeRenderingState(header) {
7153
6901
  this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
7154
6902
  this._shouldRefine = false;
@@ -7200,7 +6948,6 @@ var __exports__ = (() => {
7200
6948
  this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
7201
6949
  }
7202
6950
  }
7203
- // Update the tile's transform. The transform is applied to the tile's bounding volumes.
7204
6951
  _updateTransform(parentTransform = new Matrix4()) {
7205
6952
  const computedTransform = parentTransform.clone().multiplyRight(this.transform);
7206
6953
  const didTransformChange = !computedTransform.equals(this.computedTransform);
@@ -7210,7 +6957,6 @@ var __exports__ = (() => {
7210
6957
  this.computedTransform = computedTransform;
7211
6958
  this._updateBoundingVolume(this.header);
7212
6959
  }
7213
- // Get options which are applicable only for the particular loader
7214
6960
  _getLoaderSpecificOptions(loaderId) {
7215
6961
  switch (loaderId) {
7216
6962
  case "i3s":
@@ -7287,22 +7033,12 @@ var __exports__ = (() => {
7287
7033
  // src/tileset/format-i3s/i3s-pending-tiles-register.ts
7288
7034
  var I3SPendingTilesRegister = class {
7289
7035
  frameNumberMap = /* @__PURE__ */ new Map();
7290
- /**
7291
- * Register a new pending tile header for the particular frameNumber
7292
- * @param viewportId
7293
- * @param frameNumber
7294
- */
7295
7036
  register(viewportId, frameNumber) {
7296
7037
  const viewportMap = this.frameNumberMap.get(viewportId) || /* @__PURE__ */ new Map();
7297
7038
  const oldCount = viewportMap.get(frameNumber) || 0;
7298
7039
  viewportMap.set(frameNumber, oldCount + 1);
7299
7040
  this.frameNumberMap.set(viewportId, viewportMap);
7300
7041
  }
7301
- /**
7302
- * Deregister a pending tile header for the particular frameNumber
7303
- * @param viewportId
7304
- * @param frameNumber
7305
- */
7306
7042
  deregister(viewportId, frameNumber) {
7307
7043
  const viewportMap = this.frameNumberMap.get(viewportId);
7308
7044
  if (!viewportMap) {
@@ -7311,12 +7047,6 @@ var __exports__ = (() => {
7311
7047
  const oldCount = viewportMap.get(frameNumber) || 1;
7312
7048
  viewportMap.set(frameNumber, oldCount - 1);
7313
7049
  }
7314
- /**
7315
- * Check is there are no pending tile headers registered for the particular frameNumber
7316
- * @param viewportId
7317
- * @param frameNumber
7318
- * @returns
7319
- */
7320
7050
  isZero(viewportId, frameNumber) {
7321
7051
  const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;
7322
7052
  return count === 0;
@@ -7334,13 +7064,6 @@ var __exports__ = (() => {
7334
7064
  constructor() {
7335
7065
  this._statusMap = {};
7336
7066
  }
7337
- /**
7338
- * Add request to map
7339
- * @param request - node metadata request
7340
- * @param key - unique key
7341
- * @param callback - callback after request completed
7342
- * @param frameState - frameState data
7343
- */
7344
7067
  add(request, key, callback, frameState) {
7345
7068
  if (!this._statusMap[key]) {
7346
7069
  const {
@@ -7380,11 +7103,6 @@ var __exports__ = (() => {
7380
7103
  });
7381
7104
  }
7382
7105
  }
7383
- /**
7384
- * Update request if it is still actual for the new frameState
7385
- * @param key - unique key
7386
- * @param frameState - frameState data
7387
- */
7388
7106
  update(key, frameState) {
7389
7107
  if (this._statusMap[key]) {
7390
7108
  const {
@@ -7404,20 +7122,9 @@ var __exports__ = (() => {
7404
7122
  this._statusMap[key].frameState = frameState;
7405
7123
  }
7406
7124
  }
7407
- /**
7408
- * Find request in the map
7409
- * @param key - unique key
7410
- * @returns
7411
- */
7412
7125
  find(key) {
7413
7126
  return this._statusMap[key];
7414
7127
  }
7415
- /**
7416
- * Check it there are pending tile headers for the particular frameNumber
7417
- * @param viewportId
7418
- * @param frameNumber
7419
- * @returns
7420
- */
7421
7128
  hasPendingTiles(viewportId, frameNumber) {
7422
7129
  return !this.pendingTilesRegister.isZero(viewportId, frameNumber);
7423
7130
  }
@@ -7429,11 +7136,6 @@ var __exports__ = (() => {
7429
7136
  super(options);
7430
7137
  this._tileManager = new I3STileManager();
7431
7138
  }
7432
- /**
7433
- * Check if there are no penging tile header requests,
7434
- * that means the traversal is finished and we can call
7435
- * following-up callbacks.
7436
- */
7437
7139
  traversalFinished(frameState) {
7438
7140
  return !this._tileManager.hasPendingTiles(frameState.viewport.id, this._frameNumber || 0);
7439
7141
  }
@@ -7479,14 +7181,6 @@ var __exports__ = (() => {
7479
7181
  };
7480
7182
  return await (0, import_core22.load)(nodeUrl, loader, options);
7481
7183
  }
7482
- /**
7483
- * The callback to init Tile3D instance after loading the tile JSON
7484
- * @param {Object} header - the tile JSON from a dataset
7485
- * @param {Tile3D} tile - the parent Tile3D instance
7486
- * @param {string} extendedId - optional ID to separate copies of a tile for different viewports.
7487
- * const extendedId = `${tile.id}-${frameState.viewport.id}`;
7488
- * @return {void}
7489
- */
7490
7184
  _onTileLoad(header, tile, extendedId) {
7491
7185
  const childTile = new Tile3D(tile.tileset, header, tile, extendedId);
7492
7186
  tile.children.push(childTile);
@@ -7539,48 +7233,32 @@ var __exports__ = (() => {
7539
7233
  var POINTS_COUNT = "Points/Vertices";
7540
7234
  var TILES_GPU_MEMORY = "Tile Memory Use";
7541
7235
  var Tileset3D = class {
7542
- // props: Tileset3DProps;
7543
7236
  root = null;
7544
7237
  roots = {};
7545
- /** @todo any->unknown */
7546
7238
  asset = {};
7547
- // Metadata for the entire tileset
7548
7239
  description = "";
7549
7240
  extras = null;
7550
7241
  attributions = {};
7551
7242
  credits = {};
7552
- /** flags that contain information about data types in nested tiles */
7553
7243
  contentFormats = {
7554
7244
  draco: false,
7555
7245
  meshopt: false,
7556
7246
  dds: false,
7557
7247
  ktx2: false
7558
7248
  };
7559
- // view props
7560
7249
  cartographicCenter = null;
7561
7250
  cartesianCenter = null;
7562
7251
  zoom = 1;
7563
7252
  boundingVolume = null;
7564
- /** Updated based on the camera position and direction */
7565
7253
  dynamicScreenSpaceErrorComputedDensity = 0;
7566
- // METRICS
7567
- /**
7568
- * The maximum amount of GPU memory (in MB) that may be used to cache tiles
7569
- * Tiles not in view are unloaded to enforce private
7570
- */
7571
7254
  maximumMemoryUsage = 32;
7572
- /** The total amount of GPU memory in bytes used by the tileset. */
7573
7255
  gpuMemoryUsageInBytes = 0;
7574
- /** Update tracker. increase in each update cycle. */
7575
7256
  _frameNumber = 0;
7576
7257
  _queryParams = {};
7577
7258
  _extensionsUsed = [];
7578
7259
  _tiles = {};
7579
- /** counter for tracking tiles requests */
7580
7260
  _pendingCount = 0;
7581
- /** Hold traversal results */
7582
7261
  selectedTiles = [];
7583
- // TRAVERSAL
7584
7262
  traverseCounter = 0;
7585
7263
  geometricError = 0;
7586
7264
  lastUpdatedVieports = null;
@@ -7588,14 +7266,7 @@ var __exports__ = (() => {
7588
7266
  _emptyTiles = [];
7589
7267
  frameStateData = {};
7590
7268
  _cache = new TilesetCache();
7591
- // Promise tracking
7592
7269
  updatePromise = null;
7593
- /**
7594
- * Create a new Tileset3D
7595
- * @param json
7596
- * @param props
7597
- */
7598
- // eslint-disable-next-line max-statements
7599
7270
  constructor(tileset, options) {
7600
7271
  this.options = {
7601
7272
  ...DEFAULT_PROPS3,
@@ -7623,11 +7294,9 @@ var __exports__ = (() => {
7623
7294
  this._initializeStats();
7624
7295
  this.tilesetInitializationPromise = this._initializeTileSet(tileset);
7625
7296
  }
7626
- /** Release resources */
7627
7297
  destroy() {
7628
7298
  this._destroy();
7629
7299
  }
7630
- /** Is the tileset loaded (update needs to have been called at least once) */
7631
7300
  isLoaded() {
7632
7301
  return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;
7633
7302
  }
@@ -7646,17 +7315,12 @@ var __exports__ = (() => {
7646
7315
  ...props
7647
7316
  };
7648
7317
  }
7649
- /** @deprecated */
7650
7318
  setOptions(options) {
7651
7319
  this.options = {
7652
7320
  ...this.options,
7653
7321
  ...options
7654
7322
  };
7655
7323
  }
7656
- /**
7657
- * Return a loadable tile url for a specific tile subpath
7658
- * @param tilePath a tile subpath
7659
- */
7660
7324
  getTileUrl(tilePath) {
7661
7325
  const isDataUrl = tilePath.startsWith("data:");
7662
7326
  if (isDataUrl) {
@@ -7668,15 +7332,9 @@ var __exports__ = (() => {
7668
7332
  }
7669
7333
  return tileUrl;
7670
7334
  }
7671
- // TODO CESIUM specific
7672
7335
  hasExtension(extensionName) {
7673
7336
  return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
7674
7337
  }
7675
- /**
7676
- * Update visible tiles relying on a list of viewports
7677
- * @param viewports - list of viewports
7678
- * @deprecated
7679
- */
7680
7338
  update(viewports = null) {
7681
7339
  this.tilesetInitializationPromise.then(() => {
7682
7340
  if (!viewports && this.lastUpdatedVieports) {
@@ -7689,12 +7347,6 @@ var __exports__ = (() => {
7689
7347
  }
7690
7348
  });
7691
7349
  }
7692
- /**
7693
- * Update visible tiles relying on a list of viewports.
7694
- * Do it with debounce delay to prevent update spam
7695
- * @param viewports viewports
7696
- * @returns Promise of new frameNumber
7697
- */
7698
7350
  async selectTiles(viewports = null) {
7699
7351
  await this.tilesetInitializationPromise;
7700
7352
  if (viewports) {
@@ -7713,11 +7365,6 @@ var __exports__ = (() => {
7713
7365
  }
7714
7366
  return this.updatePromise;
7715
7367
  }
7716
- /**
7717
- * Update visible tiles relying on a list of viewports
7718
- * @param viewports viewports
7719
- */
7720
- // eslint-disable-next-line max-statements, complexity
7721
7368
  doUpdate(viewports) {
7722
7369
  if ("loadTiles" in this.options && !this.options.loadTiles) {
7723
7370
  return;
@@ -7750,11 +7397,6 @@ var __exports__ = (() => {
7750
7397
  this._traverser.traverse(this.roots[id], frameState, this.options);
7751
7398
  }
7752
7399
  }
7753
- /**
7754
- * Check if traversal is needed for particular viewport
7755
- * @param {string} viewportId - id of a viewport
7756
- * @return {boolean}
7757
- */
7758
7400
  _needTraverse(viewportId) {
7759
7401
  let traverserId = viewportId;
7760
7402
  if (this.options.viewportTraversersMap) {
@@ -7765,10 +7407,6 @@ var __exports__ = (() => {
7765
7407
  }
7766
7408
  return true;
7767
7409
  }
7768
- /**
7769
- * The callback to post-process tiles after traversal procedure
7770
- * @param frameState - frame state for tile culling
7771
- */
7772
7410
  _onTraversalEnd(frameState) {
7773
7411
  const id = frameState.viewport.id;
7774
7412
  if (!this.frameStateData[id]) {
@@ -7793,9 +7431,6 @@ var __exports__ = (() => {
7793
7431
  }
7794
7432
  this._updateTiles();
7795
7433
  }
7796
- /**
7797
- * Update tiles relying on data from all traversers
7798
- */
7799
7434
  _updateTiles() {
7800
7435
  this.selectedTiles = [];
7801
7436
  this._requestedTiles = [];
@@ -7865,12 +7500,6 @@ var __exports__ = (() => {
7865
7500
  this._initializeI3STileset();
7866
7501
  }
7867
7502
  }
7868
- /**
7869
- * Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.
7870
- * These metrics help apps center view on tileset
7871
- * For I3S there is extent (<1.8 version) or fullExtent (>=1.8 version) to calculate view props
7872
- * @returns
7873
- */
7874
7503
  calculateViewPropsI3S() {
7875
7504
  const fullExtent = this.tileset.fullExtent;
7876
7505
  if (fullExtent) {
@@ -7902,12 +7531,6 @@ var __exports__ = (() => {
7902
7531
  this.zoom = 1;
7903
7532
  return;
7904
7533
  }
7905
- /**
7906
- * Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.
7907
- * These metrics help apps center view on tileset.
7908
- * For 3DTiles the root tile data is used to calculate view props.
7909
- * @returns
7910
- */
7911
7534
  calculateViewPropsTiles3D() {
7912
7535
  const root = this.root;
7913
7536
  const {
@@ -7940,8 +7563,6 @@ var __exports__ = (() => {
7940
7563
  this.stats.get(POINTS_COUNT);
7941
7564
  this.stats.get(TILES_GPU_MEMORY, "memory");
7942
7565
  }
7943
- // Installs the main tileset JSON file or a tileset JSON file referenced from a tile.
7944
- // eslint-disable-next-line max-statements
7945
7566
  _initializeTileHeaders(tilesetJson, parentTileHeader) {
7946
7567
  const rootTile = new Tile3D(this, tilesetJson.root, parentTileHeader);
7947
7568
  if (parentTileHeader) {
@@ -8028,10 +7649,6 @@ var __exports__ = (() => {
8028
7649
  this._addTileToCache(tile);
8029
7650
  this.options.onTileLoad(tile);
8030
7651
  }
8031
- /**
8032
- * Update information about data types in nested tiles
8033
- * @param tile instance of a nested Tile3D
8034
- */
8035
7652
  updateContentTypes(tile) {
8036
7653
  if (this.type === TILESET_TYPE.I3S) {
8037
7654
  if (tile.header.isDracoGeometry) {
@@ -8086,7 +7703,6 @@ var __exports__ = (() => {
8086
7703
  this.options.onTileUnload(tile);
8087
7704
  tile.unloadContent();
8088
7705
  }
8089
- // Traverse the tree and destroy all tiles
8090
7706
  _destroy() {
8091
7707
  const stack = [];
8092
7708
  if (this.root) {
@@ -8101,7 +7717,6 @@ var __exports__ = (() => {
8101
7717
  }
8102
7718
  this.root = null;
8103
7719
  }
8104
- // Traverse the tree and destroy all sub tiles
8105
7720
  _destroySubtree(tile) {
8106
7721
  const root = tile;
8107
7722
  const stack = [];