@loaders.gl/tiles 4.2.0-alpha.4 → 4.2.0-alpha.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.
Files changed (73) hide show
  1. package/dist/constants.js +34 -32
  2. package/dist/dist.dev.js +723 -342
  3. package/dist/dist.min.js +9 -0
  4. package/dist/index.cjs +98 -240
  5. package/dist/index.cjs.map +7 -0
  6. package/dist/index.d.ts +10 -10
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -1
  9. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts +1 -1
  10. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -1
  11. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js +45 -35
  12. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js +40 -22
  13. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts +1 -1
  14. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts.map +1 -1
  15. package/dist/tileset/format-i3s/i3s-tile-manager.js +67 -69
  16. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts +2 -2
  17. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts.map +1 -1
  18. package/dist/tileset/format-i3s/i3s-tileset-traverser.js +78 -57
  19. package/dist/tileset/helpers/3d-tiles-options.d.ts +1 -1
  20. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -1
  21. package/dist/tileset/helpers/3d-tiles-options.js +3 -4
  22. package/dist/tileset/helpers/bounding-volume.js +269 -128
  23. package/dist/tileset/helpers/frame-state.d.ts +1 -1
  24. package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
  25. package/dist/tileset/helpers/frame-state.js +114 -95
  26. package/dist/tileset/helpers/i3s-lod.d.ts +2 -2
  27. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -1
  28. package/dist/tileset/helpers/i3s-lod.js +68 -39
  29. package/dist/tileset/helpers/tiles-3d-lod.js +97 -85
  30. package/dist/tileset/helpers/transform-utils.js +45 -44
  31. package/dist/tileset/helpers/zoom.d.ts +1 -1
  32. package/dist/tileset/helpers/zoom.d.ts.map +1 -1
  33. package/dist/tileset/helpers/zoom.js +70 -40
  34. package/dist/tileset/tile-3d.d.ts +5 -5
  35. package/dist/tileset/tile-3d.d.ts.map +1 -1
  36. package/dist/tileset/tile-3d.js +595 -399
  37. package/dist/tileset/tileset-3d.d.ts +5 -5
  38. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  39. package/dist/tileset/tileset-3d.js +721 -597
  40. package/dist/tileset/tileset-cache.d.ts +2 -2
  41. package/dist/tileset/tileset-cache.d.ts.map +1 -1
  42. package/dist/tileset/tileset-cache.js +62 -48
  43. package/dist/tileset/tileset-traverser.d.ts +3 -3
  44. package/dist/tileset/tileset-traverser.d.ts.map +1 -1
  45. package/dist/tileset/tileset-traverser.js +281 -220
  46. package/dist/types.js +0 -1
  47. package/dist/utils/doubly-linked-list-node.js +14 -9
  48. package/dist/utils/doubly-linked-list.d.ts +1 -1
  49. package/dist/utils/doubly-linked-list.d.ts.map +1 -1
  50. package/dist/utils/doubly-linked-list.js +85 -56
  51. package/dist/utils/managed-array.js +138 -76
  52. package/package.json +10 -9
  53. package/dist/constants.js.map +0 -1
  54. package/dist/index.js.map +0 -1
  55. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js.map +0 -1
  56. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js.map +0 -1
  57. package/dist/tileset/format-i3s/i3s-tile-manager.js.map +0 -1
  58. package/dist/tileset/format-i3s/i3s-tileset-traverser.js.map +0 -1
  59. package/dist/tileset/helpers/3d-tiles-options.js.map +0 -1
  60. package/dist/tileset/helpers/bounding-volume.js.map +0 -1
  61. package/dist/tileset/helpers/frame-state.js.map +0 -1
  62. package/dist/tileset/helpers/i3s-lod.js.map +0 -1
  63. package/dist/tileset/helpers/tiles-3d-lod.js.map +0 -1
  64. package/dist/tileset/helpers/transform-utils.js.map +0 -1
  65. package/dist/tileset/helpers/zoom.js.map +0 -1
  66. package/dist/tileset/tile-3d.js.map +0 -1
  67. package/dist/tileset/tileset-3d.js.map +0 -1
  68. package/dist/tileset/tileset-cache.js.map +0 -1
  69. package/dist/tileset/tileset-traverser.js.map +0 -1
  70. package/dist/types.js.map +0 -1
  71. package/dist/utils/doubly-linked-list-node.js.map +0 -1
  72. package/dist/utils/doubly-linked-list.js.map +0 -1
  73. package/dist/utils/managed-array.js.map +0 -1
package/dist/dist.dev.js CHANGED
@@ -2,8 +2,8 @@
2
2
  if (typeof exports === 'object' && typeof module === 'object')
