@loaders.gl/tiles 3.1.0-alpha.5 → 3.1.0-beta.1

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 (84) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +8136 -0
  4. package/dist/constants.d.ts +1 -0
  5. package/dist/constants.d.ts.map +1 -0
  6. package/dist/constants.js +35 -0
  7. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  8. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  9. package/dist/es5/utils/doubly-linked-list-node.js +7 -0
  10. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -1
  11. package/dist/es5/utils/doubly-linked-list.js +5 -3
  12. package/dist/es5/utils/doubly-linked-list.js.map +1 -1
  13. package/dist/es5/utils/managed-array.js +7 -1
  14. package/dist/es5/utils/managed-array.js.map +1 -1
  15. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
  16. package/dist/esm/tileset/tileset-cache.js.map +1 -1
  17. package/dist/esm/utils/doubly-linked-list-node.js +7 -0
  18. package/dist/esm/utils/doubly-linked-list-node.js.map +1 -1
  19. package/dist/esm/utils/doubly-linked-list.js +6 -3
  20. package/dist/esm/utils/doubly-linked-list.js.map +1 -1
  21. package/dist/esm/utils/managed-array.js +7 -1
  22. package/dist/esm/utils/managed-array.js.map +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +28 -0
  26. package/dist/tileset/helpers/3d-tiles-options.d.ts +1 -0
  27. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -0
  28. package/dist/tileset/helpers/3d-tiles-options.js +9 -0
  29. package/dist/tileset/helpers/bounding-volume.d.ts +1 -0
  30. package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -0
  31. package/dist/tileset/helpers/bounding-volume.js +177 -0
  32. package/dist/tileset/helpers/frame-state.d.ts +1 -0
  33. package/dist/tileset/helpers/frame-state.d.ts.map +1 -0
  34. package/dist/tileset/helpers/frame-state.js +70 -0
  35. package/dist/tileset/helpers/i3s-lod.d.ts +2 -1
  36. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -0
  37. package/dist/tileset/helpers/i3s-lod.js +83 -0
  38. package/dist/tileset/helpers/tiles-3d-lod.d.ts +1 -0
  39. package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -0
  40. package/dist/tileset/helpers/tiles-3d-lod.js +116 -0
  41. package/dist/tileset/helpers/transform-utils.d.ts +1 -0
  42. package/dist/tileset/helpers/transform-utils.d.ts.map +1 -0
  43. package/dist/tileset/helpers/transform-utils.js +52 -0
  44. package/dist/tileset/helpers/zoom.d.ts +1 -0
  45. package/dist/tileset/helpers/zoom.d.ts.map +1 -0
  46. package/dist/tileset/helpers/zoom.js +42 -0
  47. package/dist/tileset/tile-3d.d.ts +1 -0
  48. package/dist/tileset/tile-3d.d.ts.map +1 -0
  49. package/dist/tileset/tile-3d.js +554 -0
  50. package/dist/tileset/tileset-3d.d.ts +1 -0
  51. package/dist/tileset/tileset-3d.d.ts.map +1 -0
  52. package/dist/tileset/tileset-3d.js +601 -0
  53. package/dist/tileset/tileset-cache.d.ts +1 -0
  54. package/dist/tileset/tileset-cache.d.ts.map +1 -0
  55. package/dist/tileset/tileset-cache.js +79 -0
  56. package/dist/tileset/traversers/i3s-tile-manager.d.ts +1 -0
  57. package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +1 -0
  58. package/dist/tileset/traversers/i3s-tile-manager.js +36 -0
  59. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +1 -0
  60. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +1 -0
  61. package/dist/tileset/traversers/i3s-tileset-traverser.js +85 -0
  62. package/dist/tileset/traversers/tileset-3d-traverser.d.ts +1 -0
  63. package/dist/tileset/traversers/tileset-3d-traverser.d.ts.map +1 -0
  64. package/dist/tileset/traversers/tileset-3d-traverser.js +55 -0
  65. package/dist/tileset/traversers/tileset-traverser.d.ts +1 -0
  66. package/dist/tileset/traversers/tileset-traverser.d.ts.map +1 -0
  67. package/dist/tileset/traversers/tileset-traverser.js +294 -0
  68. package/dist/utils/doubly-linked-list-node.d.ts +2 -1
  69. package/dist/utils/doubly-linked-list-node.d.ts.map +1 -0
  70. package/dist/utils/doubly-linked-list-node.js +17 -0
  71. package/dist/utils/doubly-linked-list.d.ts +7 -6
  72. package/dist/utils/doubly-linked-list.d.ts.map +1 -0
  73. package/dist/utils/doubly-linked-list.js +100 -0
  74. package/dist/utils/managed-array.d.ts +10 -9
  75. package/dist/utils/managed-array.d.ts.map +1 -0
  76. package/dist/utils/managed-array.js +151 -0
  77. package/package.json +6 -7
  78. package/src/tileset/helpers/i3s-lod.ts +1 -1
  79. package/src/tileset/tileset-cache.ts +2 -0
  80. package/src/utils/{doubly-linked-list-node.js → doubly-linked-list-node.ts} +4 -0
  81. package/src/utils/{doubly-linked-list.js → doubly-linked-list.ts} +3 -5
  82. package/src/utils/{managed-array.js → managed-array.ts} +4 -1
  83. package/dist/dist.min.js +0 -2
  84. package/dist/dist.min.js.map +0 -1
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const doubly_linked_list_node_1 = __importDefault(require("../utils/doubly-linked-list-node"));
9
+ /**
10
+ * Doubly linked list
11
+ *
12
+ * @private
13
+ */
14
+ class DoublyLinkedList {
15
+ constructor() {
16
+ this.head = null;
17
+ this.tail = null;
18
+ this._length = 0;
19
+ }
20
+ get length() {
21
+ return this._length;
22
+ }
23
+ /**
24
+ * Adds the item to the end of the list
25
+ * @param {*} [item]
26
+ * @return {DoublyLinkedListNode}
27
+ */
28
+ add(item) {
29
+ const node = new doubly_linked_list_node_1.default(item, this.tail, null);
30
+ if (this.tail) {
31
+ this.tail.next = node;
32
+ this.tail = node;
33
+ }
34
+ else {
35
+ this.head = node;
36
+ this.tail = node;
37
+ }
38
+ ++this._length;
39
+ return node;
40
+ }
41
+ /**
42
+ * Removes the given node from the list
43
+ * @param {DoublyLinkedListNode} node
44
+ */
45
+ remove(node) {
46
+ if (!node) {
47
+ return;
48
+ }
49
+ if (node.previous && node.next) {
50
+ node.previous.next = node.next;
51
+ node.next.previous = node.previous;
52
+ }
53
+ else if (node.previous) {
54
+ // Remove last node
55
+ node.previous.next = null;
56
+ this.tail = node.previous;
57
+ }
58
+ else if (node.next) {
59
+ // Remove first node
60
+ node.next.previous = null;
61
+ this.head = node.next;
62
+ }
63
+ else {
64
+ // Remove last node in the linked list
65
+ this.head = null;
66
+ this.tail = null;
67
+ }
68
+ node.next = null;
69
+ node.previous = null;
70
+ --this._length;
71
+ }
72
+ /**
73
+ * Moves nextNode after node
74
+ * @param {DoublyLinkedListNode} node
75
+ * @param {DoublyLinkedListNode} nextNode
76
+ */
77
+ splice(node, nextNode) {
78
+ if (node === nextNode) {
79
+ return;
80
+ }
81
+ // Remove nextNode, then insert after node
82
+ this.remove(nextNode);
83
+ this._insert(node, nextNode);
84
+ }
85
+ _insert(node, nextNode) {
86
+ const oldNodeNext = node.next;
87
+ node.next = nextNode;
88
+ // nextNode is the new tail
89
+ if (this.tail === node) {
90
+ this.tail = nextNode;
91
+ }
92
+ else {
93
+ oldNodeNext.previous = nextNode;
94
+ }
95
+ nextNode.next = oldNodeNext;
96
+ nextNode.previous = node;
97
+ ++this._length;
98
+ }
99
+ }
100
+ exports.default = DoublyLinkedList;
@@ -8,11 +8,10 @@
8
8
  * @param {Number} [length=0] The initial length of the array.
9
9
  */
10
10
  export default class ManagedArray {
11
- constructor(length?: number);
12
- _array: any[];
13
11
  _map: Map<any, any>;
12
+ _array: any[];
14
13
  _length: number;
15
- set length(arg: number);
14
+ constructor(length?: number);
16
15
  /**
17
16
  * Gets or sets the length of the array.
18
17
  * If the set length is greater than the length of the internal array, the internal array is resized.
@@ -21,6 +20,7 @@ export default class ManagedArray {
21
20
  * @type Number
22
21
  */
23
22
  get length(): number;
23
+ set length(length: number);
24
24
  /**
25
25
  * Gets the internal array.
26
26
  *
@@ -28,20 +28,20 @@ export default class ManagedArray {
28
28
  * @type Array
29
29
  * @readonly
30
30
  */
31
- readonly get values(): any[];
31
+ get values(): any[];
32
32
  /**
33
33
  * Gets the element at an index.
34
34
  *
35
35
  * @param {Number} index The index to get.
36
36
  */
37
- get(index: number): any;
37
+ get(index: any): any;
38
38
  /**
39
39
  * Sets the element at an index. Resizes the array if index is greater than the length of the array.
40
40
  *
41
41
  * @param {Number} index The index to set.
42
42
  * @param {*} element The element to set at index.
43
43
  */
44
- set(index: number, element: any): void;
44
+ set(index: any, element: any): void;
45
45
  delete(element: any): void;
46
46
  /**
47
47
  * Returns the last element in the array without modifying the array.
@@ -66,19 +66,20 @@ export default class ManagedArray {
66
66
  *
67
67
  * @param {Number} length The length.
68
68
  */
69
- reserve(length: number): void;
69
+ reserve(length: any): void;
70
70
  /**
71
71
  * Resize the array.
72
72
  *
73
73
  * @param {Number} length The length.
74
74
  */
75
- resize(length: number): void;
75
+ resize(length: any): void;
76
76
  /**
77
77
  * Trim the internal array to the specified length. Defaults to the current length.
78
78
  *
79
79
  * @param {Number} [length] The length.
80
80
  */
81
- trim(length?: number | undefined): void;
81
+ trim(length: any): void;
82
82
  reset(): void;
83
83
  find(target: any): boolean;
84
84
  }
85
+ //# sourceMappingURL=managed-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-array.d.ts","sourceRoot":"","sources":["../../src/utils/managed-array.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,IAAI,gBAAa;IACjB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;gBAEJ,MAAM,SAAI;IAKtB;;;;;;OAMG;IACH,IAAI,MAAM,WAET;IAED,IAAI,MAAM,CAAC,MAAM,QAAA,EAKhB;IAED;;;;;;OAMG;IACH,IAAI,MAAM,UAET;IAED;;;;OAIG;IACH,GAAG,CAAC,KAAK,KAAA;IAKT;;;;;OAKG;IACH,GAAG,CAAC,KAAK,KAAA,EAAE,OAAO,KAAA;IAelB,MAAM,CAAC,OAAO,KAAA;IASd;;;;OAIG;IACH,IAAI;IAIJ;;;;OAIG;IACH,IAAI,CAAC,OAAO,KAAA;IAQZ;;;;OAIG;IACH,GAAG;IAMH;;;;OAIG;IACH,OAAO,CAAC,MAAM,KAAA;IAQd;;;;OAIG;IACH,MAAM,CAAC,MAAM,KAAA;IAMb;;;;OAIG;IACH,IAAI,CAAC,MAAM,KAAA;IAOX,KAAK;IAML,IAAI,CAAC,MAAM,KAAA;CAGZ"}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
6
+ /**
7
+ * A wrapper around arrays so that the internal length of the array can be manually managed.
8
+ *
9
+ * @alias ManagedArray
10
+ * @constructor
11
+ * @private
12
+ *
13
+ * @param {Number} [length=0] The initial length of the array.
14
+ */
15
+ class ManagedArray {
16
+ constructor(length = 0) {
17
+ this._map = new Map();
18
+ this._array = new Array(length);
19
+ this._length = length;
20
+ }
21
+ /**
22
+ * Gets or sets the length of the array.
23
+ * If the set length is greater than the length of the internal array, the internal array is resized.
24
+ *
25
+ * @memberof ManagedArray.prototype
26
+ * @type Number
27
+ */
28
+ get length() {
29
+ return this._length;
30
+ }
31
+ set length(length) {
32
+ this._length = length;
33
+ if (length > this._array.length) {
34
+ this._array.length = length;
35
+ }
36
+ }
37
+ /**
38
+ * Gets the internal array.
39
+ *
40
+ * @memberof ManagedArray.prototype
41
+ * @type Array
42
+ * @readonly
43
+ */
44
+ get values() {
45
+ return this._array;
46
+ }
47
+ /**
48
+ * Gets the element at an index.
49
+ *
50
+ * @param {Number} index The index to get.
51
+ */
52
+ get(index) {
53
+ (0, loader_utils_1.assert)(index < this._array.length);
54
+ return this._array[index];
55
+ }
56
+ /**
57
+ * Sets the element at an index. Resizes the array if index is greater than the length of the array.
58
+ *
59
+ * @param {Number} index The index to set.
60
+ * @param {*} element The element to set at index.
61
+ */
62
+ set(index, element) {
63
+ (0, loader_utils_1.assert)(index >= 0);
64
+ if (index >= this.length) {
65
+ this.length = index + 1;
66
+ }
67
+ if (this._map.has(this._array[index])) {
68
+ this._map.delete(this._array[index]);
69
+ }
70
+ this._array[index] = element;
71
+ this._map.set(element, index);
72
+ }
73
+ delete(element) {
74
+ const index = this._map.get(element);
75
+ if (index >= 0) {
76
+ this._array.splice(index, 1);
77
+ this._map.delete(element);
78
+ this.length--;
79
+ }
80
+ }
81
+ /**
82
+ * Returns the last element in the array without modifying the array.
83
+ *
84
+ * @returns {*} The last element in the array.
85
+ */
86
+ peek() {
87
+ return this._array[this._length - 1];
88
+ }
89
+ /**
90
+ * Push an element into the array.
91
+ *
92
+ * @param {*} element The element to push.
93
+ */
94
+ push(element) {
95
+ if (!this._map.has(element)) {
96
+ const index = this.length++;
97
+ this._array[index] = element;
98
+ this._map.set(element, index);
99
+ }
100
+ }
101
+ /**
102
+ * Pop an element from the array.
103
+ *
104
+ * @returns {*} The last element in the array.
105
+ */
106
+ pop() {
107
+ const element = this._array[--this.length];
108
+ this._map.delete(element);
109
+ return element;
110
+ }
111
+ /**
112
+ * Resize the internal array if length > _array.length.
113
+ *
114
+ * @param {Number} length The length.
115
+ */
116
+ reserve(length) {
117
+ (0, loader_utils_1.assert)(length >= 0);
118
+ if (length > this._array.length) {
119
+ this._array.length = length;
120
+ }
121
+ }
122
+ /**
123
+ * Resize the array.
124
+ *
125
+ * @param {Number} length The length.
126
+ */
127
+ resize(length) {
128
+ (0, loader_utils_1.assert)(length >= 0);
129
+ this.length = length;
130
+ }
131
+ /**
132
+ * Trim the internal array to the specified length. Defaults to the current length.
133
+ *
134
+ * @param {Number} [length] The length.
135
+ */
136
+ trim(length) {
137
+ if (length === null || length === undefined) {
138
+ length = this.length;
139
+ }
140
+ this._array.length = length;
141
+ }
142
+ reset() {
143
+ this._array = [];
144
+ this._map = new Map();
145
+ this._length = 0;
146
+ }
147
+ find(target) {
148
+ return this._map.has(target);
149
+ }
150
+ }
151
+ exports.default = ManagedArray;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tiles",
3
- "version": "3.1.0-alpha.5",
3
+ "version": "3.1.0-beta.1",
4
4
  "description": "Common components for different tiles loaders.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -30,12 +30,11 @@