3
3
  module.exports = factory();
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
- else if (typeof exports === 'object') exports['loader'] = factory();
6
- else root['loader'] = factory();})(globalThis, function () {
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
7
  "use strict";
8
8
  var __exports__ = (() => {
9
9
  var __create = Object.create;
@@ -27,6 +27,7 @@ var __exports__ = (() => {
27
27
  }
28
28
  return to;
29
29
  };
30
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
30
31
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
32
  // If the importer is in node compatibility mode or this is not an ESM
32
33
  // file that has been converted to a CommonJS file using a Babel-
@@ -44,9 +45,9 @@ var __exports__ = (() => {
44
45
  }
45
46
  });
46
47
 
47
- // src/index.ts
48
- var src_exports = {};
49
- __export(src_exports, {
48
+ // bundle.ts
49
+ var bundle_exports = {};
50
+ __export(bundle_exports, {
50
51
  LOD_METRIC_TYPE: () => LOD_METRIC_TYPE,
51
52
  TILESET_TYPE: () => TILESET_TYPE,
52
53
  TILE_CONTENT_STATE: () => TILE_CONTENT_STATE,
@@ -61,6 +62,7 @@ var __exports__ = (() => {
61
62
  getFrameState: () => getFrameState,
62
63
  getLodStatus: () => getLodStatus
63
64
  });
65
+ __reExport(bundle_exports, __toESM(require_core(), 1));
64
66
 
65
67
  // ../../node_modules/@math.gl/core/dist/lib/common.js
66
68
  var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
@@ -4949,43 +4951,56 @@ var __exports__ = (() => {
4949
4951
  var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
4950
4952
  var DEFAULT_PROPS = {
4951
4953
  id: "request-scheduler",
4954
+ /** Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing. */
4952
4955
  throttleRequests: true,
4953
- maxRequests: 6
4956
+ /** The maximum number of simultaneous active requests. Un-throttled requests do not observe this limit. */
4957
+ maxRequests: 6,
4958
+ /**
4959
+ * Specifies a debounce time, in milliseconds. All requests are queued, until no new requests have
4960
+ * been added to the queue for this amount of time.
4961
+ */
4962
+ debounceTime: 0
4954
4963
  };
4955
4964
  var RequestScheduler = class {
4956
- activeRequestCount = 0;
4957
- requestQueue = [];
4958
- requestMap = /* @__PURE__ */ new Map();
4959
- deferredUpdate = null;
4960
4965
  constructor(props = {}) {
4961
- this.props = {
4962
- ...DEFAULT_PROPS,
4963
- ...props
4964
- };
4965
- this.stats = new Stats2({
4966
- id: this.props.id
4967
- });
4966
+ this.activeRequestCount = 0;
4967
+ /** Tracks the number of active requests and prioritizes/cancels queued requests. */
4968
+ this.requestQueue = [];
4969
+ this.requestMap = /* @__PURE__ */ new Map();
4970
+ this.updateTimer = null;
4971
+ this.props = { ...DEFAULT_PROPS, ...props };
4972
+ this.stats = new Stats2({ id: this.props.id });
4968
4973
  this.stats.get(STAT_QUEUED_REQUESTS);
4969
4974
  this.stats.get(STAT_ACTIVE_REQUESTS);
4970
4975
  this.stats.get(STAT_CANCELLED_REQUESTS);
4971
4976
  this.stats.get(STAT_QUEUED_REQUESTS_EVER);
4972
4977
  this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
4973
4978
  }
4979
+ /**
4980
+ * Called by an application that wants to issue a request, without having it deeply queued by the browser
4981
+ *
4982
+ * When the returned promise resolved, it is OK for the application to issue a request.
4983
+ * The promise resolves to an object that contains a `done` method.
4984
+ * When the application's request has completed (or failed), the application must call the `done` function
4985
+ *
4986
+ * @param handle
4987
+ * @param getPriority will be called when request "slots" open up,
4988
+ * allowing the caller to update priority or cancel the request
4989
+ * Highest priority executes first, priority < 0 cancels the request
4990
+ * @returns a promise
4991
+ * - resolves to a object (with a `done` field) when the request can be issued without queueing,
4992
+ * - resolves to `null` if the request has been cancelled (by the callback return < 0).
4993
+ * In this case the application should not issue the request
4994
+ */
4974
4995
  scheduleRequest(handle, getPriority = () => 0) {
4975
4996
  if (!this.props.throttleRequests) {
4976
- return Promise.resolve({
4977
- done: () => {
4978
- }
4979
- });
4997
+ return Promise.resolve({ done: () => {
4998
+ } });
4980
4999
  }
4981
5000
  if (this.requestMap.has(handle)) {
4982
5001
  return this.requestMap.get(handle);
4983
5002
  }
4984
- const request = {
4985
- handle,
4986
- priority: 0,
4987
- getPriority
4988
- };
5003
+ const request = { handle, priority: 0, getPriority };
4989
5004
  const promise = new Promise((resolve2) => {
4990
5005
  request.resolve = resolve2;
4991
5006
  return request;
@@ -4995,11 +5010,9 @@ var __exports__ = (() => {
4995
5010
  this._issueNewRequests();
4996
5011
  return promise;
4997
5012
  }
5013
+ // PRIVATE
4998
5014
  _issueRequest(request) {
4999
- const {
5000
- handle,
5001
- resolve: resolve2
5002
- } = request;
5015
+ const { handle, resolve: resolve2 } = request;
5003
5016
  let isDone = false;
5004
5017
  const done = () => {
5005
5018
  if (!isDone) {
@@ -5010,19 +5023,21 @@ var __exports__ = (() => {
5010
5023
  }
5011
5024
  };
5012
5025
  this.activeRequestCount++;
5013
- return resolve2 ? resolve2({
5014
- done
5015
- }) : Promise.resolve({
5016
- done
5017
- });
5026
+ return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
5018
5027
  }
5028
+ /** We check requests asynchronously, to prevent multiple updates */
5019
5029
  _issueNewRequests() {
5020
- if (!this.deferredUpdate) {
5021
- this.deferredUpdate = setTimeout(() => this._issueNewRequestsAsync(), 0);
5030
+ if (this.updateTimer !== null) {
5031
+ clearTimeout(this.updateTimer);
5022
5032
  }
5033
+ this.updateTimer = setTimeout(() => this._issueNewRequestsAsync(), this.props.debounceTime);
5023
5034
  }
5035
+ /** Refresh all requests */
5024
5036
  _issueNewRequestsAsync() {
5025
- this.deferredUpdate = null;
5037
+ if (this.updateTimer !== null) {
5038
+ clearTimeout(this.updateTimer);
5039
+ }
5040
+ this.updateTimer = null;
5026
5041
  const freeSlots = Math.max(this.props.maxRequests - this.activeRequestCount, 0);
5027
5042
  if (freeSlots === 0) {
5028
5043
  return;
@@ -5035,6 +5050,7 @@ var __exports__ = (() => {
5035
5050
  }
5036
5051
  }
5037
5052
  }
5053
+ /** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */
5038
5054
  _updateAllRequests() {
5039
5055
  const requestQueue = this.requestQueue;
5040
5056
  for (let i = 0; i < requestQueue.length; ++i) {
@@ -5047,6 +5063,7 @@ var __exports__ = (() => {
5047
5063
  }
5048
5064
  requestQueue.sort((a, b) => a.priority - b.priority);
5049
5065
  }
5066
+ /** Update a single request by calling the callback */
5050
5067
  _updateRequest(request) {
5051
5068
  request.priority = request.getPriority(request.handle);
5052
5069
  if (request.priority < 0) {
@@ -5211,12 +5228,19 @@ var __exports__ = (() => {
5211
5228
 
5212
5229
  // src/utils/doubly-linked-list.ts
5213
5230
  var DoublyLinkedList = class {
5214
- head = null;
5215
- tail = null;
5216
- _length = 0;
5231
+ constructor() {
5232
+ this.head = null;
5233
+ this.tail = null;
5234
+ this._length = 0;
5235
+ }
5217
5236
  get length() {
5218
5237
  return this._length;
5219
5238
  }
5239
+ /**
5240
+ * Adds the item to the end of the list
5241
+ * @param {*} [item]
5242
+ * @return {DoublyLinkedListNode}
5243
+ */
5220
5244
  add(item) {
5221
5245
  const node = new DoublyLinkedListNode(item, this.tail, null);
5222
5246
  if (this.tail) {
@@ -5229,6 +5253,10 @@ var __exports__ = (() => {
5229
5253
  ++this._length;
5230
5254
  return node;
5231
5255
  }
5256
+ /**
5257
+ * Removes the given node from the list
5258
+ * @param {DoublyLinkedListNode} node
5259
+ */
5232
5260
  remove(node) {
5233
5261
  if (!node) {
5234
5262
  return;
@@ -5250,6 +5278,11 @@ var __exports__ = (() => {
5250
5278
  node.previous = null;
5251
5279
  --this._length;
5252
5280
  }
5281
+ /**
5282
+ * Moves nextNode after node
5283
+ * @param {DoublyLinkedListNode} node
5284
+ * @param {DoublyLinkedListNode} nextNode
5285
+ */
5253
5286
  splice(node, nextNode) {
5254
5287
  if (node === nextNode) {
5255
5288
  return;
@@ -5328,15 +5361,10 @@ var __exports__ = (() => {
5328
5361
  function calculateTransformProps(tileHeader, tile) {
5329
5362
  assert2(tileHeader);
5330
5363
  assert2(tile);
5331
- const {
5332
- rtcCenter,
5333
- gltfUpAxis
5334
- } = tile;
5364
+ const { rtcCenter, gltfUpAxis } = tile;
5335
5365
  const {
5336
5366
  computedTransform,
5337
- boundingVolume: {
5338
- center
5339
- }
5367
+ boundingVolume: { center }
5340
5368
  } = tileHeader;
5341
5369
  let modelMatrix = new Matrix4(computedTransform);
5342
5370
  if (rtcCenter) {
@@ -5362,7 +5390,10 @@ var __exports__ = (() => {
5362
5390
  const cartesianOrigin = new Vector3(center);
5363
5391
  tile.cartesianModelMatrix = modelMatrix;
5364
5392
  tile.cartesianOrigin = cartesianOrigin;
5365
- const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new Vector3());
5393
+ const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(
5394
+ cartesianOrigin,
5395
+ new Vector3()
5396
+ );
5366
5397
  const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);
5367
5398
  const toFixedFrameMatrix = fromFixedFrameMatrix.invert();
5368
5399
  tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);
@@ -5825,31 +5856,35 @@ var __exports__ = (() => {
5825
5856
  // src/tileset/helpers/frame-state.ts
5826
5857
  var scratchVector8 = new Vector3();
5827
5858
  var scratchPosition3 = new Vector3();
5828
- var cullingVolume = new CullingVolume([new Plane(), new Plane(), new Plane(), new Plane(), new Plane(), new Plane()]);
5859
+ var cullingVolume = new CullingVolume([
5860
+ new Plane(),
5861
+ new Plane(),
5862
+ new Plane(),
5863
+ new Plane(),
5864
+ new Plane(),
5865
+ new Plane()
5866
+ ]);
5829
5867
  function getFrameState(viewport, frameNumber) {
5830
- const {
5831
- cameraDirection,
5832
- cameraUp,
5833
- height
5834
- } = viewport;
5835
- const {
5836
- metersPerUnit
5837
- } = viewport.distanceScales;
5868
+ const { cameraDirection, cameraUp, height } = viewport;
5869
+ const { metersPerUnit } = viewport.distanceScales;
5838
5870
  const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);
5839
5871
  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
5840
5872
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
5841
- const cameraPositionCartesian2 = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
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();
5873
+ const cameraPositionCartesian2 = Ellipsoid.WGS84.cartographicToCartesian(
5874
+ cameraPositionCartographic,
5875
+ new Vector3()
5876
+ );
5877
+ const cameraDirectionCartesian = new Vector3(
5878
+ // @ts-ignore
5879
+ enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))
5880
+ ).normalize();
5881
+ const cameraUpCartesian = new Vector3(
5882
+ // @ts-ignore
5883
+ enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))
5884
+ ).normalize();
5844
5885
  commonSpacePlanesToWGS84(viewport);
5845
5886
  const ViewportClass = viewport.constructor;
5846
- const {
5847
- longitude,
5848
- latitude,
5849
- width,
5850
- bearing,
5851
- zoom
5852
- } = viewport;
5887
+ const { longitude, latitude, width, bearing, zoom } = viewport;
5853
5888
  const topDownViewport = new ViewportClass({
5854
5889
  longitude,
5855
5890
  latitude,
@@ -5870,7 +5905,9 @@ var __exports__ = (() => {
5870
5905
  height,
5871
5906
  cullingVolume,
5872
5907
  frameNumber,
5908
+ // TODO: This can be the same between updates, what number is unique for between updates?
5873
5909
  sseDenominator: 1.15
5910
+ // Assumes fovy = 60 degrees
5874
5911
  };
5875
5912
  }
5876
5913
  function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
@@ -5878,10 +5915,7 @@ var __exports__ = (() => {
5878
5915
  return [tiles, []];
5879
5916
  }
5880
5917
  const tuples = [];
5881
- const {
5882
- longitude: viewportLongitude,
5883
- latitude: viewportLatitude
5884
- } = frameState.viewport;
5918
+ const { longitude: viewportLongitude, latitude: viewportLatitude } = frameState.viewport;
5885
5919
  for (const [index, tile] of tiles.entries()) {
5886
5920
  const [longitude, latitude] = tile.header.mbs;
5887
5921
  const deltaLon = Math.abs(viewportLongitude - longitude);
@@ -5906,7 +5940,10 @@ var __exports__ = (() => {
5906
5940
  const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);
5907
5941
  const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition3);
5908
5942
  let i = 0;
5909
- cullingVolume.planes[i++].fromPointNormal(nearCenterCartesian, scratchVector8.copy(nearCenterCartesian).subtract(cameraCartesian));
5943
+ cullingVolume.planes[i++].fromPointNormal(
5944
+ nearCenterCartesian,
5945
+ scratchVector8.copy(nearCenterCartesian).subtract(cameraCartesian)
5946
+ );
5910
5947
  for (const dir in frustumPlanes) {
5911
5948
  if (dir === "near") {
5912
5949
  continue;
@@ -5914,7 +5951,11 @@ var __exports__ = (() => {
5914
5951
  const plane = frustumPlanes[dir];
5915
5952
  const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition3);
5916
5953
  const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition3);
5917
- cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector8.copy(nearCenterCartesian).subtract(cartesianPos));
5954
+ cullingVolume.planes[i++].fromPointNormal(
5955
+ cartesianPos,
5956
+ // Want the normal to point into the frustum since that's what culling expects
5957
+ scratchVector8.copy(nearCenterCartesian).subtract(cartesianPos)
5958
+ );
5918
5959
  }
5919
5960
  }
5920
5961
  function closestPointOnPlane(plane, refPoint, out = new Vector3()) {
@@ -5934,21 +5975,14 @@ var __exports__ = (() => {
5934
5975
  var scratchVector9 = new Vector3();
5935
5976
  function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
5936
5977
  if (boundingVolume instanceof OrientedBoundingBox) {
5937
- const {
5938
- halfAxes
5939
- } = boundingVolume;
5978
+ const { halfAxes } = boundingVolume;
5940
5979
  const obbSize = getObbSize(halfAxes);
5941
5980
  return Math.log2(WGS84_RADIUS_Z2 / (obbSize + cartorgraphicCenter[2]));
5942
5981
  } else if (boundingVolume instanceof BoundingSphere) {
5943
- const {
5944
- radius
5945
- } = boundingVolume;
5982
+ const { radius } = boundingVolume;
5946
5983
  return Math.log2(WGS84_RADIUS_Z2 / (radius + cartorgraphicCenter[2]));
5947
5984
  } else if (boundingVolume.width && boundingVolume.height) {
5948
- const {
5949
- width,
5950
- height
5951
- } = boundingVolume;
5985
+ const { width, height } = boundingVolume;
5952
5986
  const zoomX = Math.log2(WGS84_RADIUS_X2 / width);
5953
5987
  const zoomY = Math.log2(WGS84_RADIUS_Y2 / height);
5954
5988
  return (zoomX + zoomY) / 2;
@@ -5956,20 +5990,22 @@ var __exports__ = (() => {
5956
5990
  return 1;
5957
5991
  }
5958
5992
  function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
5959
- Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], scratchVector9);
5960
- const extentSize = Math.sqrt(Math.pow(scratchVector9[0] - cartesianCenter[0], 2) + Math.pow(scratchVector9[1] - cartesianCenter[1], 2) + Math.pow(scratchVector9[2] - cartesianCenter[2], 2));
5993
+ Ellipsoid.WGS84.cartographicToCartesian(
5994
+ [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],
5995
+ scratchVector9
5996
+ );
5997
+ const extentSize = Math.sqrt(
5998
+ Math.pow(scratchVector9[0] - cartesianCenter[0], 2) + Math.pow(scratchVector9[1] - cartesianCenter[1], 2) + Math.pow(scratchVector9[2] - cartesianCenter[2], 2)
5999
+ );
5961
6000
  return Math.log2(WGS84_RADIUS_Z2 / (extentSize + cartorgraphicCenter[2]));
5962
6001
  }
5963
6002
  function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
5964
6003
  const [xmin, ymin, xmax, ymax] = extent;
5965
- return getZoomFromFullExtent({
5966
- xmin,
5967
- xmax,
5968
- ymin,
5969
- ymax,
5970
- zmin: 0,
5971
- zmax: 0
5972
- }, cartorgraphicCenter, cartesianCenter);
6004
+ return getZoomFromFullExtent(
6005
+ { xmin, xmax, ymin, ymax, zmin: 0, zmax: 0 },
6006
+ cartorgraphicCenter,
6007
+ cartesianCenter
6008
+ );
5973
6009
  }
5974
6010
  function getObbSize(halfAxes) {
5975
6011
  halfAxes.getColumn(0, scratchVector9);
@@ -5986,34 +6022,40 @@ var __exports__ = (() => {
5986
6022
  // src/constants.ts
5987
6023
  var TILE_CONTENT_STATE = {
5988
6024
  UNLOADED: 0,
6025
+ // Has never been requested
5989
6026
  LOADING: 1,
6027
+ // Is waiting on a pending request
5990
6028
  PROCESSING: 2,
6029
+ // Request received. Contents are being processed for rendering. Depending on the content, it might make its own requests for external data.
5991
6030
  READY: 3,
6031
+ // Ready to render.
5992
6032
  EXPIRED: 4,
6033
+ // Is expired and will be unloaded once new content is loaded.
5993
6034
  FAILED: 5
6035
+ // Request failed.
5994
6036
  };
5995
- var TILE_REFINEMENT = function(TILE_REFINEMENT2) {
6037
+ var TILE_REFINEMENT = /* @__PURE__ */ ((TILE_REFINEMENT2) => {
5996
6038
  TILE_REFINEMENT2[TILE_REFINEMENT2["ADD"] = 1] = "ADD";
5997
6039
  TILE_REFINEMENT2[TILE_REFINEMENT2["REPLACE"] = 2] = "REPLACE";
5998
6040
  return TILE_REFINEMENT2;
5999
- }({});
6000
- var TILE_TYPE = function(TILE_TYPE2) {
6041
+ })(TILE_REFINEMENT || {});
6042
+ var TILE_TYPE = /* @__PURE__ */ ((TILE_TYPE2) => {
6001
6043
  TILE_TYPE2["EMPTY"] = "empty";
6002
6044
  TILE_TYPE2["SCENEGRAPH"] = "scenegraph";
6003
6045
  TILE_TYPE2["POINTCLOUD"] = "pointcloud";
6004
6046
  TILE_TYPE2["MESH"] = "mesh";
6005
6047
  return TILE_TYPE2;
6006
- }({});
6007
- var TILESET_TYPE = function(TILESET_TYPE2) {
6048
+ })(TILE_TYPE || {});
6049
+ var TILESET_TYPE = /* @__PURE__ */ ((TILESET_TYPE2) => {
6008
6050
  TILESET_TYPE2["I3S"] = "I3S";
6009
6051
  TILESET_TYPE2["TILES3D"] = "TILES3D";
6010
6052
  return TILESET_TYPE2;
6011
- }({});
6012
- var LOD_METRIC_TYPE = function(LOD_METRIC_TYPE2) {
6053
+ })(TILESET_TYPE || {});
6054
+ var LOD_METRIC_TYPE = /* @__PURE__ */ ((LOD_METRIC_TYPE2) => {
6013
6055
  LOD_METRIC_TYPE2["GEOMETRIC_ERROR"] = "geometricError";
6014
6056
  LOD_METRIC_TYPE2["MAX_SCREEN_THRESHOLD"] = "maxScreenThreshold";
6015
6057
  return LOD_METRIC_TYPE2;
6016
- }({});
6058
+ })(LOD_METRIC_TYPE || {});
6017
6059
  var TILE3D_OPTIMIZATION_HINT = {
6018
6060
  NOT_COMPUTED: -1,
6019
6061
  USE_OPTIMIZATION: 1,
@@ -6051,7 +6093,10 @@ var __exports__ = (() => {
6051
6093
  }
6052
6094
  if (boundingVolumeHeader.region) {
6053
6095
  const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
6054
- return [[degrees(west), degrees(south), minHeight], [degrees(east), degrees(north), maxHeight]];
6096
+ return [
6097
+ [degrees(west), degrees(south), minHeight],
6098
+ [degrees(east), degrees(north), maxHeight]
6099
+ ];
6055
6100
  }
6056
6101
  if (boundingVolumeHeader.sphere) {
6057
6102
  return boundingSphereToCartographicBounds(boundingVolume);
@@ -6082,7 +6127,17 @@ var __exports__ = (() => {
6082
6127
  const xAxis = transform.transformAsVector(origin.slice(0, 3));
6083
6128
  const yAxis = transform.transformAsVector(origin.slice(3, 6));
6084
6129
  const zAxis = transform.transformAsVector(origin.slice(6, 9));
6085
- const halfAxes = new Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
6130
+ const halfAxes = new Matrix3([
6131
+ xAxis[0],
6132
+ xAxis[1],
6133
+ xAxis[2],
6134
+ yAxis[0],
6135
+ yAxis[1],
6136
+ yAxis[2],
6137
+ zAxis[0],
6138
+ zAxis[1],
6139
+ zAxis[2]
6140
+ ]);
6086
6141
  if (defined(result)) {
6087
6142
  result.center = center;
6088
6143
  result.halfAxes = halfAxes;
@@ -6105,20 +6160,41 @@ var __exports__ = (() => {
6105
6160
  }
6106
6161
  function createObbFromRegion(region) {
6107
6162
  const [west, south, east, north, minHeight, maxHeight] = region;
6108
- const northWest = Ellipsoid.WGS84.cartographicToCartesian([degrees(west), degrees(north), minHeight], scratchNorthWest);
6109
- const southEast = Ellipsoid.WGS84.cartographicToCartesian([degrees(east), degrees(south), maxHeight], scratchSouthEast);
6163
+ const northWest = Ellipsoid.WGS84.cartographicToCartesian(
6164
+ [degrees(west), degrees(north), minHeight],
6165
+ scratchNorthWest
6166
+ );
6167
+ const southEast = Ellipsoid.WGS84.cartographicToCartesian(
6168
+ [degrees(east), degrees(south), maxHeight],
6169
+ scratchSouthEast
6170
+ );
6110
6171
  const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyByScalar(0.5);
6111
6172
  Ellipsoid.WGS84.cartesianToCartographic(centerInCartesian, scratchCenter);
6112
- Ellipsoid.WGS84.cartographicToCartesian([degrees(east), scratchCenter[1], scratchCenter[2]], scratchXAxis);
6113
- Ellipsoid.WGS84.cartographicToCartesian([scratchCenter[0], degrees(north), scratchCenter[2]], scratchYAxis);
6114
- Ellipsoid.WGS84.cartographicToCartesian([scratchCenter[0], scratchCenter[1], maxHeight], scratchZAxis);
6115
- return createBox([...centerInCartesian, ...scratchXAxis.subtract(centerInCartesian), ...scratchYAxis.subtract(centerInCartesian), ...scratchZAxis.subtract(centerInCartesian)], new Matrix4());
6173
+ Ellipsoid.WGS84.cartographicToCartesian(
6174
+ [degrees(east), scratchCenter[1], scratchCenter[2]],
6175
+ scratchXAxis
6176
+ );
6177
+ Ellipsoid.WGS84.cartographicToCartesian(
6178
+ [scratchCenter[0], degrees(north), scratchCenter[2]],
6179
+ scratchYAxis
6180
+ );
6181
+ Ellipsoid.WGS84.cartographicToCartesian(
6182
+ [scratchCenter[0], scratchCenter[1], maxHeight],
6183
+ scratchZAxis
6184
+ );
6185
+ return createBox(
6186
+ [
6187
+ ...centerInCartesian,
6188
+ ...scratchXAxis.subtract(centerInCartesian),
6189
+ ...scratchYAxis.subtract(centerInCartesian),
6190
+ ...scratchZAxis.subtract(centerInCartesian)
6191
+ ],
6192
+ new Matrix4()
6193
+ );
6116
6194
  }
6117
6195
  function orientedBoundingBoxToCartographicBounds(boundingVolume) {
6118
6196
  const result = emptyCartographicBounds();
6119
- const {
6120
- halfAxes
6121
- } = boundingVolume;
6197
+ const { halfAxes } = boundingVolume;
6122
6198
  const xAxis = new Vector3(halfAxes.getColumn(0));
6123
6199
  const yAxis = new Vector3(halfAxes.getColumn(1));
6124
6200
  const zAxis = new Vector3(halfAxes.getColumn(2));
@@ -6140,10 +6216,7 @@ var __exports__ = (() => {
6140
6216
  }
6141
6217
  function boundingSphereToCartographicBounds(boundingVolume) {
6142
6218
  const result = emptyCartographicBounds();
6143
- const {
6144
- center,
6145
- radius
6146
- } = boundingVolume;
6219
+ const { center, radius } = boundingVolume;
6147
6220
  const point = Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);
6148
6221
  let zAxis;
6149
6222
  if (point) {
@@ -6170,7 +6243,10 @@ var __exports__ = (() => {
6170
6243
  return result;
6171
6244
  }
6172
6245
  function emptyCartographicBounds() {
6173
- return [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
6246
+ return [
6247
+ [Infinity, Infinity, Infinity],
6248
+ [-Infinity, -Infinity, -Infinity]
6249
+ ];
6174
6250
  }
6175
6251
  function addToCartographicBounds(target, cartesian) {
6176
6252
  Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);
@@ -6210,13 +6286,8 @@ var __exports__ = (() => {
6210
6286
  return 0;
6211
6287
  }
6212
6288
  const distance2 = Math.max(tile._distanceToCamera, 1e-7);
6213
- const {
6214
- height,
6215
- sseDenominator
6216
- } = frameState;
6217
- const {
6218
- viewDistanceScale
6219
- } = tileset.options;
6289
+ const { height, sseDenominator } = frameState;
6290
+ const { viewDistanceScale } = tileset.options;
6220
6291
  let error = lodMetricValue * height * (viewDistanceScale || 1) / (distance2 * sseDenominator);
6221
6292
  error -= getDynamicScreenSpaceError(tileset, distance2);
6222
6293
  return error;
@@ -6246,9 +6317,7 @@ var __exports__ = (() => {
6246
6317
  return "OUT";
6247
6318
  }
6248
6319
  function getProjectedRadius(tile, frameState) {
6249
- const {
6250
- topDownViewport: viewport
6251
- } = frameState;
6320
+ const { topDownViewport: viewport } = frameState;
6252
6321
  const mbsLat = tile.header.mbs[1];
6253
6322
  const mbsLon = tile.header.mbs[0];
6254
6323
  const mbsZ = tile.header.mbs[2];
@@ -6260,16 +6329,22 @@ var __exports__ = (() => {
6260
6329
  Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
6261
6330
  cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();
6262
6331
  cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);
6263
- const projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
6332
+ const projection = Math.sqrt(
6333
+ cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]
6334
+ );
6264
6335
  const extraZ = projection * projection / cameraPositionEnu[2];
6265
6336
  extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
6266
6337
  const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
6267
6338
  const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();
6268
6339
  const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
6269
6340
  const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);
6270
- const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
6341
+ const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(
6342
+ sphereMbsBorderVertexCartesian
6343
+ );
6271
6344
  const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
6272
- const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
6345
+ const projectedMbsBorderVertex = viewport.project(
6346
+ sphereMbsBorderVertexCartographic
6347
+ );
6273
6348
  const projectedRadius = projectedOriginVector.copy(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
6274
6349
  return projectedRadius;
6275
6350
  }
@@ -6283,11 +6358,18 @@ var __exports__ = (() => {
6283
6358
 
6284
6359
  // src/utils/managed-array.ts
6285
6360
  var ManagedArray = class {
6286
- _map = /* @__PURE__ */ new Map();
6287
6361
  constructor(length4 = 0) {
6362
+ this._map = /* @__PURE__ */ new Map();
6288
6363
  this._array = new Array(length4);
6289
6364
  this._length = length4;
6290
6365
  }
6366
+ /**
6367
+ * Gets or sets the length of the array.
6368
+ * If the set length is greater than the length of the internal array, the internal array is resized.
6369
+ *
6370
+ * @memberof ManagedArray.prototype
6371
+ * @type Number
6372
+ */
6291
6373
  get length() {
6292
6374
  return this._length;
6293
6375
  }
@@ -6297,13 +6379,31 @@ var __exports__ = (() => {
6297
6379
  this._array.length = length4;
6298
6380
  }
6299
6381
  }
6382
+ /**
6383
+ * Gets the internal array.
6384
+ *
6385
+ * @memberof ManagedArray.prototype
6386
+ * @type Array
6387
+ * @readonly
6388
+ */
6300
6389
  get values() {
6301
6390
  return this._array;
6302
6391
  }
6392
+ /**
6393
+ * Gets the element at an index.
6394
+ *
6395
+ * @param {Number} index The index to get.
6396
+ */
6303
6397
  get(index) {
6304
6398
  assert2(index < this._array.length);
6305
6399
  return this._array[index];
6306
6400
  }
6401
+ /**
6402
+ * Sets the element at an index. Resizes the array if index is greater than the length of the array.
6403
+ *
6404
+ * @param {Number} index The index to set.
6405
+ * @param {*} element The element to set at index.
6406
+ */
6307
6407
  set(index, element) {
6308
6408
  assert2(index >= 0);
6309
6409
  if (index >= this.length) {
@@ -6323,9 +6423,19 @@ var __exports__ = (() => {
6323
6423
  this.length--;
6324
6424
  }
6325
6425
  }
6426
+ /**
6427
+ * Returns the last element in the array without modifying the array.
6428
+ *
6429
+ * @returns {*} The last element in the array.
6430
+ */
6326
6431
  peek() {
6327
6432
  return this._array[this._length - 1];
6328
6433
  }
6434
+ /**
6435
+ * Push an element into the array.
6436
+ *
6437
+ * @param {*} element The element to push.
6438
+ */
6329
6439
  push(element) {
6330
6440
  if (!this._map.has(element)) {
6331
6441
  const index = this.length++;
@@ -6333,21 +6443,41 @@ var __exports__ = (() => {
6333
6443
  this._map.set(element, index);
6334
6444
  }
6335
6445
  }
6446
+ /**
6447
+ * Pop an element from the array.
6448
+ *
6449
+ * @returns {*} The last element in the array.
6450
+ */
6336
6451
  pop() {
6337
6452
  const element = this._array[--this.length];
6338
6453
  this._map.delete(element);
6339
6454
  return element;
6340
6455
  }
6456
+ /**
6457
+ * Resize the internal array if length > _array.length.
6458
+ *
6459
+ * @param {Number} length The length.
6460
+ */
6341
6461
  reserve(length4) {
6342
6462
  assert2(length4 >= 0);
6343
6463
  if (length4 > this._array.length) {
6344
6464
  this._array.length = length4;
6345
6465
  }
6346
6466
  }
6467
+ /**
6468
+ * Resize the array.
6469
+ *
6470
+ * @param {Number} length The length.
6471
+ */
6347
6472
  resize(length4) {
6348
6473
  assert2(length4 >= 0);
6349
6474
  this.length = length4;
6350
6475
  }
6476
+ /**
6477
+ * Trim the internal array to the specified length. Defaults to the current length.
6478
+ *
6479
+ * @param {Number} [length] The length.
6480
+ */
6351
6481
  trim(length4) {
6352
6482
  if (length4 === null || length4 === void 0) {
6353
6483
  length4 = this.length;
@@ -6375,30 +6505,33 @@ var __exports__ = (() => {
6375
6505
  basePath: ""
6376
6506
  };
6377
6507
  var TilesetTraverser = class {
6378
- root = null;
6379
- selectedTiles = {};
6380
- requestedTiles = {};
6381
- emptyTiles = {};
6382
- lastUpdate = new Date().getTime();
6383
- updateDebounceTime = 1e3;
6384
- _traversalStack = new ManagedArray();
6385
- _emptyTraversalStack = new ManagedArray();
6386
- _frameNumber = null;
6508
+ // TODO nested props
6509
+ constructor(options) {
6510
+ // fulfill in traverse call
6511
+ this.root = null;
6512
+ // tiles should be rendered
6513
+ this.selectedTiles = {};
6514
+ // tiles should be loaded from server
6515
+ this.requestedTiles = {};
6516
+ // tiles does not have render content
6517
+ this.emptyTiles = {};
6518
+ this.lastUpdate = new Date().getTime();
6519
+ this.updateDebounceTime = 1e3;
6520
+ /** temporary storage to hold the traversed tiles during a traversal */
6521
+ this._traversalStack = new ManagedArray();
6522
+ this._emptyTraversalStack = new ManagedArray();
6523
+ /** set in every traverse cycle */
6524
+ this._frameNumber = null;
6525
+ this.options = { ...DEFAULT_PROPS2, ...options };
6526
+ }
6527
+ // RESULT
6387
6528
  traversalFinished(frameState) {
6388
6529
  return true;
6389
6530
  }
6390
- constructor(options) {
6391
- this.options = {
6392
- ...DEFAULT_PROPS2,
6393
- ...options
6394
- };
6395
- }
6531
+ // tiles should be visible
6396
6532
  traverse(root, frameState, options) {
6397
6533
  this.root = root;
6398
- this.options = {
6399
- ...this.options,
6400
- ...options
6401
- };
6534
+ this.options = { ...this.options, ...options };
6402
6535
  this.reset();
6403
6536
  this.updateTile(root, frameState);
6404
6537
  this._frameNumber = frameState.frameNumber;
@@ -6411,6 +6544,16 @@ var __exports__ = (() => {
6411
6544
  this._traversalStack.reset();
6412
6545
  this._emptyTraversalStack.reset();
6413
6546
  }
6547
+ /**
6548
+ * Execute traverse
6549
+ * Depth-first traversal that traverses all visible tiles and marks tiles for selection.
6550
+ * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
6551
+ * This is the traditional replacement refinement approach and is called the base traversal.
6552
+ * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
6553
+ * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
6554
+ * and rendering children and parent tiles simultaneously.
6555
+ */
6556
+ /* eslint-disable-next-line complexity, max-statements */
6414
6557
  executeTraversal(root, frameState) {
6415
6558
  const stack = this._traversalStack;
6416
6559
  root._selectionDepth = 1;
@@ -6420,7 +6563,12 @@ var __exports__ = (() => {
6420
6563
  let shouldRefine = false;
6421
6564
  if (this.canTraverse(tile, frameState)) {
6422
6565
  this.updateChildTiles(tile, frameState);
6423
- shouldRefine = this.updateAndPushChildren(tile, frameState, stack, tile.hasRenderContent ? tile._selectionDepth + 1 : tile._selectionDepth);
6566
+ shouldRefine = this.updateAndPushChildren(
6567
+ tile,
6568
+ frameState,
6569
+ stack,
6570
+ tile.hasRenderContent ? tile._selectionDepth + 1 : tile._selectionDepth
6571
+ );
6424
6572
  }
6425
6573
  const parent = tile.parent;
6426
6574
  const parentRefines = Boolean(!parent || parent._shouldRefine);
@@ -6431,10 +6579,10 @@ var __exports__ = (() => {
6431
6579
  if (stoppedRefining) {
6432
6580
  this.selectTile(tile, frameState);
6433
6581
  }
6434
- } else if (tile.refine === TILE_REFINEMENT.ADD) {
6582
+ } else if (tile.refine === 1 /* ADD */) {
6435
6583
  this.loadTile(tile, frameState);
6436
6584
  this.selectTile(tile, frameState);
6437
- } else if (tile.refine === TILE_REFINEMENT.REPLACE) {
6585
+ } else if (tile.refine === 2 /* REPLACE */) {
6438
6586
  this.loadTile(tile, frameState);
6439
6587
  if (stoppedRefining) {
6440
6588
  this.selectTile(tile, frameState);
@@ -6455,14 +6603,12 @@ var __exports__ = (() => {
6455
6603
  this.updateTile(child, frameState);
6456
6604
  }
6457
6605
  }
6606
+ /* eslint-disable complexity, max-statements */
6458
6607
  updateAndPushChildren(tile, frameState, stack, depth) {
6459
- const {
6460
- loadSiblings,
6461
- skipLevelOfDetail
6462
- } = this.options;
6608
+ const { loadSiblings, skipLevelOfDetail } = this.options;
6463
6609
  const children = tile.children;
6464
6610
  children.sort(this.compareDistanceToCamera.bind(this));
6465
- const checkRefines = tile.refine === TILE_REFINEMENT.REPLACE && tile.hasRenderContent && !skipLevelOfDetail;
6611
+ const checkRefines = tile.refine === 2 /* REPLACE */ && tile.hasRenderContent && !skipLevelOfDetail;
6466
6612
  let hasVisibleChild = false;
6467
6613
  let refines = true;
6468
6614
  for (const child of children) {
@@ -6497,15 +6643,18 @@ var __exports__ = (() => {
6497
6643
  }
6498
6644
  return refines;
6499
6645
  }
6646
+ /* eslint-enable complexity, max-statements */
6500
6647
  updateTile(tile, frameState) {
6501
6648
  this.updateTileVisibility(tile, frameState);
6502
6649
  }
6650
+ // tile to render in the browser
6503
6651
  selectTile(tile, frameState) {
6504
6652
  if (this.shouldSelectTile(tile)) {
6505
6653
  tile._selectedFrame = frameState.frameNumber;
6506
6654
  this.selectedTiles[tile.id] = tile;
6507
6655
  }
6508
6656
  }
6657
+ // tile to load from server
6509
6658
  loadTile(tile, frameState) {
6510
6659
  if (this.shouldLoadTile(tile)) {
6511
6660
  tile._requestedFrame = frameState.frameNumber;
@@ -6513,10 +6662,14 @@ var __exports__ = (() => {
6513
6662
  this.requestedTiles[tile.id] = tile;
6514
6663
  }
6515
6664
  }
6665
+ // cache tile
6516
6666
  touchTile(tile, frameState) {
6517
6667
  tile.tileset._cache.touch(tile);
6518
6668
  tile._touchedFrame = frameState.frameNumber;
6519
6669
  }
6670
+ // tile should be visible
6671
+ // tile should have children
6672
+ // tile LoD (level of detail) is not sufficient under current viewport
6520
6673
  canTraverse(tile, frameState, useParentMetric = false, ignoreVisibility = false) {
6521
6674
  if (!tile.hasChildren) {
6522
6675
  return false;
@@ -6535,6 +6688,7 @@ var __exports__ = (() => {
6535
6688
  shouldSelectTile(tile) {
6536
6689
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
6537
6690
  }
6691
+ /** Decide if tile LoD (level of detail) is not sufficient under current viewport */
6538
6692
  shouldRefine(tile, frameState, useParentMetric = false) {
6539
6693
  let screenSpaceError = tile._screenSpaceError;
6540
6694
  if (useParentMetric) {
@@ -6556,6 +6710,7 @@ var __exports__ = (() => {
6556
6710
  }
6557
6711
  tile.updateVisibility(frameState, viewportIds);
6558
6712
  }
6713
+ // UTILITIES
6559
6714
  compareDistanceToCamera(b, a) {
6560
6715
  return b._distanceToCamera - a._distanceToCamera;
6561
6716
  }
@@ -6567,6 +6722,8 @@ var __exports__ = (() => {
6567
6722
  }
6568
6723
  return anyVisible;
6569
6724
  }
6725
+ // Depth-first traversal that checks if all nearest descendants with content are loaded.
6726
+ // Ignores visibility.
6570
6727
  executeEmptyTraversal(root, frameState) {
6571
6728
  let allDescendantsLoaded = true;
6572
6729
  const stack = this._emptyTraversalStack;
@@ -6600,43 +6757,68 @@ var __exports__ = (() => {
6600
6757
  return x !== void 0 && x !== null;
6601
6758
  }
6602
6759
  var Tile3D = class {
6603
- lodMetricType = "geometricError";
6604
- lodMetricValue = 0;
6605
- boundingVolume = null;
6606
- content = null;
6607
- contentState = TILE_CONTENT_STATE.UNLOADED;
6608
- gpuMemoryUsageInBytes = 0;
6609
- children = [];
6610
- depth = 0;
6611
- viewportIds = [];
6612
- transform = new Matrix4();
6613
- extensions = null;
6614
- implicitTiling = null;
6615
- userData = {};
6616
- hasEmptyContent = false;
6617
- hasTilesetContent = false;
6618
- traverser = new TilesetTraverser({});
6619
- _cacheNode = null;
6620
- _frameNumber = null;
6621
- _expireDate = null;
6622
- _expiredContent = null;
6623
- _boundingBox = void 0;
6624
- _distanceToCamera = 0;
6625
- _screenSpaceError = 0;
6626
- _visible = void 0;
6627
- _initialTransform = new Matrix4();
6628
- _priority = 0;
6629
- _selectedFrame = 0;
6630
- _requestedFrame = 0;
6631
- _selectionDepth = 0;
6632
- _touchedFrame = 0;
6633
- _centerZDepth = 0;
6634
- _shouldRefine = false;
6635
- _stackLength = 0;
6636
- _visitedFrame = 0;
6637
- _inRequestVolume = false;
6638
- _lodJudge = null;
6760
+ // TODO i3s specific, needs to remove
6761
+ /**
6762
+ * @constructs
6763
+ * Create a Tile3D instance
6764
+ * @param tileset - Tileset3D instance
6765
+ * @param header - tile header - JSON loaded from a dataset
6766
+ * @param parentHeader - parent Tile3D instance
6767
+ * @param extendedId - optional ID to separate copies of a tile for different viewports.
6768
+ * const extendedId = `${tile.id}-${frameState.viewport.id}`;
6769
+ */
6770
+ // eslint-disable-next-line max-statements
6639
6771
  constructor(tileset, header, parentHeader, extendedId = "") {
6772
+ /** Different refinement algorithms used by I3S and 3D tiles */
6773
+ this.lodMetricType = "geometricError";
6774
+ /** The error, in meters, introduced if this tile is rendered and its children are not. */
6775
+ this.lodMetricValue = 0;
6776
+ /** @todo math.gl is not exporting BoundingVolume base type? */
6777
+ this.boundingVolume = null;
6778
+ /**
6779
+ * The tile's content. This represents the actual tile's payload,
6780
+ * not the content's metadata in the tileset JSON file.
6781
+ */
6782
+ this.content = null;
6783
+ this.contentState = TILE_CONTENT_STATE.UNLOADED;
6784
+ this.gpuMemoryUsageInBytes = 0;
6785
+ /** The tile's children - an array of Tile3D objects. */
6786
+ this.children = [];
6787
+ this.depth = 0;
6788
+ this.viewportIds = [];
6789
+ this.transform = new Matrix4();
6790
+ this.extensions = null;
6791
+ /** TODO Cesium 3d tiles specific */
6792
+ this.implicitTiling = null;
6793
+ /** Container to store application specific data */
6794
+ this.userData = {};
6795
+ this.hasEmptyContent = false;
6796
+ this.hasTilesetContent = false;
6797
+ this.traverser = new TilesetTraverser({});
6798
+ /** Used by TilesetCache */
6799
+ this._cacheNode = null;
6800
+ this._frameNumber = null;
6801
+ // TODO Cesium 3d tiles specific
6802
+ this._expireDate = null;
6803
+ this._expiredContent = null;
6804
+ this._boundingBox = void 0;
6805
+ /** updated every frame for tree traversal and rendering optimizations: */
6806
+ this._distanceToCamera = 0;
6807
+ this._screenSpaceError = 0;
6808
+ this._visible = void 0;
6809
+ this._initialTransform = new Matrix4();
6810
+ // Used by traverser, cannot be marked private
6811
+ this._priority = 0;
6812
+ this._selectedFrame = 0;
6813
+ this._requestedFrame = 0;
6814
+ this._selectionDepth = 0;
6815
+ this._touchedFrame = 0;
6816
+ this._centerZDepth = 0;
6817
+ this._shouldRefine = false;
6818
+ this._stackLength = 0;
6819
+ this._visitedFrame = 0;
6820
+ this._inRequestVolume = false;
6821
+ this._lodJudge = null;
6640
6822
  this.header = header;
6641
6823
  this.tileset = tileset;
6642
6824
  this.id = extendedId || header.id;
@@ -6667,64 +6849,108 @@ var __exports__ = (() => {
6667
6849
  get isVisibleAndInRequestVolume() {
6668
6850
  return this._visible && this._inRequestVolume;
6669
6851
  }
6852
+ /** Returns true if tile is not an empty tile and not an external tileset */
6670
6853
  get hasRenderContent() {
6671
6854
  return !this.hasEmptyContent && !this.hasTilesetContent;
6672
6855
  }
6856
+ /** Returns true if tile has children */
6673
6857
  get hasChildren() {
6674
6858
  return this.children.length > 0 || this.header.children && this.header.children.length > 0;
6675
6859
  }
6860
+ /**
6861
+ * Determines if the tile's content is ready. This is automatically `true` for
6862
+ * tiles with empty content.
6863
+ */
6676
6864
  get contentReady() {
6677
6865
  return this.contentState === TILE_CONTENT_STATE.READY || this.hasEmptyContent;
6678
6866
  }
6867
+ /**
6868
+ * Determines if the tile has available content to render. `true` if the tile's
6869
+ * content is ready or if it has expired content this renders while new content loads; otherwise,
6870
+ */
6679
6871
  get contentAvailable() {
6680
- return Boolean(this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed);
6872
+ return Boolean(
6873
+ this.contentReady && this.hasRenderContent || this._expiredContent && !this.contentFailed
6874
+ );
6681
6875
  }
6876
+ /** Returns true if tile has renderable content but it's unloaded */
6682
6877
  get hasUnloadedContent() {
6683
6878
  return this.hasRenderContent && this.contentUnloaded;
6684
6879
  }
6880
+ /**
6881
+ * Determines if the tile's content has not be requested. `true` if tile's
6882
+ * content has not be requested; otherwise, `false`.
6883
+ */
6685
6884
  get contentUnloaded() {
6686
6885
  return this.contentState === TILE_CONTENT_STATE.UNLOADED;
6687
6886
  }
6887
+ /**
6888
+ * Determines if the tile's content is expired. `true` if tile's
6889
+ * content is expired; otherwise, `false`.
6890
+ */
6688
6891
  get contentExpired() {
6689
6892
  return this.contentState === TILE_CONTENT_STATE.EXPIRED;
6690
6893
  }
6894
+ // Determines if the tile's content failed to load. `true` if the tile's
6895
+ // content failed to load; otherwise, `false`.
6691
6896
  get contentFailed() {
6692
6897
  return this.contentState === TILE_CONTENT_STATE.FAILED;
6693
6898
  }
6899
+ /**
6900
+ * Distance from the tile's bounding volume center to the camera
6901
+ */
6694
6902
  get distanceToCamera() {
6695
6903
  return this._distanceToCamera;
6696
6904
  }
6905
+ /**
6906
+ * Screen space error for LOD selection
6907
+ */
6697
6908
  get screenSpaceError() {
6698
6909
  return this._screenSpaceError;
6699
6910
  }
6911
+ /**
6912
+ * Get bounding box in cartographic coordinates
6913
+ * @returns [min, max] each in [longitude, latitude, altitude]
6914
+ */
6700
6915
  get boundingBox() {
6701
6916
  if (!this._boundingBox) {
6702
6917
  this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);
6703
6918
  }
6704
6919
  return this._boundingBox;
6705
6920
  }
6921
+ /** Get the tile's screen space error. */
6706
6922
  getScreenSpaceError(frameState, useParentLodMetric) {
6707
6923
  switch (this.tileset.type) {
6708
- case TILESET_TYPE.I3S:
6924
+ case "I3S" /* I3S */:
6709
6925
  return getProjectedRadius(this, frameState);
6710
- case TILESET_TYPE.TILES3D:
6926
+ case "TILES3D" /* TILES3D */:
6711
6927
  return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric);
6712
6928
  default:
6713
6929
  throw new Error("Unsupported tileset type");
6714
6930
  }
6715
6931
  }
6932
+ /**
6933
+ * Make tile unselected than means it won't be shown
6934
+ * but it can be still loaded in memory
6935
+ */
6716
6936
  unselect() {
6717
6937
  this._selectedFrame = 0;
6718
6938
  }
6939
+ /**
6940
+ * Memory usage of tile on GPU
6941
+ */
6719
6942
  _getGpuMemoryUsageInBytes() {
6720
6943
  return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
6721
6944
  }
6945
+ /*
6946
+ * If skipLevelOfDetail is off try to load child tiles as soon as possible so that their parent can refine sooner.
6947
+ * Tiles are prioritized by screen space error.
6948
+ */
6949
+ // eslint-disable-next-line complexity
6722
6950
  _getPriority() {
6723
6951
  const traverser = this.tileset._traverser;
6724
- const {
6725
- skipLevelOfDetail
6726
- } = traverser.options;
6727
- const maySkipTile = this.refine === TILE_REFINEMENT.ADD || skipLevelOfDetail;
6952
+ const { skipLevelOfDetail } = traverser.options;
6953
+ const maySkipTile = this.refine === 1 /* ADD */ || skipLevelOfDetail;
6728
6954
  if (maySkipTile && !this.isVisible && this._visible !== void 0) {
6729
6955
  return -1;
6730
6956
  }
@@ -6740,6 +6966,11 @@ var __exports__ = (() => {
6740
6966
  const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0;
6741
6967
  return Math.max(rootScreenSpaceError - screenSpaceError, 0);
6742
6968
  }
6969
+ /**
6970
+ * Requests the tile's content.
6971
+ * The request may not be made if the Request Scheduler can't prioritize it.
6972
+ */
6973
+ // eslint-disable-next-line max-statements, complexity
6743
6974
  async loadContent() {
6744
6975
  if (this.hasEmptyContent) {
6745
6976
  return false;
@@ -6752,7 +6983,10 @@ var __exports__ = (() => {
6752
6983
  this._expireDate = null;
6753
6984
  }
6754
6985
  this.contentState = TILE_CONTENT_STATE.LOADING;
6755
- const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));
6986
+ const requestToken = await this.tileset._requestScheduler.scheduleRequest(
6987
+ this.id,
6988
+ this._getPriority.bind(this)
6989
+ );
6756
6990
  if (!requestToken) {
6757
6991
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
6758
6992
  return false;
@@ -6763,6 +6997,7 @@ var __exports__ = (() => {
6763
6997
  const options = {
6764
6998
  ...this.tileset.loadOptions,
6765
6999
  [loader.id]: {
7000
+ // @ts-expect-error
6766
7001
  ...this.tileset.loadOptions[loader.id],
6767
7002
  isTileset: this.type === "json",
6768
7003
  ...this._getLoaderSpecificOptions(loader.id)
@@ -6785,6 +7020,7 @@ var __exports__ = (() => {
6785
7020
  requestToken.done();
6786
7021
  }
6787
7022
  }
7023
+ // Unloads the tile's content.
6788
7024
  unloadContent() {
6789
7025
  if (this.content && this.content.destroy) {
6790
7026
  this.content.destroy();
@@ -6797,6 +7033,12 @@ var __exports__ = (() => {
6797
7033
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
6798
7034
  return true;
6799
7035
  }
7036
+ /**
7037
+ * Update the tile's visibility
7038
+ * @param {Object} frameState - frame state for tile culling
7039
+ * @param {string[]} viewportIds - a list of viewport ids that show this tile
7040
+ * @return {void}
7041
+ */
6800
7042
  updateVisibility(frameState, viewportIds) {
6801
7043
  if (this._frameNumber === frameState.frameNumber) {
6802
7044
  return;
@@ -6815,33 +7057,52 @@ var __exports__ = (() => {
6815
7057
  this._frameNumber = frameState.frameNumber;
6816
7058
  this.viewportIds = viewportIds;
6817
7059
  }
7060
+ // Determines whether the tile's bounding volume intersects the culling volume.
7061
+ // @param {FrameState} frameState The frame state.
7062
+ // @param {Number} parentVisibilityPlaneMask The parent's plane mask to speed up the visibility check.
7063
+ // @returns {Number} A plane mask as described above in {@link CullingVolume#computeVisibilityWithPlaneMask}.
6818
7064
  visibility(frameState, parentVisibilityPlaneMask) {
6819
- const {
6820
- cullingVolume: cullingVolume2
6821
- } = frameState;
6822
- const {
6823
- boundingVolume
6824
- } = this;
7065
+ const { cullingVolume: cullingVolume2 } = frameState;
7066
+ const { boundingVolume } = this;
6825
7067
  return cullingVolume2.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);
6826
7068
  }
7069
+ // Assuming the tile's bounding volume intersects the culling volume, determines
7070
+ // whether the tile's content's bounding volume intersects the culling volume.
7071
+ // @param {FrameState} frameState The frame state.
7072
+ // @returns {Intersect} The result of the intersection: the tile's content is completely outside, completely inside, or intersecting the culling volume.
6827
7073
  contentVisibility() {
6828
7074
  return true;
6829
7075
  }
7076
+ /**
7077
+ * Computes the (potentially approximate) distance from the closest point of the tile's bounding volume to the camera.
7078
+ * @param frameState The frame state.
7079
+ * @returns {Number} The distance, in meters, or zero if the camera is inside the bounding volume.
7080
+ */
6830
7081
  distanceToTile(frameState) {
6831
7082
  const boundingVolume = this.boundingVolume;
6832
7083
  return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));
6833
7084
  }
6834
- cameraSpaceZDepth({
6835
- camera
6836
- }) {
7085
+ /**
7086
+ * Computes the tile's camera-space z-depth.
7087
+ * @param frameState The frame state.
7088
+ * @returns The distance, in meters.
7089
+ */
7090
+ cameraSpaceZDepth({ camera }) {
6837
7091
  const boundingVolume = this.boundingVolume;
6838
7092
  scratchVector10.subVectors(boundingVolume.center, camera.position);
6839
7093
  return camera.direction.dot(scratchVector10);
6840
7094
  }
7095
+ /**
7096
+ * Checks if the camera is inside the viewer request volume.
7097
+ * @param {FrameState} frameState The frame state.
7098
+ * @returns {Boolean} Whether the camera is inside the volume.
7099
+ */
6841
7100
  insideViewerRequestVolume(frameState) {
6842
7101
  const viewerRequestVolume = this._viewerRequestVolume;
6843
7102
  return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
6844
7103
  }
7104
+ // TODO Cesium specific
7105
+ // Update whether the tile has expired.
6845
7106
  updateExpiration() {
6846
7107
  if (defined2(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
6847
7108
  const now = Date.now();
@@ -6854,6 +7115,7 @@ var __exports__ = (() => {
6854
7115
  get extras() {
6855
7116
  return this.header.extras;
6856
7117
  }
7118
+ // INTERNAL METHODS
6857
7119
  _initializeLodMetric(header) {
6858
7120
  if ("lodMetricType" in header) {
6859
7121
  this.lodMetricType = header.lodMetricType;
@@ -6865,7 +7127,9 @@ var __exports__ = (() => {
6865
7127
  this.lodMetricValue = header.lodMetricValue;
6866
7128
  } else {
6867
7129
  this.lodMetricValue = this.parent && this.parent.lodMetricValue || this.tileset.lodMetricValue;
6868
- console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue");
7130
+ console.warn(
7131
+ "3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"
7132
+ );
6869
7133
  }
6870
7134
  }
6871
7135
  _initializeTransforms(tileHeader) {
@@ -6883,10 +7147,7 @@ var __exports__ = (() => {
6883
7147
  this._updateBoundingVolume(tileHeader);
6884
7148
  }
6885
7149
  _initializeContent(tileHeader) {
6886
- this.content = {
6887
- _tileset: this.tileset,
6888
- _tile: this
6889
- };
7150
+ this.content = { _tileset: this.tileset, _tile: this };
6890
7151
  this.hasEmptyContent = true;
6891
7152
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
6892
7153
  this.hasTilesetContent = false;
@@ -6895,6 +7156,7 @@ var __exports__ = (() => {
6895
7156
  this.hasEmptyContent = false;
6896
7157
  }
6897
7158
  }
7159
+ // TODO - remove anything not related to basic visibility detection
6898
7160
  _initializeRenderingState(header) {
6899
7161
  this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);
6900
7162
  this._shouldRefine = false;
@@ -6914,7 +7176,7 @@ var __exports__ = (() => {
6914
7176
  this._priority = 0;
6915
7177
  }
6916
7178
  _getRefine(refine) {
6917
- return refine || this.parent && this.parent.refine || TILE_REFINEMENT.REPLACE;
7179
+ return refine || this.parent && this.parent.refine || 2 /* REPLACE */;
6918
7180
  }
6919
7181
  _isTileset() {
6920
7182
  return this.contentUrl.indexOf(".json") !== -1;
@@ -6934,18 +7196,31 @@ var __exports__ = (() => {
6934
7196
  }
6935
7197
  }
6936
7198
  _updateBoundingVolume(header) {
6937
- this.boundingVolume = createBoundingVolume(header.boundingVolume, this.computedTransform, this.boundingVolume);
7199
+ this.boundingVolume = createBoundingVolume(
7200
+ header.boundingVolume,
7201
+ this.computedTransform,
7202
+ this.boundingVolume
7203
+ );
6938
7204
  const content = header.content;
6939
7205
  if (!content) {
6940
7206
  return;
6941
7207
  }
6942
7208
  if (content.boundingVolume) {
6943
- this._contentBoundingVolume = createBoundingVolume(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);
7209
+ this._contentBoundingVolume = createBoundingVolume(
7210
+ content.boundingVolume,
7211
+ this.computedTransform,
7212
+ this._contentBoundingVolume
7213
+ );
6944
7214
  }
6945
7215
  if (header.viewerRequestVolume) {
6946
- this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);
7216
+ this._viewerRequestVolume = createBoundingVolume(
7217
+ header.viewerRequestVolume,
7218
+ this.computedTransform,
7219
+ this._viewerRequestVolume
7220
+ );
6947
7221
  }
6948
7222
  }
7223
+ // Update the tile's transform. The transform is applied to the tile's bounding volumes.
6949
7224
  _updateTransform(parentTransform = new Matrix4()) {
6950
7225
  const computedTransform = parentTransform.clone().multiplyRight(this.transform);
6951
7226
  const didTransformChange = !computedTransform.equals(this.computedTransform);
@@ -6955,6 +7230,7 @@ var __exports__ = (() => {
6955
7230
  this.computedTransform = computedTransform;
6956
7231
  this._updateBoundingVolume(this.header);
6957
7232
  }
7233
+ // Get options which are applicable only for the particular loader
6958
7234
  _getLoaderSpecificOptions(loaderId) {
6959
7235
  switch (loaderId) {
6960
7236
  case "i3s":
@@ -7005,7 +7281,7 @@ var __exports__ = (() => {
7005
7281
  tile._visible = false;
7006
7282
  return;
7007
7283
  }
7008
- const replace = tile.refine === TILE_REFINEMENT.REPLACE;
7284
+ const replace = tile.refine === 2 /* REPLACE */;
7009
7285
  const useOptimization = tile._optimChildrenWithinParent === TILE3D_OPTIMIZATION_HINT.USE_OPTIMIZATION;
7010
7286
  if (replace && useOptimization && hasChildren) {
7011
7287
  if (!this.anyChildrenVisible(tile, frameState)) {
@@ -7015,10 +7291,8 @@ var __exports__ = (() => {
7015
7291
  }
7016
7292
  }
7017
7293
  meetsScreenSpaceErrorEarly(tile, frameState) {
7018
- const {
7019
- parent
7020
- } = tile;
7021
- if (!parent || parent.hasTilesetContent || parent.refine !== TILE_REFINEMENT.ADD) {
7294
+ const { parent } = tile;
7295
+ if (!parent || parent.hasTilesetContent || parent.refine !== 1 /* ADD */) {
7022
7296
  return false;
7023
7297
  }
7024
7298
  return !this.shouldRefine(tile, frameState, true);
@@ -7030,13 +7304,25 @@ var __exports__ = (() => {
7030
7304
 
7031
7305
  // src/tileset/format-i3s/i3s-pending-tiles-register.ts
7032
7306
  var I3SPendingTilesRegister = class {
7033
- frameNumberMap = /* @__PURE__ */ new Map();
7307
+ constructor() {
7308
+ this.frameNumberMap = /* @__PURE__ */ new Map();
7309
+ }
7310
+ /**
7311
+ * Register a new pending tile header for the particular frameNumber
7312
+ * @param viewportId
7313
+ * @param frameNumber
7314
+ */
7034
7315
  register(viewportId, frameNumber) {
7035
7316
  const viewportMap = this.frameNumberMap.get(viewportId) || /* @__PURE__ */ new Map();
7036
7317
  const oldCount = viewportMap.get(frameNumber) || 0;
7037
7318
  viewportMap.set(frameNumber, oldCount + 1);
7038
7319
  this.frameNumberMap.set(viewportId, viewportMap);
7039
7320
  }
7321
+ /**
7322
+ * Deregister a pending tile header for the particular frameNumber
7323
+ * @param viewportId
7324
+ * @param frameNumber
7325
+ */
7040
7326
  deregister(viewportId, frameNumber) {
7041
7327
  const viewportMap = this.frameNumberMap.get(viewportId);
7042
7328
  if (!viewportMap) {
@@ -7045,6 +7331,12 @@ var __exports__ = (() => {
7045
7331
  const oldCount = viewportMap.get(frameNumber) || 1;
7046
7332
  viewportMap.set(frameNumber, oldCount - 1);
7047
7333
  }
7334
+ /**
7335
+ * Check is there are no pending tile headers registered for the particular frameNumber
7336
+ * @param viewportId
7337
+ * @param frameNumber
7338
+ * @returns
7339
+ */
7048
7340
  isZero(viewportId, frameNumber) {
7049
7341
  const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;
7050
7342
  return count === 0;
@@ -7058,33 +7350,30 @@ var __exports__ = (() => {
7058
7350
  ERROR: "ERROR"
7059
7351
  };
7060
7352
  var I3STileManager = class {
7061
- pendingTilesRegister = new I3SPendingTilesRegister();
7062
7353
  constructor() {
7354
+ this.pendingTilesRegister = new I3SPendingTilesRegister();
7063
7355
  this._statusMap = {};
7064
7356
  }
7357
+ /**
7358
+ * Add request to map
7359
+ * @param request - node metadata request
7360
+ * @param key - unique key
7361
+ * @param callback - callback after request completed
7362
+ * @param frameState - frameState data
7363
+ */
7065
7364
  add(request, key, callback, frameState) {
7066
7365
  if (!this._statusMap[key]) {
7067
7366
  const {
7068
7367
  frameNumber,
7069
- viewport: {
7070
- id
7071
- }
7368
+ viewport: { id }
7072
7369
  } = frameState;
7073
- this._statusMap[key] = {
7074
- request,
7075
- callback,
7076
- key,
7077
- frameState,
7078
- status: STATUS.REQUESTED
7079
- };
7370
+ this._statusMap[key] = { request, callback, key, frameState, status: STATUS.REQUESTED };
7080
7371
  this.pendingTilesRegister.register(id, frameNumber);
7081
7372
  request().then((data) => {
7082
7373
  this._statusMap[key].status = STATUS.COMPLETED;
7083
7374
  const {
7084
7375
  frameNumber: actualFrameNumber,
7085
- viewport: {
7086
- id: id2
7087
- }
7376
+ viewport: { id: id2 }
7088
7377
  } = this._statusMap[key].frameState;
7089
7378
  this.pendingTilesRegister.deregister(id2, actualFrameNumber);
7090
7379
  this._statusMap[key].callback(data, frameState);
@@ -7092,37 +7381,47 @@ var __exports__ = (() => {
7092
7381
  this._statusMap[key].status = STATUS.ERROR;
7093
7382
  const {
7094
7383
  frameNumber: actualFrameNumber,
7095
- viewport: {
7096
- id: id2
7097
- }
7384
+ viewport: { id: id2 }
7098
7385
  } = this._statusMap[key].frameState;
7099
7386
  this.pendingTilesRegister.deregister(id2, actualFrameNumber);
7100
7387
  callback(error);
7101
7388
  });
7102
7389
  }
7103
7390
  }
7391
+ /**
7392
+ * Update request if it is still actual for the new frameState
7393
+ * @param key - unique key
7394
+ * @param frameState - frameState data
7395
+ */
7104
7396
  update(key, frameState) {
7105
7397
  if (this._statusMap[key]) {
7106
7398
  const {
7107
7399
  frameNumber,
7108
- viewport: {
7109
- id
7110
- }
7400
+ viewport: { id }
7111
7401
  } = this._statusMap[key].frameState;
7112
7402
  this.pendingTilesRegister.deregister(id, frameNumber);
7113
7403
  const {
7114
7404
  frameNumber: newFrameNumber,
7115
- viewport: {
7116
- id: newViewportId
7117
- }
7405
+ viewport: { id: newViewportId }
7118
7406
  } = frameState;
7119
7407
  this.pendingTilesRegister.register(newViewportId, newFrameNumber);
7120
7408
  this._statusMap[key].frameState = frameState;
7121
7409
  }
7122
7410
  }
7411
+ /**
7412
+ * Find request in the map
7413
+ * @param key - unique key
7414
+ * @returns
7415
+ */
7123
7416
  find(key) {
7124
7417
  return this._statusMap[key];
7125
7418
  }
7419
+ /**
7420
+ * Check it there are pending tile headers for the particular frameNumber
7421
+ * @param viewportId
7422
+ * @param frameNumber
7423
+ * @returns
7424
+ */
7126
7425
  hasPendingTiles(viewportId, frameNumber) {
7127
7426
  return !this.pendingTilesRegister.isZero(viewportId, frameNumber);
7128
7427
  }
@@ -7134,6 +7433,11 @@ var __exports__ = (() => {
7134
7433
  super(options);
7135
7434
  this._tileManager = new I3STileManager();
7136
7435
  }
7436
+ /**
7437
+ * Check if there are no penging tile header requests,
7438
+ * that means the traversal is finished and we can call
7439
+ * following-up callbacks.
7440
+ */
7137
7441
  traversalFinished(frameState) {
7138
7442
  return !this._tileManager.hasPendingTiles(frameState.viewport.id, this._frameNumber || 0);
7139
7443
  }
@@ -7155,7 +7459,12 @@ var __exports__ = (() => {
7155
7459
  if (tileset.tileset.nodePages) {
7156
7460
  request = () => tileset.tileset.nodePagesTile.formTileFromNodePages(child.id);
7157
7461
  }
7158
- this._tileManager.add(request, extendedId, (header) => this._onTileLoad(header, tile, extendedId), frameState);
7462
+ this._tileManager.add(
7463
+ request,
7464
+ extendedId,
7465
+ (header) => this._onTileLoad(header, tile, extendedId),
7466
+ frameState
7467
+ );
7159
7468
  } else {
7160
7469
  this._tileManager.update(extendedId, frameState);
7161
7470
  }
@@ -7166,9 +7475,7 @@ var __exports__ = (() => {
7166
7475
  return false;
7167
7476
  }
7168
7477
  async _loadTile(nodeId, tileset) {
7169
- const {
7170
- loader
7171
- } = tileset;
7478
+ const { loader } = tileset;
7172
7479
  const nodeUrl = tileset.getTileUrl(`${tileset.url}/nodes/${nodeId}`);
7173
7480
  const options = {
7174
7481
  ...tileset.loadOptions,
@@ -7179,6 +7486,14 @@ var __exports__ = (() => {
7179
7486
  };
7180
7487
  return await (0, import_core22.load)(nodeUrl, loader, options);
7181
7488
  }
7489
+ /**
7490
+ * The callback to init Tile3D instance after loading the tile JSON
7491
+ * @param {Object} header - the tile JSON from a dataset
7492
+ * @param {Tile3D} tile - the parent Tile3D instance
7493
+ * @param {string} extendedId - optional ID to separate copies of a tile for different viewports.
7494
+ * const extendedId = `${tile.id}-${frameState.viewport.id}`;
7495
+ * @return {void}
7496
+ */
7182
7497
  _onTileLoad(header, tile, extendedId) {
7183
7498
  const childTile = new Tile3D(tile.tileset, header, tile, extendedId);
7184
7499
  tile.children.push(childTile);
@@ -7197,6 +7512,7 @@ var __exports__ = (() => {
7197
7512
  modelMatrix: new Matrix4(),
7198
7513
  throttleRequests: true,
7199
7514
  maxRequests: 64,
7515
+ /** Default memory values optimized for viewing mesh-based 3D Tiles on both mobile and desktop devices */
7200
7516
  maximumMemoryUsage: 32,
7201
7517
  memoryCacheOverflow: 1,
7202
7518
  maximumTilesSelected: 0,
@@ -7215,9 +7531,7 @@ var __exports__ = (() => {
7215
7531
  loadTiles: true,
7216
7532
  updateTransforms: true,
7217
7533
  viewportTraversersMap: null,
7218
- loadOptions: {
7219
- fetch: {}
7220
- },
7534
+ loadOptions: { fetch: {} },
7221
7535
  attributions: [],
7222
7536
  basePath: "",
7223
7537
  i3s: {}
@@ -7234,48 +7548,68 @@ var __exports__ = (() => {
7234
7548
  var TILES_GPU_MEMORY = "Tile Memory Use";
7235
7549
  var MAXIMUM_SSE = "Maximum Screen Space Error";
7236
7550
  var Tileset3D = class {
7237
- root = null;
7238
- roots = {};
7239
- asset = {};
7240
- description = "";
7241
- extras = null;
7242
- attributions = {};
7243
- credits = {};
7244
- contentFormats = {
7245
- draco: false,
7246
- meshopt: false,
7247
- dds: false,
7248
- ktx2: false
7249
- };
7250
- cartographicCenter = null;
7251
- cartesianCenter = null;
7252
- zoom = 1;
7253
- boundingVolume = null;
7254
- dynamicScreenSpaceErrorComputedDensity = 0;
7255
- maximumMemoryUsage = 32;
7256
- gpuMemoryUsageInBytes = 0;
7257
- memoryAdjustedScreenSpaceError = 0;
7258
- _cacheBytes = 0;
7259
- _cacheOverflowBytes = 0;
7260
- _frameNumber = 0;
7261
- _queryParams = {};
7262
- _extensionsUsed = [];
7263
- _tiles = {};
7264
- _pendingCount = 0;
7265
- selectedTiles = [];
7266
- traverseCounter = 0;
7267
- geometricError = 0;
7268
- lastUpdatedVieports = null;
7269
- _requestedTiles = [];
7270
- _emptyTiles = [];
7271
- frameStateData = {};
7272
- _cache = new TilesetCache();
7273
- updatePromise = null;
7551
+ /**
7552
+ * Create a new Tileset3D
7553
+ * @param json
7554
+ * @param props
7555
+ */
7556
+ // eslint-disable-next-line max-statements
7274
7557
  constructor(tileset, options) {
7275
- this.options = {
7276
- ...DEFAULT_PROPS3,
7277
- ...options
7278
- };
7558
+ this.root = null;
7559
+ this.roots = {};
7560
+ /** @todo any->unknown */
7561
+ this.asset = {};
7562
+ // Metadata for the entire tileset
7563
+ this.description = "";
7564
+ this.extras = null;
7565
+ this.attributions = {};
7566
+ this.credits = {};
7567
+ /** flags that contain information about data types in nested tiles */
7568
+ this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
7569
+ // view props
7570
+ this.cartographicCenter = null;
7571
+ this.cartesianCenter = null;
7572
+ this.zoom = 1;
7573
+ this.boundingVolume = null;
7574
+ /** Updated based on the camera position and direction */
7575
+ this.dynamicScreenSpaceErrorComputedDensity = 0;
7576
+ // METRICS
7577
+ /**
7578
+ * The maximum amount of GPU memory (in MB) that may be used to cache tiles
7579
+ * Tiles not in view are unloaded to enforce private
7580
+ */
7581
+ this.maximumMemoryUsage = 32;
7582
+ /** The total amount of GPU memory in bytes used by the tileset. */
7583
+ this.gpuMemoryUsageInBytes = 0;
7584
+ /**
7585
+ * If loading the level of detail required by maximumScreenSpaceError
7586
+ * results in the memory usage exceeding maximumMemoryUsage (GPU), level of detail refinement
7587
+ * will instead use this (larger) adjusted screen space error to achieve the
7588
+ * best possible visual quality within the available memory.
7589
+ */
7590
+ this.memoryAdjustedScreenSpaceError = 0;
7591
+ this._cacheBytes = 0;
7592
+ this._cacheOverflowBytes = 0;
7593
+ /** Update tracker. increase in each update cycle. */
7594
+ this._frameNumber = 0;
7595
+ this._queryParams = {};
7596
+ this._extensionsUsed = [];
7597
+ this._tiles = {};
7598
+ /** counter for tracking tiles requests */
7599
+ this._pendingCount = 0;
7600
+ /** Hold traversal results */
7601
+ this.selectedTiles = [];
7602
+ // TRAVERSAL
7603
+ this.traverseCounter = 0;
7604
+ this.geometricError = 0;
7605
+ this.lastUpdatedVieports = null;
7606
+ this._requestedTiles = [];
7607
+ this._emptyTiles = [];
7608
+ this.frameStateData = {};
7609
+ this._cache = new TilesetCache();
7610
+ // Promise tracking
7611
+ this.updatePromise = null;
7612
+ this.options = { ...DEFAULT_PROPS3, ...options };
7279
7613
  this.tileset = tileset;
7280
7614
  this.loader = tileset.loader;
7281
7615
  this.type = tileset.type;
@@ -7295,15 +7629,15 @@ var __exports__ = (() => {
7295
7629
  this.memoryAdjustedScreenSpaceError = this.options.maximumScreenSpaceError;
7296
7630
  this._cacheBytes = this.options.maximumMemoryUsage * 1024 * 1024;
7297
7631
  this._cacheOverflowBytes = this.options.memoryCacheOverflow * 1024 * 1024;
7298
- this.stats = new Stats({
7299
- id: this.url
7300
- });
7632
+ this.stats = new Stats({ id: this.url });
7301
7633
  this._initializeStats();
7302
7634
  this.tilesetInitializationPromise = this._initializeTileSet(tileset);
7303
7635
  }
7636
+ /** Release resources */
7304
7637
  destroy() {
7305
7638
  this._destroy();
7306
7639
  }
7640
+ /** Is the tileset loaded (update needs to have been called at least once) */
7307
7641
  isLoaded() {
7308
7642
  return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;
7309
7643
  }
@@ -7317,11 +7651,16 @@ var __exports__ = (() => {
7317
7651
  return new URLSearchParams(this._queryParams).toString();
7318
7652
  }
7319
7653
  setProps(props) {
7320
- this.options = {
7321
- ...this.options,
7322
- ...props
7323
- };
7324
- }
7654
+ this.options = { ...this.options, ...props };
7655
+ }
7656
+ /** @deprecated */
7657
+ // setOptions(options: Tileset3DProps): void {
7658
+ // this.options = {...this.options, ...options};
7659
+ // }
7660
+ /**
7661
+ * Return a loadable tile url for a specific tile subpath
7662
+ * @param tilePath a tile subpath
7663
+ */
7325
7664
  getTileUrl(tilePath) {
7326
7665
  const isDataUrl = tilePath.startsWith("data:");
7327
7666
  if (isDataUrl) {
@@ -7333,9 +7672,15 @@ var __exports__ = (() => {
7333
7672
  }
7334
7673
  return tileUrl;
7335
7674
  }
7675
+ // TODO CESIUM specific
7336
7676
  hasExtension(extensionName) {
7337
7677
  return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
7338
7678
  }
7679
+ /**
7680
+ * Update visible tiles relying on a list of viewports
7681
+ * @param viewports - list of viewports
7682
+ * @deprecated
7683
+ */
7339
7684
  update(viewports = null) {
7340
7685
  this.tilesetInitializationPromise.then(() => {
7341
7686
  if (!viewports && this.lastUpdatedVieports) {
@@ -7348,6 +7693,12 @@ var __exports__ = (() => {
7348
7693
  }
7349
7694
  });
7350
7695
  }
7696
+ /**
7697
+ * Update visible tiles relying on a list of viewports.
7698
+ * Do it with debounce delay to prevent update spam
7699
+ * @param viewports viewports
7700
+ * @returns Promise of new frameNumber
7701
+ */
7351
7702
  async selectTiles(viewports = null) {
7352
7703
  await this.tilesetInitializationPromise;
7353
7704
  if (viewports) {
@@ -7368,11 +7719,19 @@ var __exports__ = (() => {
7368
7719
  }
7369
7720
  adjustScreenSpaceError() {
7370
7721
  if (this.gpuMemoryUsageInBytes < this._cacheBytes) {
7371
- this.memoryAdjustedScreenSpaceError = Math.max(this.memoryAdjustedScreenSpaceError / 1.02, this.options.maximumScreenSpaceError);
7722
+ this.memoryAdjustedScreenSpaceError = Math.max(
7723
+ this.memoryAdjustedScreenSpaceError / 1.02,
7724
+ this.options.maximumScreenSpaceError
7725
+ );
7372
7726
  } else if (this.gpuMemoryUsageInBytes > this._cacheBytes + this._cacheOverflowBytes) {
7373
7727
  this.memoryAdjustedScreenSpaceError *= 1.02;
7374
7728
  }
7375
7729
  }
7730
+ /**
7731
+ * Update visible tiles relying on a list of viewports
7732
+ * @param viewports viewports
7733
+ */
7734
+ // eslint-disable-next-line max-statements, complexity
7376
7735
  doUpdate(viewports) {
7377
7736
  if ("loadTiles" in this.options && !this.options.loadTiles) {
7378
7737
  return;
@@ -7405,6 +7764,11 @@ var __exports__ = (() => {
7405
7764
  this._traverser.traverse(this.roots[id], frameState, this.options);
7406
7765
  }
7407
7766
  }
7767
+ /**
7768
+ * Check if traversal is needed for particular viewport
7769
+ * @param {string} viewportId - id of a viewport
7770
+ * @return {boolean}
7771
+ */
7408
7772
  _needTraverse(viewportId) {
7409
7773
  let traverserId = viewportId;
7410
7774
  if (this.options.viewportTraversersMap) {
@@ -7415,18 +7779,22 @@ var __exports__ = (() => {
7415
7779
  }
7416
7780
  return true;
7417
7781
  }
7782
+ /**
7783
+ * The callback to post-process tiles after traversal procedure
7784
+ * @param frameState - frame state for tile culling
7785
+ */
7418
7786
  _onTraversalEnd(frameState) {
7419
7787
  const id = frameState.viewport.id;
7420
7788
  if (!this.frameStateData[id]) {
7421
- this.frameStateData[id] = {
7422
- selectedTiles: [],
7423
- _requestedTiles: [],
7424
- _emptyTiles: []
7425
- };
7789
+ this.frameStateData[id] = { selectedTiles: [], _requestedTiles: [], _emptyTiles: [] };
7426
7790
  }
7427
7791
  const currentFrameStateData = this.frameStateData[id];
7428
7792
  const selectedTiles = Object.values(this._traverser.selectedTiles);
7429
- const [filteredSelectedTiles, unselectedTiles] = limitSelectedTiles(selectedTiles, frameState, this.options.maximumTilesSelected);
7793
+ const [filteredSelectedTiles, unselectedTiles] = limitSelectedTiles(
7794
+ selectedTiles,
7795
+ frameState,
7796
+ this.options.maximumTilesSelected
7797
+ );
7430
7798
  currentFrameStateData.selectedTiles = filteredSelectedTiles;
7431
7799
  for (const tile of unselectedTiles) {
7432
7800
  tile.unselect();
@@ -7439,6 +7807,9 @@ var __exports__ = (() => {
7439
7807
  }
7440
7808
  this._updateTiles();
7441
7809
  }
7810
+ /**
7811
+ * Update tiles relying on data from all traversers
7812
+ */
7442
7813
  _updateTiles() {
7443
7814
  this.selectedTiles = [];
7444
7815
  this._requestedTiles = [];
@@ -7496,31 +7867,34 @@ var __exports__ = (() => {
7496
7867
  this.stats.get(MAXIMUM_SSE).count = this.memoryAdjustedScreenSpaceError;
7497
7868
  }
7498
7869
  async _initializeTileSet(tilesetJson) {
7499
- if (this.type === TILESET_TYPE.I3S) {
7870
+ if (this.type === "I3S" /* I3S */) {
7500
7871
  this.calculateViewPropsI3S();
7501
7872
  tilesetJson.root = await tilesetJson.root;
7502
7873
  }
7503
7874
  this.root = this._initializeTileHeaders(tilesetJson, null);
7504
- if (this.type === TILESET_TYPE.TILES3D) {
7875
+ if (this.type === "TILES3D" /* TILES3D */) {
7505
7876
  this._initializeTiles3DTileset(tilesetJson);
7506
7877
  this.calculateViewPropsTiles3D();
7507
7878
  }
7508
- if (this.type === TILESET_TYPE.I3S) {
7879
+ if (this.type === "I3S" /* I3S */) {
7509
7880
  this._initializeI3STileset();
7510
7881
  }
7511
7882
  }
7883
+ /**
7884
+ * Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.
7885
+ * These metrics help apps center view on tileset
7886
+ * For I3S there is extent (<1.8 version) or fullExtent (>=1.8 version) to calculate view props
7887
+ * @returns
7888
+ */
7512
7889
  calculateViewPropsI3S() {
7513
7890
  const fullExtent = this.tileset.fullExtent;
7514
7891
  if (fullExtent) {
7515
- const {
7516
- xmin,
7517
- xmax,
7518
- ymin,
7519
- ymax,
7520
- zmin,
7521
- zmax
7522
- } = fullExtent;
7523
- this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
7892
+ const { xmin, xmax, ymin, ymax, zmin, zmax } = fullExtent;
7893
+ this.cartographicCenter = new Vector3(
7894
+ xmin + (xmax - xmin) / 2,
7895
+ ymin + (ymax - ymin) / 2,
7896
+ zmin + (zmax - zmin) / 2
7897
+ );
7524
7898
  this.cartesianCenter = new Vector3();
7525
7899
  Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, this.cartesianCenter);
7526
7900
  this.zoom = getZoomFromFullExtent(fullExtent, this.cartographicCenter, this.cartesianCenter);
@@ -7540,11 +7914,15 @@ var __exports__ = (() => {
7540
7914
  this.zoom = 1;
7541
7915
  return;
7542
7916
  }
7917
+ /**
7918
+ * Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.
7919
+ * These metrics help apps center view on tileset.
7920
+ * For 3DTiles the root tile data is used to calculate view props.
7921
+ * @returns
7922
+ */
7543
7923
  calculateViewPropsTiles3D() {
7544
7924
  const root = this.root;
7545
- const {
7546
- center
7547
- } = root.boundingVolume;
7925
+ const { center } = root.boundingVolume;
7548
7926
  if (!center) {
7549
7927
  console.warn("center was not pre-calculated for the root tile");
7550
7928
  this.cartographicCenter = new Vector3();
@@ -7573,13 +7951,15 @@ var __exports__ = (() => {
7573
7951
  this.stats.get(TILES_GPU_MEMORY, "memory");
7574
7952
  this.stats.get(MAXIMUM_SSE);
7575
7953
  }
7954
+ // Installs the main tileset JSON file or a tileset JSON file referenced from a tile.
7955
+ // eslint-disable-next-line max-statements
7576
7956
  _initializeTileHeaders(tilesetJson, parentTileHeader) {
7577
7957
  const rootTile = new Tile3D(this, tilesetJson.root, parentTileHeader);
7578
7958
  if (parentTileHeader) {
7579
7959
  parentTileHeader.children.push(rootTile);
7580
7960
  rootTile.depth = parentTileHeader.depth + 1;
7581
7961
  }
7582
- if (this.type === TILESET_TYPE.TILES3D) {
7962
+ if (this.type === "TILES3D" /* TILES3D */) {
7583
7963
  const stack = [];
7584
7964
  stack.push(rootTile);
7585
7965
  while (stack.length > 0) {
@@ -7607,10 +7987,10 @@ var __exports__ = (() => {
7607
7987
  let TraverserClass;
7608
7988
  const type = this.type;
7609
7989
  switch (type) {
7610
- case TILESET_TYPE.TILES3D:
7990
+ case "TILES3D" /* TILES3D */:
7611
7991
  TraverserClass = Tileset3DTraverser;
7612
7992
  break;
7613
- case TILESET_TYPE.I3S:
7993
+ case "I3S" /* I3S */:
7614
7994
  TraverserClass = I3STilesetTraverser;
7615
7995
  break;
7616
7996
  default:
@@ -7647,7 +8027,7 @@ var __exports__ = (() => {
7647
8027
  if (!loaded) {
7648
8028
  return;
7649
8029
  }
7650
- if (this.type === TILESET_TYPE.I3S) {
8030
+ if (this.type === "I3S" /* I3S */) {
7651
8031
  const nodesInNodePages = this.tileset?.nodePagesTile?.nodesInNodePages || 0;
7652
8032
  this.stats.get(TILES_TOTAL).reset();
7653
8033
  this.stats.get(TILES_TOTAL).addCount(nodesInNodePages);
@@ -7659,8 +8039,12 @@ var __exports__ = (() => {
7659
8039
  this._addTileToCache(tile);
7660
8040
  this.options.onTileLoad(tile);
7661
8041
  }
8042
+ /**
8043
+ * Update information about data types in nested tiles
8044
+ * @param tile instance of a nested Tile3D
8045
+ */
7662
8046
  updateContentTypes(tile) {
7663
- if (this.type === TILESET_TYPE.I3S) {
8047
+ if (this.type === "I3S" /* I3S */) {
7664
8048
  if (tile.header.isDracoGeometry) {
7665
8049
  this.contentFormats.draco = true;
7666
8050
  }
@@ -7673,10 +8057,8 @@ var __exports__ = (() => {
7673
8057
  break;
7674
8058
  default:
7675
8059
  }
7676
- } else if (this.type === TILESET_TYPE.TILES3D) {
7677
- const {
7678
- extensionsRemoved = []
7679
- } = tile.content?.gltf || {};
8060
+ } else if (this.type === "TILES3D" /* TILES3D */) {
8061
+ const { extensionsRemoved = [] } = tile.content?.gltf || {};
7680
8062
  if (extensionsRemoved.includes("KHR_draco_mesh_compression")) {
7681
8063
  this.contentFormats.draco = true;
7682
8064
  }
@@ -7716,6 +8098,7 @@ var __exports__ = (() => {
7716
8098
  this.options.onTileUnload(tile);
7717
8099
  tile.unloadContent();
7718
8100
  }
8101
+ // Traverse the tree and destroy all tiles
7719
8102
  _destroy() {
7720
8103
  const stack = [];
7721
8104
  if (this.root) {
@@ -7730,6 +8113,7 @@ var __exports__ = (() => {
7730
8113
  }
7731
8114
  this.root = null;
7732
8115
  }
8116
+ // Traverse the tree and destroy all sub tiles
7733
8117
  _destroySubtree(tile) {
7734
8118
  const root = tile;
7735
8119
  const stack = [];
@@ -7754,10 +8138,7 @@ var __exports__ = (() => {
7754
8138
  if (tilesetJson.queryString) {
7755
8139
  const searchParams = new URLSearchParams(tilesetJson.queryString);
7756
8140
  const queryParams = Object.fromEntries(searchParams.entries());
7757
- this._queryParams = {
7758
- ...this._queryParams,
7759
- ...queryParams
7760
- };
8141
+ this._queryParams = { ...this._queryParams, ...queryParams };
7761
8142
  }
7762
8143
  this.asset = tilesetJson.asset;
7763
8144
  if (!this.asset) {
@@ -7784,7 +8165,7 @@ var __exports__ = (() => {
7784
8165
  }
7785
8166
  }
7786
8167
  };
7787
- return __toCommonJS(src_exports);
8168
+ return __toCommonJS(bundle_exports);
7788
8169
  })();
7789
8170
  return __exports__;
7790
8171
  });