30
30
  ],
31
31
  "scripts": {
32
32
  "pre-build": "npm run build-bundle",
33
- "post-build": "tsc",
34
- "build-bundle": "webpack --display=minimal --config ../../scripts/webpack/bundle.js"
33
+ "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js"
35
34
  },
36
35
  "dependencies": {
37
- "@loaders.gl/loader-utils": "3.1.0-alpha.5",
38
- "@loaders.gl/math": "3.1.0-alpha.5",
36
+ "@loaders.gl/loader-utils": "3.1.0-beta.1",
37
+ "@loaders.gl/math": "3.1.0-beta.1",
39
38
  "@math.gl/core": "^3.5.1",
40
39
  "@math.gl/culling": "^3.5.1",
41
40
  "@math.gl/geospatial": "^3.5.1",
@@ -43,7 +42,7 @@
43
42
  "@probe.gl/stats": "^3.4.0"
44
43
  },
45
44
  "peerDependencies": {
46
- "@loaders.gl/core": "^3.0.0"
45
+ "@loaders.gl/core": "4.0.0-alpha.4"
47
46
  },
48
- "gitHead": "352241dd910a8c6307a235dadbe154ca915b885b"
47
+ "gitHead": "980cdefb4e8ec9ef9c951d20c78cf77777707f49"
49
48
  }
@@ -1,6 +1,6 @@
1
1
  import {Matrix4, Vector3} from '@math.gl/core';
2
2
  import {Ellipsoid} from '@math.gl/geospatial';
3
- import {Tile3D} from '../..';
3
+ import Tile3D from '../tile-3d';
4
4
  import {FrameState} from './frame-state';
5
5
 
6
6
  /**
@@ -80,7 +80,9 @@ export default class TilesetCache {
80
80
  node !== sentinel &&
81
81
  (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)
82
82
  ) {
83
+ // @ts-expect-error
83
84
  const tile = node.item;
85
+ // @ts-expect-error
84
86
  node = node.next;
85
87
  this.unloadTile(tileset, tile, unloadCallback);
86
88
  }
@@ -7,6 +7,10 @@
7
7
  * @private
8
8
  */
9
9
  export default class DoublyLinkedListNode {
10
+ item;
11
+ previous;
12
+ next;
13
+
10
14
  constructor(item, previous, next) {
11
15
  this.item = item;
12
16
  this.previous = previous;
@@ -9,11 +9,9 @@ import DoublyLinkedListNode from '../utils/doubly-linked-list-node';
9
9
  * @private
10
10
  */
11
11
  export default class DoublyLinkedList {
12
- constructor() {
13
- this.head = null;
14
- this.tail = null;
15
- this._length = 0;
16
- }
12
+ head: DoublyLinkedListNode | null = null;
13
+ tail: DoublyLinkedListNode | null = null;
14
+ _length = 0;
17
15
 
18
16
  get length() {
19
17
  return this._length;
@@ -13,9 +13,12 @@ import {assert} from '@loaders.gl/loader-utils';
13
13
  * @param {Number} [length=0] The initial length of the array.
14
14
  */
15
15
  export default class ManagedArray {
16
+ _map = new Map();
17
+ _array: any[];
18
+ _length: number;
19
+
16
20
  constructor(length = 0) {
17
21
  this._array = new Array(length);
18
- this._map = new Map();
19
22
  this._length = length;
20
23
  }
21
24
 
package/dist/dist.min.js DELETED
@@ -1,2 +0,0 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("loaders"));else if("function"==typeof define&&define.amd)define(["loaders"],e);else{var i="object"==typeof exports?e(require("loaders")):e(t.loaders);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(window,(function(t){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(s,r,function(e){return t[e]}.bind(null,r));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=20)}([,,,,function(t,e,i){"use strict";(function(t){function s(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if(void 0!==t&&t.hrtime){const i=t.hrtime();e=1e3*i[0]+i[1]/1e6}else e=Date.now();return e}i.d(e,"a",(function(){return s}))}).call(this,i(21))},,function(t,e){},function(e,i){e.exports=t},,,,,,,,function(t,e){},,,,,function(t,e,i){const s=i(22);globalThis.loaders=globalThis.loaders||{},t.exports=Object.assign(globalThis.loaders,s)},function(t,e){var i,s,r=t.exports={};function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===n||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:n}catch(t){i=n}try{s="function"==typeof clearTimeout?clearTimeout:o}catch(t){s=o}}();var h,c=[],u=!1,l=-1;function d(){u&&h&&(u=!1,h.length?c=h.concat(c):l=-1,c.length&&m())}function m(){if(!u){var t=a(d);u=!0;for(var e=c.length;e;){for(h=c,c=[];++l<e;)h&&h[l].run();l=-1,e=c.length}h=null,u=!1,function(t){if(s===clearTimeout)return clearTimeout(t);if((s===o||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(t);try{s(t)}catch(e){try{return s.call(null,t)}catch(e){return s.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function f(){}r.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];c.push(new p(t,e)),1!==c.length||u||a(m)},p.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=f,r.addListener=f,r.once=f,r.off=f,r.removeListener=f,r.removeAllListeners=f,r.emit=f,r.prependListener=f,r.prependOnceListener=f,r.listeners=function(t){return[]},r.binding=function(t){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(t){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},function(t,e,i){"use strict";i.r(e),i.d(e,"Tileset3D",(function(){return wi})),i.d(e,"Tile3D",(function(){return di})),i.d(e,"TilesetTraverser",(function(){return ci})),i.d(e,"TilesetCache",(function(){return Lt})),i.d(e,"createBoundingVolume",(function(){return ei})),i.d(e,"calculateTransformProps",(function(){return Pt})),i.d(e,"getFrameState",(function(){return je})),i.d(e,"getLodStatus",(function(){return ri})),i.d(e,"TILE_CONTENT_STATE",(function(){return Ge})),i.d(e,"TILE_REFINEMENT",(function(){return Ze})),i.d(e,"TILE_TYPE",(function(){return Ye})),i.d(e,"TILESET_TYPE",(function(){return Ke})),i.d(e,"LOD_METRIC_TYPE",(function(){return Qe}));var s={};function r(t,e){if(!t)throw new Error("math.gl assertion ".concat(e))}i.r(s),i.d(s,"filename",(function(){return St})),i.d(s,"dirname",(function(){return bt})),i.d(s,"join",(function(){return Ct}));const n=1/Math.PI*180,o=1/180*Math.PI,a={};function h(t,{precision:e=a.precision||4}={}){return t=function(t){return Math.round(t/a.EPSILON)*a.EPSILON}(t),"".concat(parseFloat(t.toPrecision(e)))}function c(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function u(t,e,i){if(c(t)){i=i||((s=t).clone?s.clone():new Array(s.length));for(let s=0;s<i.length&&s<t.length;++s)i[s]=e(t[s],s,i);return i}var s;return e(t)}function l(t){return function(t,e){return u(t,t=>t*o,e)}(t)}function d(t){return m(t)}function m(t,e){return u(t,t=>t*n,e)}function p(t,e,i){const s=a.EPSILON;i&&(a.EPSILON=i);try{if(t===e)return!0;if(c(t)&&c(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;++i)if(!p(t[i],e[i]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):!(!Number.isFinite(t)||!Number.isFinite(e))&&Math.abs(t-e)<=a.EPSILON*Math.max(1,Math.abs(t),Math.abs(e))}finally{a.EPSILON=s}}function f(t){if(!Number.isFinite(t))throw new Error("Invalid number ".concat(t));return t}function g(t,e,i=""){if(a.debug&&!function(t,e){if(t.length!==e)return!1;for(let e=0;e<t.length;++e)if(!Number.isFinite(t[e]))return!1;return!0}(t,e))throw new Error("math.gl: ".concat(i," some fields set to invalid numbers'"));return t}a.EPSILON=1e-12,a.debug=!1,a.precision=4,a.printTypes=!1,a.printDegrees=!1,a.printRowMajor=!0;const T={};function _(t,e){T[t]||(T[t]=!0,console.warn("".concat(t," has been removed in version ").concat(e,", see upgrade guide for more information")))}class y extends(function(t){function e(){var e=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}(Array)){get ELEMENTS(){return r(!1),0}clone(){return(new this.constructor).copy(this)}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}fromArray(t,e=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=t[i+e];return this.check()}to(t){return t===this?this:c(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toArray(t=[],e=0){for(let i=0;i<this.ELEMENTS;++i)t[e+i]=this[i];return t}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(a)}formatString(t){let e="";for(let i=0;i<this.ELEMENTS;++i)e+=(i>0?", ":"")+h(this[i],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(e,"]")}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!p(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,i){void 0===i&&(i=e,e=t,t=this);for(let s=0;s<this.ELEMENTS;++s){const r=t[s];this[s]=r+i*(e[s]-r)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],t[i]),e[i]);return this.check()}add(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]+=e[t];return this.check()}subtract(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]-=e[t];return this.check()}scale(t){if(Array.isArray(t))return this.multiply(t);for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.scale(1/t)}clampScalar(t,e){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],t),e);return this.check()}multiplyByScalar(t){return this.scale(t)}get elements(){return this}check(){if(a.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}}class v extends y{get ELEMENTS(){return r(!1),0}get RANK(){return r(!1),0}toString(){let t="[";if(a.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let i=0;i<this.RANK;++i)t+=" ".concat(this[i*this.RANK+e])}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=" ".concat(this[e])}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,i){return this[e*this.RANK+t]=f(i),this}getColumn(t,e=new Array(this.RANK).fill(-0)){const i=t*this.RANK;for(let t=0;t<this.RANK;++t)e[t]=this[i+t];return e}setColumn(t,e){const i=t*this.RANK;for(let t=0;t<this.RANK;++t)this[i+t]=e[t];return this}}function w(t,e,i){const s=e[0],r=e[1],n=e[2],o=i[3]*s+i[7]*r+i[11]*n||1;return t[0]=(i[0]*s+i[4]*r+i[8]*n)/o,t[1]=(i[1]*s+i[5]*r+i[9]*n)/o,t[2]=(i[2]*s+i[6]*r+i[10]*n)/o,t}var E=1e-6,M="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function S(t,e,i){var s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],d=e[9],m=e[10],p=e[11],f=e[12],g=e[13],T=e[14],_=e[15],y=i[0],v=i[1],w=i[2],E=i[3];return t[0]=y*s+v*a+w*l+E*f,t[1]=y*r+v*h+w*d+E*g,t[2]=y*n+v*c+w*m+E*T,t[3]=y*o+v*u+w*p+E*_,y=i[4],v=i[5],w=i[6],E=i[7],t[4]=y*s+v*a+w*l+E*f,t[5]=y*r+v*h+w*d+E*g,t[6]=y*n+v*c+w*m+E*T,t[7]=y*o+v*u+w*p+E*_,y=i[8],v=i[9],w=i[10],E=i[11],t[8]=y*s+v*a+w*l+E*f,t[9]=y*r+v*h+w*d+E*g,t[10]=y*n+v*c+w*m+E*T,t[11]=y*o+v*u+w*p+E*_,y=i[12],v=i[13],w=i[14],E=i[15],t[12]=y*s+v*a+w*l+E*f,t[13]=y*r+v*h+w*d+E*g,t[14]=y*n+v*c+w*m+E*T,t[15]=y*o+v*u+w*p+E*_,t}function b(t,e,i){var s=i[0],r=i[1],n=i[2];return t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function C(t,e){var i=e[0],s=e[1],r=e[2],n=e[4],o=e[5],a=e[6],h=e[8],c=e[9],u=e[10];return t[0]=Math.hypot(i,s,r),t[1]=Math.hypot(n,o,a),t[2]=Math.hypot(h,c,u),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var x,R;x=new M(2),M!=Float32Array&&(x[0]=0,x[1]=0),R=x;function O(){var t=new M(3);return M!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function N(t){var e=t[0],i=t[1],s=t[2];return Math.hypot(e,i,s)}function A(t,e,i){var s=new M(3);return s[0]=t,s[1]=e,s[2]=i,s}function q(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function I(t,e,i){var s=e[0],r=e[1],n=e[2],o=i[0],a=i[1],h=i[2];return t[0]=r*h-n*a,t[1]=n*o-s*h,t[2]=s*a-r*o,t}function L(t,e,i){var s=e[0],r=e[1],n=e[2],o=i[3]*s+i[7]*r+i[11]*n+i[15];return o=o||1,t[0]=(i[0]*s+i[4]*r+i[8]*n+i[12])/o,t[1]=(i[1]*s+i[5]*r+i[9]*n+i[13])/o,t[2]=(i[2]*s+i[6]*r+i[10]*n+i[14])/o,t}function P(t,e,i){var s=e[0],r=e[1],n=e[2];return t[0]=s*i[0]+r*i[3]+n*i[6],t[1]=s*i[1]+r*i[4]+n*i[7],t[2]=s*i[2]+r*i[5]+n*i[8],t}var D=N;!function(){var t=O()}();function V(t){var e=t[0],i=t[1],s=t[2],r=t[3];return Math.hypot(e,i,s,r)}function k(t){var e=t[0],i=t[1],s=t[2],r=t[3];return e*e+i*i+s*s+r*r}!function(){var t=function(){var t=new M(4);return M!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}()}();const z=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),U=Object.freeze([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),j=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL0ROW3:3,COL1ROW0:4,COL1ROW1:5,COL1ROW2:6,COL1ROW3:7,COL2ROW0:8,COL2ROW1:9,COL2ROW2:10,COL2ROW3:11,COL3ROW0:12,COL3ROW1:13,COL3ROW2:14,COL3ROW3:15}),F={};class W extends v{static get IDENTITY(){return F.IDENTITY=F.IDENTITY||Object.freeze(new W(z)),F.IDENTITY}static get ZERO(){return F.ZERO=F.ZERO||Object.freeze(new W(U)),F.ZERO}get INDICES(){return j}get ELEMENTS(){return 16}get RANK(){return 4}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,i,s,r,n,o,a,h,c,u,l,d,m,p,f){return this[0]=t,this[1]=e,this[2]=i,this[3]=s,this[4]=r,this[5]=n,this[6]=o,this[7]=a,this[8]=h,this[9]=c,this[10]=u,this[11]=l,this[12]=d,this[13]=m,this[14]=p,this[15]=f,this.check()}setRowMajor(t,e,i,s,r,n,o,a,h,c,u,l,d,m,p,f){return this[0]=t,this[1]=r,this[2]=h,this[3]=d,this[4]=e,this[5]=n,this[6]=c,this[7]=m,this[8]=i,this[9]=o,this[10]=u,this[11]=p,this[12]=s,this[13]=a,this[14]=l,this[15]=f,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(z)}fromQuaternion(t){return function(t,e){var i=e[0],s=e[1],r=e[2],n=e[3],o=i+i,a=s+s,h=r+r,c=i*o,u=s*o,l=s*a,d=r*o,m=r*a,p=r*h,f=n*o,g=n*a,T=n*h;t[0]=1-l-p,t[1]=u+T,t[2]=d-g,t[3]=0,t[4]=u-T,t[5]=1-c-p,t[6]=m+f,t[7]=0,t[8]=d+g,t[9]=m-f,t[10]=1-c-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(this,t),this.check()}frustum({left:t,right:e,bottom:i,top:s,near:r,far:n}){return n===1/0?W._computeInfinitePerspectiveOffCenter(this,t,e,i,s,r):function(t,e,i,s,r,n,o){var a=1/(i-e),h=1/(r-s),c=1/(n-o);t[0]=2*n*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*n*h,t[6]=0,t[7]=0,t[8]=(i+e)*a,t[9]=(r+s)*h,t[10]=(o+n)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*n*2*c,t[15]=0}(this,t,e,i,s,r,n),this.check()}static _computeInfinitePerspectiveOffCenter(t,e,i,s,r,n){const o=2*n/(i-e),a=2*n/(r-s),h=(i+e)/(i-e),c=(r+s)/(r-s),u=-2*n;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=h,t[9]=c,t[10]=-1,t[11]=-1,t[12]=0,t[13]=0,t[14]=u,t[15]=0,t}lookAt(t,e,i){return 1===arguments.length&&({eye:t,center:e,up:i}=t),function(t,e,i,s){var r,n,o,a,h,c,u,l,d,m,p=e[0],f=e[1],g=e[2],T=s[0],_=s[1],y=s[2],v=i[0],w=i[1],M=i[2];Math.abs(p-v)<E&&Math.abs(f-w)<E&&Math.abs(g-M)<E?function(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(t):(u=p-v,l=f-w,d=g-M,r=_*(d*=m=1/Math.hypot(u,l,d))-y*(l*=m),n=y*(u*=m)-T*d,o=T*l-_*u,(m=Math.hypot(r,n,o))?(r*=m=1/m,n*=m,o*=m):(r=0,n=0,o=0),a=l*o-d*n,h=d*r-u*o,c=u*n-l*r,(m=Math.hypot(a,h,c))?(a*=m=1/m,h*=m,c*=m):(a=0,h=0,c=0),t[0]=r,t[1]=a,t[2]=u,t[3]=0,t[4]=n,t[5]=h,t[6]=l,t[7]=0,t[8]=o,t[9]=c,t[10]=d,t[11]=0,t[12]=-(r*p+n*f+o*g),t[13]=-(a*p+h*f+c*g),t[14]=-(u*p+l*f+d*g),t[15]=1)}(this,t,e=e||[0,0,0],i=i||[0,1,0]),this.check()}ortho({left:t,right:e,bottom:i,top:s,near:r=.1,far:n=500}){return function(t,e,i,s,r,n,o){var a=1/(e-i),h=1/(s-r),c=1/(n-o);t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*a,t[13]=(r+s)*h,t[14]=(o+n)*c,t[15]=1}(this,t,e,i,s,r,n),this.check()}orthographic({fovy:t=45*Math.PI/180,aspect:e=1,focalDistance:i=1,near:s=.1,far:r=500}){if(t>2*Math.PI)throw Error("radians");const n=t/2,o=i*Math.tan(n),a=o*e;return(new W).ortho({left:-a,right:a,bottom:-o,top:o,near:s,far:r})}perspective({fovy:t,fov:e=45*Math.PI/180,aspect:i=1,near:s=.1,far:r=500}={}){if((t=t||e)>2*Math.PI)throw Error("radians");return function(t,e,i,s,r){var n,o=1/Math.tan(e/2);t[0]=o/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=r&&r!==1/0?(n=1/(s-r),t[10]=(r+s)*n,t[14]=2*r*s*n):(t[10]=-1,t[14]=-2*s)}(this,t,i,s,r),this.check()}determinant(){return e=(t=this)[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],c=t[8],u=t[9],l=t[10],d=t[11],m=t[12],p=t[13],f=t[14],g=t[15],(e*o-i*n)*(l*g-d*f)-(e*a-s*n)*(u*g-d*p)+(e*h-r*n)*(u*f-l*p)+(i*a-s*o)*(c*g-d*m)-(i*h-r*o)*(c*f-l*m)+(s*h-r*a)*(c*p-u*m);var t,e,i,s,r,n,o,a,h,c,u,l,d,m,p,f,g}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t=[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=null){const i=this.getScale(e||[-0,-0,-0]),s=1/i[0],r=1/i[1],n=1/i[2];return t[0]=this[0]*s,t[1]=this[1]*r,t[2]=this[2]*n,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*r,t[6]=this[6]*n,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*r,t[10]=this[10]*n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t=[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=null){const i=this.getScale(e||[-0,-0,-0]),s=1/i[0],r=1/i[1],n=1/i[2];return t[0]=this[0]*s,t[1]=this[1]*r,t[2]=this[2]*n,t[3]=this[4]*s,t[4]=this[5]*r,t[5]=this[6]*n,t[6]=this[8]*s,t[7]=this[9]*r,t[8]=this[10]*n,t}transpose(){return function(t,e){if(t===e){var i=e[1],s=e[2],r=e[3],n=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=i,t[6]=e[9],t[7]=e[13],t[8]=s,t[9]=n,t[11]=e[14],t[12]=r,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15]}(this,this),this.check()}invert(){return function(t,e){var i=e[0],s=e[1],r=e[2],n=e[3],o=e[4],a=e[5],h=e[6],c=e[7],u=e[8],l=e[9],d=e[10],m=e[11],p=e[12],f=e[13],g=e[14],T=e[15],_=i*a-s*o,y=i*h-r*o,v=i*c-n*o,w=s*h-r*a,E=s*c-n*a,M=r*c-n*h,S=u*f-l*p,b=u*g-d*p,C=u*T-m*p,x=l*g-d*f,R=l*T-m*f,O=d*T-m*g,N=_*O-y*R+v*x+w*C-E*b+M*S;N&&(N=1/N,t[0]=(a*O-h*R+c*x)*N,t[1]=(r*R-s*O-n*x)*N,t[2]=(f*M-g*E+T*w)*N,t[3]=(d*E-l*M-m*w)*N,t[4]=(h*C-o*O-c*b)*N,t[5]=(i*O-r*C+n*b)*N,t[6]=(g*v-p*M-T*y)*N,t[7]=(u*M-d*v+m*y)*N,t[8]=(o*R-a*C+c*S)*N,t[9]=(s*C-i*R-n*S)*N,t[10]=(p*E-f*v+T*_)*N,t[11]=(l*v-u*E-m*_)*N,t[12]=(a*b-o*x-h*S)*N,t[13]=(i*x-s*b+r*S)*N,t[14]=(f*y-p*w-g*_)*N,t[15]=(u*w-l*y+d*_)*N)}(this,this),this.check()}multiplyLeft(t){return S(this,t,this),this.check()}multiplyRight(t){return S(this,this,t),this.check()}rotateX(t){return function(t,e,i){var s=Math.sin(i),r=Math.cos(i),n=e[4],o=e[5],a=e[6],h=e[7],c=e[8],u=e[9],l=e[10],d=e[11];e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*r+c*s,t[5]=o*r+u*s,t[6]=a*r+l*s,t[7]=h*r+d*s,t[8]=c*r-n*s,t[9]=u*r-o*s,t[10]=l*r-a*s,t[11]=d*r-h*s}(this,this,t),this.check()}rotateY(t){return function(t,e,i){var s=Math.sin(i),r=Math.cos(i),n=e[0],o=e[1],a=e[2],h=e[3],c=e[8],u=e[9],l=e[10],d=e[11];e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*r-c*s,t[1]=o*r-u*s,t[2]=a*r-l*s,t[3]=h*r-d*s,t[8]=n*s+c*r,t[9]=o*s+u*r,t[10]=a*s+l*r,t[11]=h*s+d*r}(this,this,t),this.check()}rotateZ(t){return function(t,e,i){var s=Math.sin(i),r=Math.cos(i),n=e[0],o=e[1],a=e[2],h=e[3],c=e[4],u=e[5],l=e[6],d=e[7];e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*r+c*s,t[1]=o*r+u*s,t[2]=a*r+l*s,t[3]=h*r+d*s,t[4]=c*r-n*s,t[5]=u*r-o*s,t[6]=l*r-a*s,t[7]=d*r-h*s}(this,this,t),this.check()}rotateXYZ([t,e,i]){return this.rotateX(t).rotateY(e).rotateZ(i)}rotateAxis(t,e){return function(t,e,i,s){var r,n,o,a,h,c,u,l,d,m,p,f,g,T,_,y,v,w,M,S,b,C,x,R,O=s[0],N=s[1],A=s[2],q=Math.hypot(O,N,A);q<E||(O*=q=1/q,N*=q,A*=q,r=Math.sin(i),o=1-(n=Math.cos(i)),a=e[0],h=e[1],c=e[2],u=e[3],l=e[4],d=e[5],m=e[6],p=e[7],f=e[8],g=e[9],T=e[10],_=e[11],y=O*O*o+n,v=N*O*o+A*r,w=A*O*o-N*r,M=O*N*o-A*r,S=N*N*o+n,b=A*N*o+O*r,C=O*A*o+N*r,x=N*A*o-O*r,R=A*A*o+n,t[0]=a*y+l*v+f*w,t[1]=h*y+d*v+g*w,t[2]=c*y+m*v+T*w,t[3]=u*y+p*v+_*w,t[4]=a*M+l*S+f*b,t[5]=h*M+d*S+g*b,t[6]=c*M+m*S+T*b,t[7]=u*M+p*S+_*b,t[8]=a*C+l*x+f*R,t[9]=h*C+d*x+g*R,t[10]=c*C+m*x+T*R,t[11]=u*C+p*x+_*R,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]))}(this,this,t,e),this.check()}scale(t){return Array.isArray(t)?b(this,this,t):b(this,this,[t,t,t]),this.check()}translate(t){return function(t,e,i){var s,r,n,o,a,h,c,u,l,d,m,p,f=i[0],g=i[1],T=i[2];e===t?(t[12]=e[0]*f+e[4]*g+e[8]*T+e[12],t[13]=e[1]*f+e[5]*g+e[9]*T+e[13],t[14]=e[2]*f+e[6]*g+e[10]*T+e[14],t[15]=e[3]*f+e[7]*g+e[11]*T+e[15]):(s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],d=e[9],m=e[10],p=e[11],t[0]=s,t[1]=r,t[2]=n,t[3]=o,t[4]=a,t[5]=h,t[6]=c,t[7]=u,t[8]=l,t[9]=d,t[10]=m,t[11]=p,t[12]=s*f+a*g+l*T+e[12],t[13]=r*f+h*g+d*T+e[13],t[14]=n*f+c*g+m*T+e[14],t[15]=o*f+u*g+p*T+e[15])}(this,this,t),this.check()}transform(t,e){return 4===t.length?(g(e=function(t,e,i){var s=e[0],r=e[1],n=e[2],o=e[3];return t[0]=i[0]*s+i[4]*r+i[8]*n+i[12]*o,t[1]=i[1]*s+i[5]*r+i[9]*n+i[13]*o,t[2]=i[2]*s+i[6]*r+i[10]*n+i[14]*o,t[3]=i[3]*s+i[7]*r+i[11]*n+i[15]*o,t}(e||[-0,-0,-0,-0],t,this),4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){const{length:i}=t;switch(i){case 2:e=function(t,e,i){var s=e[0],r=e[1];return t[0]=i[0]*s+i[4]*r+i[12],t[1]=i[1]*s+i[5]*r+i[13],t}(e||[-0,-0],t,this);break;case 3:e=L(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return g(e,t.length),e}transformAsVector(t,e){switch(t.length){case 2:e=function(t,e,i){const s=e[0],r=e[1],n=i[3]*s+i[7]*r||1;return t[0]=(i[0]*s+i[4]*r)/n,t[1]=(i[1]*s+i[5]*r)/n,t}(e||[-0,-0],t,this);break;case 3:e=w(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return g(e,t.length),e}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,i){return this.identity().translate([t,e,i])}transformPoint(t,e){return _("Matrix4.transformPoint","3.0"),this.transformAsPoint(t,e)}transformVector(t,e){return _("Matrix4.transformVector","3.0"),this.transformAsPoint(t,e)}transformDirection(t,e){return _("Matrix4.transformDirection","3.0"),this.transformAsVector(t,e)}}class B extends y{get ELEMENTS(){return r(!1),0}copy(t){return r(!1),this}get x(){return this[0]}set x(t){this[0]=f(t)}get y(){return this[1]}set y(t){this[1]=f(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let i=0;i<this.ELEMENTS;++i){const s=this[i]-t[i];e+=s*s}return f(e)}dot(t){let e=0;for(let i=0;i<this.ELEMENTS;++i)e+=this[i]*t[i];return f(e)}normalize(){const t=this.magnitude();if(0!==t)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e[t];return this.check()}divide(...t){for(const e of t)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e[t];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return r(t>=0&&t<this.ELEMENTS,"index is out of range"),f(this[t])}setComponent(t,e){return r(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}}const G=[0,0,0],Z={};class Y extends B{static get ZERO(){return Z.ZERO=Z.ZERO||Object.freeze(new Y(0,0,0,0))}constructor(t=0,e=0,i=0){super(-0,-0,-0),1===arguments.length&&c(t)?this.copy(t):(a.debug&&(f(t),f(e),f(i)),this[0]=t,this[1]=e,this[2]=i)}set(t,e,i){return this[0]=t,this[1]=e,this[2]=i,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return a.debug&&(f(t.x),f(t.y),f(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=f(t)}angle(t){return i=t,s=(e=this)[0],r=e[1],n=e[2],o=i[0],a=i[1],h=i[2],c=Math.sqrt(s*s+r*r+n*n)*Math.sqrt(o*o+a*a+h*h),u=c&&q(e,i)/c,Math.acos(Math.min(Math.max(u,-1),1));var e,i,s,r,n,o,a,h,c,u}cross(t){return I(this,this,t),this.check()}rotateX({radians:t,origin:e=G}){return function(t,e,i,s){var r=[],n=[];r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],n[0]=r[0],n[1]=r[1]*Math.cos(s)-r[2]*Math.sin(s),n[2]=r[1]*Math.sin(s)+r[2]*Math.cos(s),t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2]}(this,this,e,t),this.check()}rotateY({radians:t,origin:e=G}){return function(t,e,i,s){var r=[],n=[];r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],n[0]=r[2]*Math.sin(s)+r[0]*Math.cos(s),n[1]=r[1],n[2]=r[2]*Math.cos(s)-r[0]*Math.sin(s),t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2]}(this,this,e,t),this.check()}rotateZ({radians:t,origin:e=G}){return function(t,e,i,s){var r=[],n=[];r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],n[0]=r[0]*Math.cos(s)-r[1]*Math.sin(s),n[1]=r[0]*Math.sin(s)+r[1]*Math.cos(s),n[2]=r[2],t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2]}(this,this,e,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return L(this,this,t),this.check()}transformAsVector(t){return w(this,this,t),this.check()}transformByMatrix3(t){return P(this,this,t),this.check()}transformByMatrix2(t){return function(t,e,i){const s=e[0],r=e[1];t[0]=i[0]*s+i[2]*r,t[1]=i[1]*s+i[3]*r,t[2]=e[2]}(this,this,t),this.check()}transformByQuaternion(t){return function(t,e,i){var s=i[0],r=i[1],n=i[2],o=i[3],a=e[0],h=e[1],c=e[2],u=r*c-n*h,l=n*a-s*c,d=s*h-r*a,m=r*d-n*l,p=n*u-s*d,f=s*l-r*u,g=2*o;u*=g,l*=g,d*=g,m*=2,p*=2,f*=2,t[0]=a+u+m,t[1]=h+l+p,t[2]=c+d+f}(this,this,t),this.check()}}var K=.1,Q=1e-12,H=1e-15;Math.PI,Math.PI,Math.PI,Math.PI;Math.max(6378137,6378137,6356752.314245179);const X=t=>t,$=new Y;function J(t,e,i=X){return c(t)?(e[0]=i(t[0]),e[1]=i(t[1]),e[2]=t[2]):"longitude"in t?(e[0]=i(t.longitude),e[1]=i(t.latitude),e[2]=t.height):(e[0]=i(t.x),e[1]=i(t.y),e[2]=t.z),e}function tt(t,e,i=X){return c(e)?(e[0]=i(t[0]),e[1]=i(t[1]),e[2]=t[2]):"longitude"in e?(e.longitude=i(t[0]),e.latitude=i(t[1]),e.height=t[2]):(e.x=i(t[0]),e.y=i(t[1]),e.z=t[2]),e}const et=new Y,it=new Y,st=new Y;const rt=new Y,nt={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},ot={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},at={east:new Y,north:new Y,up:new Y,west:new Y,south:new Y,down:new Y},ht=new Y,ct=new Y,ut=new Y;function lt(t,e,i,s,n,o){const a=nt[e]&&nt[e][i];let h,c,u;r(a&&(!s||s===a));const l=rt.copy(n);if(p(l.x,0,1e-14)&&p(l.y,0,1e-14)){const t=Math.sign(l.z);h=ht.fromArray(ot[e]),"east"!==e&&"west"!==e&&h.scale(t),c=ct.fromArray(ot[i]),"east"!==i&&"west"!==i&&c.scale(t),u=ut.fromArray(ot[s]),"east"!==s&&"west"!==s&&u.scale(t)}else{const{up:r,east:n,north:o}=at;n.set(-l.y,l.x,0).normalize(),t.geodeticSurfaceNormal(l,r),o.copy(r).cross(n);const{down:a,west:d,south:m}=at;a.copy(r).scale(-1),d.copy(n).scale(-1),m.copy(o).scale(-1),h=at[e],c=at[i],u=at[s]}return o[0]=h.x,o[1]=h.y,o[2]=h.z,o[3]=0,o[4]=c.x,o[5]=c.y,o[6]=c.z,o[7]=0,o[8]=u.x,o[9]=u.y,o[10]=u.z,o[11]=0,o[12]=l.x,o[13]=l.y,o[14]=l.z,o[15]=1,o}const dt=new Y,mt=new Y,pt=new Y,ft=new Y,gt=new Y,Tt=new Y;let _t;class yt{static get WGS84(){return _t=_t||new yt(6378137,6378137,6356752.314245179),_t}constructor(t=0,e=0,i=0){r(t>=0),r(e>=0),r(i>=0),this.radii=new Y(t,e,i),this.radiiSquared=new Y(t*t,e*e,i*i),this.radiiToTheFourth=new Y(t*t*t*t,e*e*e*e,i*i*i*i),this.oneOverRadii=new Y(0===t?0:1/t,0===e?0:1/e,0===i?0:1/i),this.oneOverRadiiSquared=new Y(0===t?0:1/(t*t),0===e?0:1/(e*e),0===i?0:1/(i*i)),this.minimumRadius=Math.min(t,e,i),this.maximumRadius=Math.max(t,e,i),this.centerToleranceSquared=K,0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,e=[0,0,0]){const i=mt,s=pt,[,,r]=t;this.geodeticSurfaceNormalCartographic(t,i),s.copy(this.radiiSquared).scale(i);const n=Math.sqrt(i.dot(s));return s.scale(1/n),i.scale(r),s.add(i),s.to(e)}cartesianToCartographic(t,e=[0,0,0]){Tt.from(t);const i=this.scaleToGeodeticSurface(Tt,ft);if(!i)return;const s=this.geodeticSurfaceNormal(i,mt),r=gt;r.copy(Tt).subtract(i);const n=Math.atan2(s.y,s.x),o=Math.asin(s.z),h=Math.sign(q(r,Tt))*N(r);return tt([n,o,h],e,a._cartographicRadians?X:d)}eastNorthUpToFixedFrame(t,e=new W){return lt(this,"east","north","up",t,e)}localFrameToFixedFrame(t,e,i,s,r=new W){return lt(this,t,e,i,s,r)}geocentricSurfaceNormal(t,e=[0,0,0]){return dt.from(t).normalize().to(e)}geodeticSurfaceNormalCartographic(t,e=[0,0,0]){const i=function(t,e=$){return J(t,e,a._cartographicRadians?X:l)}(t),s=i[0],r=i[1],n=Math.cos(r);return dt.set(n*Math.cos(s),n*Math.sin(s),Math.sin(r)).normalize(),dt.to(e)}geodeticSurfaceNormal(t,e=[0,0,0]){return dt.from(t).scale(this.oneOverRadiiSquared).normalize().to(e)}scaleToGeodeticSurface(t,e){return function(t,e,i=new Y){const{oneOverRadii:s,oneOverRadiiSquared:r,centerToleranceSquared:n}=e;et.from(t);const o=t.x,a=t.y,h=t.z,c=s.x,u=s.y,l=s.z,d=o*o*c*c,m=a*a*u*u,p=h*h*l*l,f=d+m+p,g=Math.sqrt(1/f);if(!Number.isFinite(g))return;const T=it;if(T.copy(t).scale(g),f<n)return T.to(i);const _=r.x,y=r.y,v=r.z,w=st;w.set(T.x*_*2,T.y*y*2,T.z*v*2);let E,M,S,b,C=(1-g)*t.len()/(.5*w.len()),x=0;do{C-=x,E=1/(1+C*_),M=1/(1+C*y),S=1/(1+C*v);const t=E*E,e=M*M,i=S*S;b=d*t+m*e+p*i-1;x=b/(-2*(d*(t*E)*_+m*(e*M)*y+p*(i*S)*v))}while(Math.abs(b)>Q);return et.scale([E,M,S]).to(i)}(t,this,e)}scaleToGeocentricSurface(t,e=[0,0,0]){ft.from(t);const i=ft.x,s=ft.y,r=ft.z,n=this.oneOverRadiiSquared,o=1/Math.sqrt(i*i*n.x+s*s*n.y+r*r*n.z);return ft.multiplyScalar(o).to(e)}transformPositionToScaledSpace(t,e=[0,0,0]){return ft.from(t).scale(this.oneOverRadii).to(e)}transformPositionFromScaledSpace(t,e=[0,0,0]){return ft.from(t).scale(this.radii).to(e)}getSurfaceNormalIntersectionWithZAxis(t,e=0,i=[0,0,0]){r(p(this.radii.x,this.radii.y,H)),r(this.radii.z>0),ft.from(t);const s=ft.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-e))return ft.set(0,0,s).to(i)}}var vt=i(4);class wt{constructor(t,e){this.name=t,this.type=e,this.sampleSize=1,this.reset()}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Object(vt.a)(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Object(vt.a)()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Et{constructor({id:t,stats:e}){this.id=t,this.stats={},this._initializeStats(e),Object.seal(this)}get(t,e="count"){return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(const t in this.stats)this.stats[t].reset();return this}forEach(t){for(const e in this.stats)t(this.stats[e])}getTable(){const t={};return this.forEach(e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(t=>this._getOrCreate(t))}_getOrCreate(t){if(!t||!t.name)return null;const{name:e,type:i}=t;return this.stats[e]||(this.stats[e]=t instanceof wt?t:new wt(e,i)),this.stats[e]}}function Mt(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function St(t){const e=t&&t.lastIndexOf("/");return e>=0?t.substr(e+1):""}function bt(t){const e=t&&t.lastIndexOf("/");return e>=0?t.substr(0,e):""}function Ct(...t){return(t=t.map((e,i)=>(i&&(e=e.replace(new RegExp("^/"),"")),i!==t.length-1&&(e=e.replace(new RegExp("/$"),"")),e))).join("/")}i(6),i(15);function xt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const Rt={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class Ot{constructor(t={}){xt(this,"props",void 0),xt(this,"stats",void 0),xt(this,"activeRequestCount",0),xt(this,"requestQueue",[]),xt(this,"requestMap",new Map),xt(this,"deferredUpdate",null),this.props={...Rt,...t},this.stats=new Et({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(t,e=(()=>0)){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);const i={handle:t,priority:0,getPriority:e},s=new Promise(t=>(i.resolve=t,i));return this.requestQueue.push(i),this.requestMap.set(t,s),this._issueNewRequests(),s}_issueRequest(t){const{handle:e,resolve:i}=t;let s=!1;const r=()=>{s||(s=!0,this.requestMap.delete(e),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({done:r}):Promise.resolve({done:r})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==t){this._updateAllRequests();for(let e=0;e<t;++e){const t=this.requestQueue.shift();t&&this._issueRequest(t)}}}_updateAllRequests(){const t=this.requestQueue;for(let e=0;e<t.length;++e){const i=t[e];this._updateRequest(i)||(t.splice(e,1),this.requestMap.delete(i.handle),e--)}t.sort((t,e)=>t.priority-e.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),!(t.priority<0)||(t.resolve(null),!1)}}class Nt{constructor(t,e,i){this.item=t,this.previous=e,this.next=i}}class At{constructor(){this.head=null,this.tail=null,this._length=0}get length(){return this._length}add(t){const e=new Nt(t,this.tail,null);return this.tail?(this.tail.next=e,this.tail=e):(this.head=e,this.tail=e),++this._length,e}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,e){t!==e&&(this.remove(e),this._insert(t,e))}_insert(t,e){const i=t.next;t.next=e,this.tail===t?this.tail=e:i.previous=e,e.next=i,e.previous=t,++this._length}}function qt(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function It(t){return null!=t}class Lt{constructor(){qt(this,"_list",void 0),qt(this,"_sentinel",void 0),qt(this,"_trimTiles",void 0),this._list=new At,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){const e=t._cacheNode;It(e)&&this._list.splice(this._sentinel,e)}add(t,e,i){It(e._cacheNode)||(e._cacheNode=this._list.add(e),i&&i(t,e))}unloadTile(t,e,i){const s=e._cacheNode;It(s)&&(this._list.remove(s),e._cacheNode=void 0,i&&i(t,e))}unloadTiles(t,e){const i=this._trimTiles;this._trimTiles=!1;const s=this._list,r=1024*t.maximumMemoryUsage*1024,n=this._sentinel;let o=s.head;for(;o!==n&&(t.gpuMemoryUsageInBytes>r||i);){const i=o.item;o=o.next,this.unloadTile(t,i,e)}}trim(){this._trimTiles=!0}}function Pt(t,e){Mt(t),Mt(e);const{rtcCenter:i,gltfUpAxis:s}=e,{computedTransform:r,boundingVolume:{center:n}}=t;let o=new W(r);switch(i&&o.translate(i),s){case"Z":break;case"Y":const t=(new W).rotateX(Math.PI/2);o=o.multiplyRight(t);break;case"X":const e=(new W).rotateY(-Math.PI/2);o=o.multiplyRight(e)}e.isQuantized&&o.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);const a=new Y(n);e.cartesianModelMatrix=o,e.cartesianOrigin=a;const h=yt.WGS84.cartesianToCartographic(a,new Y),c=yt.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=c.multiplyRight(o),e.cartographicOrigin=h,e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}const Dt=Object.freeze({OUTSIDE:-1,INTERSECTING:0,INSIDE:1});new Y,new Y;const Vt=new Y,kt=new Y;class zt{constructor(t=[0,0,0],e=0){this.radius=-0,this.center=new Y,this.fromCenterRadius(t,e)}fromCenterRadius(t,e){return this.center.from(t),this.radius=e,this}fromCornerPoints(t,e){return e=Vt.from(e),this.center=(new Y).from(t).add(e).scale(.5),this.radius=this.center.distance(e),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new zt(this.center,this.radius)}union(t){const e=this.center,i=this.radius,s=t.center,r=t.radius,n=Vt.copy(s).subtract(e),o=n.magnitude();if(i>=o+r)return this.clone();if(r>=o+i)return t.clone();const a=.5*(i+o+r);return kt.copy(n).scale((-i+a)/o).add(e),this.center.copy(kt),this.radius=a,this}expand(t){const e=(t=Vt.from(t)).subtract(this.center).magnitude();return e>this.radius&&(this.radius=e),this}transform(t){this.center.transform(t);const e=C(Vt,t);return this.radius=Math.max(e[0],Math.max(e[1],e[2]))*this.radius,this}distanceSquaredTo(t){return(t=Vt.from(t)).subtract(this.center).lengthSquared()-this.radius*this.radius}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}intersectPlane(t){const e=this.center,i=this.radius,s=t.normal.dot(e)+t.distance;return s<-i?Dt.OUTSIDE:s<i?Dt.INTERSECTING:Dt.INSIDE}}function Ut(t,e,i){var s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],d=i[0],m=i[1],p=i[2],f=i[3],g=i[4],T=i[5],_=i[6],y=i[7],v=i[8];return t[0]=d*s+m*o+p*c,t[1]=d*r+m*a+p*u,t[2]=d*n+m*h+p*l,t[3]=f*s+g*o+T*c,t[4]=f*r+g*a+T*u,t[5]=f*n+g*h+T*l,t[6]=_*s+y*o+v*c,t[7]=_*r+y*a+v*u,t[8]=_*n+y*h+v*l,t}function jt(t,e,i){var s=i[0],r=i[1];return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=r*e[3],t[4]=r*e[4],t[5]=r*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}const Ft=Object.freeze([1,0,0,0,1,0,0,0,1]),Wt=Object.freeze([0,0,0,0,0,0,0,0,0]),Bt=Object.freeze({COL0ROW0:0,COL0ROW1:1,COL0ROW2:2,COL1ROW0:3,COL1ROW1:4,COL1ROW2:5,COL2ROW0:6,COL2ROW1:7,COL2ROW2:8}),Gt={};class Zt extends v{static get IDENTITY(){return Gt.IDENTITY=Gt.IDENTITY||Object.freeze(new Zt(Ft)),Gt.IDENTITY}static get ZERO(){return Gt.ZERO=Gt.ZERO||Object.freeze(new Zt(Wt)),Gt.ZERO}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Bt}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}set(t,e,i,s,r,n,o,a,h){return this[0]=t,this[1]=e,this[2]=i,this[3]=s,this[4]=r,this[5]=n,this[6]=o,this[7]=a,this[8]=h,this.check()}setRowMajor(t,e,i,s,r,n,o,a,h){return this[0]=t,this[1]=s,this[2]=o,this[3]=e,this[4]=r,this[5]=a,this[6]=i,this[7]=n,this[8]=h,this.check()}determinant(){return e=(t=this)[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],c=t[8],e*(c*n-o*h)+i*(-c*r+o*a)+s*(h*r-n*a);var t,e,i,s,r,n,o,a,h,c}identity(){return this.copy(Ft)}fromQuaternion(t){return function(t,e){var i=e[0],s=e[1],r=e[2],n=e[3],o=i+i,a=s+s,h=r+r,c=i*o,u=s*o,l=s*a,d=r*o,m=r*a,p=r*h,f=n*o,g=n*a,T=n*h;t[0]=1-l-p,t[3]=u-T,t[6]=d+g,t[1]=u+T,t[4]=1-c-p,t[7]=m-f,t[2]=d-g,t[5]=m+f,t[8]=1-c-l}(this,t),this.check()}transpose(){return function(t,e){if(t===e){var i=e[1],s=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=s,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8]}(this,this),this.check()}invert(){return function(t,e){var i=e[0],s=e[1],r=e[2],n=e[3],o=e[4],a=e[5],h=e[6],c=e[7],u=e[8],l=u*o-a*c,d=-u*n+a*h,m=c*n-o*h,p=i*l+s*d+r*m;p&&(p=1/p,t[0]=l*p,t[1]=(-u*s+r*c)*p,t[2]=(a*s-r*o)*p,t[3]=d*p,t[4]=(u*i-r*h)*p,t[5]=(-a*i+r*n)*p,t[6]=m*p,t[7]=(-c*i+s*h)*p,t[8]=(o*i-s*n)*p)}(this,this),this.check()}multiplyLeft(t){return Ut(this,t,this),this.check()}multiplyRight(t){return Ut(this,this,t),this.check()}rotate(t){return function(t,e,i){var s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],d=Math.sin(i),m=Math.cos(i);t[0]=m*s+d*o,t[1]=m*r+d*a,t[2]=m*n+d*h,t[3]=m*o-d*s,t[4]=m*a-d*r,t[5]=m*h-d*n,t[6]=c,t[7]=u,t[8]=l}(this,this,t),this.check()}scale(t){return Array.isArray(t)?jt(this,this,t):jt(this,this,[t,t,t]),this.check()}translate(t){return function(t,e,i){var s=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],d=i[0],m=i[1];t[0]=s,t[1]=r,t[2]=n,t[3]=o,t[4]=a,t[5]=h,t[6]=d*s+m*o+c,t[7]=d*r+m*a+u,t[8]=d*n+m*h+l}(this,this,t),this.check()}transform(t,e){switch(t.length){case 2:e=function(t,e,i){var s=e[0],r=e[1];return t[0]=i[0]*s+i[3]*r+i[6],t[1]=i[1]*s+i[4]*r+i[7],t}(e||[-0,-0],t,this);break;case 3:e=P(e||[-0,-0,-0],t,this);break;case 4:e=function(t,e,i){const s=e[0],r=e[1],n=e[2];return t[0]=i[0]*s+i[3]*r+i[6]*n,t[1]=i[1]*s+i[4]*r+i[7]*n,t[2]=i[2]*s+i[5]*r+i[8]*n,t[3]=e[3],t}(e||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return g(e,t.length),e}transformVector(t,e){return _("Matrix3.transformVector"),this.transform(t,e)}transformVector2(t,e){return _("Matrix3.transformVector"),this.transform(t,e)}transformVector3(t,e){return _("Matrix3.transformVector"),this.transform(t,e)}}function Yt(){var t=new M(4);return M!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Kt(t,e,i){i*=.5;var s=Math.sin(i);return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=Math.cos(i),t}function Qt(t,e,i){var s=e[0],r=e[1],n=e[2],o=e[3],a=i[0],h=i[1],c=i[2],u=i[3];return t[0]=s*u+o*a+r*c-n*h,t[1]=r*u+o*h+n*a-s*c,t[2]=n*u+o*c+s*h-r*a,t[3]=o*u-s*a-r*h-n*c,t}function Ht(t,e,i,s){var r,n,o,a,h,c=e[0],u=e[1],l=e[2],d=e[3],m=i[0],p=i[1],f=i[2],g=i[3];return(n=c*m+u*p+l*f+d*g)<0&&(n=-n,m=-m,p=-p,f=-f,g=-g),1-n>E?(r=Math.acos(n),o=Math.sin(r),a=Math.sin((1-s)*r)/o,h=Math.sin(s*r)/o):(a=1-s,h=s),t[0]=a*c+h*m,t[1]=a*u+h*p,t[2]=a*l+h*f,t[3]=a*d+h*g,t}function Xt(t,e){var i,s=e[0]+e[4]+e[8];if(s>0)i=Math.sqrt(s+1),t[3]=.5*i,i=.5/i,t[0]=(e[5]-e[7])*i,t[1]=(e[6]-e[2])*i,t[2]=(e[1]-e[3])*i;else{var r=0;e[4]>e[0]&&(r=1),e[8]>e[3*r+r]&&(r=2);var n=(r+1)%3,o=(r+2)%3;i=Math.sqrt(e[3*r+r]-e[3*n+n]-e[3*o+o]+1),t[r]=.5*i,i=.5/i,t[3]=(e[3*n+o]-e[3*o+n])*i,t[n]=(e[3*n+r]+e[3*r+n])*i,t[o]=(e[3*o+r]+e[3*r+o])*i}return t}var $t,Jt,te,ee,ie,se,re=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t},ne=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t},oe=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},ae=function(t,e,i,s){var r=e[0],n=e[1],o=e[2],a=e[3];return t[0]=r+s*(i[0]-r),t[1]=n+s*(i[1]-n),t[2]=o+s*(i[2]-o),t[3]=a+s*(i[3]-a),t},he=V,ce=k,ue=function(t,e){var i=e[0],s=e[1],r=e[2],n=e[3],o=i*i+s*s+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=i*o,t[1]=s*o,t[2]=r*o,t[3]=n*o,t},le=($t=O(),Jt=A(1,0,0),te=A(0,1,0),function(t,e,i){var s=q(e,i);return s<-.999999?(I($t,Jt,e),D($t)<1e-6&&I($t,te,e),function(t,e){var i=e[0],s=e[1],r=e[2],n=i*i+s*s+r*r;n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n}($t,$t),Kt(t,$t,Math.PI),t):s>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(I($t,e,i),t[0]=$t[0],t[1]=$t[1],t[2]=$t[2],t[3]=1+s,ue(t,t))});ee=Yt(),ie=Yt(),se=function(){var t=new M(9);return M!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}();const de=[0,0,0,1];class me extends y{constructor(t=0,e=0,i=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&1===arguments.length?this.copy(t):this.set(t,e,i,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,e,i,s){return this[0]=t,this[1]=e,this[2]=i,this[3]=s,this.check()}fromMatrix3(t){return Xt(this,t),this.check()}identity(){return function(t){t[0]=0,t[1]=0,t[2]=0,t[3]=1}(this),this.check()}fromAxisRotation(t,e){return Kt(this,t,e),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=f(t)}get y(){return this[1]}set y(t){this[1]=f(t)}get z(){return this[2]}set z(t){this[2]=f(t)}get w(){return this[3]}set w(t){this[3]=f(t)}len(){return he(this)}lengthSquared(){return ce(this)}dot(t,e){if(void 0!==e)throw new Error("Quaternion.dot only takes one argument");return oe(this,t)}rotationTo(t,e){return le(this,t,e),this.check()}add(t,e){if(void 0!==e)throw new Error("Quaternion.add only takes one argument");return re(this,this,t),this.check()}calculateW(){return function(t,e){var i=e[0],s=e[1],r=e[2];t[0]=i,t[1]=s,t[2]=r,t[3]=Math.sqrt(Math.abs(1-i*i-s*s-r*r))}(this,this),this.check()}conjugate(){return function(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3]}(this,this),this.check()}invert(){return function(t,e){var i=e[0],s=e[1],r=e[2],n=e[3],o=i*i+s*s+r*r+n*n,a=o?1/o:0;t[0]=-i*a,t[1]=-s*a,t[2]=-r*a,t[3]=n*a}(this,this),this.check()}lerp(t,e,i){return ae(this,t,e,i),this.check()}multiplyRight(t,e){return r(!e),Qt(this,this,t),this.check()}multiplyLeft(t,e){return r(!e),Qt(this,t,this),this.check()}normalize(){const t=this.len(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,0===t&&(this[3]=1),this.check()}rotateX(t){return function(t,e,i){i*=.5;var s=e[0],r=e[1],n=e[2],o=e[3],a=Math.sin(i),h=Math.cos(i);t[0]=s*h+o*a,t[1]=r*h+n*a,t[2]=n*h-r*a,t[3]=o*h-s*a}(this,this,t),this.check()}rotateY(t){return function(t,e,i){i*=.5;var s=e[0],r=e[1],n=e[2],o=e[3],a=Math.sin(i),h=Math.cos(i);t[0]=s*h-n*a,t[1]=r*h+o*a,t[2]=n*h+s*a,t[3]=o*h-r*a}(this,this,t),this.check()}rotateZ(t){return function(t,e,i){i*=.5;var s=e[0],r=e[1],n=e[2],o=e[3],a=Math.sin(i),h=Math.cos(i);t[0]=s*h+r*a,t[1]=r*h-s*a,t[2]=n*h+o*a,t[3]=o*h-n*a}(this,this,t),this.check()}scale(t){return ne(this,this,t),this.check()}slerp(t,e,i){switch(arguments.length){case 1:({start:t=de,target:e,ratio:i}=arguments[0]);break;case 2:[e,i]=arguments,t=this}return Ht(this,t,e,i),this.check()}transformVector4(t,e=t){return function(t,e,i){var s=e[0],r=e[1],n=e[2],o=i[0],a=i[1],h=i[2],c=i[3],u=c*s+a*n-h*r,l=c*r+h*s-o*n,d=c*n+o*r-a*s,m=-o*s-a*r-h*n;t[0]=u*c+m*-o+l*-h-d*-a,t[1]=l*c+m*-a+d*-o-u*-h,t[2]=d*c+m*-h+u*-a-l*-o,t[3]=e[3]}(e,t,this),g(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t,e){return this.multiplyLeft(t,e)}multiply(t,e){return this.multiplyRight(t,e)}}const pe=new Y,fe=new Y,ge=new Y,Te=new Y,_e=new Y,ye=new Y,ve=new Y,we=0,Ee=1,Me=2,Se=3,be=4,Ce=5,xe=6,Re=7,Oe=8;class Ne{constructor(t=[0,0,0],e=[0,0,0,0,0,0,0,0,0]){this.center=(new Y).from(t),this.halfAxes=new Zt(e)}get halfSize(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2);return[new Y(t).len(),new Y(e).len(),new Y(i).len()]}get quaternion(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2),s=new Y(t).normalize(),r=new Y(e).normalize(),n=new Y(i).normalize();return(new me).fromMatrix3(new Zt([...s,...r,...n]))}fromCenterHalfSizeQuaternion(t,e,i){const s=new me(i),r=(new Zt).fromQuaternion(s);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],this.center=(new Y).from(t),this.halfAxes=r,this}clone(){return new Ne(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new zt){const e=this.halfAxes,i=e.getColumn(0,ge),s=e.getColumn(1,Te),r=e.getColumn(2,_e),n=pe.copy(i).add(s).add(r);return t.center.copy(this.center),t.radius=n.magnitude(),t}intersectPlane(t){const e=this.center,i=t.normal,s=this.halfAxes,r=i.x,n=i.y,o=i.z,a=Math.abs(r*s[we]+n*s[Ee]+o*s[Me])+Math.abs(r*s[Se]+n*s[be]+o*s[Ce])+Math.abs(r*s[xe]+n*s[Re]+o*s[Oe]),h=i.dot(e)+t.distance;return h<=-a?Dt.OUTSIDE:h>=a?Dt.INSIDE:Dt.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){const e=fe.from(t).subtract(this.center),i=this.halfAxes,s=i.getColumn(0,ge),r=i.getColumn(1,Te),n=i.getColumn(2,_e),o=s.magnitude(),a=r.magnitude(),h=n.magnitude();s.normalize(),r.normalize(),n.normalize();let c,u=0;return c=Math.abs(e.dot(s))-o,c>0&&(u+=c*c),c=Math.abs(e.dot(r))-a,c>0&&(u+=c*c),c=Math.abs(e.dot(n))-h,c>0&&(u+=c*c),u}computePlaneDistances(t,e,i=[-0,-0]){let s=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const n=this.center,o=this.halfAxes,a=o.getColumn(0,ge),h=o.getColumn(1,Te),c=o.getColumn(2,_e),u=ye.copy(a).add(h).add(c).add(n),l=ve.copy(u).subtract(t);let d=e.dot(l);return s=Math.min(d,s),r=Math.max(d,r),u.copy(n).add(a).add(h).subtract(c),l.copy(u).subtract(t),d=e.dot(l),s=Math.min(d,s),r=Math.max(d,r),u.copy(n).add(a).subtract(h).add(c),l.copy(u).subtract(t),d=e.dot(l),s=Math.min(d,s),r=Math.max(d,r),u.copy(n).add(a).subtract(h).subtract(c),l.copy(u).subtract(t),d=e.dot(l),s=Math.min(d,s),r=Math.max(d,r),n.copy(u).subtract(a).add(h).add(c),l.copy(u).subtract(t),d=e.dot(l),s=Math.min(d,s),r=Math.max(d,r),n.copy(u).subtract(a).add(h).subtract(c),l.copy(u).subtract(t),d=e.dot(l),s=Math.min(d,s),r=Math.max(d,r),n.copy(u).subtract(a).subtract(h).add(c),l.copy(u).subtract(t),d=e.dot(l),s=Math.min(d,s),r=Math.max(d,r),n.copy(u).subtract(a).subtract(h).subtract(c),l.copy(u).subtract(t),d=e.dot(l),s=Math.min(d,s),r=Math.max(d,r),i[0]=s,i[1]=r,i}transform(t){this.center.transformAsPoint(t);const e=this.halfAxes.getColumn(0,ge);e.transformAsPoint(t);const i=this.halfAxes.getColumn(1,Te);i.transformAsPoint(t);const s=this.halfAxes.getColumn(2,_e);return s.transformAsPoint(t),this.halfAxes=new Zt([...e,...i,...s]),this}getTransform(){throw new Error("not implemented")}}const Ae=new Y,qe=new Y;class Ie{constructor(t=[0,0,1],e=0){this.normal=new Y,this.distance=-0,this.fromNormalDistance(t,e)}fromNormalDistance(t,e){return r(Number.isFinite(e)),this.normal.from(t).normalize(),this.distance=e,this}fromPointNormal(t,e){t=Ae.from(t),this.normal.from(e).normalize();const i=-this.normal.dot(t);return this.distance=i,this}fromCoefficients(t,e,i,s){return this.normal.set(t,e,i),r(p(this.normal.len(),1)),this.distance=s,this}clone(t){return new Ie(this.normal,this.distance)}equals(t){return p(this.distance,t.distance)&&p(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){const e=qe.copy(this.normal).transformAsVector(t).normalize(),i=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(i,e)}projectPointOntoPlane(t,e=[0,0,0]){t=Ae.from(t);const i=this.getPointDistance(t),s=qe.copy(this.normal).scale(i);return t.subtract(s).to(e)}}const Le=[new Y([1,0,0]),new Y([0,1,0]),new Y([0,0,1])],Pe=new Y,De=new Y;new Ie(new Y(1,0,0),0);class Ve{static get MASK_OUTSIDE(){return 4294967295}static get MASK_INSIDE(){return 0}static get MASK_INDETERMINATE(){return 2147483647}constructor(t=[]){this.planes=t,r(this.planes.every(t=>t instanceof Ie))}fromBoundingSphere(t){this.planes.length=2*Le.length;const e=t.center,i=t.radius;let s=0;for(const t of Le){let r=this.planes[s],n=this.planes[s+1];r||(r=this.planes[s]=new Ie),n||(n=this.planes[s+1]=new Ie);const o=Pe.copy(t).scale(-i).add(e);t.dot(o);r.fromPointNormal(o,t);const a=Pe.copy(t).scale(i).add(e),h=De.copy(t).negate();h.dot(a);n.fromPointNormal(a,h),s+=2}return this}computeVisibility(t){r(t);let e=Dt.INSIDE;for(const i of this.planes){switch(t.intersectPlane(i)){case Dt.OUTSIDE:return Dt.OUTSIDE;case Dt.INTERSECTING:e=Dt.INTERSECTING}}return e}computeVisibilityWithPlaneMask(t,e){if(r(t,"boundingVolume is required."),r(Number.isFinite(e),"parentPlaneMask is required."),e===Ve.MASK_OUTSIDE||e===Ve.MASK_INSIDE)return e;let i=Ve.MASK_INSIDE;const s=this.planes;for(let r=0;r<this.planes.length;++r){const n=r<31?1<<r:0;if(r<31&&0==(e&n))continue;const o=s[r],a=t.intersectPlane(o);if(a===Dt.OUTSIDE)return Ve.MASK_OUTSIDE;a===Dt.INTERSECTING&&(i|=n)}return i}}new Y,new Y,new Y,new Y,new Y;new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y,new Y,Math.PI;new Zt,new Zt,new Zt,new Zt,new Zt;new Y,new Y,new Y,new Y,new Y,new Zt,new Zt,new Zt;const ke=new Y,ze=new Y,Ue=new Ve([new Ie,new Ie,new Ie,new Ie,new Ie,new Ie]);function je(t,e){const{cameraDirection:i,cameraUp:s,height:r}=t,{metersPerUnit:n}=t.distanceScales,o=[t.longitude,t.latitude,0],a=yt.WGS84.cartographicToCartesian(o,new Y),h=yt.WGS84.eastNorthUpToFixedFrame(a),c=t.unprojectPosition(t.cameraPosition),u=yt.WGS84.cartographicToCartesian(c,new Y),l=new Y(h.transformAsVector(new Y(i).scale(n))).normalize(),d=new Y(h.transformAsVector(new Y(s).scale(n))).normalize();return function(t,e){const i=t.getFrustumPlanes();let s=0;for(const r in i){const n=i[r],o=n.normal.dot(t.center);ze.copy(n.normal).scale(n.distance-o).add(t.center);const a=t.unprojectPosition(ze),h=yt.WGS84.cartographicToCartesian(a,new Y);Ue.planes[s++].fromPointNormal(h,ke.copy(e).subtract(h))}}(t,a),{camera:{position:u,direction:l,up:d},viewport:t,height:r,cullingVolume:Ue,frameNumber:e,sseDenominator:1.15}}const Fe=new Y;function We(t){const{halfAxes:e,radius:i,width:s,height:r}=t;if(e){const t=function(t){t.getColumn(0,Fe);const e=t.getColumn(1),i=t.getColumn(2),s=Fe.add(e).add(i);return s.len()}(e);return Math.log2(6356752.314245179/t)}if(i)return Math.log2(6356752.314245179/i);if(r&&s){return(Math.log2(6378137/s)+Math.log2(6378137/r))/2}return 1}var Be=i(7);const Ge={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},Ze={ADD:1,REPLACE:2},Ye={EMPTY:"empty",SCENEGRAPH:"scenegraph",POINTCLOUD:"pointcloud",MESH:"mesh"},Ke={I3S:"I3S",TILES3D:"TILES3D"},Qe={GEOMETRIC_ERROR:"geometricError",MAX_SCREEN_THRESHOLD:"maxScreenThreshold"},He=1;function Xe(t){return null!=t}const $e=new Y,Je=new Y,ti=new Y;function ei(t,e,i){if(Mt(t,"3D Tile: boundingVolume must be defined"),t.box)return function(t,e,i){const s=new Y(t[0],t[1],t[2]);e.transform(s,s);let r=[];if(10===t.length){const e=t.slice(3,6),i=new me;i.fromArray(t,6);const s=new Y([1,0,0]),n=new Y([0,1,0]),o=new Y([0,0,1]);s.transformByQuaternion(i),s.scale(e[0]),n.transformByQuaternion(i),n.scale(e[1]),o.transformByQuaternion(i),o.scale(e[2]),r=[...s.toArray(),...n.toArray(),...o.toArray()]}else r=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];const n=e.transformAsVector(r.slice(0,3)),o=e.transformAsVector(r.slice(3,6)),a=e.transformAsVector(r.slice(6,9)),h=new Zt([n[0],n[1],n[2],o[0],o[1],o[2],a[0],a[1],a[2]]);if(Xe(i))return i.center=s,i.halfAxes=h,i;return new Ne(s,h)}(t.box,e,i);if(t.region){const[e,i,s,r,n,o]=t.region,a=yt.WGS84.cartographicToCartesian([m(e),m(r),n],Je),h=yt.WGS84.cartographicToCartesian([m(s),m(i),o],ti),c=(new Y).addVectors(a,h).multiplyScalar(.5),u=(new Y).subVectors(a,h).len()/2;return ii([c[0],c[1],c[2],u],new W)}if(t.sphere)return ii(t.sphere,e,i);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function ii(t,e,i){const s=new Y(t[0],t[1],t[2]);e.transform(s,s);const r=e.getScale($e),n=Math.max(Math.max(r[0],r[1]),r[2]),o=t[3]*n;return Xe(i)?(i.center=s,i.radius=o,i):new zt(s,o)}new Y,new Y,new W,new Y,new Y,new Y;function si(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){const i=t.dynamicScreenSpaceErrorComputedDensity,s=t.dynamicScreenSpaceErrorFactor;return function(t,e){const i=t*e;return 1-Math.exp(-i*i)}(e,i)*s}return 0}function ri(t,e){if(0===t.lodMetricValue||isNaN(t.lodMetricValue))return"DIG";const i=2*ni(t,e);return i<2?"OUT":!t.header.children||i<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function ni(t,e){const i=e.viewport,s=i.constructor,{longitude:r,latitude:n,height:o,width:a,bearing:h,zoom:c}=i,u=new s({longitude:r,latitude:n,height:o,width:a,bearing:h,zoom:c,pitch:0}),l=t.header.mbs[1],d=t.header.mbs[0],m=t.header.mbs[2],p=t.header.mbs[3],f=[...t.boundingVolume.center],g=u.unprojectPosition(u.cameraPosition),T=yt.WGS84.cartographicToCartesian(g,new Y),_=new Y(T).subtract(f).normalize(),y=new W;yt.WGS84.eastNorthUpToFixedFrame(f,y);const v=new W(y).invert(),w=new Y(T).transform(v),E=Math.sqrt(w[0]*w[0]+w[1]*w[1]),M=E*E/w[2],S=new Y([w[0],w[1],M]).transform(y),b=new Y(S).subtract(f).normalize(),C=_.cross(b).normalize().scale(p),x=new Y(f).add(C),R=yt.WGS84.cartesianToCartographic(x),O=u.project([d,l,m]),N=u.project(R);return new Y(O).subtract(N).magnitude()}class oi{constructor(t=0){this._array=new Array(t),this._map=new Map,this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return Mt(t<this._array.length),this._array[t]}set(t,e){Mt(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=e,this._map.set(e,t)}delete(t){const e=this._map.get(t);e>=0&&(this._array.splice(e,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){const e=this.length++;this._array[e]=t,this._map.set(t,e)}}pop(){const t=this._array[--this.length];return this._map.delete(t),t}reserve(t){Mt(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){Mt(t>=0),this.length=t}trim(t){null==t&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}}function ai(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const hi={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class ci{constructor(t){ai(this,"options",void 0),ai(this,"root",void 0),ai(this,"requestedTiles",void 0),ai(this,"selectedTiles",void 0),ai(this,"emptyTiles",void 0),ai(this,"_traversalStack",void 0),ai(this,"_emptyTraversalStack",void 0),ai(this,"_frameNumber",void 0),this.options={...hi,...t},this._traversalStack=new oi,this._emptyTraversalStack=new oi,this._frameNumber=null,this.root=null,this.selectedTiles={},this.requestedTiles={},this.emptyTiles={}}traverse(t,e,i){this.root=t,this.options={...this.options,...i},this.reset(),this.updateTile(t,e),this._frameNumber=e.frameNumber,this.executeTraversal(t,e)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,e){const i=this._traversalStack;for(t._selectionDepth=1,i.push(t);i.length>0;){const t=i.pop();let s=!1;this.canTraverse(t,e)&&(this.updateChildTiles(t,e),s=this.updateAndPushChildren(t,e,i,t.hasRenderContent?t._selectionDepth+1:t._selectionDepth));const r=t.parent,n=Boolean(!r||r._shouldRefine),o=!s;t.hasRenderContent?t.refine===Ze.ADD?(this.loadTile(t,e),this.selectTile(t,e)):t.refine===Ze.REPLACE&&(this.loadTile(t,e),o&&this.selectTile(t,e)):(this.emptyTiles[t.id]=t,this.loadTile(t,e),o&&this.selectTile(t,e)),this.touchTile(t,e),t._shouldRefine=s&&n}this.options.onTraversalEnd(e)}updateChildTiles(t,e){const i=t.children;for(const t of i)this.updateTile(t,e);return!0}updateAndPushChildren(t,e,i,s){const{loadSiblings:r,skipLevelOfDetail:n}=this.options,o=t.children;o.sort(this.compareDistanceToCamera.bind(this));const a=t.refine===Ze.REPLACE&&t.hasRenderContent&&!n;let h=!1,c=!0;for(const t of o)if(t._selectionDepth=s,t.isVisibleAndInRequestVolume?(i.find(t)&&i.delete(t),i.push(t),h=!0):(a||r)&&(this.loadTile(t,e),this.touchTile(t,e)),a){let i;if(i=!!t._inRequestVolume&&(t.hasRenderContent?t.contentAvailable:this.executeEmptyTraversal(t,e)),c=c&&i,!c)return!1}return h||(c=!1),c}updateTile(t,e){this.updateTileVisibility(t,e)}selectTile(t,e){this.shouldSelectTile(t)&&(t._selectedFrame=e.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,e){this.shouldLoadTile(t)&&(t._requestedFrame=e.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,e){t.tileset._cache.touch(t),t._touchedFrame=e.frameNumber}canTraverse(t,e,i=!1,s=!1){return!!t.hasChildren&&(t.hasTilesetContent?!t.contentExpired:!(!s&&!t.isVisibleAndInRequestVolume)&&this.shouldRefine(t,e,i))}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,e,i){let s=t._screenSpaceError;return i&&(s=t.getScreenSpaceError(e,!0)),s>this.options.maximumScreenSpaceError}updateTileVisibility(t,e){const i=[];if(this.options.viewportTraversersMap)for(const t in this.options.viewportTraversersMap){this.options.viewportTraversersMap[t]===e.viewport.id&&i.push(t)}else i.push(e.viewport.id);t.updateVisibility(e,i)}compareDistanceToCamera(t,e){return t._distanceToCamera-e._distanceToCamera}anyChildrenVisible(t,e){let i=!1;for(const s of t.children)s.updateVisibility(e),i=i||s.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(t,e){let i=!0;const s=this._emptyTraversalStack;for(s.push(t);s.length>0&&i;){const t=s.pop();this.updateTile(t,e),t.isVisibleAndInRequestVolume||this.loadTile(t,e),this.touchTile(t,e);if(!t.hasRenderContent&&this.canTraverse(t,e,!1,!0)){const e=t.children;for(const t of e)s.find(t)&&s.delete(t),s.push(t)}else t.contentAvailable||(i=!1)}return i}}function ui(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const li=new Y;class di{constructor(t,e,i,s=""){ui(this,"tileset",void 0),ui(this,"header",void 0),ui(this,"id",void 0),ui(this,"url",void 0),ui(this,"parent",void 0),ui(this,"refine",void 0),ui(this,"type",void 0),ui(this,"contentUrl",void 0),ui(this,"lodMetricType",void 0),ui(this,"lodMetricValue",void 0),ui(this,"boundingVolume",void 0),ui(this,"content",void 0),ui(this,"contentState",void 0),ui(this,"gpuMemoryUsageInBytes",void 0),ui(this,"children",void 0),ui(this,"depth",void 0),ui(this,"viewportIds",void 0),ui(this,"transform",void 0),ui(this,"userData",void 0),ui(this,"computedTransform",void 0),ui(this,"hasEmptyContent",void 0),ui(this,"hasTilesetContent",void 0),ui(this,"traverser",void 0),ui(this,"_cacheNode",void 0),ui(this,"_frameNumber",void 0),ui(this,"_lodJudge",void 0),ui(this,"_expireDate",void 0),ui(this,"_expiredContent",void 0),ui(this,"_shouldRefine",void 0),ui(this,"_distanceToCamera",void 0),ui(this,"_centerZDepth",void 0),ui(this,"_screenSpaceError",void 0),ui(this,"_visibilityPlaneMask",void 0),ui(this,"_visible",void 0),ui(this,"_inRequestVolume",void 0),ui(this,"_stackLength",void 0),ui(this,"_selectionDepth",void 0),ui(this,"_touchedFrame",void 0),ui(this,"_visitedFrame",void 0),ui(this,"_selectedFrame",void 0),ui(this,"_requestedFrame",void 0),ui(this,"_priority",void 0),ui(this,"_contentBoundingVolume",void 0),ui(this,"_viewerRequestVolume",void 0),ui(this,"_initialTransform",void 0),this.header=e,this.tileset=t,this.id=s||e.id,this.url=e.url,this.parent=i,this.refine=this._getRefine(e.refine),this.type=e.type,this.contentUrl=e.contentUrl,this.lodMetricType="geometricError",this.lodMetricValue=0,this.boundingVolume=null,this.content=null,this.contentState=Ge.UNLOADED,this.gpuMemoryUsageInBytes=0,this.children=[],this.hasEmptyContent=!1,this.hasTilesetContent=!1,this.depth=0,this.viewportIds=[],this.userData={},this._priority=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._screenSpaceError=0,this._cacheNode=null,this._frameNumber=null,this._cacheNode=null,this.traverser=new ci({}),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._initialTransform=new W,this.transform=new W,this._initializeLodMetric(e),this._initializeTransforms(e),this._initializeBoundingVolumes(e),this._initializeContent(e),this._initializeRenderingState(e),this._lodJudge=null,this._expireDate=null,this._expiredContent=null,Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Ge.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Ge.UNLOADED}get contentExpired(){return this.contentState===Ge.EXPIRED}get contentFailed(){return this.contentState===Ge.FAILED}getScreenSpaceError(t,e){switch(this.tileset.type){case Ke.I3S:return ni(this,t);case Ke.TILES3D:return function(t,e,i){const s=t.tileset,r=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,n=i?r:t.lodMetricValue;if(0===n)return 0;const o=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:h}=e,{viewDistanceScale:c}=s.options;let u=n*a*(c||1)/(o*h);return u-=si(s,o),u}(this,t,e);default:throw new Error("Unsupported tileset type")}}_getPriority(){const t=this.tileset._traverser,{skipLevelOfDetail:e}=t.options,i=this.refine===Ze.ADD||e;if(i&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===Ge.UNLOADED)return-1;const s=this.parent,r=s&&(!i||0===this._screenSpaceError||s.hasTilesetContent)?s._screenSpaceError:this._screenSpaceError,n=t.root?t.root._screenSpaceError:0;return Math.max(n-r,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Ge.LOADING;const t=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!t)return this.contentState=Ge.UNLOADED,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),i=this.tileset.loader,s={...this.tileset.loadOptions,[i.id]:{...this.tileset.loadOptions[i.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(i.id)}};return this.content=await Object(Be.load)(e,i,s),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Ge.READY,this._onContentLoaded(),!0}catch(t){throw this.contentState=Ge.FAILED,t}finally{t.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Ge.UNLOADED,!0}updateVisibility(t,e){if(this._frameNumber===t.frameNumber)return;const i=this.parent,s=i?i._visibilityPlaneMask:Ve.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const t=i?i.computedTransform:this.tileset.modelMatrix;this._updateTransform(t)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,s),this._visible=this._visibilityPlaneMask!==Ve.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=e}visibility(t,e){const{cullingVolume:i}=t,{boundingVolume:s}=this;return i.computeVisibilityWithPlaneMask(s,e)}contentVisibility(){return!0}distanceToTile(t){const e=this.boundingVolume;return Math.sqrt(Math.max(e.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){const e=this.boundingVolume;return li.subVectors(e.center,t.position),t.direction.dot(li)}insideViewerRequestVolume(t){const e=this._viewerRequestVolume;return!e||e.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(null!=this._expireDate&&this.contentReady&&!this.hasEmptyContent){const t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=Ge.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new W(t.transform):new W;const e=this.parent,i=this.tileset,s=e&&e.computedTransform?e.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new W(s).multiplyRight(this.transform);const r=e&&e._initialTransform?e._initialTransform.clone():new W;this._initialTransform=new W(r).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Ge.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=Ve.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(t){return t||this.parent&&this.parent.refine||Ze.REPLACE}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()&&(this.hasTilesetContent=!0)}_updateBoundingVolume(t){this.boundingVolume=ei(t.boundingVolume,this.computedTransform,this.boundingVolume);const e=t.content;e&&(e.boundingVolume&&(this._contentBoundingVolume=ei(e.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=ei(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new W){const e=t.clone().multiplyRight(this.transform);!e.equals(this.computedTransform)&&(this.computedTransform=e,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){switch(t){case"i3s":return{...this.tileset.options.i3s,tile:this.header,tileset:this.tileset.tileset,isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return{assetGltfUpAxis:(e=this.tileset.tileset).asset&&e.asset.gltfUpAxis||"Y"}}var e}}class mi extends ci{compareDistanceToCamera(t,e){return 0===e._distanceToCamera&&0===t._distanceToCamera?e._centerZDepth-t._centerZDepth:e._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,e){if(super.updateTileVisibility(t,e),!t.isVisibleAndInRequestVolume)return;const i=t.children.length>0;if(t.hasTilesetContent&&i){const i=t.children[0];return this.updateTileVisibility(i,e),void(t._visible=i._visible)}if(this.meetsScreenSpaceErrorEarly(t,e))return void(t._visible=!1);const s=t.refine===Ze.REPLACE,r=t._optimChildrenWithinParent===He;s&&r&&i&&!this.anyChildrenVisible(t,e)&&(t._visible=!1)}meetsScreenSpaceErrorEarly(t,e){const{parent:i}=t;return!(!i||i.hasTilesetContent||i.refine!==Ze.ADD)&&!this.shouldRefine(t,e,!0)}}const pi="REQUESTED",fi="COMPLETED",gi="ERROR";class Ti{constructor(){var t,e,i;i=void 0,(e="_statusMap")in(t=this)?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,this._statusMap={}}add(t,e,i,s){this._statusMap[e]||(this._statusMap[e]={request:t,callback:i,key:e,frameState:s,status:pi},t().then(t=>{this._statusMap[e].status=fi,this._statusMap[e].callback(t,s)}).catch(t=>{this._statusMap[e].status=gi,i(t)}))}update(t,e){this._statusMap[t]&&(this._statusMap[t].frameState=e)}find(t){return this._statusMap[t]}}class _i extends ci{constructor(t){var e,i,s;super(t),s=void 0,(i="_tileManager")in(e=this)?Object.defineProperty(e,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[i]=s,this._tileManager=new Ti}shouldRefine(t,e){return t._lodJudge=ri(t,e),"DIG"===t._lodJudge}updateChildTiles(t,e){const i=t.header.children||[],s=t.children,r=t.tileset;for(const n of i){const i=`${n.id}-${e.viewport.id}`,o=s&&s.find(t=>t.id===i);if(o)o&&this.updateTile(o,e);else{let s=()=>this._loadTile(n.id,r);this._tileManager.find(i)?this._tileManager.update(i,e):(r.tileset.nodePages&&(s=()=>r.tileset.nodePagesTile.formTileFromNodePages(n.id)),this._tileManager.add(s,i,e=>this._onTileLoad(e,t,i),e))}}return!1}async _loadTile(t,e){const{loader:i}=e,s=e.getTileUrl(`${e.url}/nodes/${t}`),r={...e.loadOptions,i3s:{...e.loadOptions.i3s,isTileHeader:!0,loadContent:!1}};return await Object(Be.load)(s,i,r)}_onTileLoad(t,e,i){const s=new di(e.tileset,t,e,i);e.children.push(s);const r=this._tileManager.find(s.id).frameState;this.updateTile(s,r),this._frameNumber===r.frameNumber&&this.executeTraversal(s,r)}}function yi(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const vi={description:"",ellipsoid:yt.WGS84,modelMatrix:new W,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}};class wi{constructor(t,e){yi(this,"options",void 0),yi(this,"loadOptions",void 0),yi(this,"type",void 0),yi(this,"tileset",void 0),yi(this,"loader",void 0),yi(this,"url",void 0),yi(this,"basePath",void 0),yi(this,"modelMatrix",void 0),yi(this,"ellipsoid",void 0),yi(this,"lodMetricType",void 0),yi(this,"lodMetricValue",void 0),yi(this,"refine",void 0),yi(this,"root",void 0),yi(this,"roots",void 0),yi(this,"asset",void 0),yi(this,"description",void 0),yi(this,"properties",void 0),yi(this,"extras",void 0),yi(this,"attributions",void 0),yi(this,"credits",void 0),yi(this,"stats",void 0),yi(this,"traverseCounter",void 0),yi(this,"geometricError",void 0),yi(this,"selectedTiles",void 0),yi(this,"cartographicCenter",void 0),yi(this,"cartesianCenter",void 0),yi(this,"zoom",void 0),yi(this,"boundingVolume",void 0),yi(this,"gpuMemoryUsageInBytes",void 0),yi(this,"dynamicScreenSpaceErrorComputedDensity",void 0),yi(this,"_traverser",void 0),yi(this,"_cache",void 0),yi(this,"_requestScheduler",void 0),yi(this,"_frameNumber",void 0),yi(this,"_queryParamsString",void 0),yi(this,"_queryParams",void 0),yi(this,"_extensionsUsed",void 0),yi(this,"_tiles",void 0),yi(this,"_pendingCount",void 0),yi(this,"lastUpdatedVieports",void 0),yi(this,"_requestedTiles",void 0),yi(this,"_emptyTiles",void 0),yi(this,"frameStateData",void 0),yi(this,"maximumMemoryUsage",void 0),Mt(t),this.options={...vi,...e},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||s.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this.root=null,this.roots={},this.cartographicCenter=null,this.cartesianCenter=null,this.zoom=1,this.boundingVolume=null,this.traverseCounter=0,this.geometricError=0,this._traverser=this._initializeTraverser(),this._cache=new Lt,this._requestScheduler=new Ot({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this._frameNumber=0,this._pendingCount=0,this._tiles={},this.selectedTiles=[],this._emptyTiles=[],this._requestedTiles=[],this.frameStateData={},this.lastUpdatedVieports=null,this._queryParams={},this._queryParamsString="",this.maximumMemoryUsage=this.options.maximumMemoryUsage||32,this.gpuMemoryUsageInBytes=0,this.stats=new Et({id:this.url}),this._initializeStats(),this._extensionsUsed=void 0,this.dynamicScreenSpaceErrorComputedDensity=0,this.extras=null,this.asset={},this.credits={},this.description=this.options.description||"",this._initializeTileSet(t)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return this._queryParamsString||(this._queryParamsString=function(t){const e=[];for(const i of Object.keys(t))e.push(`${i}=${t[i]}`);switch(e.length){case 0:return"";case 1:return"?"+e[0];default:return"?"+e.join("&")}}(this._queryParams)),this._queryParamsString}setProps(t){this.options={...this.options,...t}}setOptions(t){this.options={...this.options,...t}}getTileUrl(t){return t.startsWith("data:")?t:`${t}${this.queryParams}`}hasExtension(t){return Boolean(this._extensionsUsed&&this._extensionsUsed.indexOf(t)>-1)}update(t){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t instanceof Array||(t=[t]),this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const e=[];for(const i of t){const t=i.id;this._needTraverse(t)?e.push(t):this.traverseCounter--}for(const i of t){const t=i.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!e.includes(t))continue;const s=je(i,this._frameNumber);this._traverser.traverse(this.roots[t],s,this.options)}}_needTraverse(t){let e=t;return this.options.viewportTraversersMap&&(e=this.options.viewportTraversersMap[t]),e===t}_onTraversalEnd(t){const e=t.viewport.id;this.frameStateData[e]||(this.frameStateData[e]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const i=this.frameStateData[e],s=Object.values(this._traverser.selectedTiles);i.selectedTiles=s,i._requestedTiles=Object.values(this._traverser.requestedTiles),i._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,this.traverseCounter>0||this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const t in this.frameStateData){const e=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(e.selectedTiles),this._requestedTiles=this._requestedTiles.concat(e._requestedTiles),this._emptyTiles=this._emptyTiles.concat(e._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,e){if(t.length!==e.length)return!0;const i=new Set(t.map(t=>t.id)),s=new Set(e.map(t=>t.id));let r=t.filter(t=>!s.has(t.id)).length>0;return r=r||e.filter(t=>!i.has(t.id)).length>0,r}_loadTiles(){for(const t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,e)=>t._unloadTile(e))}_updateStats(){let t=0,e=0;for(const i of this.selectedTiles)i.contentAvailable&&i.content&&(t++,i.content.pointCount&&(e+=i.content.pointCount));this.stats.get("Tiles In View").count=this.selectedTiles.length,this.stats.get("Tiles To Render").count=t,this.stats.get("Points").count=e}_initializeTileSet(t){this.root=this._initializeTileHeaders(t,null),this.type===Ke.TILES3D&&this._initializeCesiumTileset(t),this.type===Ke.I3S&&this._initializeI3STileset(),this._calculateViewProps()}_calculateViewProps(){const t=this.root;Mt(t);const{center:e}=t.boundingVolume;if(!e)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new Y,void(this.zoom=1);this.cartographicCenter=yt.WGS84.cartesianToCartographic(e,new Y),this.cartesianCenter=e,this.zoom=We(t.boundingVolume)}_initializeStats(){this.stats.get("Tiles In Tileset(s)"),this.stats.get("Tiles Loading"),this.stats.get("Tiles In Memory"),this.stats.get("Tiles In View"),this.stats.get("Tiles To Render"),this.stats.get("Tiles Loaded"),this.stats.get("Tiles Unloaded"),this.stats.get("Failed Tile Loads"),this.stats.get("Points","memory"),this.stats.get("Tile Memory Use","memory")}_initializeTileHeaders(t,e){const i=new di(this,t.root,e);if(e&&(e.children.push(i),i.depth=e.depth+1),this.type===Ke.TILES3D){const t=[];for(t.push(i);t.length>0;){const e=t.pop();this.stats.get("Tiles In Tileset(s)").incrementCount();const i=e.header.children||[];for(const s of i){const i=new di(this,s,e);e.children.push(i),i.depth=e.depth+1,t.push(i)}}}return i}_initializeTraverser(){let t;switch(this.type){case Ke.TILES3D:t=mi;break;case Ke.I3S:t=_i;break;default:t=ci}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let e;try{this._onStartTileLoading(),e=await t.loadContent()}catch(e){this._onTileLoadError(t,e)}finally{this._onEndTileLoading(),this._onTileLoad(t,e)}}_onTileLoadError(t,e){this.stats.get("Failed Tile Loads").incrementCount();const i=e.message||e.toString(),s=t.url;console.error(`A 3D tile failed to load: ${t.url} ${i}`),this.options.onTileError(t,i,s)}_onTileLoad(t,e){e&&(t&&t.content&&Pt(t,t.content),this._addTileToCache(t),this.options.onTileLoad(t))}_onStartTileLoading(){this._pendingCount++,this.stats.get("Tiles Loading").incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get("Tiles Loading").decrementCount()}_addTileToCache(t){this._cache.add(this,t,e=>e._updateCacheStats(t))}_updateCacheStats(t){this.stats.get("Tiles Loaded").incrementCount(),this.stats.get("Tiles In Memory").incrementCount(),this.gpuMemoryUsageInBytes+=t.content.byteLength||0,this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.content&&t.content.byteLength||0,this.stats.get("Tiles In Memory").decrementCount(),this.stats.get("Tiles Unloaded").incrementCount(),this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){const t=[];for(this.root&&t.push(this.root);t.length>0;){const e=t.pop();for(const i of e.children)t.push(i);this._destroyTile(e)}this.root=null}_destroySubtree(t){const e=t,i=[];for(i.push(e);i.length>0;){t=i.pop();for(const e of t.children)i.push(e);t!==e&&this._destroyTile(t)}e.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeCesiumTileset(t){if(this.asset=t.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version 0.0 or 1.0.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed,this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}}])}));
2
- //# sourceMappingURL=dist.min.js.map