@loaders.gl/tiles 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (201) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/constants.d.ts +6 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +29 -26
  5. package/dist/dist.min.js +1994 -1035
  6. package/dist/es5/bundle.js +6 -0
  7. package/dist/es5/bundle.js.map +1 -0
  8. package/dist/es5/constants.js +44 -0
  9. package/dist/es5/constants.js.map +1 -0
  10. package/dist/es5/index.js +93 -0
  11. package/dist/es5/index.js.map +1 -0
  12. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +70 -0
  13. package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  14. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +45 -0
  15. package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  16. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +84 -0
  17. package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  18. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +143 -0
  19. package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  20. package/dist/es5/tileset/helpers/3d-tiles-options.js +12 -0
  21. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -0
  22. package/dist/es5/tileset/helpers/bounding-volume.js +176 -0
  23. package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -0
  24. package/dist/es5/tileset/helpers/frame-state.js +129 -0
  25. package/dist/es5/tileset/helpers/frame-state.js.map +1 -0
  26. package/dist/es5/tileset/helpers/i3s-lod.js +60 -0
  27. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -0
  28. package/dist/es5/tileset/helpers/tiles-3d-lod.js +103 -0
  29. package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -0
  30. package/dist/es5/tileset/helpers/transform-utils.js +50 -0
  31. package/dist/es5/tileset/helpers/transform-utils.js.map +1 -0
  32. package/dist/es5/tileset/helpers/zoom.js +63 -0
  33. package/dist/es5/tileset/helpers/zoom.js.map +1 -0
  34. package/dist/es5/tileset/tile-3d.js +536 -0
  35. package/dist/es5/tileset/tile-3d.js.map +1 -0
  36. package/dist/es5/tileset/tileset-3d.js +855 -0
  37. package/dist/es5/tileset/tileset-3d.js.map +1 -0
  38. package/dist/es5/tileset/tileset-cache.js +82 -0
  39. package/dist/es5/tileset/tileset-cache.js.map +1 -0
  40. package/dist/es5/tileset/tileset-traverser.js +321 -0
  41. package/dist/es5/tileset/tileset-traverser.js.map +1 -0
  42. package/dist/es5/types.js +2 -0
  43. package/dist/es5/types.js.map +1 -0
  44. package/dist/es5/utils/doubly-linked-list-node.js +21 -0
  45. package/dist/es5/utils/doubly-linked-list-node.js.map +1 -0
  46. package/dist/es5/utils/doubly-linked-list.js +88 -0
  47. package/dist/es5/utils/doubly-linked-list.js.map +1 -0
  48. package/dist/es5/utils/managed-array.js +126 -0
  49. package/dist/es5/utils/managed-array.js.map +1 -0
  50. package/dist/esm/bundle.js +4 -0
  51. package/dist/esm/bundle.js.map +1 -0
  52. package/dist/esm/constants.js +32 -0
  53. package/dist/esm/constants.js.map +1 -0
  54. package/dist/esm/index.js +10 -0
  55. package/dist/esm/index.js.map +1 -0
  56. package/dist/{tileset/traversers → esm/tileset/format-3d-tiles}/tileset-3d-traverser.js +2 -13
  57. package/dist/esm/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
  58. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js +26 -0
  59. package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
  60. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js +79 -0
  61. package/dist/esm/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
  62. package/dist/{tileset/traversers → esm/tileset/format-i3s}/i3s-tileset-traverser.js +14 -26
  63. package/dist/esm/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
  64. package/dist/esm/tileset/helpers/3d-tiles-options.js +6 -0
  65. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -0
  66. package/dist/esm/tileset/helpers/bounding-volume.js +155 -0
  67. package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -0
  68. package/dist/esm/tileset/helpers/frame-state.js +109 -0
  69. package/dist/esm/tileset/helpers/frame-state.js.map +1 -0
  70. package/dist/esm/tileset/helpers/i3s-lod.js +53 -0
  71. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -0
  72. package/dist/esm/tileset/helpers/tiles-3d-lod.js +100 -0
  73. package/dist/{tileset → esm/tileset}/helpers/tiles-3d-lod.js.map +1 -1
  74. package/dist/esm/tileset/helpers/transform-utils.js +50 -0
  75. package/dist/esm/tileset/helpers/transform-utils.js.map +1 -0
  76. package/dist/esm/tileset/helpers/zoom.js +55 -0
  77. package/dist/esm/tileset/helpers/zoom.js.map +1 -0
  78. package/dist/esm/tileset/tile-3d.js +414 -0
  79. package/dist/esm/tileset/tile-3d.js.map +1 -0
  80. package/dist/esm/tileset/tileset-3d.js +606 -0
  81. package/dist/esm/tileset/tileset-3d.js.map +1 -0
  82. package/dist/esm/tileset/tileset-cache.js +57 -0
  83. package/dist/esm/tileset/tileset-cache.js.map +1 -0
  84. package/dist/{tileset/traversers → esm/tileset}/tileset-traverser.js +29 -88
  85. package/dist/esm/tileset/tileset-traverser.js.map +1 -0
  86. package/dist/esm/types.js +2 -0
  87. package/dist/esm/types.js.map +1 -0
  88. package/dist/esm/utils/doubly-linked-list-node.js +12 -0
  89. package/dist/esm/utils/doubly-linked-list-node.js.map +1 -0
  90. package/dist/esm/utils/doubly-linked-list.js +65 -0
  91. package/dist/esm/utils/doubly-linked-list.js.map +1 -0
  92. package/dist/esm/utils/managed-array.js +87 -0
  93. package/dist/esm/utils/managed-array.js.map +1 -0
  94. package/dist/index.d.ts +4 -4
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +26 -10
  97. package/dist/tileset/{traversers → format-3d-tiles}/tileset-3d-traverser.d.ts +2 -2
  98. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -0
  99. package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js +54 -0
  100. package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts +27 -0
  101. package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts.map +1 -0
  102. package/dist/tileset/format-i3s/i3s-pending-tiles-register.js +47 -0
  103. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts +34 -0
  104. package/dist/tileset/format-i3s/i3s-tile-manager.d.ts.map +1 -0
  105. package/dist/tileset/format-i3s/i3s-tile-manager.js +80 -0
  106. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts +25 -0
  107. package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts.map +1 -0
  108. package/dist/tileset/format-i3s/i3s-tileset-traverser.js +92 -0
  109. package/dist/tileset/helpers/3d-tiles-options.d.ts +3 -2
  110. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -1
  111. package/dist/tileset/helpers/3d-tiles-options.js +8 -5
  112. package/dist/tileset/helpers/bounding-volume.d.ts +10 -0
  113. package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -1
  114. package/dist/tileset/helpers/bounding-volume.js +274 -69
  115. package/dist/tileset/helpers/frame-state.d.ts +16 -5
  116. package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
  117. package/dist/tileset/helpers/frame-state.js +131 -49
  118. package/dist/tileset/helpers/i3s-lod.d.ts +1 -1
  119. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -1
  120. package/dist/tileset/helpers/i3s-lod.js +82 -64
  121. package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -1
  122. package/dist/tileset/helpers/tiles-3d-lod.js +112 -100
  123. package/dist/tileset/helpers/transform-utils.d.ts.map +1 -1
  124. package/dist/tileset/helpers/transform-utils.js +51 -56
  125. package/dist/tileset/helpers/zoom.d.ts +41 -2
  126. package/dist/tileset/helpers/zoom.d.ts.map +1 -1
  127. package/dist/tileset/helpers/zoom.js +83 -30
  128. package/dist/tileset/tile-3d.d.ts +82 -35
  129. package/dist/tileset/tile-3d.d.ts.map +1 -1
  130. package/dist/tileset/tile-3d.js +607 -534
  131. package/dist/tileset/tileset-3d.d.ts +140 -48
  132. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  133. package/dist/tileset/tileset-3d.js +693 -652
  134. package/dist/tileset/tileset-cache.d.ts +6 -5
  135. package/dist/tileset/tileset-cache.d.ts.map +1 -1
  136. package/dist/tileset/tileset-cache.js +66 -73
  137. package/dist/tileset/tileset-traverser.d.ts +57 -0
  138. package/dist/tileset/tileset-traverser.d.ts.map +1 -0
  139. package/dist/tileset/tileset-traverser.js +300 -0
  140. package/dist/types.d.ts +34 -0
  141. package/dist/types.d.ts.map +1 -0
  142. package/dist/types.js +2 -0
  143. package/dist/utils/doubly-linked-list-node.d.ts +1 -2
  144. package/dist/utils/doubly-linked-list-node.d.ts.map +1 -1
  145. package/dist/utils/doubly-linked-list-node.js +17 -15
  146. package/dist/utils/doubly-linked-list.d.ts +2 -3
  147. package/dist/utils/doubly-linked-list.d.ts.map +1 -1
  148. package/dist/utils/doubly-linked-list.js +91 -75
  149. package/dist/utils/managed-array.d.ts +1 -1
  150. package/dist/utils/managed-array.d.ts.map +1 -1
  151. package/dist/utils/managed-array.js +144 -109
  152. package/package.json +11 -8
  153. package/src/constants.ts +20 -0
  154. package/src/index.ts +6 -4
  155. package/src/tileset/{traversers → format-3d-tiles}/tileset-3d-traverser.ts +4 -2
  156. package/src/tileset/format-i3s/i3s-pending-tiles-register.ts +44 -0
  157. package/src/tileset/format-i3s/i3s-tile-manager.ts +101 -0
  158. package/src/tileset/{traversers → format-i3s}/i3s-tileset-traverser.ts +25 -12
  159. package/src/tileset/helpers/3d-tiles-options.ts +3 -1
  160. package/src/tileset/helpers/bounding-volume.ts +136 -0
  161. package/src/tileset/helpers/frame-state.ts +102 -18
  162. package/src/tileset/helpers/i3s-lod.ts +24 -21
  163. package/src/tileset/helpers/tiles-3d-lod.ts +2 -0
  164. package/src/tileset/helpers/transform-utils.ts +2 -0
  165. package/src/tileset/helpers/zoom.ts +84 -9
  166. package/src/tileset/tile-3d.ts +137 -123
  167. package/src/tileset/tileset-3d.ts +378 -251
  168. package/src/tileset/tileset-cache.ts +24 -17
  169. package/src/tileset/{traversers/tileset-traverser.ts → tileset-traverser.ts} +71 -72
  170. package/src/types.ts +36 -0
  171. package/src/utils/doubly-linked-list-node.ts +3 -2
  172. package/src/utils/doubly-linked-list.ts +2 -3
  173. package/src/utils/managed-array.ts +1 -1
  174. package/dist/bundle.js.map +0 -1
  175. package/dist/constants.js.map +0 -1
  176. package/dist/index.js.map +0 -1
  177. package/dist/tileset/helpers/3d-tiles-options.js.map +0 -1
  178. package/dist/tileset/helpers/bounding-volume.js.map +0 -1
  179. package/dist/tileset/helpers/frame-state.js.map +0 -1
  180. package/dist/tileset/helpers/i3s-lod.js.map +0 -1
  181. package/dist/tileset/helpers/transform-utils.js.map +0 -1
  182. package/dist/tileset/helpers/zoom.js.map +0 -1
  183. package/dist/tileset/tile-3d.js.map +0 -1
  184. package/dist/tileset/tileset-3d.js.map +0 -1
  185. package/dist/tileset/tileset-cache.js.map +0 -1
  186. package/dist/tileset/traversers/i3s-tile-manager.d.ts +0 -8
  187. package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +0 -1
  188. package/dist/tileset/traversers/i3s-tile-manager.js +0 -45
  189. package/dist/tileset/traversers/i3s-tile-manager.js.map +0 -1
  190. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +0 -18
  191. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +0 -1
  192. package/dist/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
  193. package/dist/tileset/traversers/tileset-3d-traverser.d.ts.map +0 -1
  194. package/dist/tileset/traversers/tileset-3d-traverser.js.map +0 -1
  195. package/dist/tileset/traversers/tileset-traverser.d.ts +0 -52
  196. package/dist/tileset/traversers/tileset-traverser.d.ts.map +0 -1
  197. package/dist/tileset/traversers/tileset-traverser.js.map +0 -1
  198. package/dist/utils/doubly-linked-list-node.js.map +0 -1
  199. package/dist/utils/doubly-linked-list.js.map +0 -1
  200. package/dist/utils/managed-array.js.map +0 -1
  201. package/src/tileset/traversers/i3s-tile-manager.ts +0 -39
package/dist/dist.min.js CHANGED
@@ -25,11 +25,8 @@
25
25
  });
26
26
 
27
27
  // ../../node_modules/@math.gl/core/dist/esm/lib/common.js
28
- function round(value) {
29
- return Math.round(value / config.EPSILON) * config.EPSILON;
30
- }
31
28
  function formatValue(value, {
32
- precision = config.precision || 4
29
+ precision = config.precision
33
30
  } = {}) {
34
31
  value = round(value);
35
32
  return "".concat(parseFloat(value.toPrecision(precision)));
@@ -37,19 +34,6 @@
37
34
  function isArray(value) {
38
35
  return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
39
36
  }
40
- function duplicateArray(array) {
41
- return array.clone ? array.clone() : new Array(array.length);
42
- }
43
- function map(value, func, result) {
44
- if (isArray(value)) {
45
- result = result || duplicateArray(value);
46
- for (let i = 0; i < result.length && i < value.length; ++i) {
47
- result[i] = func(value[i], i, result);
48
- }
49
- return result;
50
- }
51
- return func(value);
52
- }
53
37
  function toRadians(degrees2) {
54
38
  return radians(degrees2);
55
39
  }
@@ -88,7 +72,7 @@
88
72
  if (b && b.equals) {
89
73
  return b.equals(a);
90
74
  }
91
- if (Number.isFinite(a) && Number.isFinite(b)) {
75
+ if (typeof a === "number" && typeof b === "number") {
92
76
  return Math.abs(a - b) <= config.EPSILON * Math.max(1, Math.abs(a), Math.abs(b));
93
77
  }
94
78
  return false;
@@ -96,18 +80,36 @@
96
80
  config.EPSILON = oldEpsilon;
97
81
  }
98
82
  }
83
+ function round(value) {
84
+ return Math.round(value / config.EPSILON) * config.EPSILON;
85
+ }
86
+ function duplicateArray(array) {
87
+ return array.clone ? array.clone() : new Array(array.length);
88
+ }
89
+ function map(value, func, result) {
90
+ if (isArray(value)) {
91
+ const array = value;
92
+ result = result || duplicateArray(array);
93
+ for (let i = 0; i < result.length && i < array.length; ++i) {
94
+ result[i] = func(value[i], i, result);
95
+ }
96
+ return result;
97
+ }
98
+ return func(value);
99
+ }
99
100
  var RADIANS_TO_DEGREES, DEGREES_TO_RADIANS, config;
100
101
  var init_common = __esm({
101
102
  "../../node_modules/@math.gl/core/dist/esm/lib/common.js"() {
102
103
  RADIANS_TO_DEGREES = 1 / Math.PI * 180;
103
104
  DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
104
- config = {};
105
- config.EPSILON = 1e-12;
106
- config.debug = false;
107
- config.precision = 4;
108
- config.printTypes = false;
109
- config.printDegrees = false;
110
- config.printRowMajor = true;
105
+ config = {
106
+ EPSILON: 1e-12,
107
+ debug: false,
108
+ precision: 4,
109
+ printTypes: false,
110
+ printDegrees: false,
111
+ printRowMajor: true
112
+ };
111
113
  }
112
114
  });
113
115
 
@@ -137,24 +139,25 @@
137
139
  var init_math_array = __esm({
138
140
  "../../node_modules/@math.gl/core/dist/esm/classes/base/math-array.js"() {
139
141
  init_common();
140
- init_assert();
141
142
  MathArray = class extends _extendableBuiltin(Array) {
142
- get ELEMENTS() {
143
- assert(false);
144
- return 0;
145
- }
146
143
  clone() {
147
144
  return new this.constructor().copy(this);
148
145
  }
149
- from(arrayOrObject) {
150
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
151
- }
152
146
  fromArray(array, offset = 0) {
153
147
  for (let i = 0; i < this.ELEMENTS; ++i) {
154
148
  this[i] = array[i + offset];
155
149
  }
156
150
  return this.check();
157
151
  }
152
+ toArray(targetArray = [], offset = 0) {
153
+ for (let i = 0; i < this.ELEMENTS; ++i) {
154
+ targetArray[offset + i] = this[i];
155
+ }
156
+ return targetArray;
157
+ }
158
+ from(arrayOrObject) {
159
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
160
+ }
158
161
  to(arrayOrObject) {
159
162
  if (arrayOrObject === this) {
160
163
  return this;
@@ -164,12 +167,6 @@
164
167
  toTarget(target) {
165
168
  return target ? this.to(target) : this;
166
169
  }
167
- toArray(array = [], offset = 0) {
168
- for (let i = 0; i < this.ELEMENTS; ++i) {
169
- array[offset + i] = this[i];
170
- }
171
- return array;
172
- }
173
170
  toFloat32Array() {
174
171
  return new Float32Array(this);
175
172
  }
@@ -213,9 +210,7 @@
213
210
  }
214
211
  lerp(a, b, t) {
215
212
  if (t === void 0) {
216
- t = b;
217
- b = a;
218
- a = this;
213
+ return this.lerp(this, a, b);
219
214
  }
220
215
  for (let i = 0; i < this.ELEMENTS; ++i) {
221
216
  const ai = a[i];
@@ -258,14 +253,36 @@
258
253
  return this.check();
259
254
  }
260
255
  scale(scale5) {
261
- if (Array.isArray(scale5)) {
262
- return this.multiply(scale5);
256
+ if (typeof scale5 === "number") {
257
+ for (let i = 0; i < this.ELEMENTS; ++i) {
258
+ this[i] *= scale5;
259
+ }
260
+ } else {
261
+ for (let i = 0; i < this.ELEMENTS && i < scale5.length; ++i) {
262
+ this[i] *= scale5[i];
263
+ }
263
264
  }
265
+ return this.check();
266
+ }
267
+ multiplyByScalar(scalar) {
264
268
  for (let i = 0; i < this.ELEMENTS; ++i) {
265
- this[i] *= scale5;
269
+ this[i] *= scalar;
266
270
  }
267
271
  return this.check();
268
272
  }
273
+ check() {
274
+ if (config.debug && !this.validate()) {
275
+ throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
276
+ }
277
+ return this;
278
+ }
279
+ validate() {
280
+ let valid = this.length === this.ELEMENTS;
281
+ for (let i = 0; i < this.ELEMENTS; ++i) {
282
+ valid = valid && Number.isFinite(this[i]);
283
+ }
284
+ return valid;
285
+ }
269
286
  sub(a) {
270
287
  return this.subtract(a);
271
288
  }
@@ -291,7 +308,7 @@
291
308
  return this.check();
292
309
  }
293
310
  divideScalar(a) {
294
- return this.scale(1 / a);
311
+ return this.multiplyByScalar(1 / a);
295
312
  }
296
313
  clampScalar(min, max) {
297
314
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -299,25 +316,9 @@
299
316
  }
300
317
  return this.check();
301
318
  }
302
- multiplyByScalar(scalar) {
303
- return this.scale(scalar);
304
- }
305
319
  get elements() {
306
320
  return this;
307
321
  }
308
- check() {
309
- if (config.debug && !this.validate()) {
310
- throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
311
- }
312
- return this;
313
- }
314
- validate() {
315
- let valid = this.length === this.ELEMENTS;
316
- for (let i = 0; i < this.ELEMENTS; ++i) {
317
- valid = valid && Number.isFinite(this[i]);
318
- }
319
- return valid;
320
- }
321
322
  };
322
323
  }
323
324
  });
@@ -346,17 +347,9 @@
346
347
  }
347
348
  return v;
348
349
  }
349
- function deprecated(method, version) {
350
- if (!map2[method]) {
351
- map2[method] = true;
352
- console.warn("".concat(method, " has been removed in version ").concat(version, ", see upgrade guide for more information"));
353
- }
354
- }
355
- var map2;
356
350
  var init_validators = __esm({
357
351
  "../../node_modules/@math.gl/core/dist/esm/lib/validators.js"() {
358
352
  init_common();
359
- map2 = {};
360
353
  }
361
354
  });
362
355
 
@@ -368,14 +361,6 @@
368
361
  init_validators();
369
362
  init_assert();
370
363
  Vector = class extends MathArray {
371
- get ELEMENTS() {
372
- assert(false);
373
- return 0;
374
- }
375
- copy(vector) {
376
- assert(false);
377
- return this;
378
- }
379
364
  get x() {
380
365
  return this[0];
381
366
  }
@@ -580,6 +565,15 @@
580
565
  out[2] = a[2];
581
566
  return out;
582
567
  }
568
+ function vec4_transformMat2(out, a, m) {
569
+ const x = a[0];
570
+ const y = a[1];
571
+ out[0] = m[0] * x + m[2] * y;
572
+ out[1] = m[1] * x + m[3] * y;
573
+ out[2] = a[2];
574
+ out[3] = a[3];
575
+ return out;
576
+ }
583
577
  function vec4_transformMat3(out, a, m) {
584
578
  const x = a[0];
585
579
  const y = a[1];
@@ -754,7 +748,7 @@
754
748
  });
755
749
 
756
750
  // ../../node_modules/@math.gl/core/dist/esm/classes/vector3.js
757
- var ORIGIN, constants, Vector3;
751
+ var ORIGIN, ZERO, Vector3;
758
752
  var init_vector3 = __esm({
759
753
  "../../node_modules/@math.gl/core/dist/esm/classes/vector3.js"() {
760
754
  init_vector();
@@ -763,10 +757,13 @@
763
757
  init_vec3();
764
758
  init_gl_matrix_extras();
765
759
  ORIGIN = [0, 0, 0];
766
- constants = {};
767
760
  Vector3 = class extends Vector {
768
761
  static get ZERO() {
769
- return constants.ZERO = constants.ZERO || Object.freeze(new Vector3(0, 0, 0, 0));
762
+ if (!ZERO) {
763
+ ZERO = new Vector3(0, 0, 0);
764
+ Object.freeze(ZERO);
765
+ }
766
+ return ZERO;
770
767
  }
771
768
  constructor(x = 0, y = 0, z = 0) {
772
769
  super(-0, -0, -0);
@@ -876,6 +873,113 @@
876
873
  }
877
874
  });
878
875
 
876
+ // ../../node_modules/@math.gl/core/dist/esm/classes/vector4.js
877
+ var ZERO2, Vector4;
878
+ var init_vector4 = __esm({
879
+ "../../node_modules/@math.gl/core/dist/esm/classes/vector4.js"() {
880
+ init_vector();
881
+ init_common();
882
+ init_validators();
883
+ init_vec3();
884
+ init_gl_matrix_extras();
885
+ Vector4 = class extends Vector {
886
+ static get ZERO() {
887
+ if (!ZERO2) {
888
+ ZERO2 = new Vector4(0, 0, 0, 0);
889
+ Object.freeze(ZERO2);
890
+ }
891
+ return ZERO2;
892
+ }
893
+ constructor(x = 0, y = 0, z = 0, w = 0) {
894
+ super(-0, -0, -0, -0);
895
+ if (isArray(x) && arguments.length === 1) {
896
+ this.copy(x);
897
+ } else {
898
+ if (config.debug) {
899
+ checkNumber(x);
900
+ checkNumber(y);
901
+ checkNumber(z);
902
+ checkNumber(w);
903
+ }
904
+ this[0] = x;
905
+ this[1] = y;
906
+ this[2] = z;
907
+ this[3] = w;
908
+ }
909
+ }
910
+ set(x, y, z, w) {
911
+ this[0] = x;
912
+ this[1] = y;
913
+ this[2] = z;
914
+ this[3] = w;
915
+ return this.check();
916
+ }
917
+ copy(array) {
918
+ this[0] = array[0];
919
+ this[1] = array[1];
920
+ this[2] = array[2];
921
+ this[3] = array[3];
922
+ return this.check();
923
+ }
924
+ fromObject(object) {
925
+ if (config.debug) {
926
+ checkNumber(object.x);
927
+ checkNumber(object.y);
928
+ checkNumber(object.z);
929
+ checkNumber(object.w);
930
+ }
931
+ this[0] = object.x;
932
+ this[1] = object.y;
933
+ this[2] = object.z;
934
+ this[3] = object.w;
935
+ return this;
936
+ }
937
+ toObject(object) {
938
+ object.x = this[0];
939
+ object.y = this[1];
940
+ object.z = this[2];
941
+ object.w = this[3];
942
+ return object;
943
+ }
944
+ get ELEMENTS() {
945
+ return 4;
946
+ }
947
+ get z() {
948
+ return this[2];
949
+ }
950
+ set z(value) {
951
+ this[2] = checkNumber(value);
952
+ }
953
+ get w() {
954
+ return this[3];
955
+ }
956
+ set w(value) {
957
+ this[3] = checkNumber(value);
958
+ }
959
+ transform(matrix4) {
960
+ transformMat42(this, this, matrix4);
961
+ return this.check();
962
+ }
963
+ transformByMatrix3(matrix3) {
964
+ vec4_transformMat3(this, this, matrix3);
965
+ return this.check();
966
+ }
967
+ transformByMatrix2(matrix2) {
968
+ vec4_transformMat2(this, this, matrix2);
969
+ return this.check();
970
+ }
971
+ transformByQuaternion(quaternion) {
972
+ transformQuat(this, this, quaternion);
973
+ return this.check();
974
+ }
975
+ applyMatrix4(m) {
976
+ m.transform(this, this);
977
+ return this;
978
+ }
979
+ };
980
+ }
981
+ });
982
+
879
983
  // ../../node_modules/@math.gl/core/dist/esm/classes/base/matrix.js
880
984
  var Matrix;
881
985
  var init_matrix = __esm({
@@ -883,16 +987,7 @@
883
987
  init_math_array();
884
988
  init_validators();
885
989
  init_common();
886
- init_assert();
887
990
  Matrix = class extends MathArray {
888
- get ELEMENTS() {
889
- assert(false);
890
- return 0;
891
- }
892
- get RANK() {
893
- assert(false);
894
- return 0;
895
- }
896
991
  toString() {
897
992
  let string = "[";
898
993
  if (config.printRowMajor) {
@@ -1095,7 +1190,21 @@
1095
1190
  });
1096
1191
 
1097
1192
  // ../../node_modules/@math.gl/core/dist/esm/classes/matrix3.js
1098
- var IDENTITY, ZERO, INDICES, constants2, Matrix3;
1193
+ function getZeroMatrix() {
1194
+ if (!ZERO_MATRIX3) {
1195
+ ZERO_MATRIX3 = new Matrix3([0, 0, 0, 0, 0, 0, 0, 0, 0]);
1196
+ Object.freeze(ZERO_MATRIX3);
1197
+ }
1198
+ return ZERO_MATRIX3;
1199
+ }
1200
+ function getIdentityMatrix() {
1201
+ if (!IDENTITY_MATRIX3) {
1202
+ IDENTITY_MATRIX3 = new Matrix3();
1203
+ Object.freeze(IDENTITY_MATRIX3);
1204
+ }
1205
+ return IDENTITY_MATRIX3;
1206
+ }
1207
+ var INDICES, IDENTITY_MATRIX, Matrix3, ZERO_MATRIX3, IDENTITY_MATRIX3;
1099
1208
  var init_matrix3 = __esm({
1100
1209
  "../../node_modules/@math.gl/core/dist/esm/classes/matrix3.js"() {
1101
1210
  init_matrix();
@@ -1104,28 +1213,24 @@
1104
1213
  init_mat3();
1105
1214
  init_vec2();
1106
1215
  init_vec3();
1107
- IDENTITY = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
1108
- ZERO = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0]);
1109
- INDICES = Object.freeze({
1110
- COL0ROW0: 0,
1111
- COL0ROW1: 1,
1112
- COL0ROW2: 2,
1113
- COL1ROW0: 3,
1114
- COL1ROW1: 4,
1115
- COL1ROW2: 5,
1116
- COL2ROW0: 6,
1117
- COL2ROW1: 7,
1118
- COL2ROW2: 8
1119
- });
1120
- constants2 = {};
1216
+ (function(INDICES3) {
1217
+ INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
1218
+ INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
1219
+ INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
1220
+ INDICES3[INDICES3["COL1ROW0"] = 3] = "COL1ROW0";
1221
+ INDICES3[INDICES3["COL1ROW1"] = 4] = "COL1ROW1";
1222
+ INDICES3[INDICES3["COL1ROW2"] = 5] = "COL1ROW2";
1223
+ INDICES3[INDICES3["COL2ROW0"] = 6] = "COL2ROW0";
1224
+ INDICES3[INDICES3["COL2ROW1"] = 7] = "COL2ROW1";
1225
+ INDICES3[INDICES3["COL2ROW2"] = 8] = "COL2ROW2";
1226
+ })(INDICES || (INDICES = {}));
1227
+ IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]);
1121
1228
  Matrix3 = class extends Matrix {
1122
1229
  static get IDENTITY() {
1123
- constants2.IDENTITY = constants2.IDENTITY || Object.freeze(new Matrix3(IDENTITY));
1124
- return constants2.IDENTITY;
1230
+ return getIdentityMatrix();
1125
1231
  }
1126
1232
  static get ZERO() {
1127
- constants2.ZERO = constants2.ZERO || Object.freeze(new Matrix3(ZERO));
1128
- return constants2.ZERO;
1233
+ return getZeroMatrix();
1129
1234
  }
1130
1235
  get ELEMENTS() {
1131
1236
  return 9;
@@ -1136,10 +1241,12 @@
1136
1241
  get INDICES() {
1137
1242
  return INDICES;
1138
1243
  }
1139
- constructor(array) {
1244
+ constructor(array, ...args) {
1140
1245
  super(-0, -0, -0, -0, -0, -0, -0, -0, -0);
1141
1246
  if (arguments.length === 1 && Array.isArray(array)) {
1142
1247
  this.copy(array);
1248
+ } else if (args.length > 0) {
1249
+ this.copy([array, ...args]);
1143
1250
  } else {
1144
1251
  this.identity();
1145
1252
  }
@@ -1156,6 +1263,16 @@
1156
1263
  this[8] = array[8];
1157
1264
  return this.check();
1158
1265
  }
1266
+ identity() {
1267
+ return this.copy(IDENTITY_MATRIX);
1268
+ }
1269
+ fromObject(object) {
1270
+ return this.check();
1271
+ }
1272
+ fromQuaternion(q) {
1273
+ fromQuat(this, q);
1274
+ return this.check();
1275
+ }
1159
1276
  set(m00, m10, m20, m01, m11, m21, m02, m12, m22) {
1160
1277
  this[0] = m00;
1161
1278
  this[1] = m10;
@@ -1183,13 +1300,6 @@
1183
1300
  determinant() {
1184
1301
  return determinant(this);
1185
1302
  }
1186
- identity() {
1187
- return this.copy(IDENTITY);
1188
- }
1189
- fromQuaternion(q) {
1190
- fromQuat(this, q);
1191
- return this.check();
1192
- }
1193
1303
  transpose() {
1194
1304
  transpose(this, this);
1195
1305
  return this.check();
@@ -1214,7 +1324,7 @@
1214
1324
  if (Array.isArray(factor)) {
1215
1325
  scale(this, this, factor);
1216
1326
  } else {
1217
- scale(this, this, [factor, factor, factor]);
1327
+ scale(this, this, [factor, factor]);
1218
1328
  }
1219
1329
  return this.check();
1220
1330
  }
@@ -1223,32 +1333,30 @@
1223
1333
  return this.check();
1224
1334
  }
1225
1335
  transform(vector, result) {
1336
+ let out;
1226
1337
  switch (vector.length) {
1227
1338
  case 2:
1228
- result = transformMat3(result || [-0, -0], vector, this);
1339
+ out = transformMat3(result || [-0, -0], vector, this);
1229
1340
  break;
1230
1341
  case 3:
1231
- result = transformMat32(result || [-0, -0, -0], vector, this);
1342
+ out = transformMat32(result || [-0, -0, -0], vector, this);
1232
1343
  break;
1233
1344
  case 4:
1234
- result = vec4_transformMat3(result || [-0, -0, -0, -0], vector, this);
1345
+ out = vec4_transformMat3(result || [-0, -0, -0, -0], vector, this);
1235
1346
  break;
1236
1347
  default:
1237
1348
  throw new Error("Illegal vector");
1238
1349
  }
1239
- checkVector(result, vector.length);
1240
- return result;
1350
+ checkVector(out, vector.length);
1351
+ return out;
1241
1352
  }
1242
1353
  transformVector(vector, result) {
1243
- deprecated("Matrix3.transformVector");
1244
1354
  return this.transform(vector, result);
1245
1355
  }
1246
1356
  transformVector2(vector, result) {
1247
- deprecated("Matrix3.transformVector");
1248
1357
  return this.transform(vector, result);
1249
1358
  }
1250
1359
  transformVector3(vector, result) {
1251
- deprecated("Matrix3.transformVector");
1252
1360
  return this.transform(vector, result);
1253
1361
  }
1254
1362
  };
@@ -1692,7 +1800,7 @@
1692
1800
  out[15] = 0;
1693
1801
  return out;
1694
1802
  }
1695
- function perspective(out, fovy, aspect, near, far) {
1803
+ function perspectiveNO(out, fovy, aspect, near, far) {
1696
1804
  var f = 1 / Math.tan(fovy / 2), nf;
1697
1805
  out[0] = f / aspect;
1698
1806
  out[1] = 0;
@@ -1718,7 +1826,7 @@
1718
1826
  }
1719
1827
  return out;
1720
1828
  }
1721
- function ortho(out, left, right, bottom, top, near, far) {
1829
+ function orthoNO(out, left, right, bottom, top, near, far) {
1722
1830
  var lr = 1 / (left - right);
1723
1831
  var bt = 1 / (bottom - top);
1724
1832
  var nf = 1 / (near - far);
@@ -1807,9 +1915,12 @@
1807
1915
  out[15] = 1;
1808
1916
  return out;
1809
1917
  }
1918
+ var perspective, ortho;
1810
1919
  var init_mat4 = __esm({
1811
1920
  "../../node_modules/gl-matrix/esm/mat4.js"() {
1812
1921
  init_common2();
1922
+ perspective = perspectiveNO;
1923
+ ortho = orthoNO;
1813
1924
  }
1814
1925
  });
1815
1926
 
@@ -1939,48 +2050,90 @@
1939
2050
  });
1940
2051
 
1941
2052
  // ../../node_modules/@math.gl/core/dist/esm/classes/matrix4.js
1942
- var IDENTITY2, ZERO2, INDICES2, constants3, Matrix4;
2053
+ function getZeroMatrix2() {
2054
+ if (!ZERO3) {
2055
+ ZERO3 = new Matrix4([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
2056
+ Object.freeze(ZERO3);
2057
+ }
2058
+ return ZERO3;
2059
+ }
2060
+ function getIdentityMatrix2() {
2061
+ if (!IDENTITY) {
2062
+ IDENTITY = new Matrix4();
2063
+ Object.freeze(IDENTITY);
2064
+ }
2065
+ return IDENTITY;
2066
+ }
2067
+ function checkRadians(possiblyDegrees) {
2068
+ if (possiblyDegrees > Math.PI * 2) {
2069
+ throw Error("expected radians");
2070
+ }
2071
+ }
2072
+ function computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
2073
+ const column0Row0 = 2 * near / (right - left);
2074
+ const column1Row1 = 2 * near / (top - bottom);
2075
+ const column2Row0 = (right + left) / (right - left);
2076
+ const column2Row1 = (top + bottom) / (top - bottom);
2077
+ const column2Row2 = -1;
2078
+ const column2Row3 = -1;
2079
+ const column3Row2 = -2 * near;
2080
+ result[0] = column0Row0;
2081
+ result[1] = 0;
2082
+ result[2] = 0;
2083
+ result[3] = 0;
2084
+ result[4] = 0;
2085
+ result[5] = column1Row1;
2086
+ result[6] = 0;
2087
+ result[7] = 0;
2088
+ result[8] = column2Row0;
2089
+ result[9] = column2Row1;
2090
+ result[10] = column2Row2;
2091
+ result[11] = column2Row3;
2092
+ result[12] = 0;
2093
+ result[13] = 0;
2094
+ result[14] = column3Row2;
2095
+ result[15] = 0;
2096
+ return result;
2097
+ }
2098
+ var INDICES2, DEFAULT_FOVY, DEFAULT_ASPECT, DEFAULT_NEAR, DEFAULT_FAR, IDENTITY_MATRIX2, Matrix4, ZERO3, IDENTITY;
1943
2099
  var init_matrix4 = __esm({
1944
2100
  "../../node_modules/@math.gl/core/dist/esm/classes/matrix4.js"() {
1945
- init_validators();
1946
2101
  init_matrix();
2102
+ init_validators();
1947
2103
  init_gl_matrix_extras();
1948
2104
  init_mat4();
1949
2105
  init_vec2();
1950
2106
  init_vec3();
1951
2107
  init_vec4();
1952
- IDENTITY2 = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
1953
- ZERO2 = Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
1954
- INDICES2 = Object.freeze({
1955
- COL0ROW0: 0,
1956
- COL0ROW1: 1,
1957
- COL0ROW2: 2,
1958
- COL0ROW3: 3,
1959
- COL1ROW0: 4,
1960
- COL1ROW1: 5,
1961
- COL1ROW2: 6,
1962
- COL1ROW3: 7,
1963
- COL2ROW0: 8,
1964
- COL2ROW1: 9,
1965
- COL2ROW2: 10,
1966
- COL2ROW3: 11,
1967
- COL3ROW0: 12,
1968
- COL3ROW1: 13,
1969
- COL3ROW2: 14,
1970
- COL3ROW3: 15
1971
- });
1972
- constants3 = {};
2108
+ (function(INDICES3) {
2109
+ INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
2110
+ INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
2111
+ INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
2112
+ INDICES3[INDICES3["COL0ROW3"] = 3] = "COL0ROW3";
2113
+ INDICES3[INDICES3["COL1ROW0"] = 4] = "COL1ROW0";
2114
+ INDICES3[INDICES3["COL1ROW1"] = 5] = "COL1ROW1";
2115
+ INDICES3[INDICES3["COL1ROW2"] = 6] = "COL1ROW2";
2116
+ INDICES3[INDICES3["COL1ROW3"] = 7] = "COL1ROW3";
2117
+ INDICES3[INDICES3["COL2ROW0"] = 8] = "COL2ROW0";
2118
+ INDICES3[INDICES3["COL2ROW1"] = 9] = "COL2ROW1";
2119
+ INDICES3[INDICES3["COL2ROW2"] = 10] = "COL2ROW2";
2120
+ INDICES3[INDICES3["COL2ROW3"] = 11] = "COL2ROW3";
2121
+ INDICES3[INDICES3["COL3ROW0"] = 12] = "COL3ROW0";
2122
+ INDICES3[INDICES3["COL3ROW1"] = 13] = "COL3ROW1";
2123
+ INDICES3[INDICES3["COL3ROW2"] = 14] = "COL3ROW2";
2124
+ INDICES3[INDICES3["COL3ROW3"] = 15] = "COL3ROW3";
2125
+ })(INDICES2 || (INDICES2 = {}));
2126
+ DEFAULT_FOVY = 45 * Math.PI / 180;
2127
+ DEFAULT_ASPECT = 1;
2128
+ DEFAULT_NEAR = 0.1;
2129
+ DEFAULT_FAR = 500;
2130
+ IDENTITY_MATRIX2 = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
1973
2131
  Matrix4 = class extends Matrix {
1974
2132
  static get IDENTITY() {
1975
- constants3.IDENTITY = constants3.IDENTITY || Object.freeze(new Matrix4(IDENTITY2));
1976
- return constants3.IDENTITY;
2133
+ return getIdentityMatrix2();
1977
2134
  }
1978
2135
  static get ZERO() {
1979
- constants3.ZERO = constants3.ZERO || Object.freeze(new Matrix4(ZERO2));
1980
- return constants3.ZERO;
1981
- }
1982
- get INDICES() {
1983
- return INDICES2;
2136
+ return getZeroMatrix2();
1984
2137
  }
1985
2138
  get ELEMENTS() {
1986
2139
  return 16;
@@ -1988,6 +2141,9 @@
1988
2141
  get RANK() {
1989
2142
  return 4;
1990
2143
  }
2144
+ get INDICES() {
2145
+ return INDICES2;
2146
+ }
1991
2147
  constructor(array) {
1992
2148
  super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
1993
2149
  if (arguments.length === 1 && Array.isArray(array)) {
@@ -2073,91 +2229,65 @@
2073
2229
  return result;
2074
2230
  }
2075
2231
  identity() {
2076
- return this.copy(IDENTITY2);
2232
+ return this.copy(IDENTITY_MATRIX2);
2077
2233
  }
2078
- fromQuaternion(q) {
2079
- fromQuat2(this, q);
2234
+ fromObject(object) {
2080
2235
  return this.check();
2081
2236
  }
2082
- frustum({
2083
- left,
2084
- right,
2085
- bottom,
2086
- top,
2087
- near,
2088
- far
2089
- }) {
2237
+ fromQuaternion(quaternion) {
2238
+ fromQuat2(this, quaternion);
2239
+ return this.check();
2240
+ }
2241
+ frustum(view) {
2242
+ const {
2243
+ left,
2244
+ right,
2245
+ bottom,
2246
+ top,
2247
+ near = DEFAULT_NEAR,
2248
+ far = DEFAULT_FAR
2249
+ } = view;
2090
2250
  if (far === Infinity) {
2091
- Matrix4._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
2251
+ computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
2092
2252
  } else {
2093
2253
  frustum(this, left, right, bottom, top, near, far);
2094
2254
  }
2095
2255
  return this.check();
2096
2256
  }
2097
- static _computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) {
2098
- const column0Row0 = 2 * near / (right - left);
2099
- const column1Row1 = 2 * near / (top - bottom);
2100
- const column2Row0 = (right + left) / (right - left);
2101
- const column2Row1 = (top + bottom) / (top - bottom);
2102
- const column2Row2 = -1;
2103
- const column2Row3 = -1;
2104
- const column3Row2 = -2 * near;
2105
- result[0] = column0Row0;
2106
- result[1] = 0;
2107
- result[2] = 0;
2108
- result[3] = 0;
2109
- result[4] = 0;
2110
- result[5] = column1Row1;
2111
- result[6] = 0;
2112
- result[7] = 0;
2113
- result[8] = column2Row0;
2114
- result[9] = column2Row1;
2115
- result[10] = column2Row2;
2116
- result[11] = column2Row3;
2117
- result[12] = 0;
2118
- result[13] = 0;
2119
- result[14] = column3Row2;
2120
- result[15] = 0;
2121
- return result;
2122
- }
2123
- lookAt(eye, center, up) {
2124
- if (arguments.length === 1) {
2125
- ({
2126
- eye,
2127
- center,
2128
- up
2129
- } = eye);
2130
- }
2131
- center = center || [0, 0, 0];
2132
- up = up || [0, 1, 0];
2257
+ lookAt(view) {
2258
+ const {
2259
+ eye,
2260
+ center = [0, 0, 0],
2261
+ up = [0, 1, 0]
2262
+ } = view;
2133
2263
  lookAt(this, eye, center, up);
2134
2264
  return this.check();
2135
2265
  }
2136
- ortho({
2137
- left,
2138
- right,
2139
- bottom,
2140
- top,
2141
- near = 0.1,
2142
- far = 500
2143
- }) {
2266
+ ortho(view) {
2267
+ const {
2268
+ left,
2269
+ right,
2270
+ bottom,
2271
+ top,
2272
+ near = DEFAULT_NEAR,
2273
+ far = DEFAULT_FAR
2274
+ } = view;
2144
2275
  ortho(this, left, right, bottom, top, near, far);
2145
2276
  return this.check();
2146
2277
  }
2147
- orthographic({
2148
- fovy = 45 * Math.PI / 180,
2149
- aspect = 1,
2150
- focalDistance = 1,
2151
- near = 0.1,
2152
- far = 500
2153
- }) {
2154
- if (fovy > Math.PI * 2) {
2155
- throw Error("radians");
2156
- }
2278
+ orthographic(view) {
2279
+ const {
2280
+ fovy = DEFAULT_FOVY,
2281
+ aspect = DEFAULT_ASPECT,
2282
+ focalDistance = 1,
2283
+ near = DEFAULT_NEAR,
2284
+ far = DEFAULT_FAR
2285
+ } = view;
2286
+ checkRadians(fovy);
2157
2287
  const halfY = fovy / 2;
2158
2288
  const top = focalDistance * Math.tan(halfY);
2159
2289
  const right = top * aspect;
2160
- return new Matrix4().ortho({
2290
+ return this.ortho({
2161
2291
  left: -right,
2162
2292
  right,
2163
2293
  bottom: -top,
@@ -2166,17 +2296,14 @@
2166
2296
  far
2167
2297
  });
2168
2298
  }
2169
- perspective({
2170
- fovy = void 0,
2171
- fov = 45 * Math.PI / 180,
2172
- aspect = 1,
2173
- near = 0.1,
2174
- far = 500
2175
- } = {}) {
2176
- fovy = fovy || fov;
2177
- if (fovy > Math.PI * 2) {
2178
- throw Error("radians");
2179
- }
2299
+ perspective(view) {
2300
+ const {
2301
+ fovy = 45 * Math.PI / 180,
2302
+ aspect = 1,
2303
+ near = 0.1,
2304
+ far = 500
2305
+ } = view;
2306
+ checkRadians(fovy);
2180
2307
  perspective(this, fovy, aspect, near, far);
2181
2308
  return this.check();
2182
2309
  }
@@ -2195,8 +2322,10 @@
2195
2322
  result[2] = this[14];
2196
2323
  return result;
2197
2324
  }
2198
- getRotation(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
2199
- const scale5 = this.getScale(scaleResult || [-0, -0, -0]);
2325
+ getRotation(result, scaleResult) {
2326
+ result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
2327
+ scaleResult = scaleResult || [-0, -0, -0];
2328
+ const scale5 = this.getScale(scaleResult);
2200
2329
  const inverseScale0 = 1 / scale5[0];
2201
2330
  const inverseScale1 = 1 / scale5[1];
2202
2331
  const inverseScale2 = 1 / scale5[2];
@@ -2218,8 +2347,10 @@
2218
2347
  result[15] = 1;
2219
2348
  return result;
2220
2349
  }
2221
- getRotationMatrix3(result = [-0, -0, -0, -0, -0, -0, -0, -0, -0], scaleResult = null) {
2222
- const scale5 = this.getScale(scaleResult || [-0, -0, -0]);
2350
+ getRotationMatrix3(result, scaleResult) {
2351
+ result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
2352
+ scaleResult = scaleResult || [-0, -0, -0];
2353
+ const scale5 = this.getScale(scaleResult);
2223
2354
  const inverseScale0 = 1 / scale5[0];
2224
2355
  const inverseScale1 = 1 / scale5[1];
2225
2356
  const inverseScale2 = 1 / scale5[2];
@@ -2262,23 +2393,19 @@
2262
2393
  rotateZ2(this, this, radians2);
2263
2394
  return this.check();
2264
2395
  }
2265
- rotateXYZ([rx, ry, rz]) {
2266
- return this.rotateX(rx).rotateY(ry).rotateZ(rz);
2396
+ rotateXYZ(angleXYZ) {
2397
+ return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
2267
2398
  }
2268
2399
  rotateAxis(radians2, axis) {
2269
2400
  rotate2(this, this, radians2, axis);
2270
2401
  return this.check();
2271
2402
  }
2272
2403
  scale(factor) {
2273
- if (Array.isArray(factor)) {
2274
- scale2(this, this, factor);
2275
- } else {
2276
- scale2(this, this, [factor, factor, factor]);
2277
- }
2404
+ scale2(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
2278
2405
  return this.check();
2279
2406
  }
2280
- translate(vec) {
2281
- translate2(this, this, vec);
2407
+ translate(vector) {
2408
+ translate2(this, this, vector);
2282
2409
  return this.check();
2283
2410
  }
2284
2411
  transform(vector, result) {
@@ -2293,51 +2420,50 @@
2293
2420
  const {
2294
2421
  length: length4
2295
2422
  } = vector;
2423
+ let out;
2296
2424
  switch (length4) {
2297
2425
  case 2:
2298
- result = transformMat4(result || [-0, -0], vector, this);
2426
+ out = transformMat4(result || [-0, -0], vector, this);
2299
2427
  break;
2300
2428
  case 3:
2301
- result = transformMat42(result || [-0, -0, -0], vector, this);
2429
+ out = transformMat42(result || [-0, -0, -0], vector, this);
2302
2430
  break;
2303
2431
  default:
2304
2432
  throw new Error("Illegal vector");
2305
2433
  }
2306
- checkVector(result, vector.length);
2307
- return result;
2434
+ checkVector(out, vector.length);
2435
+ return out;
2308
2436
  }
2309
2437
  transformAsVector(vector, result) {
2438
+ let out;
2310
2439
  switch (vector.length) {
2311
2440
  case 2:
2312
- result = vec2_transformMat4AsVector(result || [-0, -0], vector, this);
2441
+ out = vec2_transformMat4AsVector(result || [-0, -0], vector, this);
2313
2442
  break;
2314
2443
  case 3:
2315
- result = vec3_transformMat4AsVector(result || [-0, -0, -0], vector, this);
2444
+ out = vec3_transformMat4AsVector(result || [-0, -0, -0], vector, this);
2316
2445
  break;
2317
2446
  default:
2318
2447
  throw new Error("Illegal vector");
2319
2448
  }
2320
- checkVector(result, vector.length);
2321
- return result;
2322
- }
2323
- makeRotationX(radians2) {
2324
- return this.identity().rotateX(radians2);
2325
- }
2326
- makeTranslation(x, y, z) {
2327
- return this.identity().translate([x, y, z]);
2449
+ checkVector(out, vector.length);
2450
+ return out;
2328
2451
  }
2329
2452
  transformPoint(vector, result) {
2330
- deprecated("Matrix4.transformPoint", "3.0");
2331
2453
  return this.transformAsPoint(vector, result);
2332
2454
  }
2333
2455
  transformVector(vector, result) {
2334
- deprecated("Matrix4.transformVector", "3.0");
2335
2456
  return this.transformAsPoint(vector, result);
2336
2457
  }
2337
2458
  transformDirection(vector, result) {
2338
- deprecated("Matrix4.transformDirection", "3.0");
2339
2459
  return this.transformAsVector(vector, result);
2340
2460
  }
2461
+ makeRotationX(radians2) {
2462
+ return this.identity().rotateX(radians2);
2463
+ }
2464
+ makeTranslation(x, y, z) {
2465
+ return this.identity().translate([x, y, z]);
2466
+ }
2341
2467
  };
2342
2468
  }
2343
2469
  });
@@ -2564,7 +2690,7 @@
2564
2690
  "../../node_modules/@math.gl/core/dist/esm/classes/quaternion.js"() {
2565
2691
  init_math_array();
2566
2692
  init_validators();
2567
- init_assert();
2693
+ init_vector4();
2568
2694
  init_quat();
2569
2695
  init_vec4();
2570
2696
  IDENTITY_QUATERNION = [0, 0, 0, 1];
@@ -2591,18 +2717,25 @@
2591
2717
  this[3] = w;
2592
2718
  return this.check();
2593
2719
  }
2594
- fromMatrix3(m) {
2595
- fromMat3(this, m);
2720
+ fromObject(object) {
2721
+ this[0] = object.x;
2722
+ this[1] = object.y;
2723
+ this[2] = object.z;
2724
+ this[3] = object.w;
2596
2725
  return this.check();
2597
2726
  }
2598
- identity() {
2599
- identity2(this);
2727
+ fromMatrix3(m) {
2728
+ fromMat3(this, m);
2600
2729
  return this.check();
2601
2730
  }
2602
2731
  fromAxisRotation(axis, rad) {
2603
2732
  setAxisAngle(this, axis, rad);
2604
2733
  return this.check();
2605
2734
  }
2735
+ identity() {
2736
+ identity2(this);
2737
+ return this.check();
2738
+ }
2606
2739
  setAxisAngle(axis, rad) {
2607
2740
  return this.fromAxisRotation(axis, rad);
2608
2741
  }
@@ -2639,20 +2772,14 @@
2639
2772
  lengthSquared() {
2640
2773
  return squaredLength2(this);
2641
2774
  }
2642
- dot(a, b) {
2643
- if (b !== void 0) {
2644
- throw new Error("Quaternion.dot only takes one argument");
2645
- }
2775
+ dot(a) {
2646
2776
  return dot3(this, a);
2647
2777
  }
2648
2778
  rotationTo(vectorA, vectorB) {
2649
2779
  rotationTo(this, vectorA, vectorB);
2650
2780
  return this.check();
2651
2781
  }
2652
- add(a, b) {
2653
- if (b !== void 0) {
2654
- throw new Error("Quaternion.add only takes one argument");
2655
- }
2782
+ add(a) {
2656
2783
  add2(this, this, a);
2657
2784
  return this.check();
2658
2785
  }
@@ -2669,16 +2796,17 @@
2669
2796
  return this.check();
2670
2797
  }
2671
2798
  lerp(a, b, t) {
2799
+ if (t === void 0) {
2800
+ return this.lerp(this, a, b);
2801
+ }
2672
2802
  lerp2(this, a, b, t);
2673
2803
  return this.check();
2674
2804
  }
2675
- multiplyRight(a, b) {
2676
- assert(!b);
2805
+ multiplyRight(a) {
2677
2806
  multiply3(this, this, a);
2678
2807
  return this.check();
2679
2808
  }
2680
- multiplyLeft(a, b) {
2681
- assert(!b);
2809
+ multiplyLeft(a) {
2682
2810
  multiply3(this, a, this);
2683
2811
  return this.check();
2684
2812
  }
@@ -2710,25 +2838,32 @@
2710
2838
  scale4(this, this, b);
2711
2839
  return this.check();
2712
2840
  }
2713
- slerp(start, target, ratio) {
2841
+ slerp(arg0, arg1, arg2) {
2842
+ let start;
2843
+ let target;
2844
+ let ratio;
2714
2845
  switch (arguments.length) {
2715
2846
  case 1:
2716
2847
  ({
2717
2848
  start = IDENTITY_QUATERNION,
2718
2849
  target,
2719
2850
  ratio
2720
- } = arguments[0]);
2851
+ } = arg0);
2721
2852
  break;
2722
2853
  case 2:
2723
- [target, ratio] = arguments;
2724
2854
  start = this;
2855
+ target = arg0;
2856
+ ratio = arg1;
2725
2857
  break;
2726
2858
  default:
2859
+ start = arg0;
2860
+ target = arg1;
2861
+ ratio = arg2;
2727
2862
  }
2728
2863
  slerp(this, start, target, ratio);
2729
2864
  return this.check();
2730
2865
  }
2731
- transformVector4(vector, result = vector) {
2866
+ transformVector4(vector, result = new Vector4()) {
2732
2867
  transformQuat2(result, vector, this);
2733
2868
  return checkVector(result, 4);
2734
2869
  }
@@ -2738,16 +2873,82 @@
2738
2873
  setFromAxisAngle(axis, rad) {
2739
2874
  return this.setAxisAngle(axis, rad);
2740
2875
  }
2741
- premultiply(a, b) {
2742
- return this.multiplyLeft(a, b);
2876
+ premultiply(a) {
2877
+ return this.multiplyLeft(a);
2743
2878
  }
2744
- multiply(a, b) {
2745
- return this.multiplyRight(a, b);
2879
+ multiply(a) {
2880
+ return this.multiplyRight(a);
2746
2881
  }
2747
2882
  };
2748
2883
  }
2749
2884
  });
2750
2885
 
2886
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
2887
+ function _typeof(obj) {
2888
+ "@babel/helpers - typeof";
2889
+ return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
2890
+ return typeof obj2;
2891
+ } : function(obj2) {
2892
+ return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
2893
+ }, _typeof(obj);
2894
+ }
2895
+ var init_typeof = __esm({
2896
+ "../../node_modules/@babel/runtime/helpers/esm/typeof.js"() {
2897
+ }
2898
+ });
2899
+
2900
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
2901
+ function _toPrimitive(input, hint) {
2902
+ if (_typeof(input) !== "object" || input === null)
2903
+ return input;
2904
+ var prim = input[Symbol.toPrimitive];
2905
+ if (prim !== void 0) {
2906
+ var res = prim.call(input, hint || "default");
2907
+ if (_typeof(res) !== "object")
2908
+ return res;
2909
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2910
+ }
2911
+ return (hint === "string" ? String : Number)(input);
2912
+ }
2913
+ var init_toPrimitive = __esm({
2914
+ "../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js"() {
2915
+ init_typeof();
2916
+ }
2917
+ });
2918
+
2919
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
2920
+ function _toPropertyKey(arg) {
2921
+ var key = _toPrimitive(arg, "string");
2922
+ return _typeof(key) === "symbol" ? key : String(key);
2923
+ }
2924
+ var init_toPropertyKey = __esm({
2925
+ "../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"() {
2926
+ init_typeof();
2927
+ init_toPrimitive();
2928
+ }
2929
+ });
2930
+
2931
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
2932
+ function _defineProperty(obj, key, value) {
2933
+ key = _toPropertyKey(key);
2934
+ if (key in obj) {
2935
+ Object.defineProperty(obj, key, {
2936
+ value,
2937
+ enumerable: true,
2938
+ configurable: true,
2939
+ writable: true
2940
+ });
2941
+ } else {
2942
+ obj[key] = value;
2943
+ }
2944
+ return obj;
2945
+ }
2946
+ var init_defineProperty = __esm({
2947
+ "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
2948
+ init_toPropertyKey();
2949
+ }
2950
+ });
2951
+
2751
2952
  // ../../node_modules/@math.gl/core/dist/esm/lib/math-utils.js
2752
2953
  var math_utils_default;
2753
2954
  var init_math_utils = __esm({
@@ -2782,26 +2983,15 @@
2782
2983
  });
2783
2984
 
2784
2985
  // ../../node_modules/@math.gl/core/dist/esm/index.js
2785
- var globals, global_;
2786
2986
  var init_esm = __esm({
2787
2987
  "../../node_modules/@math.gl/core/dist/esm/index.js"() {
2788
- init_common();
2789
2988
  init_vector3();
2790
2989
  init_matrix3();
2791
2990
  init_matrix4();
2792
2991
  init_quaternion();
2793
- init_common();
2794
2992
  init_math_utils();
2795
2993
  init_assert();
2796
- globals = {
2797
- self: typeof self !== "undefined" && self,
2798
- window: typeof window !== "undefined" && window,
2799
- global: typeof global !== "undefined" && global
2800
- };
2801
- global_ = globals.global || globals.self || globals.window;
2802
- global_.mathgl = {
2803
- config
2804
- };
2994
+ init_common();
2805
2995
  }
2806
2996
  });
2807
2997
 
@@ -2824,65 +3014,67 @@
2824
3014
  });
2825
3015
 
2826
3016
  // ../../node_modules/@math.gl/geospatial/dist/esm/type-utils.js
2827
- function fromCartographic(cartographic, result, map3 = noop) {
2828
- if (isArray(cartographic)) {
2829
- result[0] = map3(cartographic[0]);
2830
- result[1] = map3(cartographic[1]);
2831
- result[2] = cartographic[2];
2832
- } else if ("longitude" in cartographic) {
2833
- result[0] = map3(cartographic.longitude);
2834
- result[1] = map3(cartographic.latitude);
3017
+ function identity3(x) {
3018
+ return x;
3019
+ }
3020
+ function fromCartographic(cartographic, result = [], map2 = identity3) {
3021
+ if ("longitude" in cartographic) {
3022
+ result[0] = map2(cartographic.longitude);
3023
+ result[1] = map2(cartographic.latitude);
2835
3024
  result[2] = cartographic.height;
2836
- } else {
2837
- result[0] = map3(cartographic.x);
2838
- result[1] = map3(cartographic.y);
3025
+ } else if ("x" in cartographic) {
3026
+ result[0] = map2(cartographic.x);
3027
+ result[1] = map2(cartographic.y);
2839
3028
  result[2] = cartographic.z;
3029
+ } else {
3030
+ result[0] = map2(cartographic[0]);
3031
+ result[1] = map2(cartographic[1]);
3032
+ result[2] = cartographic[2];
2840
3033
  }
2841
3034
  return result;
2842
3035
  }
2843
- function fromCartographicToRadians(cartographic, vector = scratchVector) {
2844
- return fromCartographic(cartographic, vector, config._cartographicRadians ? noop : toRadians);
3036
+ function fromCartographicToRadians(cartographic, vector = []) {
3037
+ return fromCartographic(cartographic, vector, config._cartographicRadians ? identity3 : toRadians);
2845
3038
  }
2846
- function toCartographic(vector, cartographic, map3 = noop) {
2847
- if (isArray(cartographic)) {
2848
- cartographic[0] = map3(vector[0]);
2849
- cartographic[1] = map3(vector[1]);
2850
- cartographic[2] = vector[2];
2851
- } else if ("longitude" in cartographic) {
2852
- cartographic.longitude = map3(vector[0]);
2853
- cartographic.latitude = map3(vector[1]);
3039
+ function toCartographic(vector, cartographic, map2 = identity3) {
3040
+ if ("longitude" in cartographic) {
3041
+ cartographic.longitude = map2(vector[0]);
3042
+ cartographic.latitude = map2(vector[1]);
2854
3043
  cartographic.height = vector[2];
2855
- } else {
2856
- cartographic.x = map3(vector[0]);
2857
- cartographic.y = map3(vector[1]);
3044
+ } else if ("x" in cartographic) {
3045
+ cartographic.x = map2(vector[0]);
3046
+ cartographic.y = map2(vector[1]);
2858
3047
  cartographic.z = vector[2];
3048
+ } else {
3049
+ cartographic[0] = map2(vector[0]);
3050
+ cartographic[1] = map2(vector[1]);
3051
+ cartographic[2] = vector[2];
2859
3052
  }
2860
3053
  return cartographic;
2861
3054
  }
2862
3055
  function toCartographicFromRadians(vector, cartographic) {
2863
- return toCartographic(vector, cartographic, config._cartographicRadians ? noop : toDegrees);
3056
+ return toCartographic(vector, cartographic, config._cartographicRadians ? identity3 : toDegrees);
2864
3057
  }
2865
- var noop, scratchVector;
3058
+ var scratchVector;
2866
3059
  var init_type_utils = __esm({
2867
3060
  "../../node_modules/@math.gl/geospatial/dist/esm/type-utils.js"() {
2868
3061
  init_esm();
2869
3062
  init_constants();
2870
- noop = (x) => x;
2871
3063
  scratchVector = new Vector3();
2872
3064
  }
2873
3065
  });
2874
3066
 
2875
3067
  // ../../node_modules/@math.gl/geospatial/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js
2876
- function scaleToGeodeticSurface(cartesian, ellipsoid, result = new Vector3()) {
3068
+ function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
2877
3069
  const {
2878
3070
  oneOverRadii,
2879
3071
  oneOverRadiiSquared,
2880
3072
  centerToleranceSquared
2881
3073
  } = ellipsoid;
2882
3074
  scratchVector2.from(cartesian);
2883
- const positionX = cartesian.x;
2884
- const positionY = cartesian.y;
2885
- const positionZ = cartesian.z;
3075
+ const positionX = scratchVector2.x;
3076
+ const positionY = scratchVector2.y;
3077
+ const positionZ = scratchVector2.z;
2886
3078
  const oneOverRadiiX = oneOverRadii.x;
2887
3079
  const oneOverRadiiY = oneOverRadii.y;
2888
3080
  const oneOverRadiiZ = oneOverRadii.z;
@@ -2904,7 +3096,7 @@
2904
3096
  const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
2905
3097
  const gradient = scaleToGeodeticSurfaceGradient;
2906
3098
  gradient.set(intersection.x * oneOverRadiiSquaredX * 2, intersection.y * oneOverRadiiSquaredY * 2, intersection.z * oneOverRadiiSquaredZ * 2);
2907
- let lambda = (1 - ratio) * cartesian.len() / (0.5 * gradient.len());
3099
+ let lambda = (1 - ratio) * scratchVector2.len() / (0.5 * gradient.len());
2908
3100
  let correction = 0;
2909
3101
  let xMultiplier;
2910
3102
  let yMultiplier;
@@ -3067,9 +3259,10 @@
3067
3259
  });
3068
3260
 
3069
3261
  // ../../node_modules/@math.gl/geospatial/dist/esm/ellipsoid/ellipsoid.js
3070
- var scratchVector4, scratchNormal, scratchK, scratchPosition, scratchHeight, scratchCartesian, wgs84, Ellipsoid;
3262
+ var scratchVector4, scratchNormal, scratchK, scratchPosition, scratchHeight, scratchCartesian, Ellipsoid;
3071
3263
  var init_ellipsoid = __esm({
3072
3264
  "../../node_modules/@math.gl/geospatial/dist/esm/ellipsoid/ellipsoid.js"() {
3265
+ init_defineProperty();
3073
3266
  init_esm();
3074
3267
  init_vec3();
3075
3268
  init_constants();
@@ -3083,11 +3276,16 @@
3083
3276
  scratchHeight = new Vector3();
3084
3277
  scratchCartesian = new Vector3();
3085
3278
  Ellipsoid = class {
3086
- static get WGS84() {
3087
- wgs84 = wgs84 || new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
3088
- return wgs84;
3089
- }
3090
3279
  constructor(x = 0, y = 0, z = 0) {
3280
+ _defineProperty(this, "radii", void 0);
3281
+ _defineProperty(this, "radiiSquared", void 0);
3282
+ _defineProperty(this, "radiiToTheFourth", void 0);
3283
+ _defineProperty(this, "oneOverRadii", void 0);
3284
+ _defineProperty(this, "oneOverRadiiSquared", void 0);
3285
+ _defineProperty(this, "minimumRadius", void 0);
3286
+ _defineProperty(this, "maximumRadius", void 0);
3287
+ _defineProperty(this, "centerToleranceSquared", math_utils_default.EPSILON1);
3288
+ _defineProperty(this, "squaredXOverSquaredZ", void 0);
3091
3289
  assert(x >= 0);
3092
3290
  assert(y >= 0);
3093
3291
  assert(z >= 0);
@@ -3098,7 +3296,6 @@
3098
3296
  this.oneOverRadiiSquared = new Vector3(x === 0 ? 0 : 1 / (x * x), y === 0 ? 0 : 1 / (y * y), z === 0 ? 0 : 1 / (z * z));
3099
3297
  this.minimumRadius = Math.min(x, y, z);
3100
3298
  this.maximumRadius = Math.max(x, y, z);
3101
- this.centerToleranceSquared = math_utils_default.EPSILON1;
3102
3299
  if (this.radiiSquared.z !== 0) {
3103
3300
  this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;
3104
3301
  }
@@ -3185,6 +3382,7 @@
3185
3382
  return scratchPosition.set(0, 0, z).to(result);
3186
3383
  }
3187
3384
  };
3385
+ _defineProperty(Ellipsoid, "WGS84", new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z));
3188
3386
  }
3189
3387
  });
3190
3388
 
@@ -3196,26 +3394,7 @@
3196
3394
  }
3197
3395
  });
3198
3396
 
3199
- // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
3200
- function _defineProperty(obj, key, value) {
3201
- if (key in obj) {
3202
- Object.defineProperty(obj, key, {
3203
- value,
3204
- enumerable: true,
3205
- configurable: true,
3206
- writable: true
3207
- });
3208
- } else {
3209
- obj[key] = value;
3210
- }
3211
- return obj;
3212
- }
3213
- var init_defineProperty = __esm({
3214
- "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
3215
- }
3216
- });
3217
-
3218
- // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
3397
+ // node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
3219
3398
  function getHiResTimestamp() {
3220
3399
  let timestamp;
3221
3400
  if (typeof window !== "undefined" && window.performance) {
@@ -3229,14 +3408,14 @@
3229
3408
  return timestamp;
3230
3409
  }
3231
3410
  var init_hi_res_timestamp = __esm({
3232
- "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
3411
+ "node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js"() {
3233
3412
  }
3234
3413
  });
3235
3414
 
3236
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
3415
+ // node_modules/@probe.gl/stats/dist/lib/stat.js
3237
3416
  var Stat;
3238
3417
  var init_stat = __esm({
3239
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
3418
+ "node_modules/@probe.gl/stats/dist/lib/stat.js"() {
3240
3419
  init_defineProperty();
3241
3420
  init_hi_res_timestamp();
3242
3421
  Stat = class {
@@ -3244,12 +3423,12 @@
3244
3423
  _defineProperty(this, "name", void 0);
3245
3424
  _defineProperty(this, "type", void 0);
3246
3425
  _defineProperty(this, "sampleSize", 1);
3247
- _defineProperty(this, "time", void 0);
3248
- _defineProperty(this, "count", void 0);
3249
- _defineProperty(this, "samples", void 0);
3250
- _defineProperty(this, "lastTiming", void 0);
3251
- _defineProperty(this, "lastSampleTime", void 0);
3252
- _defineProperty(this, "lastSampleCount", void 0);
3426
+ _defineProperty(this, "time", 0);
3427
+ _defineProperty(this, "count", 0);
3428
+ _defineProperty(this, "samples", 0);
3429
+ _defineProperty(this, "lastTiming", 0);
3430
+ _defineProperty(this, "lastSampleTime", 0);
3431
+ _defineProperty(this, "lastSampleCount", 0);
3253
3432
  _defineProperty(this, "_count", 0);
3254
3433
  _defineProperty(this, "_time", 0);
3255
3434
  _defineProperty(this, "_samples", 0);
@@ -3259,6 +3438,20 @@
3259
3438
  this.type = type;
3260
3439
  this.reset();
3261
3440
  }
3441
+ reset() {
3442
+ this.time = 0;
3443
+ this.count = 0;
3444
+ this.samples = 0;
3445
+ this.lastTiming = 0;
3446
+ this.lastSampleTime = 0;
3447
+ this.lastSampleCount = 0;
3448
+ this._count = 0;
3449
+ this._time = 0;
3450
+ this._samples = 0;
3451
+ this._startTime = 0;
3452
+ this._timerPending = false;
3453
+ return this;
3454
+ }
3262
3455
  setSampleSize(samples) {
3263
3456
  this.sampleSize = samples;
3264
3457
  return this;
@@ -3322,20 +3515,6 @@
3322
3515
  getHz() {
3323
3516
  return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
3324
3517
  }
3325
- reset() {
3326
- this.time = 0;
3327
- this.count = 0;
3328
- this.samples = 0;
3329
- this.lastTiming = 0;
3330
- this.lastSampleTime = 0;
3331
- this.lastSampleCount = 0;
3332
- this._count = 0;
3333
- this._time = 0;
3334
- this._samples = 0;
3335
- this._startTime = 0;
3336
- this._timerPending = false;
3337
- return this;
3338
- }
3339
3518
  _checkSampling() {
3340
3519
  if (this._samples === this.sampleSize) {
3341
3520
  this.lastSampleTime = this._time;
@@ -3352,10 +3531,10 @@
3352
3531
  }
3353
3532
  });
3354
3533
 
3355
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
3534
+ // node_modules/@probe.gl/stats/dist/lib/stats.js
3356
3535
  var Stats;
3357
3536
  var init_stats = __esm({
3358
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
3537
+ "node_modules/@probe.gl/stats/dist/lib/stats.js"() {
3359
3538
  init_defineProperty();
3360
3539
  init_stat();
3361
3540
  Stats = class {
@@ -3378,14 +3557,14 @@
3378
3557
  return Object.keys(this.stats).length;
3379
3558
  }
3380
3559
  reset() {
3381
- for (const key in this.stats) {
3382
- this.stats[key].reset();
3560
+ for (const stat of Object.values(this.stats)) {
3561
+ stat.reset();
3383
3562
  }
3384
3563
  return this;
3385
3564
  }
3386
3565
  forEach(fn) {
3387
- for (const key in this.stats) {
3388
- fn(this.stats[key]);
3566
+ for (const stat of Object.values(this.stats)) {
3567
+ fn(stat);
3389
3568
  }
3390
3569
  }
3391
3570
  getTable() {
@@ -3405,29 +3584,28 @@
3405
3584
  stats.forEach((stat) => this._getOrCreate(stat));
3406
3585
  }
3407
3586
  _getOrCreate(stat) {
3408
- if (!stat || !stat.name) {
3409
- return null;
3410
- }
3411
3587
  const {
3412
3588
  name,
3413
3589
  type
3414
3590
  } = stat;
3415
- if (!this.stats[name]) {
3591
+ let result = this.stats[name];
3592
+ if (!result) {
3416
3593
  if (stat instanceof Stat) {
3417
- this.stats[name] = stat;
3594
+ result = stat;
3418
3595
  } else {
3419
- this.stats[name] = new Stat(name, type);
3596
+ result = new Stat(name, type);
3420
3597
  }
3598
+ this.stats[name] = result;
3421
3599
  }
3422
- return this.stats[name];
3600
+ return result;
3423
3601
  }
3424
3602
  };
3425
3603
  }
3426
3604
  });
3427
3605
 
3428
- // ../../node_modules/@probe.gl/stats/dist/esm/index.js
3429
- var init_esm3 = __esm({
3430
- "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
3606
+ // node_modules/@probe.gl/stats/dist/index.js
3607
+ var init_dist = __esm({
3608
+ "node_modules/@probe.gl/stats/dist/index.js"() {
3431
3609
  init_stats();
3432
3610
  init_stat();
3433
3611
  init_hi_res_timestamp();
@@ -3446,19 +3624,19 @@
3446
3624
  });
3447
3625
 
3448
3626
  // ../loader-utils/src/lib/env-utils/globals.ts
3449
- var globals2, self_, window_, global_2, document_, isBrowser, matches, nodeVersion;
3627
+ var globals, self_, window_, global_, document_, isBrowser, matches, nodeVersion;
3450
3628
  var init_globals = __esm({
3451
3629
  "../loader-utils/src/lib/env-utils/globals.ts"() {
3452
- globals2 = {
3630
+ globals = {
3453
3631
  self: typeof self !== "undefined" && self,
3454
3632
  window: typeof window !== "undefined" && window,
3455
3633
  global: typeof global !== "undefined" && global,
3456
3634
  document: typeof document !== "undefined" && document
3457
3635
  };
3458
- self_ = globals2.self || globals2.window || globals2.global || {};
3459
- window_ = globals2.window || globals2.self || globals2.global || {};
3460
- global_2 = globals2.global || globals2.self || globals2.window || {};
3461
- document_ = globals2.document || {};
3636
+ self_ = globals.self || globals.window || globals.global || {};
3637
+ window_ = globals.window || globals.self || globals.global || {};
3638
+ global_ = globals.global || globals.self || globals.window || {};
3639
+ document_ = globals.document || {};
3462
3640
  isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
3463
3641
  matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
3464
3642
  nodeVersion = matches && parseFloat(matches[1]) || 0;
@@ -3489,19 +3667,19 @@
3489
3667
  });
3490
3668
 
3491
3669
  // ../worker-utils/src/lib/env-utils/globals.ts
3492
- var globals3, self_2, window_2, global_3, document_2, isBrowser2, isMobile, matches2, nodeVersion2;
3670
+ var globals2, self_2, window_2, global_2, document_2, isBrowser2, isMobile, matches2, nodeVersion2;
3493
3671
  var init_globals2 = __esm({
3494
3672
  "../worker-utils/src/lib/env-utils/globals.ts"() {
3495
- globals3 = {
3673
+ globals2 = {
3496
3674
  self: typeof self !== "undefined" && self,
3497
3675
  window: typeof window !== "undefined" && window,
3498
3676
  global: typeof global !== "undefined" && global,
3499
3677
  document: typeof document !== "undefined" && document
3500
3678
  };
3501
- self_2 = globals3.self || globals3.window || globals3.global || {};
3502
- window_2 = globals3.window || globals3.self || globals3.global || {};
3503
- global_3 = globals3.global || globals3.self || globals3.window || {};
3504
- document_2 = globals3.document || {};
3679
+ self_2 = globals2.self || globals2.window || globals2.global || {};
3680
+ window_2 = globals2.window || globals2.self || globals2.global || {};
3681
+ global_2 = globals2.global || globals2.self || globals2.window || {};
3682
+ document_2 = globals2.document || {};
3505
3683
  isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser;
3506
3684
  isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
3507
3685
  matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
@@ -3516,15 +3694,15 @@
3516
3694
  init_assert3();
3517
3695
  WorkerJob = class {
3518
3696
  constructor(jobName, workerThread) {
3519
- this.name = jobName;
3520
- this.workerThread = workerThread;
3521
3697
  this.isRunning = true;
3522
3698
  this._resolve = () => {
3523
3699
  };
3524
3700
  this._reject = () => {
3525
3701
  };
3526
- this.result = new Promise((resolve, reject) => {
3527
- this._resolve = resolve;
3702
+ this.name = jobName;
3703
+ this.workerThread = workerThread;
3704
+ this.result = new Promise((resolve2, reject) => {
3705
+ this._resolve = resolve2;
3528
3706
  this._reject = reject;
3529
3707
  });
3530
3708
  }
@@ -3549,6 +3727,17 @@
3549
3727
  }
3550
3728
  });
3551
3729
 
3730
+ // ../worker-utils/src/lib/node/worker_threads-browser.ts
3731
+ var Worker2;
3732
+ var init_worker_threads_browser = __esm({
3733
+ "../worker-utils/src/lib/node/worker_threads-browser.ts"() {
3734
+ Worker2 = class {
3735
+ terminate() {
3736
+ }
3737
+ };
3738
+ }
3739
+ });
3740
+
3552
3741
  // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
3553
3742
  function getLoadableWorkerURL(props) {
3554
3743
  assert3(props.source && !props.url || !props.source && props.url);
@@ -3636,6 +3825,8 @@
3636
3825
  var NOOP, WorkerThread;
3637
3826
  var init_worker_thread = __esm({
3638
3827
  "../worker-utils/src/lib/worker-farm/worker-thread.ts"() {
3828
+ init_worker_threads_browser();
3829
+ init_globals2();
3639
3830
  init_assert3();
3640
3831
  init_get_loadable_worker_url();
3641
3832
  init_get_transfer_list();
@@ -3652,10 +3843,10 @@
3652
3843
  this.url = url;
3653
3844
  this.onMessage = NOOP;
3654
3845
  this.onError = (error) => console.log(error);
3655
- this.worker = this._createBrowserWorker();
3846
+ this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
3656
3847
  }
3657
3848
  static isSupported() {
3658
- return typeof Worker !== "undefined";
3849
+ return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== "undefined" && !isBrowser2;
3659
3850
  }
3660
3851
  destroy() {
3661
3852
  this.onMessage = NOOP;
@@ -3698,6 +3889,27 @@
3698
3889
  worker.onmessageerror = (event) => console.error(event);
3699
3890
  return worker;
3700
3891
  }
3892
+ _createNodeWorker() {
3893
+ let worker;
3894
+ if (this.url) {
3895
+ const absolute = this.url.includes(":/") || this.url.startsWith("/");
3896
+ const url = absolute ? this.url : `./${this.url}`;
3897
+ worker = new Worker2(url, { eval: false });
3898
+ } else if (this.source) {
3899
+ worker = new Worker2(this.source, { eval: true });
3900
+ } else {
3901
+ throw new Error("no worker");
3902
+ }
3903
+ worker.on("message", (data) => {
3904
+ this.onMessage(data);
3905
+ });
3906
+ worker.on("error", (error) => {
3907
+ this.onError(error);
3908
+ });
3909
+ worker.on("exit", (code) => {
3910
+ });
3911
+ return worker;
3912
+ }
3701
3913
  };
3702
3914
  }
3703
3915
  });
@@ -3726,6 +3938,9 @@
3726
3938
  this.url = props.url;
3727
3939
  this.setProps(props);
3728
3940
  }
3941
+ static isSupported() {
3942
+ return WorkerThread.isSupported();
3943
+ }
3729
3944
  destroy() {
3730
3945
  this.idleQueue.forEach((worker) => worker.destroy());
3731
3946
  this.isDestroyed = true;
@@ -3784,7 +3999,7 @@
3784
3999
  }
3785
4000
  }
3786
4001
  returnWorkerToQueue(worker) {
3787
- const shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
4002
+ const shouldDestroyWorker = !isBrowser2 || this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency();
3788
4003
  if (shouldDestroyWorker) {
3789
4004
  worker.destroy();
3790
4005
  this.count--;
@@ -3822,9 +4037,9 @@
3822
4037
  DEFAULT_PROPS = {
3823
4038
  maxConcurrency: 3,
3824
4039
  maxMobileConcurrency: 1,
4040
+ reuseWorkers: true,
3825
4041
  onDebug: () => {
3826
- },
3827
- reuseWorkers: true
4042
+ }
3828
4043
  };
3829
4044
  WorkerFarm = class {
3830
4045
  constructor(props) {
@@ -3845,6 +4060,7 @@
3845
4060
  for (const workerPool of this.workerPools.values()) {
3846
4061
  workerPool.destroy();
3847
4062
  }
4063
+ this.workerPools = new Map();
3848
4064
  }
3849
4065
  setProps(props) {
3850
4066
  this.props = { ...this.props, ...props };
@@ -3881,7 +4097,7 @@
3881
4097
  // ../worker-utils/src/lib/worker-api/get-worker-url.ts
3882
4098
  function getWorkerURL(worker, options = {}) {
3883
4099
  const workerOptions = options[worker.id] || {};
3884
- const workerFile = `${worker.id}-worker.js`;
4100
+ const workerFile = isBrowser2 ? `${worker.id}-worker.js` : `${worker.id}-worker-node.js`;
3885
4101
  let url = workerOptions.workerUrl;
3886
4102
  if (!url && worker.id === "compression") {
3887
4103
  url = options.workerUrl;
@@ -3904,6 +4120,7 @@
3904
4120
  var init_get_worker_url = __esm({
3905
4121
  "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
3906
4122
  init_assert3();
4123
+ init_globals2();
3907
4124
  NPM_TAG = "beta";
3908
4125
  }
3909
4126
  });
@@ -3928,6 +4145,7 @@
3928
4145
  var init_src = __esm({
3929
4146
  "../worker-utils/src/index.ts"() {
3930
4147
  init_assert3();
4148
+ init_globals2();
3931
4149
  init_worker_farm();
3932
4150
  init_get_worker_url();
3933
4151
  init_validate_worker_version();
@@ -3939,6 +4157,9 @@
3939
4157
  if (!WorkerFarm.isSupported()) {
3940
4158
  return false;
3941
4159
  }
4160
+ if (!isBrowser2 && !options?._nodeWorkers) {
4161
+ return false;
4162
+ }
3942
4163
  return loader.worker && options?.worker;
3943
4164
  }
3944
4165
  async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
@@ -3947,10 +4168,12 @@
3947
4168
  const workerFarm = WorkerFarm.getWorkerFarm(options);
3948
4169
  const workerPool = workerFarm.getWorkerPool({ name, url });
3949
4170
  options = JSON.parse(JSON.stringify(options));
4171
+ context = JSON.parse(JSON.stringify(context || {}));
3950
4172
  const job = await workerPool.startJob("process-on-worker", onMessage.bind(null, parseOnMainThread));
3951
4173
  job.postMessage("process", {
3952
4174
  input: data,
3953
- options
4175
+ options,
4176
+ context
3954
4177
  });
3955
4178
  const result = await job.result;
3956
4179
  return await result.result;
@@ -3980,49 +4203,11 @@
3980
4203
  var init_parse_with_worker = __esm({
3981
4204
  "../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
3982
4205
  init_src();
3983
- }
3984
- });
3985
-
3986
- // ../loader-utils/src/lib/binary-utils/buffer-utils.ts
3987
- function isBuffer(value) {
3988
- return value && typeof value === "object" && value.isBuffer;
3989
- }
3990
- function bufferToArrayBuffer(buffer) {
3991
- if (isBuffer(buffer)) {
3992
- const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
3993
- return typedArray.slice().buffer;
3994
- }
3995
- return buffer;
3996
- }
3997
- var init_buffer_utils = __esm({
3998
- "../loader-utils/src/lib/binary-utils/buffer-utils.ts"() {
4206
+ init_src();
3999
4207
  }
4000
4208
  });
4001
4209
 
4002
4210
  // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
4003
- function toArrayBuffer(data) {
4004
- if (isBuffer(data)) {
4005
- return bufferToArrayBuffer(data);
4006
- }
4007
- if (data instanceof ArrayBuffer) {
4008
- return data;
4009
- }
4010
- if (ArrayBuffer.isView(data)) {
4011
- if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
4012
- return data.buffer;
4013
- }
4014
- return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
4015
- }
4016
- if (typeof data === "string") {
4017
- const text = data;
4018
- const uint8Array = new TextEncoder().encode(text);
4019
- return uint8Array.buffer;
4020
- }
4021
- if (data && typeof data === "object" && data._toArrayBuffer) {
4022
- return data._toArrayBuffer();
4023
- }
4024
- throw new Error("toArrayBuffer");
4025
- }
4026
4211
  function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
4027
4212
  byteLength = byteLength || arrayBuffer1.byteLength;
4028
4213
  if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
@@ -4050,7 +4235,6 @@
4050
4235
  }
4051
4236
  var init_array_buffer_utils = __esm({
4052
4237
  "../loader-utils/src/lib/binary-utils/array-buffer-utils.ts"() {
4053
- init_buffer_utils();
4054
4238
  }
4055
4239
  });
4056
4240
 
@@ -4068,46 +4252,264 @@
4068
4252
  }
4069
4253
  });
4070
4254
 
4071
- // ../loader-utils/src/lib/request-utils/request-scheduler.ts
4072
- var STAT_QUEUED_REQUESTS, STAT_ACTIVE_REQUESTS, STAT_CANCELLED_REQUESTS, STAT_QUEUED_REQUESTS_EVER, STAT_ACTIVE_REQUESTS_EVER, DEFAULT_PROPS2, RequestScheduler;
4073
- var init_request_scheduler = __esm({
4074
- "../loader-utils/src/lib/request-utils/request-scheduler.ts"() {
4075
- init_esm3();
4076
- STAT_QUEUED_REQUESTS = "Queued Requests";
4077
- STAT_ACTIVE_REQUESTS = "Active Requests";
4078
- STAT_CANCELLED_REQUESTS = "Cancelled Requests";
4079
- STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
4080
- STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
4081
- DEFAULT_PROPS2 = {
4082
- id: "request-scheduler",
4083
- throttleRequests: true,
4084
- maxRequests: 6
4085
- };
4086
- RequestScheduler = class {
4087
- constructor(props = {}) {
4088
- this.activeRequestCount = 0;
4089
- this.requestQueue = [];
4090
- this.requestMap = new Map();
4091
- this.deferredUpdate = null;
4092
- this.props = { ...DEFAULT_PROPS2, ...props };
4093
- this.stats = new Stats({ id: this.props.id });
4094
- this.stats.get(STAT_QUEUED_REQUESTS);
4095
- this.stats.get(STAT_ACTIVE_REQUESTS);
4096
- this.stats.get(STAT_CANCELLED_REQUESTS);
4097
- this.stats.get(STAT_QUEUED_REQUESTS_EVER);
4098
- this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
4255
+ // ../loader-utils/node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js
4256
+ function getHiResTimestamp2() {
4257
+ let timestamp;
4258
+ if (typeof window !== "undefined" && window.performance) {
4259
+ timestamp = window.performance.now();
4260
+ } else if (typeof process !== "undefined" && process.hrtime) {
4261
+ const timeParts = process.hrtime();
4262
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
4263
+ } else {
4264
+ timestamp = Date.now();
4265
+ }
4266
+ return timestamp;
4267
+ }
4268
+ var init_hi_res_timestamp2 = __esm({
4269
+ "../loader-utils/node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js"() {
4270
+ }
4271
+ });
4272
+
4273
+ // ../loader-utils/node_modules/@probe.gl/stats/dist/lib/stat.js
4274
+ var Stat2;
4275
+ var init_stat2 = __esm({
4276
+ "../loader-utils/node_modules/@probe.gl/stats/dist/lib/stat.js"() {
4277
+ init_defineProperty();
4278
+ init_hi_res_timestamp2();
4279
+ Stat2 = class {
4280
+ constructor(name, type) {
4281
+ _defineProperty(this, "name", void 0);
4282
+ _defineProperty(this, "type", void 0);
4283
+ _defineProperty(this, "sampleSize", 1);
4284
+ _defineProperty(this, "time", 0);
4285
+ _defineProperty(this, "count", 0);
4286
+ _defineProperty(this, "samples", 0);
4287
+ _defineProperty(this, "lastTiming", 0);
4288
+ _defineProperty(this, "lastSampleTime", 0);
4289
+ _defineProperty(this, "lastSampleCount", 0);
4290
+ _defineProperty(this, "_count", 0);
4291
+ _defineProperty(this, "_time", 0);
4292
+ _defineProperty(this, "_samples", 0);
4293
+ _defineProperty(this, "_startTime", 0);
4294
+ _defineProperty(this, "_timerPending", false);
4295
+ this.name = name;
4296
+ this.type = type;
4297
+ this.reset();
4099
4298
  }
4100
- scheduleRequest(handle, getPriority = () => 0) {
4101
- if (!this.props.throttleRequests) {
4102
- return Promise.resolve({ done: () => {
4299
+ reset() {
4300
+ this.time = 0;
4301
+ this.count = 0;
4302
+ this.samples = 0;
4303
+ this.lastTiming = 0;
4304
+ this.lastSampleTime = 0;
4305
+ this.lastSampleCount = 0;
4306
+ this._count = 0;
4307
+ this._time = 0;
4308
+ this._samples = 0;
4309
+ this._startTime = 0;
4310
+ this._timerPending = false;
4311
+ return this;
4312
+ }
4313
+ setSampleSize(samples) {
4314
+ this.sampleSize = samples;
4315
+ return this;
4316
+ }
4317
+ incrementCount() {
4318
+ this.addCount(1);
4319
+ return this;
4320
+ }
4321
+ decrementCount() {
4322
+ this.subtractCount(1);
4323
+ return this;
4324
+ }
4325
+ addCount(value) {
4326
+ this._count += value;
4327
+ this._samples++;
4328
+ this._checkSampling();
4329
+ return this;
4330
+ }
4331
+ subtractCount(value) {
4332
+ this._count -= value;
4333
+ this._samples++;
4334
+ this._checkSampling();
4335
+ return this;
4336
+ }
4337
+ addTime(time) {
4338
+ this._time += time;
4339
+ this.lastTiming = time;
4340
+ this._samples++;
4341
+ this._checkSampling();
4342
+ return this;
4343
+ }
4344
+ timeStart() {
4345
+ this._startTime = getHiResTimestamp2();
4346
+ this._timerPending = true;
4347
+ return this;
4348
+ }
4349
+ timeEnd() {
4350
+ if (!this._timerPending) {
4351
+ return this;
4352
+ }
4353
+ this.addTime(getHiResTimestamp2() - this._startTime);
4354
+ this._timerPending = false;
4355
+ this._checkSampling();
4356
+ return this;
4357
+ }
4358
+ getSampleAverageCount() {
4359
+ return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
4360
+ }
4361
+ getSampleAverageTime() {
4362
+ return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
4363
+ }
4364
+ getSampleHz() {
4365
+ return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
4366
+ }
4367
+ getAverageCount() {
4368
+ return this.samples > 0 ? this.count / this.samples : 0;
4369
+ }
4370
+ getAverageTime() {
4371
+ return this.samples > 0 ? this.time / this.samples : 0;
4372
+ }
4373
+ getHz() {
4374
+ return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
4375
+ }
4376
+ _checkSampling() {
4377
+ if (this._samples === this.sampleSize) {
4378
+ this.lastSampleTime = this._time;
4379
+ this.lastSampleCount = this._count;
4380
+ this.count += this._count;
4381
+ this.time += this._time;
4382
+ this.samples += this._samples;
4383
+ this._time = 0;
4384
+ this._count = 0;
4385
+ this._samples = 0;
4386
+ }
4387
+ }
4388
+ };
4389
+ }
4390
+ });
4391
+
4392
+ // ../loader-utils/node_modules/@probe.gl/stats/dist/lib/stats.js
4393
+ var Stats2;
4394
+ var init_stats2 = __esm({
4395
+ "../loader-utils/node_modules/@probe.gl/stats/dist/lib/stats.js"() {
4396
+ init_defineProperty();
4397
+ init_stat2();
4398
+ Stats2 = class {
4399
+ constructor(options) {
4400
+ _defineProperty(this, "id", void 0);
4401
+ _defineProperty(this, "stats", {});
4402
+ this.id = options.id;
4403
+ this.stats = {};
4404
+ this._initializeStats(options.stats);
4405
+ Object.seal(this);
4406
+ }
4407
+ get(name) {
4408
+ let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
4409
+ return this._getOrCreate({
4410
+ name,
4411
+ type
4412
+ });
4413
+ }
4414
+ get size() {
4415
+ return Object.keys(this.stats).length;
4416
+ }
4417
+ reset() {
4418
+ for (const stat of Object.values(this.stats)) {
4419
+ stat.reset();
4420
+ }
4421
+ return this;
4422
+ }
4423
+ forEach(fn) {
4424
+ for (const stat of Object.values(this.stats)) {
4425
+ fn(stat);
4426
+ }
4427
+ }
4428
+ getTable() {
4429
+ const table = {};
4430
+ this.forEach((stat) => {
4431
+ table[stat.name] = {
4432
+ time: stat.time || 0,
4433
+ count: stat.count || 0,
4434
+ average: stat.getAverageTime() || 0,
4435
+ hz: stat.getHz() || 0
4436
+ };
4437
+ });
4438
+ return table;
4439
+ }
4440
+ _initializeStats() {
4441
+ let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
4442
+ stats.forEach((stat) => this._getOrCreate(stat));
4443
+ }
4444
+ _getOrCreate(stat) {
4445
+ const {
4446
+ name,
4447
+ type
4448
+ } = stat;
4449
+ let result = this.stats[name];
4450
+ if (!result) {
4451
+ if (stat instanceof Stat2) {
4452
+ result = stat;
4453
+ } else {
4454
+ result = new Stat2(name, type);
4455
+ }
4456
+ this.stats[name] = result;
4457
+ }
4458
+ return result;
4459
+ }
4460
+ };
4461
+ }
4462
+ });
4463
+
4464
+ // ../loader-utils/node_modules/@probe.gl/stats/dist/index.js
4465
+ var init_dist2 = __esm({
4466
+ "../loader-utils/node_modules/@probe.gl/stats/dist/index.js"() {
4467
+ init_stats2();
4468
+ init_stat2();
4469
+ init_hi_res_timestamp2();
4470
+ }
4471
+ });
4472
+
4473
+ // ../loader-utils/src/lib/request-utils/request-scheduler.ts
4474
+ var STAT_QUEUED_REQUESTS, STAT_ACTIVE_REQUESTS, STAT_CANCELLED_REQUESTS, STAT_QUEUED_REQUESTS_EVER, STAT_ACTIVE_REQUESTS_EVER, DEFAULT_PROPS2, RequestScheduler;
4475
+ var init_request_scheduler = __esm({
4476
+ "../loader-utils/src/lib/request-utils/request-scheduler.ts"() {
4477
+ init_dist2();
4478
+ STAT_QUEUED_REQUESTS = "Queued Requests";
4479
+ STAT_ACTIVE_REQUESTS = "Active Requests";
4480
+ STAT_CANCELLED_REQUESTS = "Cancelled Requests";
4481
+ STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
4482
+ STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
4483
+ DEFAULT_PROPS2 = {
4484
+ id: "request-scheduler",
4485
+ throttleRequests: true,
4486
+ maxRequests: 6
4487
+ };
4488
+ RequestScheduler = class {
4489
+ constructor(props = {}) {
4490
+ this.activeRequestCount = 0;
4491
+ this.requestQueue = [];
4492
+ this.requestMap = new Map();
4493
+ this.deferredUpdate = null;
4494
+ this.props = { ...DEFAULT_PROPS2, ...props };
4495
+ this.stats = new Stats2({ id: this.props.id });
4496
+ this.stats.get(STAT_QUEUED_REQUESTS);
4497
+ this.stats.get(STAT_ACTIVE_REQUESTS);
4498
+ this.stats.get(STAT_CANCELLED_REQUESTS);
4499
+ this.stats.get(STAT_QUEUED_REQUESTS_EVER);
4500
+ this.stats.get(STAT_ACTIVE_REQUESTS_EVER);
4501
+ }
4502
+ scheduleRequest(handle, getPriority = () => 0) {
4503
+ if (!this.props.throttleRequests) {
4504
+ return Promise.resolve({ done: () => {
4103
4505
  } });
4104
4506
  }
4105
4507
  if (this.requestMap.has(handle)) {
4106
4508
  return this.requestMap.get(handle);
4107
4509
  }
4108
4510
  const request = { handle, priority: 0, getPriority };
4109
- const promise = new Promise((resolve) => {
4110
- request.resolve = resolve;
4511
+ const promise = new Promise((resolve2) => {
4512
+ request.resolve = resolve2;
4111
4513
  return request;
4112
4514
  });
4113
4515
  this.requestQueue.push(request);
@@ -4116,7 +4518,7 @@
4116
4518
  return promise;
4117
4519
  }
4118
4520
  _issueRequest(request) {
4119
- const { handle, resolve } = request;
4521
+ const { handle, resolve: resolve2 } = request;
4120
4522
  let isDone = false;
4121
4523
  const done = () => {
4122
4524
  if (!isDone) {
@@ -4127,7 +4529,7 @@
4127
4529
  }
4128
4530
  };
4129
4531
  this.activeRequestCount++;
4130
- return resolve ? resolve({ done }) : Promise.resolve({ done });
4532
+ return resolve2 ? resolve2({ done }) : Promise.resolve({ done });
4131
4533
  }
4132
4534
  _issueNewRequests() {
4133
4535
  if (!this.deferredUpdate) {
@@ -4193,19 +4595,75 @@
4193
4595
  }
4194
4596
  });
4195
4597
 
4598
+ // ../loader-utils/src/lib/node/buffer.browser.ts
4599
+ function toArrayBuffer(buffer) {
4600
+ return buffer;
4601
+ }
4602
+ var init_buffer_browser = __esm({
4603
+ "../loader-utils/src/lib/node/buffer.browser.ts"() {
4604
+ }
4605
+ });
4606
+
4607
+ // ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
4608
+ function isBuffer(value) {
4609
+ return value && typeof value === "object" && value.isBuffer;
4610
+ }
4611
+ function toArrayBuffer2(data) {
4612
+ if (isBuffer(data)) {
4613
+ return toArrayBuffer(data);
4614
+ }
4615
+ if (data instanceof ArrayBuffer) {
4616
+ return data;
4617
+ }
4618
+ if (ArrayBuffer.isView(data)) {
4619
+ if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
4620
+ return data.buffer;
4621
+ }
4622
+ return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
4623
+ }
4624
+ if (typeof data === "string") {
4625
+ const text = data;
4626
+ const uint8Array = new TextEncoder().encode(text);
4627
+ return uint8Array.buffer;
4628
+ }
4629
+ if (data && typeof data === "object" && data._toArrayBuffer) {
4630
+ return data._toArrayBuffer();
4631
+ }
4632
+ throw new Error("toArrayBuffer");
4633
+ }
4634
+ var init_memory_conversion_utils = __esm({
4635
+ "../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts"() {
4636
+ init_buffer_browser();
4637
+ }
4638
+ });
4639
+
4640
+ // ../loader-utils/src/lib/path-utils/get-cwd.ts
4641
+ function getCWD() {
4642
+ if (typeof process !== "undefined" && typeof process.cwd !== "undefined") {
4643
+ return process.cwd();
4644
+ }
4645
+ const pathname = window.location?.pathname;
4646
+ return pathname?.slice(0, pathname.lastIndexOf("/") + 1) || "";
4647
+ }
4648
+ var init_get_cwd = __esm({
4649
+ "../loader-utils/src/lib/path-utils/get-cwd.ts"() {
4650
+ }
4651
+ });
4652
+
4196
4653
  // ../loader-utils/src/lib/path-utils/path.ts
4197
4654
  var path_exports = {};
4198
4655
  __export(path_exports, {
4199
4656
  dirname: () => dirname,
4200
4657
  filename: () => filename,
4201
- join: () => join
4658
+ join: () => join,
4659
+ resolve: () => resolve
4202
4660
  });
4203
4661
  function filename(url) {
4204
- const slashIndex = url && url.lastIndexOf("/");
4662
+ const slashIndex = url ? url.lastIndexOf("/") : -1;
4205
4663
  return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
4206
4664
  }
4207
4665
  function dirname(url) {
4208
- const slashIndex = url && url.lastIndexOf("/");
4666
+ const slashIndex = url ? url.lastIndexOf("/") : -1;
4209
4667
  return slashIndex >= 0 ? url.substr(0, slashIndex) : "";
4210
4668
  }
4211
4669
  function join(...parts) {
@@ -4221,8 +4679,112 @@
4221
4679
  });
4222
4680
  return parts.join(separator);
4223
4681
  }
4682
+ function resolve(...components) {
4683
+ const paths = [];
4684
+ for (let _i = 0; _i < components.length; _i++) {
4685
+ paths[_i] = components[_i];
4686
+ }
4687
+ let resolvedPath = "";
4688
+ let resolvedAbsolute = false;
4689
+ let cwd;
4690
+ for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) {
4691
+ let path;
4692
+ if (i >= 0) {
4693
+ path = paths[i];
4694
+ } else {
4695
+ if (cwd === void 0) {
4696
+ cwd = getCWD();
4697
+ }
4698
+ path = cwd;
4699
+ }
4700
+ if (path.length === 0) {
4701
+ continue;
4702
+ }
4703
+ resolvedPath = `${path}/${resolvedPath}`;
4704
+ resolvedAbsolute = path.charCodeAt(0) === SLASH;
4705
+ }
4706
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
4707
+ if (resolvedAbsolute) {
4708
+ return `/${resolvedPath}`;
4709
+ } else if (resolvedPath.length > 0) {
4710
+ return resolvedPath;
4711
+ }
4712
+ return ".";
4713
+ }
4714
+ function normalizeStringPosix(path, allowAboveRoot) {
4715
+ let res = "";
4716
+ let lastSlash = -1;
4717
+ let dots = 0;
4718
+ let code;
4719
+ let isAboveRoot = false;
4720
+ for (let i = 0; i <= path.length; ++i) {
4721
+ if (i < path.length) {
4722
+ code = path.charCodeAt(i);
4723
+ } else if (code === SLASH) {
4724
+ break;
4725
+ } else {
4726
+ code = SLASH;
4727
+ }
4728
+ if (code === SLASH) {
4729
+ if (lastSlash === i - 1 || dots === 1) {
4730
+ } else if (lastSlash !== i - 1 && dots === 2) {
4731
+ if (res.length < 2 || !isAboveRoot || res.charCodeAt(res.length - 1) !== DOT || res.charCodeAt(res.length - 2) !== DOT) {
4732
+ if (res.length > 2) {
4733
+ const start = res.length - 1;
4734
+ let j = start;
4735
+ for (; j >= 0; --j) {
4736
+ if (res.charCodeAt(j) === SLASH) {
4737
+ break;
4738
+ }
4739
+ }
4740
+ if (j !== start) {
4741
+ res = j === -1 ? "" : res.slice(0, j);
4742
+ lastSlash = i;
4743
+ dots = 0;
4744
+ isAboveRoot = false;
4745
+ continue;
4746
+ }
4747
+ } else if (res.length === 2 || res.length === 1) {
4748
+ res = "";
4749
+ lastSlash = i;
4750
+ dots = 0;
4751
+ isAboveRoot = false;
4752
+ continue;
4753
+ }
4754
+ }
4755
+ if (allowAboveRoot) {
4756
+ if (res.length > 0) {
4757
+ res += "/..";
4758
+ } else {
4759
+ res = "..";
4760
+ }
4761
+ isAboveRoot = true;
4762
+ }
4763
+ } else {
4764
+ const slice = path.slice(lastSlash + 1, i);
4765
+ if (res.length > 0) {
4766
+ res += `/${slice}`;
4767
+ } else {
4768
+ res = slice;
4769
+ }
4770
+ isAboveRoot = false;
4771
+ }
4772
+ lastSlash = i;
4773
+ dots = 0;
4774
+ } else if (code === DOT && dots !== -1) {
4775
+ ++dots;
4776
+ } else {
4777
+ dots = -1;
4778
+ }
4779
+ }
4780
+ return res;
4781
+ }
4782
+ var SLASH, DOT;
4224
4783
  var init_path = __esm({
4225
4784
  "../loader-utils/src/lib/path-utils/path.ts"() {
4785
+ init_get_cwd();
4786
+ SLASH = 47;
4787
+ DOT = 46;
4226
4788
  }
4227
4789
  });
4228
4790
 
@@ -4236,6 +4798,7 @@
4236
4798
  init_async_iteration();
4237
4799
  init_request_scheduler();
4238
4800
  init_file_aliases();
4801
+ init_memory_conversion_utils();
4239
4802
  init_path();
4240
4803
  }
4241
4804
  });
@@ -4269,55 +4832,55 @@
4269
4832
  return this._length;
4270
4833
  }
4271
4834
  add(item) {
4272
- const node = new DoublyLinkedListNode(item, this.tail, null);
4835
+ const node2 = new DoublyLinkedListNode(item, this.tail, null);
4273
4836
  if (this.tail) {
4274
- this.tail.next = node;
4275
- this.tail = node;
4837
+ this.tail.next = node2;
4838
+ this.tail = node2;
4276
4839
  } else {
4277
- this.head = node;
4278
- this.tail = node;
4840
+ this.head = node2;
4841
+ this.tail = node2;
4279
4842
  }
4280
4843
  ++this._length;
4281
- return node;
4844
+ return node2;
4282
4845
  }
4283
- remove(node) {
4284
- if (!node) {
4846
+ remove(node2) {
4847
+ if (!node2) {
4285
4848
  return;
4286
4849
  }
4287
- if (node.previous && node.next) {
4288
- node.previous.next = node.next;
4289
- node.next.previous = node.previous;
4290
- } else if (node.previous) {
4291
- node.previous.next = null;
4292
- this.tail = node.previous;
4293
- } else if (node.next) {
4294
- node.next.previous = null;
4295
- this.head = node.next;
4850
+ if (node2.previous && node2.next) {
4851
+ node2.previous.next = node2.next;
4852
+ node2.next.previous = node2.previous;
4853
+ } else if (node2.previous) {
4854
+ node2.previous.next = null;
4855
+ this.tail = node2.previous;
4856
+ } else if (node2.next) {
4857
+ node2.next.previous = null;
4858
+ this.head = node2.next;
4296
4859
  } else {
4297
4860
  this.head = null;
4298
4861
  this.tail = null;
4299
4862
  }
4300
- node.next = null;
4301
- node.previous = null;
4863
+ node2.next = null;
4864
+ node2.previous = null;
4302
4865
  --this._length;
4303
4866
  }
4304
- splice(node, nextNode) {
4305
- if (node === nextNode) {
4867
+ splice(node2, nextNode) {
4868
+ if (node2 === nextNode) {
4306
4869
  return;
4307
4870
  }
4308
4871
  this.remove(nextNode);
4309
- this._insert(node, nextNode);
4872
+ this._insert(node2, nextNode);
4310
4873
  }
4311
- _insert(node, nextNode) {
4312
- const oldNodeNext = node.next;
4313
- node.next = nextNode;
4314
- if (this.tail === node) {
4874
+ _insert(node2, nextNode) {
4875
+ const oldNodeNext = node2.next;
4876
+ node2.next = nextNode;
4877
+ if (this.tail === node2) {
4315
4878
  this.tail = nextNode;
4316
4879
  } else {
4317
4880
  oldNodeNext.previous = nextNode;
4318
4881
  }
4319
4882
  nextNode.next = oldNodeNext;
4320
- nextNode.previous = node;
4883
+ nextNode.previous = node2;
4321
4884
  ++this._length;
4322
4885
  }
4323
4886
  };
@@ -4325,9 +4888,6 @@
4325
4888
  });
4326
4889
 
4327
4890
  // src/tileset/tileset-cache.ts
4328
- function defined(x) {
4329
- return x !== void 0 && x !== null;
4330
- }
4331
4891
  var TilesetCache;
4332
4892
  var init_tileset_cache = __esm({
4333
4893
  "src/tileset/tileset-cache.ts"() {
@@ -4342,13 +4902,13 @@
4342
4902
  this._list.splice(this._list.tail, this._sentinel);
4343
4903
  }
4344
4904
  touch(tile) {
4345
- const node = tile._cacheNode;
4346
- if (defined(node)) {
4347
- this._list.splice(this._sentinel, node);
4905
+ const node2 = tile._cacheNode;
4906
+ if (node2) {
4907
+ this._list.splice(this._sentinel, node2);
4348
4908
  }
4349
4909
  }
4350
4910
  add(tileset, tile, addCallback) {
4351
- if (!defined(tile._cacheNode)) {
4911
+ if (!tile._cacheNode) {
4352
4912
  tile._cacheNode = this._list.add(tile);
4353
4913
  if (addCallback) {
4354
4914
  addCallback(tileset, tile);
@@ -4356,12 +4916,12 @@
4356
4916
  }
4357
4917
  }
4358
4918
  unloadTile(tileset, tile, unloadCallback) {
4359
- const node = tile._cacheNode;
4360
- if (!defined(node)) {
4919
+ const node2 = tile._cacheNode;
4920
+ if (!node2) {
4361
4921
  return;
4362
4922
  }
4363
- this._list.remove(node);
4364
- tile._cacheNode = void 0;
4923
+ this._list.remove(node2);
4924
+ tile._cacheNode = null;
4365
4925
  if (unloadCallback) {
4366
4926
  unloadCallback(tileset, tile);
4367
4927
  }
@@ -4372,10 +4932,10 @@
4372
4932
  const list = this._list;
4373
4933
  const maximumMemoryUsageInBytes = tileset.maximumMemoryUsage * 1024 * 1024;
4374
4934
  const sentinel = this._sentinel;
4375
- let node = list.head;
4376
- while (node !== sentinel && (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)) {
4377
- const tile = node.item;
4378
- node = node.next;
4935
+ let node2 = list.head;
4936
+ while (node2 !== sentinel && (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)) {
4937
+ const tile = node2.item;
4938
+ node2 = node2.next;
4379
4939
  this.unloadTile(tileset, tile, unloadCallback);
4380
4940
  }
4381
4941
  }
@@ -4440,11 +5000,11 @@
4440
5000
  var INTERSECTION;
4441
5001
  var init_constants2 = __esm({
4442
5002
  "../../node_modules/@math.gl/culling/dist/esm/constants.js"() {
4443
- INTERSECTION = Object.freeze({
5003
+ INTERSECTION = {
4444
5004
  OUTSIDE: -1,
4445
5005
  INTERSECTING: 0,
4446
5006
  INSIDE: 1
4447
- });
5007
+ };
4448
5008
  }
4449
5009
  });
4450
5010
 
@@ -4452,6 +5012,7 @@
4452
5012
  var scratchVector5, scratchNormal2;
4453
5013
  var init_axis_aligned_bounding_box = __esm({
4454
5014
  "../../node_modules/@math.gl/culling/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.js"() {
5015
+ init_defineProperty();
4455
5016
  init_esm();
4456
5017
  init_constants2();
4457
5018
  scratchVector5 = new Vector3();
@@ -4463,6 +5024,7 @@
4463
5024
  var scratchVector6, scratchVector23, BoundingSphere;
4464
5025
  var init_bounding_sphere = __esm({
4465
5026
  "../../node_modules/@math.gl/culling/dist/esm/lib/bounding-volumes/bounding-sphere.js"() {
5027
+ init_defineProperty();
4466
5028
  init_esm();
4467
5029
  init_mat4();
4468
5030
  init_constants2();
@@ -4470,6 +5032,8 @@
4470
5032
  scratchVector23 = new Vector3();
4471
5033
  BoundingSphere = class {
4472
5034
  constructor(center = [0, 0, 0], radius = 0) {
5035
+ _defineProperty(this, "center", void 0);
5036
+ _defineProperty(this, "radius", void 0);
4473
5037
  this.radius = -0;
4474
5038
  this.center = new Vector3();
4475
5039
  this.fromCenterRadius(center, radius);
@@ -4511,8 +5075,8 @@
4511
5075
  return this;
4512
5076
  }
4513
5077
  expand(point) {
4514
- point = scratchVector6.from(point);
4515
- const radius = point.subtract(this.center).magnitude();
5078
+ const scratchPoint2 = scratchVector6.from(point);
5079
+ const radius = scratchPoint2.subtract(this.center).magnitude();
4516
5080
  if (radius > this.radius) {
4517
5081
  this.radius = radius;
4518
5082
  }
@@ -4525,12 +5089,13 @@
4525
5089
  return this;
4526
5090
  }
4527
5091
  distanceSquaredTo(point) {
4528
- point = scratchVector6.from(point);
4529
- const delta = point.subtract(this.center);
4530
- return delta.lengthSquared() - this.radius * this.radius;
5092
+ const d = this.distanceTo(point);
5093
+ return d * d;
4531
5094
  }
4532
5095
  distanceTo(point) {
4533
- return Math.sqrt(this.distanceSquaredTo(point));
5096
+ const scratchPoint2 = scratchVector6.from(point);
5097
+ const delta = scratchPoint2.subtract(this.center);
5098
+ return Math.max(0, delta.len() - this.radius);
4534
5099
  }
4535
5100
  intersectPlane(plane) {
4536
5101
  const center = this.center;
@@ -4553,6 +5118,7 @@
4553
5118
  var scratchVector32, scratchOffset, scratchVectorU, scratchVectorV, scratchVectorW, scratchCorner, scratchToCenter, MATRIX3, OrientedBoundingBox;
4554
5119
  var init_oriented_bounding_box = __esm({
4555
5120
  "../../node_modules/@math.gl/culling/dist/esm/lib/bounding-volumes/oriented-bounding-box.js"() {
5121
+ init_defineProperty();
4556
5122
  init_esm();
4557
5123
  init_bounding_sphere();
4558
5124
  init_constants2();
@@ -4576,6 +5142,8 @@
4576
5142
  };
4577
5143
  OrientedBoundingBox = class {
4578
5144
  constructor(center = [0, 0, 0], halfAxes = [0, 0, 0, 0, 0, 0, 0, 0, 0]) {
5145
+ _defineProperty(this, "center", void 0);
5146
+ _defineProperty(this, "halfAxes", void 0);
4579
5147
  this.center = new Vector3().from(center);
4580
5148
  this.halfAxes = new Matrix3(halfAxes);
4581
5149
  }
@@ -4747,11 +5315,14 @@
4747
5315
  var scratchPosition2, scratchNormal3, Plane;
4748
5316
  var init_plane = __esm({
4749
5317
  "../../node_modules/@math.gl/culling/dist/esm/lib/plane.js"() {
5318
+ init_defineProperty();
4750
5319
  init_esm();
4751
5320
  scratchPosition2 = new Vector3();
4752
5321
  scratchNormal3 = new Vector3();
4753
5322
  Plane = class {
4754
5323
  constructor(normal = [0, 0, 1], distance = 0) {
5324
+ _defineProperty(this, "normal", void 0);
5325
+ _defineProperty(this, "distance", void 0);
4755
5326
  this.normal = new Vector3();
4756
5327
  this.distance = -0;
4757
5328
  this.fromNormalDistance(normal, distance);
@@ -4775,7 +5346,7 @@
4775
5346
  this.distance = d;
4776
5347
  return this;
4777
5348
  }
4778
- clone(plane) {
5349
+ clone() {
4779
5350
  return new Plane(this.normal, this.distance);
4780
5351
  }
4781
5352
  equals(right) {
@@ -4803,6 +5374,7 @@
4803
5374
  var faces, scratchPlaneCenter, scratchPlaneNormal, scratchPlane, CullingVolume;
4804
5375
  var init_culling_volume = __esm({
4805
5376
  "../../node_modules/@math.gl/culling/dist/esm/lib/culling-volume.js"() {
5377
+ init_defineProperty();
4806
5378
  init_esm();
4807
5379
  init_constants2();
4808
5380
  init_plane();
@@ -4811,18 +5383,9 @@
4811
5383
  scratchPlaneNormal = new Vector3();
4812
5384
  scratchPlane = new Plane(new Vector3(1, 0, 0), 0);
4813
5385
  CullingVolume = class {
4814
- static get MASK_OUTSIDE() {
4815
- return 4294967295;
4816
- }
4817
- static get MASK_INSIDE() {
4818
- return 0;
4819
- }
4820
- static get MASK_INDETERMINATE() {
4821
- return 2147483647;
4822
- }
4823
5386
  constructor(planes = []) {
5387
+ _defineProperty(this, "planes", void 0);
4824
5388
  this.planes = planes;
4825
- assert(this.planes.every((plane) => plane instanceof Plane));
4826
5389
  }
4827
5390
  fromBoundingSphere(boundingSphere) {
4828
5391
  this.planes.length = 2 * faces.length;
@@ -4850,7 +5413,6 @@
4850
5413
  return this;
4851
5414
  }
4852
5415
  computeVisibility(boundingVolume) {
4853
- assert(boundingVolume);
4854
5416
  let intersect = INTERSECTION.INSIDE;
4855
5417
  for (const plane of this.planes) {
4856
5418
  const result = boundingVolume.intersectPlane(plane);
@@ -4866,7 +5428,6 @@
4866
5428
  return intersect;
4867
5429
  }
4868
5430
  computeVisibilityWithPlaneMask(boundingVolume, parentPlaneMask) {
4869
- assert(boundingVolume, "boundingVolume is required.");
4870
5431
  assert(Number.isFinite(parentPlaneMask), "parentPlaneMask is required.");
4871
5432
  if (parentPlaneMask === CullingVolume.MASK_OUTSIDE || parentPlaneMask === CullingVolume.MASK_INSIDE) {
4872
5433
  return parentPlaneMask;
@@ -4889,6 +5450,9 @@
4889
5450
  return mask;
4890
5451
  }
4891
5452
  };
5453
+ _defineProperty(CullingVolume, "MASK_OUTSIDE", 4294967295);
5454
+ _defineProperty(CullingVolume, "MASK_INSIDE", 0);
5455
+ _defineProperty(CullingVolume, "MASK_INDETERMINATE", 2147483647);
4892
5456
  }
4893
5457
  });
4894
5458
 
@@ -4896,6 +5460,7 @@
4896
5460
  var scratchPlaneUpVector, scratchPlaneRightVector, scratchPlaneNearCenter, scratchPlaneFarCenter, scratchPlaneNormal2;
4897
5461
  var init_perspective_off_center_frustum = __esm({
4898
5462
  "../../node_modules/@math.gl/culling/dist/esm/lib/perspective-off-center-frustum.js"() {
5463
+ init_defineProperty();
4899
5464
  init_esm();
4900
5465
  init_culling_volume();
4901
5466
  init_plane();
@@ -4910,6 +5475,7 @@
4910
5475
  // ../../node_modules/@math.gl/culling/dist/esm/lib/perspective-frustum.js
4911
5476
  var init_perspective_frustum = __esm({
4912
5477
  "../../node_modules/@math.gl/culling/dist/esm/lib/perspective-frustum.js"() {
5478
+ init_defineProperty();
4913
5479
  init_perspective_off_center_frustum();
4914
5480
  }
4915
5481
  });
@@ -4971,7 +5537,7 @@
4971
5537
  });
4972
5538
 
4973
5539
  // ../../node_modules/@math.gl/culling/dist/esm/index.js
4974
- var init_esm4 = __esm({
5540
+ var init_esm3 = __esm({
4975
5541
  "../../node_modules/@math.gl/culling/dist/esm/index.js"() {
4976
5542
  init_constants2();
4977
5543
  init_axis_aligned_bounding_box();
@@ -4984,8 +5550,6 @@
4984
5550
  init_bounding_sphere_from_points();
4985
5551
  init_bounding_box_from_points();
4986
5552
  init_compute_eigen_decomposition();
4987
- init_constants2();
4988
- init_constants2();
4989
5553
  }
4990
5554
  });
4991
5555
 
@@ -4993,44 +5557,93 @@
4993
5557
  function getFrameState(viewport, frameNumber) {
4994
5558
  const { cameraDirection, cameraUp, height } = viewport;
4995
5559
  const { metersPerUnit } = viewport.distanceScales;
4996
- const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
4997
- const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new Vector3());
5560
+ const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);
4998
5561
  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
4999
5562
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
5000
- const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
5563
+ const cameraPositionCartesian2 = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
5001
5564
  const cameraDirectionCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))).normalize();
5002
5565
  const cameraUpCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))).normalize();
5003
- commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
5566
+ commonSpacePlanesToWGS84(viewport);
5567
+ const ViewportClass = viewport.constructor;
5568
+ const { longitude, latitude, width, bearing, zoom } = viewport;
5569
+ const topDownViewport = new ViewportClass({
5570
+ longitude,
5571
+ latitude,
5572
+ height,
5573
+ width,
5574
+ bearing,
5575
+ zoom,
5576
+ pitch: 0
5577
+ });
5004
5578
  return {
5005
5579
  camera: {
5006
- position: cameraPositionCartesian,
5580
+ position: cameraPositionCartesian2,
5007
5581
  direction: cameraDirectionCartesian,
5008
5582
  up: cameraUpCartesian
5009
5583
  },
5010
5584
  viewport,
5585
+ topDownViewport,
5011
5586
  height,
5012
5587
  cullingVolume,
5013
5588
  frameNumber,
5014
5589
  sseDenominator: 1.15
5015
5590
  };
5016
5591
  }
5017
- function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
5592
+ function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
5593
+ if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {
5594
+ return [tiles, []];
5595
+ }
5596
+ const tuples = [];
5597
+ const { longitude: viewportLongitude, latitude: viewportLatitude } = frameState.viewport;
5598
+ for (const [index, tile] of tiles.entries()) {
5599
+ const [longitude, latitude] = tile.header.mbs;
5600
+ const deltaLon = Math.abs(viewportLongitude - longitude);
5601
+ const deltaLat = Math.abs(viewportLatitude - latitude);
5602
+ const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);
5603
+ tuples.push([index, distance]);
5604
+ }
5605
+ const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);
5606
+ const selectedTiles = [];
5607
+ for (let i = 0; i < maximumTilesSelected; i++) {
5608
+ selectedTiles.push(tiles[tuplesSorted[i][0]]);
5609
+ }
5610
+ const unselectedTiles = [];
5611
+ for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {
5612
+ unselectedTiles.push(tiles[tuplesSorted[i][0]]);
5613
+ }
5614
+ return [selectedTiles, unselectedTiles];
5615
+ }
5616
+ function commonSpacePlanesToWGS84(viewport) {
5018
5617
  const frustumPlanes = viewport.getFrustumPlanes();
5618
+ const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);
5619
+ const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);
5620
+ const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition3);
5019
5621
  let i = 0;
5622
+ cullingVolume.planes[i++].fromPointNormal(nearCenterCartesian, scratchVector7.copy(nearCenterCartesian).subtract(cameraCartesian));
5020
5623
  for (const dir in frustumPlanes) {
5624
+ if (dir === "near") {
5625
+ continue;
5626
+ }
5021
5627
  const plane = frustumPlanes[dir];
5022
- const distanceToCenter = plane.normal.dot(viewport.center);
5023
- scratchPosition3.copy(plane.normal).scale(plane.distance - distanceToCenter).add(viewport.center);
5024
- const cartographicPos = viewport.unprojectPosition(scratchPosition3);
5025
- const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());
5026
- cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector7.copy(viewportCenterCartesian).subtract(cartesianPos));
5628
+ const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition3);
5629
+ const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition3);
5630
+ cullingVolume.planes[i++].fromPointNormal(cartesianPos, scratchVector7.copy(nearCenterCartesian).subtract(cartesianPos));
5027
5631
  }
5028
5632
  }
5633
+ function closestPointOnPlane(plane, refPoint, out = new Vector3()) {
5634
+ const distanceToRef = plane.normal.dot(refPoint);
5635
+ out.copy(plane.normal).scale(plane.distance - distanceToRef).add(refPoint);
5636
+ return out;
5637
+ }
5638
+ function worldToCartesian(viewport, point, out = new Vector3()) {
5639
+ const cartographicPos = viewport.unprojectPosition(point);
5640
+ return Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);
5641
+ }
5029
5642
  var scratchVector7, scratchPosition3, cullingVolume;
5030
5643
  var init_frame_state = __esm({
5031
5644
  "src/tileset/helpers/frame-state.ts"() {
5032
5645
  init_esm();
5033
- init_esm4();
5646
+ init_esm3();
5034
5647
  init_esm2();
5035
5648
  scratchVector7 = new Vector3();
5036
5649
  scratchPosition3 = new Vector3();
@@ -5046,20 +5659,31 @@
5046
5659
  });
5047
5660
 
5048
5661
  // src/tileset/helpers/zoom.ts
5049
- function getZoomFromBoundingVolume(boundingVolume) {
5050
- const { halfAxes, radius, width, height } = boundingVolume;
5051
- if (halfAxes) {
5662
+ function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
5663
+ if (boundingVolume instanceof OrientedBoundingBox) {
5664
+ const { halfAxes } = boundingVolume;
5052
5665
  const obbSize = getObbSize(halfAxes);
5053
- return Math.log2(WGS84_RADIUS_Z2 / obbSize);
5054
- } else if (radius) {
5055
- return Math.log2(WGS84_RADIUS_Z2 / radius);
5056
- } else if (height && width) {
5666
+ return Math.log2(WGS84_RADIUS_Z2 / (obbSize + cartorgraphicCenter[2]));
5667
+ } else if (boundingVolume instanceof BoundingSphere) {
5668
+ const { radius } = boundingVolume;
5669
+ return Math.log2(WGS84_RADIUS_Z2 / (radius + cartorgraphicCenter[2]));
5670
+ } else if (boundingVolume.width && boundingVolume.height) {
5671
+ const { width, height } = boundingVolume;
5057
5672
  const zoomX = Math.log2(WGS84_RADIUS_X2 / width);
5058
5673
  const zoomY = Math.log2(WGS84_RADIUS_Y2 / height);
5059
5674
  return (zoomX + zoomY) / 2;
5060
5675
  }
5061
5676
  return 1;
5062
5677
  }
5678
+ function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
5679
+ const extentVertex = Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], new Vector3());
5680
+ const extentSize = Math.sqrt(Math.pow(extentVertex[0] - cartesianCenter[0], 2) + Math.pow(extentVertex[1] - cartesianCenter[1], 2) + Math.pow(extentVertex[2] - cartesianCenter[2], 2));
5681
+ return Math.log2(WGS84_RADIUS_Z2 / (extentSize + cartorgraphicCenter[2]));
5682
+ }
5683
+ function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
5684
+ const [xmin, ymin, xmax, ymax] = extent;
5685
+ return getZoomFromFullExtent({ xmin, xmax, ymin, ymax, zmin: 0, zmax: 0 }, cartorgraphicCenter, cartesianCenter);
5686
+ }
5063
5687
  function getObbSize(halfAxes) {
5064
5688
  halfAxes.getColumn(0, scratchVector8);
5065
5689
  const axeY = halfAxes.getColumn(1);
@@ -5072,6 +5696,8 @@
5072
5696
  var init_zoom = __esm({
5073
5697
  "src/tileset/helpers/zoom.ts"() {
5074
5698
  init_esm();
5699
+ init_esm3();
5700
+ init_esm2();
5075
5701
  WGS84_RADIUS_X2 = 6378137;
5076
5702
  WGS84_RADIUS_Y2 = 6378137;
5077
5703
  WGS84_RADIUS_Z2 = 6356752314245179e-9;
@@ -5121,39 +5747,60 @@
5121
5747
  }
5122
5748
  });
5123
5749
 
5750
+ // ../core/src/lib/utils/url-utils.ts
5751
+ function extractQueryString(url) {
5752
+ const matches3 = url.match(QUERY_STRING_PATTERN);
5753
+ return matches3 && matches3[0];
5754
+ }
5755
+ function stripQueryString(url) {
5756
+ return url.replace(QUERY_STRING_PATTERN, "");
5757
+ }
5758
+ var QUERY_STRING_PATTERN;
5759
+ var init_url_utils = __esm({
5760
+ "../core/src/lib/utils/url-utils.ts"() {
5761
+ QUERY_STRING_PATTERN = /\?.*/;
5762
+ }
5763
+ });
5764
+
5124
5765
  // ../core/src/lib/utils/resource-utils.ts
5125
- function getResourceUrlAndType(resource) {
5766
+ function getResourceUrl(resource) {
5126
5767
  if (isResponse(resource)) {
5127
- const url = stripQueryString(resource.url || "");
5128
- const contentTypeHeader = resource.headers.get("content-type") || "";
5129
- return {
5130
- url,
5131
- type: parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(url)
5132
- };
5768
+ const response = resource;
5769
+ return response.url;
5133
5770
  }
5134
5771
  if (isBlob(resource)) {
5135
- return {
5136
- url: stripQueryString(resource.name || ""),
5137
- type: resource.type || ""
5138
- };
5772
+ const blob = resource;
5773
+ return blob.name || "";
5139
5774
  }
5140
5775
  if (typeof resource === "string") {
5141
- return {
5142
- url: stripQueryString(resource),
5143
- type: parseMIMETypeFromURL(resource)
5144
- };
5776
+ return resource;
5145
5777
  }
5146
- return {
5147
- url: "",
5148
- type: ""
5149
- };
5778
+ return "";
5779
+ }
5780
+ function getResourceMIMEType(resource) {
5781
+ if (isResponse(resource)) {
5782
+ const response = resource;
5783
+ const contentTypeHeader = response.headers.get("content-type") || "";
5784
+ const noQueryUrl = stripQueryString(response.url);
5785
+ return parseMIMEType(contentTypeHeader) || parseMIMETypeFromURL(noQueryUrl);
5786
+ }
5787
+ if (isBlob(resource)) {
5788
+ const blob = resource;
5789
+ return blob.type || "";
5790
+ }
5791
+ if (typeof resource === "string") {
5792
+ return parseMIMETypeFromURL(resource);
5793
+ }
5794
+ return "";
5150
5795
  }
5151
5796
  function getResourceContentLength(resource) {
5152
5797
  if (isResponse(resource)) {
5153
- return resource.headers["content-length"] || -1;
5798
+ const response = resource;
5799
+ return response.headers["content-length"] || -1;
5154
5800
  }
5155
5801
  if (isBlob(resource)) {
5156
- return resource.size;
5802
+ const blob = resource;
5803
+ return blob.size;
5157
5804
  }
5158
5805
  if (typeof resource === "string") {
5159
5806
  return resource.length;
@@ -5166,15 +5813,11 @@
5166
5813
  }
5167
5814
  return -1;
5168
5815
  }
5169
- function stripQueryString(url) {
5170
- return url.replace(QUERY_STRING_PATTERN, "");
5171
- }
5172
- var QUERY_STRING_PATTERN;
5173
5816
  var init_resource_utils = __esm({
5174
5817
  "../core/src/lib/utils/resource-utils.ts"() {
5175
5818
  init_is_type();
5176
5819
  init_mime_type_utils();
5177
- QUERY_STRING_PATTERN = /\?.*/;
5820
+ init_url_utils();
5178
5821
  }
5179
5822
  });
5180
5823
 
@@ -5188,7 +5831,8 @@
5188
5831
  if (contentLength >= 0) {
5189
5832
  headers["content-length"] = String(contentLength);
5190
5833
  }
5191
- const { url, type } = getResourceUrlAndType(resource);
5834
+ const url = getResourceUrl(resource);
5835
+ const type = getResourceMIMEType(resource);
5192
5836
  if (type) {
5193
5837
  headers["content-type"] = type;
5194
5838
  }
@@ -5218,7 +5862,7 @@
5218
5862
  text += ` ${await response.text()}`;
5219
5863
  }
5220
5864
  message += text;
5221
- message = message.length > 60 ? `${message.slice(60)}...` : message;
5865
+ message = message.length > 60 ? `${message.slice(0, 60)}...` : message;
5222
5866
  } catch (error) {
5223
5867
  }
5224
5868
  return message;
@@ -5230,9 +5874,9 @@
5230
5874
  }
5231
5875
  if (resource instanceof Blob) {
5232
5876
  const blobSlice = resource.slice(0, 5);
5233
- return await new Promise((resolve) => {
5877
+ return await new Promise((resolve2) => {
5234
5878
  const reader = new FileReader();
5235
- reader.onload = (event) => resolve(event?.target?.result);
5879
+ reader.onload = (event) => resolve2(event?.target?.result);
5236
5880
  reader.readAsDataURL(blobSlice);
5237
5881
  });
5238
5882
  }
@@ -5277,12 +5921,12 @@
5277
5921
  }
5278
5922
  });
5279
5923
 
5280
- // ../../node_modules/probe.gl/dist/esm/env/is-electron.js
5924
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
5281
5925
  function isElectron(mockUserAgent) {
5282
5926
  if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
5283
5927
  return true;
5284
5928
  }
5285
- if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions.electron)) {
5929
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
5286
5930
  return true;
5287
5931
  }
5288
5932
  const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
@@ -5293,52 +5937,54 @@
5293
5937
  return false;
5294
5938
  }
5295
5939
  var init_is_electron = __esm({
5296
- "../../node_modules/probe.gl/dist/esm/env/is-electron.js"() {
5940
+ "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js"() {
5297
5941
  }
5298
5942
  });
5299
5943
 
5300
- // ../../node_modules/probe.gl/dist/esm/env/is-browser.js
5944
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
5301
5945
  function isBrowser3() {
5302
5946
  const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
5303
5947
  return !isNode || isElectron();
5304
5948
  }
5305
5949
  var init_is_browser = __esm({
5306
- "../../node_modules/probe.gl/dist/esm/env/is-browser.js"() {
5950
+ "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js"() {
5307
5951
  init_is_electron();
5308
5952
  }
5309
5953
  });
5310
5954
 
5311
- // ../../node_modules/probe.gl/dist/esm/env/globals.js
5312
- var globals4, self_3, window_3, global_4, document_3, process_;
5955
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
5956
+ var self_3, window_3, document_3, process_, console_, navigator_;
5313
5957
  var init_globals3 = __esm({
5314
- "../../node_modules/probe.gl/dist/esm/env/globals.js"() {
5315
- globals4 = {
5316
- self: typeof self !== "undefined" && self,
5317
- window: typeof window !== "undefined" && window,
5318
- global: typeof global !== "undefined" && global,
5319
- document: typeof document !== "undefined" && document,
5320
- process: typeof process === "object" && process
5321
- };
5322
- self_3 = globals4.self || globals4.window || globals4.global;
5323
- window_3 = globals4.window || globals4.self || globals4.global;
5324
- global_4 = globals4.global || globals4.self || globals4.window;
5325
- document_3 = globals4.document || {};
5326
- process_ = globals4.process || {};
5958
+ "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js"() {
5959
+ self_3 = globalThis.self || globalThis.window || globalThis.global;
5960
+ window_3 = globalThis.window || globalThis.self || globalThis.global;
5961
+ document_3 = globalThis.document || {};
5962
+ process_ = globalThis.process || {};
5963
+ console_ = globalThis.console;
5964
+ navigator_ = globalThis.navigator || {};
5327
5965
  }
5328
5966
  });
5329
5967
 
5330
- // ../../node_modules/probe.gl/dist/esm/utils/globals.js
5968
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
5331
5969
  var VERSION2, isBrowser4;
5332
5970
  var init_globals4 = __esm({
5333
- "../../node_modules/probe.gl/dist/esm/utils/globals.js"() {
5971
+ "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js"() {
5334
5972
  init_is_browser();
5335
- init_globals3();
5336
5973
  VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
5337
5974
  isBrowser4 = isBrowser3();
5338
5975
  }
5339
5976
  });
5340
5977
 
5341
- // ../../node_modules/probe.gl/dist/esm/utils/local-storage.js
5978
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js
5979
+ var init_dist3 = __esm({
5980
+ "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js"() {
5981
+ init_globals4();
5982
+ init_globals3();
5983
+ init_is_browser();
5984
+ }
5985
+ });
5986
+
5987
+ // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
5342
5988
  function getStorage(type) {
5343
5989
  try {
5344
5990
  const storage = window[type];
@@ -5352,29 +5998,28 @@
5352
5998
  }
5353
5999
  var LocalStorage;
5354
6000
  var init_local_storage = __esm({
5355
- "../../node_modules/probe.gl/dist/esm/utils/local-storage.js"() {
6001
+ "../../node_modules/@probe.gl/log/dist/utils/local-storage.js"() {
6002
+ init_defineProperty();
5356
6003
  LocalStorage = class {
5357
- constructor(id, defaultSettings, type = "sessionStorage") {
6004
+ constructor(id, defaultConfig) {
6005
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
6006
+ _defineProperty(this, "storage", void 0);
6007
+ _defineProperty(this, "id", void 0);
6008
+ _defineProperty(this, "config", void 0);
5358
6009
  this.storage = getStorage(type);
5359
6010
  this.id = id;
5360
- this.config = {};
5361
- Object.assign(this.config, defaultSettings);
6011
+ this.config = defaultConfig;
5362
6012
  this._loadConfiguration();
5363
6013
  }
5364
6014
  getConfiguration() {
5365
6015
  return this.config;
5366
6016
  }
5367
6017
  setConfiguration(configuration) {
5368
- this.config = {};
5369
- return this.updateConfiguration(configuration);
5370
- }
5371
- updateConfiguration(configuration) {
5372
6018
  Object.assign(this.config, configuration);
5373
6019
  if (this.storage) {
5374
6020
  const serialized = JSON.stringify(this.config);
5375
6021
  this.storage.setItem(this.id, serialized);
5376
6022
  }
5377
- return this;
5378
6023
  }
5379
6024
  _loadConfiguration() {
5380
6025
  let configuration = {};
@@ -5389,7 +6034,7 @@
5389
6034
  }
5390
6035
  });
5391
6036
 
5392
- // ../../node_modules/probe.gl/dist/esm/utils/formatters.js
6037
+ // ../../node_modules/@probe.gl/log/dist/utils/formatters.js
5393
6038
  function formatTime(ms) {
5394
6039
  let formatted;
5395
6040
  if (ms < 10) {
@@ -5403,11 +6048,13 @@
5403
6048
  }
5404
6049
  return formatted;
5405
6050
  }
5406
- function leftPad(string, length4 = 8) {
6051
+ function leftPad(string) {
6052
+ let length4 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
5407
6053
  const padLength = Math.max(length4 - string.length, 0);
5408
6054
  return "".concat(" ".repeat(padLength)).concat(string);
5409
6055
  }
5410
- function formatImage(image, message, scale5, maxWidth = 600) {
6056
+ function formatImage(image, message, scale5) {
6057
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
5411
6058
  const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
5412
6059
  if (image.width > maxWidth) {
5413
6060
  scale5 = Math.min(scale5, maxWidth / image.width);
@@ -5418,109 +6065,111 @@
5418
6065
  return ["".concat(message, " %c+"), style];
5419
6066
  }
5420
6067
  var init_formatters = __esm({
5421
- "../../node_modules/probe.gl/dist/esm/utils/formatters.js"() {
6068
+ "../../node_modules/@probe.gl/log/dist/utils/formatters.js"() {
5422
6069
  }
5423
6070
  });
5424
6071
 
5425
- // ../../node_modules/probe.gl/dist/esm/utils/color.js
6072
+ // ../../node_modules/@probe.gl/log/dist/utils/color.js
5426
6073
  function getColor(color) {
5427
- return typeof color === "string" ? COLOR[color.toUpperCase()] || COLOR.WHITE : color;
6074
+ if (typeof color !== "string") {
6075
+ return color;
6076
+ }
6077
+ color = color.toUpperCase();
6078
+ return COLOR[color] || COLOR.WHITE;
5428
6079
  }
5429
6080
  function addColor(string, color, background) {
5430
- if (!isBrowser4 && typeof string === "string") {
6081
+ if (!isBrowser3 && typeof string === "string") {
5431
6082
  if (color) {
5432
- color = getColor(color);
5433
- string = "[".concat(color, "m").concat(string, "");
6083
+ const colorCode = getColor(color);
6084
+ string = "[".concat(colorCode, "m").concat(string, "");
5434
6085
  }
5435
6086
  if (background) {
5436
- color = getColor(background);
5437
- string = "[".concat(background + 10, "m").concat(string, "");
6087
+ const colorCode = getColor(background);
6088
+ string = "[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "");
5438
6089
  }
5439
6090
  }
5440
6091
  return string;
5441
6092
  }
5442
- var COLOR;
6093
+ var COLOR, BACKGROUND_INCREMENT;
5443
6094
  var init_color = __esm({
5444
- "../../node_modules/probe.gl/dist/esm/utils/color.js"() {
5445
- init_globals4();
5446
- COLOR = {
5447
- BLACK: 30,
5448
- RED: 31,
5449
- GREEN: 32,
5450
- YELLOW: 33,
5451
- BLUE: 34,
5452
- MAGENTA: 35,
5453
- CYAN: 36,
5454
- WHITE: 37,
5455
- BRIGHT_BLACK: 90,
5456
- BRIGHT_RED: 91,
5457
- BRIGHT_GREEN: 92,
5458
- BRIGHT_YELLOW: 93,
5459
- BRIGHT_BLUE: 94,
5460
- BRIGHT_MAGENTA: 95,
5461
- BRIGHT_CYAN: 96,
5462
- BRIGHT_WHITE: 97
5463
- };
6095
+ "../../node_modules/@probe.gl/log/dist/utils/color.js"() {
6096
+ init_dist3();
6097
+ (function(COLOR2) {
6098
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
6099
+ COLOR2[COLOR2["RED"] = 31] = "RED";
6100
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
6101
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
6102
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
6103
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
6104
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
6105
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
6106
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
6107
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
6108
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
6109
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
6110
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
6111
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
6112
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
6113
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
6114
+ })(COLOR || (COLOR = {}));
6115
+ BACKGROUND_INCREMENT = 10;
5464
6116
  }
5465
6117
  });
5466
6118
 
5467
- // ../../node_modules/probe.gl/dist/esm/utils/autobind.js
5468
- function autobind(obj, predefined = ["constructor"]) {
6119
+ // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
6120
+ function autobind(obj) {
6121
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
5469
6122
  const proto = Object.getPrototypeOf(obj);
5470
6123
  const propNames = Object.getOwnPropertyNames(proto);
6124
+ const object = obj;
5471
6125
  for (const key of propNames) {
5472
- if (typeof obj[key] === "function") {
6126
+ const value = object[key];
6127
+ if (typeof value === "function") {
5473
6128
  if (!predefined.find((name) => key === name)) {
5474
- obj[key] = obj[key].bind(obj);
6129
+ object[key] = value.bind(obj);
5475
6130
  }
5476
6131
  }
5477
6132
  }
5478
6133
  }
5479
6134
  var init_autobind = __esm({
5480
- "../../node_modules/probe.gl/dist/esm/utils/autobind.js"() {
6135
+ "../../node_modules/@probe.gl/log/dist/utils/autobind.js"() {
5481
6136
  }
5482
6137
  });
5483
6138
 
5484
- // ../../node_modules/probe.gl/dist/esm/utils/assert.js
6139
+ // ../../node_modules/@probe.gl/log/dist/utils/assert.js
5485
6140
  function assert4(condition, message) {
5486
6141
  if (!condition) {
5487
6142
  throw new Error(message || "Assertion failed");
5488
6143
  }
5489
6144
  }
5490
6145
  var init_assert4 = __esm({
5491
- "../../node_modules/probe.gl/dist/esm/utils/assert.js"() {
6146
+ "../../node_modules/@probe.gl/log/dist/utils/assert.js"() {
5492
6147
  }
5493
6148
  });
5494
6149
 
5495
- // ../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js
5496
- function getHiResTimestamp2() {
6150
+ // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
6151
+ function getHiResTimestamp3() {
5497
6152
  let timestamp;
5498
- if (isBrowser4 && window_3.performance) {
5499
- timestamp = window_3.performance.now();
5500
- } else if (process_.hrtime) {
5501
- const timeParts = process_.hrtime();
6153
+ if (isBrowser3() && window_3.performance) {
6154
+ var _window$performance, _window$performance$n;
6155
+ timestamp = window_3 === null || window_3 === void 0 ? void 0 : (_window$performance = window_3.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
6156
+ } else if ("hrtime" in process_) {
6157
+ var _process$hrtime;
6158
+ const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
5502
6159
  timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
5503
6160
  } else {
5504
6161
  timestamp = Date.now();
5505
6162
  }
5506
6163
  return timestamp;
5507
6164
  }
5508
- var init_hi_res_timestamp2 = __esm({
5509
- "../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js"() {
5510
- init_globals4();
6165
+ var init_hi_res_timestamp3 = __esm({
6166
+ "../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js"() {
6167
+ init_dist3();
5511
6168
  }
5512
6169
  });
5513
6170
 
5514
- // ../../node_modules/probe.gl/dist/esm/lib/log.js
5515
- function noop2() {
5516
- }
5517
- function getTableHeader(table) {
5518
- for (const key in table) {
5519
- for (const title in table[key]) {
5520
- return title || "untitled";
5521
- }
5522
- }
5523
- return "empty";
6171
+ // ../../node_modules/@probe.gl/log/dist/log.js
6172
+ function noop() {
5524
6173
  }
5525
6174
  function normalizeLogLevel(logLevel) {
5526
6175
  if (!logLevel) {
@@ -5549,7 +6198,6 @@
5549
6198
  const args = opts.args ? Array.from(opts.args) : [];
5550
6199
  while (args.length && args.shift() !== message) {
5551
6200
  }
5552
- opts.args = args;
5553
6201
  switch (typeof logLevel) {
5554
6202
  case "string":
5555
6203
  case "function":
@@ -5568,7 +6216,9 @@
5568
6216
  }
5569
6217
  const messageType = typeof opts.message;
5570
6218
  assert4(messageType === "string" || messageType === "object");
5571
- return Object.assign(opts, opts.opts);
6219
+ return Object.assign(opts, {
6220
+ args
6221
+ }, opts.opts);
5572
6222
  }
5573
6223
  function decorateMessage(id, message, opts) {
5574
6224
  if (typeof message === "string") {
@@ -5578,29 +6228,21 @@
5578
6228
  }
5579
6229
  return message;
5580
6230
  }
5581
- function logImageInNode({
5582
- image,
5583
- message = "",
5584
- scale: scale5 = 1
5585
- }) {
5586
- let asciify = null;
5587
- try {
5588
- asciify = module.require("asciify-image");
5589
- } catch (error) {
5590
- }
5591
- if (asciify) {
5592
- return () => asciify(image, {
5593
- fit: "box",
5594
- width: "".concat(Math.round(80 * scale5), "%")
5595
- }).then((data) => console.log(data));
5596
- }
5597
- return noop2;
5598
- }
5599
- function logImageInBrowser({
5600
- image,
5601
- message = "",
5602
- scale: scale5 = 1
5603
- }) {
6231
+ function logImageInNode(_ref2) {
6232
+ let {
6233
+ image,
6234
+ message = "",
6235
+ scale: scale5 = 1
6236
+ } = _ref2;
6237
+ console.warn("removed");
6238
+ return noop;
6239
+ }
6240
+ function logImageInBrowser(_ref3) {
6241
+ let {
6242
+ image,
6243
+ message = "",
6244
+ scale: scale5 = 1
6245
+ } = _ref3;
5604
6246
  if (typeof image === "string") {
5605
6247
  const img = new Image();
5606
6248
  img.onload = () => {
@@ -5608,39 +6250,48 @@
5608
6250
  console.log(...args);
5609
6251
  };
5610
6252
  img.src = image;
5611
- return noop2;
6253
+ return noop;
5612
6254
  }
5613
6255
  const element = image.nodeName || "";
5614
6256
  if (element.toLowerCase() === "img") {
5615
6257
  console.log(...formatImage(image, message, scale5));
5616
- return noop2;
6258
+ return noop;
5617
6259
  }
5618
6260
  if (element.toLowerCase() === "canvas") {
5619
6261
  const img = new Image();
5620
6262
  img.onload = () => console.log(...formatImage(img, message, scale5));
5621
6263
  img.src = image.toDataURL();
5622
- return noop2;
6264
+ return noop;
6265
+ }
6266
+ return noop;
6267
+ }
6268
+ function getTableHeader(table) {
6269
+ for (const key in table) {
6270
+ for (const title in table[key]) {
6271
+ return title || "untitled";
6272
+ }
5623
6273
  }
5624
- return noop2;
6274
+ return "empty";
5625
6275
  }
5626
- var originalConsole, DEFAULT_SETTINGS, cache, ONCE, Log;
6276
+ var originalConsole, DEFAULT_LOG_CONFIGURATION, cache, ONCE, Log;
5627
6277
  var init_log = __esm({
5628
- "../../node_modules/probe.gl/dist/esm/lib/log.js"() {
5629
- init_globals4();
6278
+ "../../node_modules/@probe.gl/log/dist/log.js"() {
6279
+ init_defineProperty();
6280
+ init_dist3();
5630
6281
  init_local_storage();
5631
6282
  init_formatters();
5632
6283
  init_color();
5633
6284
  init_autobind();
5634
6285
  init_assert4();
5635
- init_hi_res_timestamp2();
6286
+ init_hi_res_timestamp3();
5636
6287
  originalConsole = {
5637
- debug: isBrowser4 ? console.debug || console.log : console.log,
6288
+ debug: isBrowser3() ? console.debug || console.log : console.log,
5638
6289
  log: console.log,
5639
6290
  info: console.info,
5640
6291
  warn: console.warn,
5641
6292
  error: console.error
5642
6293
  };
5643
- DEFAULT_SETTINGS = {
6294
+ DEFAULT_LOG_CONFIGURATION = {
5644
6295
  enabled: true,
5645
6296
  level: 0
5646
6297
  };
@@ -5649,18 +6300,22 @@
5649
6300
  once: true
5650
6301
  };
5651
6302
  Log = class {
5652
- constructor({
5653
- id
5654
- } = {
5655
- id: ""
5656
- }) {
6303
+ constructor() {
6304
+ let {
6305
+ id
6306
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
6307
+ id: ""
6308
+ };
6309
+ _defineProperty(this, "id", void 0);
6310
+ _defineProperty(this, "VERSION", VERSION2);
6311
+ _defineProperty(this, "_startTs", getHiResTimestamp3());
6312
+ _defineProperty(this, "_deltaTs", getHiResTimestamp3());
6313
+ _defineProperty(this, "_storage", void 0);
6314
+ _defineProperty(this, "userData", {});
6315
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
5657
6316
  this.id = id;
5658
- this.VERSION = VERSION2;
5659
- this._startTs = getHiResTimestamp2();
5660
- this._deltaTs = getHiResTimestamp2();
5661
- this.LOG_THROTTLE_TIMEOUT = 0;
5662
- this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS);
5663
6317
  this.userData = {};
6318
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
5664
6319
  this.timeStamp("".concat(this.id, " started"));
5665
6320
  autobind(this);
5666
6321
  Object.seal(this);
@@ -5678,10 +6333,10 @@
5678
6333
  return this._storage.config.level;
5679
6334
  }
5680
6335
  getTotal() {
5681
- return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
6336
+ return Number((getHiResTimestamp3() - this._startTs).toPrecision(10));
5682
6337
  }
5683
6338
  getDelta() {
5684
- return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
6339
+ return Number((getHiResTimestamp3() - this._deltaTs).toPrecision(10));
5685
6340
  }
5686
6341
  set priority(newPriority) {
5687
6342
  this.level = newPriority;
@@ -5692,18 +6347,34 @@
5692
6347
  getPriority() {
5693
6348
  return this.level;
5694
6349
  }
5695
- enable(enabled = true) {
5696
- this._storage.updateConfiguration({
6350
+ enable() {
6351
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
6352
+ this._storage.setConfiguration({
5697
6353
  enabled
5698
6354
  });
5699
6355
  return this;
5700
6356
  }
5701
6357
  setLevel(level) {
5702
- this._storage.updateConfiguration({
6358
+ this._storage.setConfiguration({
5703
6359
  level
5704
6360
  });
5705
6361
  return this;
5706
6362
  }
6363
+ get(setting) {
6364
+ return this._storage.config[setting];
6365
+ }
6366
+ set(setting, value) {
6367
+ this._storage.setConfiguration({
6368
+ [setting]: value
6369
+ });
6370
+ }
6371
+ settings() {
6372
+ if (console.table) {
6373
+ console.table(this._storage.config);
6374
+ } else {
6375
+ console.log(this._storage.config);
6376
+ }
6377
+ }
5707
6378
  assert(condition, message) {
5708
6379
  assert4(condition, message);
5709
6380
  }
@@ -5736,23 +6407,24 @@
5736
6407
  }
5737
6408
  table(logLevel, table, columns) {
5738
6409
  if (table) {
5739
- return this._getLogFunction(logLevel, table, console.table || noop2, columns && [columns], {
6410
+ return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
5740
6411
  tag: getTableHeader(table)
5741
6412
  });
5742
6413
  }
5743
- return noop2;
6414
+ return noop;
5744
6415
  }
5745
- image({
5746
- logLevel,
5747
- priority,
5748
- image,
5749
- message = "",
5750
- scale: scale5 = 1
5751
- }) {
6416
+ image(_ref) {
6417
+ let {
6418
+ logLevel,
6419
+ priority,
6420
+ image,
6421
+ message = "",
6422
+ scale: scale5 = 1
6423
+ } = _ref;
5752
6424
  if (!this._shouldLog(logLevel || priority)) {
5753
- return noop2;
6425
+ return noop;
5754
6426
  }
5755
- return isBrowser4 ? logImageInBrowser({
6427
+ return isBrowser3() ? logImageInBrowser({
5756
6428
  image,
5757
6429
  message,
5758
6430
  scale: scale5
@@ -5762,21 +6434,6 @@
5762
6434
  scale: scale5
5763
6435
  });
5764
6436
  }
5765
- settings() {
5766
- if (console.table) {
5767
- console.table(this._storage.config);
5768
- } else {
5769
- console.log(this._storage.config);
5770
- }
5771
- }
5772
- get(setting) {
5773
- return this._storage.config[setting];
5774
- }
5775
- set(setting, value) {
5776
- this._storage.updateConfiguration({
5777
- [setting]: value
5778
- });
5779
- }
5780
6437
  time(logLevel, message) {
5781
6438
  return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
5782
6439
  }
@@ -5784,12 +6441,13 @@
5784
6441
  return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
5785
6442
  }
5786
6443
  timeStamp(logLevel, message) {
5787
- return this._getLogFunction(logLevel, message, console.timeStamp || noop2);
6444
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop);
5788
6445
  }
5789
- group(logLevel, message, opts = {
5790
- collapsed: false
5791
- }) {
5792
- opts = normalizeArguments({
6446
+ group(logLevel, message) {
6447
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
6448
+ collapsed: false
6449
+ };
6450
+ const options = normalizeArguments({
5793
6451
  logLevel,
5794
6452
  message,
5795
6453
  opts
@@ -5797,16 +6455,17 @@
5797
6455
  const {
5798
6456
  collapsed
5799
6457
  } = opts;
5800
- opts.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
5801
- return this._getLogFunction(opts);
6458
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
6459
+ return this._getLogFunction(options);
5802
6460
  }
5803
- groupCollapsed(logLevel, message, opts = {}) {
6461
+ groupCollapsed(logLevel, message) {
6462
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
5804
6463
  return this.group(logLevel, message, Object.assign({}, opts, {
5805
6464
  collapsed: true
5806
6465
  }));
5807
6466
  }
5808
6467
  groupEnd(logLevel) {
5809
- return this._getLogFunction(logLevel, "", console.groupEnd || noop2);
6468
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop);
5810
6469
  }
5811
6470
  withGroup(logLevel, message, func) {
5812
6471
  this.group(logLevel, message)();
@@ -5824,7 +6483,7 @@
5824
6483
  _shouldLog(logLevel) {
5825
6484
  return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
5826
6485
  }
5827
- _getLogFunction(logLevel, message, method, args = [], opts) {
6486
+ _getLogFunction(logLevel, message, method, args, opts) {
5828
6487
  if (this._shouldLog(logLevel)) {
5829
6488
  opts = normalizeArguments({
5830
6489
  logLevel,
@@ -5836,63 +6495,33 @@
5836
6495
  assert4(method);
5837
6496
  opts.total = this.getTotal();
5838
6497
  opts.delta = this.getDelta();
5839
- this._deltaTs = getHiResTimestamp2();
6498
+ this._deltaTs = getHiResTimestamp3();
5840
6499
  const tag = opts.tag || opts.message;
5841
- if (opts.once) {
6500
+ if (opts.once && tag) {
5842
6501
  if (!cache[tag]) {
5843
- cache[tag] = getHiResTimestamp2();
6502
+ cache[tag] = getHiResTimestamp3();
5844
6503
  } else {
5845
- return noop2;
6504
+ return noop;
5846
6505
  }
5847
6506
  }
5848
6507
  message = decorateMessage(this.id, opts.message, opts);
5849
6508
  return method.bind(console, message, ...opts.args);
5850
6509
  }
5851
- return noop2;
6510
+ return noop;
5852
6511
  }
5853
6512
  };
5854
- Log.VERSION = VERSION2;
5855
- }
5856
- });
5857
-
5858
- // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
5859
- var init_hi_res_timestamp3 = __esm({
5860
- "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
5861
- }
5862
- });
5863
-
5864
- // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js
5865
- var init_stat2 = __esm({
5866
- "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
5867
- init_hi_res_timestamp3();
6513
+ _defineProperty(Log, "VERSION", VERSION2);
5868
6514
  }
5869
6515
  });
5870
6516
 
5871
- // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js
5872
- var init_stats2 = __esm({
5873
- "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
5874
- init_stat2();
5875
- }
5876
- });
5877
-
5878
- // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js
5879
- var init_esm5 = __esm({
5880
- "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js"() {
5881
- init_stats2();
5882
- init_stat2();
5883
- init_hi_res_timestamp3();
5884
- }
5885
- });
5886
-
5887
- // ../../node_modules/probe.gl/dist/esm/index.js
5888
- var esm_default;
5889
- var init_esm6 = __esm({
5890
- "../../node_modules/probe.gl/dist/esm/index.js"() {
6517
+ // ../../node_modules/@probe.gl/log/dist/index.js
6518
+ var dist_default;
6519
+ var init_dist4 = __esm({
6520
+ "../../node_modules/@probe.gl/log/dist/index.js"() {
5891
6521
  init_log();
5892
6522
  init_log();
5893
- init_esm5();
5894
- esm_default = new Log({
5895
- id: "probe.gl"
6523
+ dist_default = new Log({
6524
+ id: "@probe.gl/log"
5896
6525
  });
5897
6526
  }
5898
6527
  });
@@ -5901,7 +6530,7 @@
5901
6530
  var probeLog, NullLog, ConsoleLog;
5902
6531
  var init_loggers = __esm({
5903
6532
  "../core/src/lib/loader-utils/loggers.ts"() {
5904
- init_esm6();
6533
+ init_dist4();
5905
6534
  probeLog = new Log({ id: "loaders.gl" });
5906
6535
  NullLog = class {
5907
6536
  log() {
@@ -5945,6 +6574,7 @@
5945
6574
  var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
5946
6575
  var init_option_defaults = __esm({
5947
6576
  "../core/src/lib/loader-utils/option-defaults.ts"() {
6577
+ init_src2();
5948
6578
  init_loggers();
5949
6579
  DEFAULT_LOADER_OPTIONS = {
5950
6580
  fetch: null,
@@ -5955,7 +6585,8 @@
5955
6585
  worker: true,
5956
6586
  maxConcurrency: 3,
5957
6587
  maxMobileConcurrency: 1,
5958
- reuseWorkers: true,
6588
+ reuseWorkers: isBrowser,
6589
+ _nodeWorkers: false,
5959
6590
  _workerType: "",
5960
6591
  limit: 0,
5961
6592
  _limitMB: 0,
@@ -5997,20 +6628,6 @@
5997
6628
  validateOptions(options, loaders);
5998
6629
  return normalizeOptionsInternal(loader, options, url);
5999
6630
  }
6000
- function getFetchFunction(options, context) {
6001
- const globalOptions = getGlobalLoaderOptions();
6002
- const fetchOptions = options || globalOptions;
6003
- if (typeof fetchOptions.fetch === "function") {
6004
- return fetchOptions.fetch;
6005
- }
6006
- if (isObject(fetchOptions.fetch)) {
6007
- return (url) => fetchFile(url, fetchOptions);
6008
- }
6009
- if (context?.fetch) {
6010
- return context?.fetch;
6011
- }
6012
- return fetchFile;
6013
- }
6014
6631
  function validateOptions(options, loaders) {
6015
6632
  validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);
6016
6633
  for (const loader of loaders) {
@@ -6089,7 +6706,6 @@
6089
6706
  var init_option_utils = __esm({
6090
6707
  "../core/src/lib/loader-utils/option-utils.ts"() {
6091
6708
  init_is_type();
6092
- init_fetch_file();
6093
6709
  init_loggers();
6094
6710
  init_option_defaults();
6095
6711
  getGlobalLoaderOptions = () => {
@@ -6153,6 +6769,15 @@
6153
6769
  }
6154
6770
  });
6155
6771
 
6772
+ // ../core/src/lib/utils/log.ts
6773
+ var log;
6774
+ var init_log2 = __esm({
6775
+ "../core/src/lib/utils/log.ts"() {
6776
+ init_dist4();
6777
+ log = new Log({ id: "loaders.gl" });
6778
+ }
6779
+ });
6780
+
6156
6781
  // ../core/src/lib/api/select-loader.ts
6157
6782
  async function selectLoader(data, loaders = [], options, context) {
6158
6783
  if (!validHTTPResponse(data)) {
@@ -6193,16 +6818,26 @@
6193
6818
  return loader;
6194
6819
  }
6195
6820
  function selectLoaderInternal(data, loaders, options, context) {
6196
- const { url, type } = getResourceUrlAndType(data);
6197
- const testUrl = url || context?.url;
6821
+ const url = getResourceUrl(data);
6822
+ const type = getResourceMIMEType(data);
6823
+ const testUrl = stripQueryString(url) || context?.url;
6198
6824
  let loader = null;
6825
+ let reason = "";
6199
6826
  if (options?.mimeType) {
6200
6827
  loader = findLoaderByMIMEType(loaders, options?.mimeType);
6828
+ reason = `match forced by supplied MIME type ${options?.mimeType}`;
6201
6829
  }
6202
6830
  loader = loader || findLoaderByUrl(loaders, testUrl);
6831
+ reason = reason || (loader ? `matched url ${testUrl}` : "");
6203
6832
  loader = loader || findLoaderByMIMEType(loaders, type);
6833
+ reason = reason || (loader ? `matched MIME type ${type}` : "");
6204
6834
  loader = loader || findLoaderByInitialBytes(loaders, data);
6835
+ reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
6205
6836
  loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6837
+ reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6838
+ if (reason) {
6839
+ log.log(1, `selectLoader selected ${loader?.name}: ${reason}.`);
6840
+ }
6206
6841
  return loader;
6207
6842
  }
6208
6843
  function validHTTPResponse(data) {
@@ -6214,7 +6849,8 @@
6214
6849
  return true;
6215
6850
  }
6216
6851
  function getNoValidLoaderMessage(data) {
6217
- const { url, type } = getResourceUrlAndType(data);
6852
+ const url = getResourceUrl(data);
6853
+ const type = getResourceMIMEType(data);
6218
6854
  let message = "No valid loader found (";
6219
6855
  message += url ? `${path_exports.filename(url)}, ` : "no url provided, ";
6220
6856
  message += `MIME type: ${type ? `"${type}"` : "not provided"}, `;
@@ -6329,9 +6965,11 @@
6329
6965
  "../core/src/lib/api/select-loader.ts"() {
6330
6966
  init_src2();
6331
6967
  init_normalize_loader();
6968
+ init_log2();
6332
6969
  init_resource_utils();
6333
6970
  init_register_loaders();
6334
6971
  init_is_type();
6972
+ init_url_utils();
6335
6973
  EXT_PATTERN = /\.([^.]+)$/;
6336
6974
  }
6337
6975
  });
@@ -6411,7 +7049,7 @@
6411
7049
  if (done) {
6412
7050
  return;
6413
7051
  }
6414
- yield toArrayBuffer(value);
7052
+ yield toArrayBuffer2(value);
6415
7053
  }
6416
7054
  } catch (error) {
6417
7055
  reader.releaseLock();
@@ -6419,7 +7057,7 @@
6419
7057
  }
6420
7058
  async function* makeNodeStreamIterator(stream, options) {
6421
7059
  for await (const chunk of stream) {
6422
- yield toArrayBuffer(chunk);
7060
+ yield toArrayBuffer2(chunk);
6423
7061
  }
6424
7062
  }
6425
7063
  var init_make_stream_iterator = __esm({
@@ -6520,19 +7158,49 @@
6520
7158
  }
6521
7159
  });
6522
7160
 
7161
+ // ../core/src/lib/loader-utils/get-fetch-function.ts
7162
+ function getFetchFunction(options, context) {
7163
+ const globalOptions = getGlobalLoaderOptions();
7164
+ const fetchOptions = options || globalOptions;
7165
+ if (typeof fetchOptions.fetch === "function") {
7166
+ return fetchOptions.fetch;
7167
+ }
7168
+ if (isObject(fetchOptions.fetch)) {
7169
+ return (url) => fetchFile(url, fetchOptions);
7170
+ }
7171
+ if (context?.fetch) {
7172
+ return context?.fetch;
7173
+ }
7174
+ return fetchFile;
7175
+ }
7176
+ var init_get_fetch_function = __esm({
7177
+ "../core/src/lib/loader-utils/get-fetch-function.ts"() {
7178
+ init_is_type();
7179
+ init_fetch_file();
7180
+ init_option_utils();
7181
+ }
7182
+ });
7183
+
6523
7184
  // ../core/src/lib/loader-utils/loader-context.ts
6524
- function getLoaderContext(context, options, previousContext = null) {
6525
- if (previousContext) {
6526
- return previousContext;
7185
+ function getLoaderContext(context, options, parentContext) {
7186
+ if (parentContext) {
7187
+ return parentContext;
6527
7188
  }
6528
- const resolvedContext = {
7189
+ const newContext = {
6529
7190
  fetch: getFetchFunction(options, context),
6530
7191
  ...context
6531
7192
  };
6532
- if (!Array.isArray(resolvedContext.loaders)) {
6533
- resolvedContext.loaders = null;
7193
+ if (newContext.url) {
7194
+ const baseUrl = stripQueryString(newContext.url);
7195
+ newContext.baseUrl = baseUrl;
7196
+ newContext.queryString = extractQueryString(newContext.url);
7197
+ newContext.filename = path_exports.filename(baseUrl);
7198
+ newContext.baseUrl = path_exports.dirname(baseUrl);
6534
7199
  }
6535
- return resolvedContext;
7200
+ if (!Array.isArray(newContext.loaders)) {
7201
+ newContext.loaders = null;
7202
+ }
7203
+ return newContext;
6536
7204
  }
6537
7205
  function getLoadersFromContext(loaders, context) {
6538
7206
  if (!context && loaders && !Array.isArray(loaders)) {
@@ -6550,7 +7218,9 @@
6550
7218
  }
6551
7219
  var init_loader_context = __esm({
6552
7220
  "../core/src/lib/loader-utils/loader-context.ts"() {
6553
- init_option_utils();
7221
+ init_get_fetch_function();
7222
+ init_url_utils();
7223
+ init_src2();
6554
7224
  }
6555
7225
  });
6556
7226
 
@@ -6564,7 +7234,7 @@
6564
7234
  }
6565
7235
  data = await data;
6566
7236
  options = options || {};
6567
- const { url } = getResourceUrlAndType(data);
7237
+ const url = getResourceUrl(data);
6568
7238
  const typedLoaders = loaders;
6569
7239
  const candidateLoaders = getLoadersFromContext(typedLoaders, context);
6570
7240
  const loader = await selectLoader(data, candidateLoaders, options);
@@ -6572,11 +7242,17 @@
6572
7242
  return null;
6573
7243
  }
6574
7244
  options = normalizeOptions(options, loader, candidateLoaders, url);
6575
- context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context);
7245
+ context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context || null);
6576
7246
  return await parseWithLoader(loader, data, options, context);
6577
7247
  }
6578
7248
  async function parseWithLoader(loader, data, options, context) {
6579
7249
  validateWorkerVersion(loader);
7250
+ if (isResponse(data)) {
7251
+ const response = data;
7252
+ const { ok, redirected, status, statusText, type, url } = response;
7253
+ const headers = Object.fromEntries(response.headers.entries());
7254
+ context.response = { headers, ok, redirected, status, statusText, type, url };
7255
+ }
6580
7256
  data = await getArrayBufferOrStringFromData(data, loader, options);
6581
7257
  if (loader.parseTextSync && typeof data === "string") {
6582
7258
  options.dataType = "text";
@@ -6599,6 +7275,7 @@
6599
7275
  init_src();
6600
7276
  init_src2();
6601
7277
  init_normalize_loader();
7278
+ init_is_type();
6602
7279
  init_option_utils();
6603
7280
  init_get_data();
6604
7281
  init_loader_context();
@@ -6609,12 +7286,17 @@
6609
7286
 
6610
7287
  // ../core/src/lib/api/load.ts
6611
7288
  async function load(url, loaders, options, context) {
7289
+ let resolvedLoaders;
7290
+ let resolvedOptions;
6612
7291
  if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
7292
+ resolvedLoaders = [];
7293
+ resolvedOptions = loaders;
6613
7294
  context = void 0;
6614
- options = loaders;
6615
- loaders = void 0;
7295
+ } else {
7296
+ resolvedLoaders = loaders;
7297
+ resolvedOptions = options;
6616
7298
  }
6617
- const fetch2 = getFetchFunction(options);
7299
+ const fetch2 = getFetchFunction(resolvedOptions);
6618
7300
  let data = url;
6619
7301
  if (typeof url === "string") {
6620
7302
  data = await fetch2(url);
@@ -6622,13 +7304,13 @@
6622
7304
  if (isBlob(url)) {
6623
7305
  data = await fetch2(url);
6624
7306
  }
6625
- return await parse(data, loaders, options);
7307
+ return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions) : await parse(data, resolvedLoaders, resolvedOptions);
6626
7308
  }
6627
7309
  var init_load = __esm({
6628
7310
  "../core/src/lib/api/load.ts"() {
6629
7311
  init_is_type();
6630
7312
  init_normalize_loader();
6631
- init_option_utils();
7313
+ init_get_fetch_function();
6632
7314
  init_parse();
6633
7315
  }
6634
7316
  });
@@ -6679,7 +7361,7 @@
6679
7361
  });
6680
7362
 
6681
7363
  // src/tileset/helpers/bounding-volume.ts
6682
- function defined2(x) {
7364
+ function defined(x) {
6683
7365
  return x !== void 0 && x !== null;
6684
7366
  }
6685
7367
  function createBoundingVolume(boundingVolumeHeader, transform, result) {
@@ -6700,6 +7382,22 @@
6700
7382
  }
6701
7383
  throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box");
6702
7384
  }
7385
+ function getCartographicBounds(boundingVolumeHeader, boundingVolume) {
7386
+ if (boundingVolumeHeader.box) {
7387
+ return orientedBoundingBoxToCartographicBounds(boundingVolume);
7388
+ }
7389
+ if (boundingVolumeHeader.region) {
7390
+ const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
7391
+ return [
7392
+ [degrees(west), degrees(south), minHeight],
7393
+ [degrees(east), degrees(north), maxHeight]
7394
+ ];
7395
+ }
7396
+ if (boundingVolumeHeader.sphere) {
7397
+ return boundingSphereToCartographicBounds(boundingVolume);
7398
+ }
7399
+ throw new Error("Unkown boundingVolume type");
7400
+ }
6703
7401
  function createBox(box, transform, result) {
6704
7402
  const center = new Vector3(box[0], box[1], box[2]);
6705
7403
  transform.transform(center, center);
@@ -6735,7 +7433,7 @@
6735
7433
  zAxis[1],
6736
7434
  zAxis[2]
6737
7435
  ]);
6738
- if (defined2(result)) {
7436
+ if (defined(result)) {
6739
7437
  result.center = center;
6740
7438
  result.halfAxes = halfAxes;
6741
7439
  return result;
@@ -6748,20 +7446,86 @@
6748
7446
  const scale5 = transform.getScale(scratchScale);
6749
7447
  const uniformScale = Math.max(Math.max(scale5[0], scale5[1]), scale5[2]);
6750
7448
  const radius = sphere[3] * uniformScale;
6751
- if (defined2(result)) {
7449
+ if (defined(result)) {
6752
7450
  result.center = center;
6753
7451
  result.radius = radius;
6754
7452
  return result;
6755
7453
  }
6756
7454
  return new BoundingSphere(center, radius);
6757
7455
  }
6758
- var scratchScale, scratchNorthWest, scratchSouthEast;
7456
+ function orientedBoundingBoxToCartographicBounds(boundingVolume) {
7457
+ const result = emptyCartographicBounds();
7458
+ const { halfAxes } = boundingVolume;
7459
+ const xAxis = new Vector3(halfAxes.getColumn(0));
7460
+ const yAxis = new Vector3(halfAxes.getColumn(1));
7461
+ const zAxis = new Vector3(halfAxes.getColumn(2));
7462
+ for (let x = 0; x < 2; x++) {
7463
+ for (let y = 0; y < 2; y++) {
7464
+ for (let z = 0; z < 2; z++) {
7465
+ scratchPoint.copy(boundingVolume.center);
7466
+ scratchPoint.add(xAxis);
7467
+ scratchPoint.add(yAxis);
7468
+ scratchPoint.add(zAxis);
7469
+ addToCartographicBounds(result, scratchPoint);
7470
+ zAxis.negate();
7471
+ }
7472
+ yAxis.negate();
7473
+ }
7474
+ xAxis.negate();
7475
+ }
7476
+ return result;
7477
+ }
7478
+ function boundingSphereToCartographicBounds(boundingVolume) {
7479
+ const result = emptyCartographicBounds();
7480
+ const { center, radius } = boundingVolume;
7481
+ const point = Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);
7482
+ let zAxis;
7483
+ if (point) {
7484
+ zAxis = Ellipsoid.WGS84.geodeticSurfaceNormal(point);
7485
+ } else {
7486
+ zAxis = new Vector3(0, 0, 1);
7487
+ }
7488
+ let xAxis = new Vector3(zAxis[2], -zAxis[1], 0);
7489
+ if (xAxis.len() > 0) {
7490
+ xAxis.normalize();
7491
+ } else {
7492
+ xAxis = new Vector3(0, 1, 0);
7493
+ }
7494
+ const yAxis = xAxis.clone().cross(zAxis);
7495
+ for (const axis of [xAxis, yAxis, zAxis]) {
7496
+ scratchScale.copy(axis).scale(radius);
7497
+ for (let dir = 0; dir < 2; dir++) {
7498
+ scratchPoint.copy(center);
7499
+ scratchPoint.add(scratchScale);
7500
+ addToCartographicBounds(result, scratchPoint);
7501
+ scratchScale.negate();
7502
+ }
7503
+ }
7504
+ return result;
7505
+ }
7506
+ function emptyCartographicBounds() {
7507
+ return [
7508
+ [Infinity, Infinity, Infinity],
7509
+ [-Infinity, -Infinity, -Infinity]
7510
+ ];
7511
+ }
7512
+ function addToCartographicBounds(target, cartesian) {
7513
+ Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);
7514
+ target[0][0] = Math.min(target[0][0], scratchPoint[0]);
7515
+ target[0][1] = Math.min(target[0][1], scratchPoint[1]);
7516
+ target[0][2] = Math.min(target[0][2], scratchPoint[2]);
7517
+ target[1][0] = Math.max(target[1][0], scratchPoint[0]);
7518
+ target[1][1] = Math.max(target[1][1], scratchPoint[1]);
7519
+ target[1][2] = Math.max(target[1][2], scratchPoint[2]);
7520
+ }
7521
+ var scratchPoint, scratchScale, scratchNorthWest, scratchSouthEast;
6759
7522
  var init_bounding_volume = __esm({
6760
7523
  "src/tileset/helpers/bounding-volume.ts"() {
6761
7524
  init_esm();
6762
- init_esm4();
7525
+ init_esm3();
6763
7526
  init_esm2();
6764
7527
  init_src2();
7528
+ scratchPoint = new Vector3();
6765
7529
  scratchScale = new Vector3();
6766
7530
  scratchNorthWest = new Vector3();
6767
7531
  scratchSouthEast = new Vector3();
@@ -6826,39 +7590,43 @@
6826
7590
  return "OUT";
6827
7591
  }
6828
7592
  function getProjectedRadius(tile, frameState) {
6829
- const originalViewport = frameState.viewport;
6830
- const ViewportClass = originalViewport.constructor;
6831
- const { longitude, latitude, height, width, bearing, zoom } = originalViewport;
6832
- const viewport = new ViewportClass({ longitude, latitude, height, width, bearing, zoom, pitch: 0 });
7593
+ const { topDownViewport: viewport } = frameState;
6833
7594
  const mbsLat = tile.header.mbs[1];
6834
7595
  const mbsLon = tile.header.mbs[0];
6835
7596
  const mbsZ = tile.header.mbs[2];
6836
7597
  const mbsR = tile.header.mbs[3];
6837
7598
  const mbsCenterCartesian = [...tile.boundingVolume.center];
6838
7599
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
6839
- const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
6840
- const toEye = new Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
6841
- const enuToCartesianMatrix = new Matrix4();
7600
+ Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);
7601
+ toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
6842
7602
  Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
6843
- const cartesianToEnuMatrix = new Matrix4(enuToCartesianMatrix).invert();
6844
- const cameraPositionEnu = new Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
7603
+ cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();
7604
+ cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);
6845
7605
  const projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
6846
7606
  const extraZ = projection * projection / cameraPositionEnu[2];
6847
- const extraVertexEnu = new Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
7607
+ extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
6848
7608
  const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
6849
- const extraVectorCartesian = new Vector3(extraVertexCartesian).subtract(mbsCenterCartesian).normalize();
7609
+ const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();
6850
7610
  const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
6851
- const sphereMbsBorderVertexCartesian = new Vector3(mbsCenterCartesian).add(radiusVector);
7611
+ const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);
6852
7612
  const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
6853
7613
  const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
6854
7614
  const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
6855
- const projectedRadius = new Vector3(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
7615
+ const projectedRadius = projectedOriginVector.copy(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
6856
7616
  return projectedRadius;
6857
7617
  }
7618
+ var cameraPositionCartesian, toEye, cameraPositionEnu, extraVertexEnu, projectedOriginVector, enuToCartesianMatrix, cartesianToEnuMatrix;
6858
7619
  var init_i3s_lod = __esm({
6859
7620
  "src/tileset/helpers/i3s-lod.ts"() {
6860
7621
  init_esm();
6861
7622
  init_esm2();
7623
+ cameraPositionCartesian = new Vector3();
7624
+ toEye = new Vector3();
7625
+ cameraPositionEnu = new Vector3();
7626
+ extraVertexEnu = new Vector3();
7627
+ projectedOriginVector = new Vector3();
7628
+ enuToCartesianMatrix = new Matrix4();
7629
+ cartesianToEnuMatrix = new Matrix4();
6862
7630
  }
6863
7631
  });
6864
7632
 
@@ -6962,10 +7730,10 @@
6962
7730
  }
6963
7731
  });
6964
7732
 
6965
- // src/tileset/traversers/tileset-traverser.ts
7733
+ // src/tileset/tileset-traverser.ts
6966
7734
  var DEFAULT_PROPS3, TilesetTraverser;
6967
7735
  var init_tileset_traverser = __esm({
6968
- "src/tileset/traversers/tileset-traverser.ts"() {
7736
+ "src/tileset/tileset-traverser.ts"() {
6969
7737
  init_managed_array();
6970
7738
  init_constants3();
6971
7739
  DEFAULT_PROPS3 = {
@@ -6980,14 +7748,19 @@
6980
7748
  };
6981
7749
  TilesetTraverser = class {
6982
7750
  constructor(options) {
6983
- this.options = { ...DEFAULT_PROPS3, ...options };
6984
- this._traversalStack = new ManagedArray();
6985
- this._emptyTraversalStack = new ManagedArray();
6986
- this._frameNumber = null;
6987
7751
  this.root = null;
6988
7752
  this.selectedTiles = {};
6989
7753
  this.requestedTiles = {};
6990
7754
  this.emptyTiles = {};
7755
+ this.lastUpdate = new Date().getTime();
7756
+ this.updateDebounceTime = 1e3;
7757
+ this._traversalStack = new ManagedArray();
7758
+ this._emptyTraversalStack = new ManagedArray();
7759
+ this._frameNumber = null;
7760
+ this.options = { ...DEFAULT_PROPS3, ...options };
7761
+ }
7762
+ traversalFinished(frameState) {
7763
+ return true;
6991
7764
  }
6992
7765
  traverse(root, frameState, options) {
6993
7766
  this.root = root;
@@ -7036,14 +7809,17 @@
7036
7809
  this.touchTile(tile, frameState);
7037
7810
  tile._shouldRefine = shouldRefine && parentRefines;
7038
7811
  }
7039
- this.options.onTraversalEnd(frameState);
7812
+ const newTime = new Date().getTime();
7813
+ if (this.traversalFinished(frameState) || newTime - this.lastUpdate > this.updateDebounceTime) {
7814
+ this.lastUpdate = newTime;
7815
+ this.options.onTraversalEnd(frameState);
7816
+ }
7040
7817
  }
7041
7818
  updateChildTiles(tile, frameState) {
7042
7819
  const children = tile.children;
7043
7820
  for (const child of children) {
7044
7821
  this.updateTile(child, frameState);
7045
7822
  }
7046
- return true;
7047
7823
  }
7048
7824
  updateAndPushChildren(tile, frameState, stack, depth) {
7049
7825
  const { loadSiblings, skipLevelOfDetail } = this.options;
@@ -7122,7 +7898,7 @@
7122
7898
  shouldSelectTile(tile) {
7123
7899
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
7124
7900
  }
7125
- shouldRefine(tile, frameState, useParentMetric) {
7901
+ shouldRefine(tile, frameState, useParentMetric = false) {
7126
7902
  let screenSpaceError = tile._screenSpaceError;
7127
7903
  if (useParentMetric) {
7128
7904
  screenSpaceError = tile.getScreenSpaceError(frameState, true);
@@ -7185,14 +7961,14 @@
7185
7961
  });
7186
7962
 
7187
7963
  // src/tileset/tile-3d.ts
7188
- function defined3(x) {
7964
+ function defined2(x) {
7189
7965
  return x !== void 0 && x !== null;
7190
7966
  }
7191
- var scratchVector9, TileHeader;
7967
+ var scratchVector9, Tile3D;
7192
7968
  var init_tile_3d = __esm({
7193
7969
  "src/tileset/tile-3d.ts"() {
7194
7970
  init_esm();
7195
- init_esm4();
7971
+ init_esm3();
7196
7972
  init_src3();
7197
7973
  init_constants3();
7198
7974
  init_bounding_volume();
@@ -7201,16 +7977,8 @@
7201
7977
  init_d_tiles_options();
7202
7978
  init_tileset_traverser();
7203
7979
  scratchVector9 = new Vector3();
7204
- TileHeader = class {
7980
+ Tile3D = class {
7205
7981
  constructor(tileset, header, parentHeader, extendedId = "") {
7206
- this.header = header;
7207
- this.tileset = tileset;
7208
- this.id = extendedId || header.id;
7209
- this.url = header.url;
7210
- this.parent = parentHeader;
7211
- this.refine = this._getRefine(header.refine);
7212
- this.type = header.type;
7213
- this.contentUrl = header.contentUrl;
7214
7982
  this.lodMetricType = "geometricError";
7215
7983
  this.lodMetricValue = 0;
7216
7984
  this.boundingVolume = null;
@@ -7218,39 +7986,47 @@
7218
7986
  this.contentState = TILE_CONTENT_STATE.UNLOADED;
7219
7987
  this.gpuMemoryUsageInBytes = 0;
7220
7988
  this.children = [];
7221
- this.hasEmptyContent = false;
7222
- this.hasTilesetContent = false;
7223
7989
  this.depth = 0;
7224
7990
  this.viewportIds = [];
7225
- this.userData = {};
7991
+ this.transform = new Matrix4();
7226
7992
  this.extensions = null;
7227
- this._priority = 0;
7228
- this._touchedFrame = 0;
7229
- this._visitedFrame = 0;
7230
- this._selectedFrame = 0;
7231
- this._requestedFrame = 0;
7232
- this._screenSpaceError = 0;
7993
+ this.implicitTiling = null;
7994
+ this.userData = {};
7995
+ this.hasEmptyContent = false;
7996
+ this.hasTilesetContent = false;
7997
+ this.traverser = new TilesetTraverser({});
7233
7998
  this._cacheNode = null;
7234
7999
  this._frameNumber = null;
7235
- this._cacheNode = null;
7236
- this.traverser = new TilesetTraverser({});
7237
- this._shouldRefine = false;
8000
+ this._expireDate = null;
8001
+ this._expiredContent = null;
7238
8002
  this._distanceToCamera = 0;
7239
- this._centerZDepth = 0;
8003
+ this._screenSpaceError = 0;
7240
8004
  this._visible = void 0;
7241
- this._inRequestVolume = false;
7242
- this._stackLength = 0;
7243
- this._selectionDepth = 0;
7244
8005
  this._initialTransform = new Matrix4();
7245
- this.transform = new Matrix4();
8006
+ this._priority = 0;
8007
+ this._selectedFrame = 0;
8008
+ this._requestedFrame = 0;
8009
+ this._selectionDepth = 0;
8010
+ this._touchedFrame = 0;
8011
+ this._centerZDepth = 0;
8012
+ this._shouldRefine = false;
8013
+ this._stackLength = 0;
8014
+ this._visitedFrame = 0;
8015
+ this._inRequestVolume = false;
8016
+ this._lodJudge = null;
8017
+ this.header = header;
8018
+ this.tileset = tileset;
8019
+ this.id = extendedId || header.id;
8020
+ this.url = header.url;
8021
+ this.parent = parentHeader;
8022
+ this.refine = this._getRefine(header.refine);
8023
+ this.type = header.type;
8024
+ this.contentUrl = header.contentUrl;
7246
8025
  this._initializeLodMetric(header);
7247
8026
  this._initializeTransforms(header);
7248
8027
  this._initializeBoundingVolumes(header);
7249
8028
  this._initializeContent(header);
7250
8029
  this._initializeRenderingState(header);
7251
- this._lodJudge = null;
7252
- this._expireDate = null;
7253
- this._expiredContent = null;
7254
8030
  Object.seal(this);
7255
8031
  }
7256
8032
  destroy() {
@@ -7292,6 +8068,18 @@
7292
8068
  get contentFailed() {
7293
8069
  return this.contentState === TILE_CONTENT_STATE.FAILED;
7294
8070
  }
8071
+ get distanceToCamera() {
8072
+ return this._distanceToCamera;
8073
+ }
8074
+ get screenSpaceError() {
8075
+ return this._screenSpaceError;
8076
+ }
8077
+ get boundingBox() {
8078
+ if (!this._boundingBox) {
8079
+ this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);
8080
+ }
8081
+ return this._boundingBox;
8082
+ }
7295
8083
  getScreenSpaceError(frameState, useParentLodMetric) {
7296
8084
  switch (this.tileset.type) {
7297
8085
  case TILESET_TYPE.I3S:
@@ -7302,6 +8090,12 @@
7302
8090
  throw new Error("Unsupported tileset type");
7303
8091
  }
7304
8092
  }
8093
+ unselect() {
8094
+ this._selectedFrame = 0;
8095
+ }
8096
+ _getGpuMemoryUsageInBytes() {
8097
+ return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
8098
+ }
7305
8099
  _getPriority() {
7306
8100
  const traverser = this.tileset._traverser;
7307
8101
  const { skipLevelOfDetail } = traverser.options;
@@ -7418,7 +8212,7 @@
7418
8212
  return !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0;
7419
8213
  }
7420
8214
  updateExpiration() {
7421
- if (defined3(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
8215
+ if (defined2(this._expireDate) && this.contentReady && !this.hasEmptyContent) {
7422
8216
  const now = Date.now();
7423
8217
  if (Date.lessThan(this._expireDate, now)) {
7424
8218
  this.contentState = TILE_CONTENT_STATE.EXPIRED;
@@ -7501,6 +8295,8 @@
7501
8295
  }
7502
8296
  if (this._isTileset()) {
7503
8297
  this.hasTilesetContent = true;
8298
+ } else {
8299
+ this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
7504
8300
  }
7505
8301
  }
7506
8302
  _updateBoundingVolume(header) {
@@ -7530,8 +8326,20 @@
7530
8326
  case "i3s":
7531
8327
  return {
7532
8328
  ...this.tileset.options.i3s,
7533
- tile: this.header,
7534
- tileset: this.tileset.tileset,
8329
+ _tileOptions: {
8330
+ attributeUrls: this.header.attributeUrls,
8331
+ textureUrl: this.header.textureUrl,
8332
+ textureFormat: this.header.textureFormat,
8333
+ textureLoaderOptions: this.header.textureLoaderOptions,
8334
+ materialDefinition: this.header.materialDefinition,
8335
+ isDracoGeometry: this.header.isDracoGeometry,
8336
+ mbs: this.header.mbs
8337
+ },
8338
+ _tilesetOptions: {
8339
+ store: this.tileset.tileset.store,
8340
+ attributeStorageInfo: this.tileset.tileset.attributeStorageInfo,
8341
+ fields: this.tileset.tileset.fields
8342
+ },
7535
8343
  isTileHeader: false
7536
8344
  };
7537
8345
  case "3d-tiles":
@@ -7544,10 +8352,10 @@
7544
8352
  }
7545
8353
  });
7546
8354
 
7547
- // src/tileset/traversers/tileset-3d-traverser.ts
8355
+ // src/tileset/format-3d-tiles/tileset-3d-traverser.ts
7548
8356
  var Tileset3DTraverser;
7549
8357
  var init_tileset_3d_traverser = __esm({
7550
- "src/tileset/traversers/tileset-3d-traverser.ts"() {
8358
+ "src/tileset/format-3d-tiles/tileset-3d-traverser.ts"() {
7551
8359
  init_constants3();
7552
8360
  init_tileset_traverser();
7553
8361
  Tileset3DTraverser = class extends TilesetTraverser {
@@ -7590,10 +8398,41 @@
7590
8398
  }
7591
8399
  });
7592
8400
 
7593
- // src/tileset/traversers/i3s-tile-manager.ts
8401
+ // src/tileset/format-i3s/i3s-pending-tiles-register.ts
8402
+ var I3SPendingTilesRegister;
8403
+ var init_i3s_pending_tiles_register = __esm({
8404
+ "src/tileset/format-i3s/i3s-pending-tiles-register.ts"() {
8405
+ I3SPendingTilesRegister = class {
8406
+ constructor() {
8407
+ this.frameNumberMap = new Map();
8408
+ }
8409
+ register(viewportId, frameNumber) {
8410
+ const viewportMap = this.frameNumberMap.get(viewportId) || new Map();
8411
+ const oldCount = viewportMap.get(frameNumber) || 0;
8412
+ viewportMap.set(frameNumber, oldCount + 1);
8413
+ this.frameNumberMap.set(viewportId, viewportMap);
8414
+ }
8415
+ deregister(viewportId, frameNumber) {
8416
+ const viewportMap = this.frameNumberMap.get(viewportId);
8417
+ if (!viewportMap) {
8418
+ return;
8419
+ }
8420
+ const oldCount = viewportMap.get(frameNumber) || 1;
8421
+ viewportMap.set(frameNumber, oldCount - 1);
8422
+ }
8423
+ isZero(viewportId, frameNumber) {
8424
+ const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;
8425
+ return count === 0;
8426
+ }
8427
+ };
8428
+ }
8429
+ });
8430
+
8431
+ // src/tileset/format-i3s/i3s-tile-manager.ts
7594
8432
  var STATUS, I3STileManager;
7595
8433
  var init_i3s_tile_manager = __esm({
7596
- "src/tileset/traversers/i3s-tile-manager.ts"() {
8434
+ "src/tileset/format-i3s/i3s-tile-manager.ts"() {
8435
+ init_i3s_pending_tiles_register();
7597
8436
  STATUS = {
7598
8437
  REQUESTED: "REQUESTED",
7599
8438
  COMPLETED: "COMPLETED",
@@ -7601,36 +8440,65 @@
7601
8440
  };
7602
8441
  I3STileManager = class {
7603
8442
  constructor() {
8443
+ this.pendingTilesRegister = new I3SPendingTilesRegister();
7604
8444
  this._statusMap = {};
7605
8445
  }
7606
8446
  add(request, key, callback, frameState) {
7607
8447
  if (!this._statusMap[key]) {
8448
+ const {
8449
+ frameNumber,
8450
+ viewport: { id }
8451
+ } = frameState;
7608
8452
  this._statusMap[key] = { request, callback, key, frameState, status: STATUS.REQUESTED };
8453
+ this.pendingTilesRegister.register(id, frameNumber);
7609
8454
  request().then((data) => {
7610
8455
  this._statusMap[key].status = STATUS.COMPLETED;
8456
+ const {
8457
+ frameNumber: actualFrameNumber,
8458
+ viewport: { id: id2 }
8459
+ } = this._statusMap[key].frameState;
8460
+ this.pendingTilesRegister.deregister(id2, actualFrameNumber);
7611
8461
  this._statusMap[key].callback(data, frameState);
7612
8462
  }).catch((error) => {
7613
8463
  this._statusMap[key].status = STATUS.ERROR;
8464
+ const {
8465
+ frameNumber: actualFrameNumber,
8466
+ viewport: { id: id2 }
8467
+ } = this._statusMap[key].frameState;
8468
+ this.pendingTilesRegister.deregister(id2, actualFrameNumber);
7614
8469
  callback(error);
7615
8470
  });
7616
8471
  }
7617
8472
  }
7618
8473
  update(key, frameState) {
7619
8474
  if (this._statusMap[key]) {
8475
+ const {
8476
+ frameNumber,
8477
+ viewport: { id }
8478
+ } = this._statusMap[key].frameState;
8479
+ this.pendingTilesRegister.deregister(id, frameNumber);
8480
+ const {
8481
+ frameNumber: newFrameNumber,
8482
+ viewport: { id: newViewportId }
8483
+ } = frameState;
8484
+ this.pendingTilesRegister.register(newViewportId, newFrameNumber);
7620
8485
  this._statusMap[key].frameState = frameState;
7621
8486
  }
7622
8487
  }
7623
8488
  find(key) {
7624
8489
  return this._statusMap[key];
7625
8490
  }
8491
+ hasPendingTiles(viewportId, frameNumber) {
8492
+ return !this.pendingTilesRegister.isZero(viewportId, frameNumber);
8493
+ }
7626
8494
  };
7627
8495
  }
7628
8496
  });
7629
8497
 
7630
- // src/tileset/traversers/i3s-tileset-traverser.ts
8498
+ // src/tileset/format-i3s/i3s-tileset-traverser.ts
7631
8499
  var I3STilesetTraverser;
7632
8500
  var init_i3s_tileset_traverser = __esm({
7633
- "src/tileset/traversers/i3s-tileset-traverser.ts"() {
8501
+ "src/tileset/format-i3s/i3s-tileset-traverser.ts"() {
7634
8502
  init_src3();
7635
8503
  init_tileset_traverser();
7636
8504
  init_i3s_lod();
@@ -7641,6 +8509,9 @@
7641
8509
  super(options);
7642
8510
  this._tileManager = new I3STileManager();
7643
8511
  }
8512
+ traversalFinished(frameState) {
8513
+ return !this._tileManager.hasPendingTiles(frameState.viewport.id, this._frameNumber || 0);
8514
+ }
7644
8515
  shouldRefine(tile, frameState) {
7645
8516
  tile._lodJudge = getLodStatus(tile, frameState);
7646
8517
  return tile._lodJudge === "DIG";
@@ -7676,18 +8547,17 @@
7676
8547
  ...tileset.loadOptions,
7677
8548
  i3s: {
7678
8549
  ...tileset.loadOptions.i3s,
7679
- isTileHeader: true,
7680
- loadContent: false
8550
+ isTileHeader: true
7681
8551
  }
7682
8552
  };
7683
8553
  return await load(nodeUrl, loader, options);
7684
8554
  }
7685
8555
  _onTileLoad(header, tile, extendedId) {
7686
- const childTile = new TileHeader(tile.tileset, header, tile, extendedId);
8556
+ const childTile = new Tile3D(tile.tileset, header, tile, extendedId);
7687
8557
  tile.children.push(childTile);
7688
8558
  const frameState = this._tileManager.find(childTile.id).frameState;
7689
8559
  this.updateTile(childTile, frameState);
7690
- if (this._frameNumber === frameState.frameNumber) {
8560
+ if (this._frameNumber === frameState.frameNumber && (this.traversalFinished(frameState) || new Date().getTime() - this.lastUpdate > this.updateDebounceTime)) {
7691
8561
  this.executeTraversal(childTile, frameState);
7692
8562
  }
7693
8563
  }
@@ -7696,36 +8566,22 @@
7696
8566
  });
7697
8567
 
7698
8568
  // src/tileset/tileset-3d.ts
7699
- function getQueryParamString(queryParams) {
7700
- const queryParamStrings = [];
7701
- for (const key of Object.keys(queryParams)) {
7702
- queryParamStrings.push(`${key}=${queryParams[key]}`);
7703
- }
7704
- switch (queryParamStrings.length) {
7705
- case 0:
7706
- return "";
7707
- case 1:
7708
- return `?${queryParamStrings[0]}`;
7709
- default:
7710
- return `?${queryParamStrings.join("&")}`;
7711
- }
7712
- }
7713
8569
  var DEFAULT_PROPS4, TILES_TOTAL, TILES_IN_MEMORY, TILES_IN_VIEW, TILES_RENDERABLE, TILES_LOADED, TILES_LOADING, TILES_UNLOADED, TILES_LOAD_FAILED, POINTS_COUNT, TILES_GPU_MEMORY, Tileset3D;
7714
8570
  var init_tileset_3d = __esm({
7715
8571
  "src/tileset/tileset-3d.ts"() {
7716
8572
  init_esm();
7717
8573
  init_esm2();
7718
- init_esm3();
8574
+ init_dist();
7719
8575
  init_src2();
7720
8576
  init_tileset_cache();
7721
8577
  init_transform_utils();
7722
8578
  init_frame_state();
7723
8579
  init_zoom();
7724
8580
  init_tile_3d();
7725
- init_tileset_3d_traverser();
8581
+ init_constants3();
7726
8582
  init_tileset_traverser();
8583
+ init_tileset_3d_traverser();
7727
8584
  init_i3s_tileset_traverser();
7728
- init_constants3();
7729
8585
  DEFAULT_PROPS4 = {
7730
8586
  description: "",
7731
8587
  ellipsoid: Ellipsoid.WGS84,
@@ -7733,6 +8589,8 @@
7733
8589
  throttleRequests: true,
7734
8590
  maxRequests: 64,
7735
8591
  maximumMemoryUsage: 32,
8592
+ maximumTilesSelected: 0,
8593
+ debounceTime: 0,
7736
8594
  onTileLoad: () => {
7737
8595
  },
7738
8596
  onTileUnload: () => {
@@ -7759,64 +8617,65 @@
7759
8617
  TILES_LOADING = "Tiles Loading";
7760
8618
  TILES_UNLOADED = "Tiles Unloaded";
7761
8619
  TILES_LOAD_FAILED = "Failed Tile Loads";
7762
- POINTS_COUNT = "Points";
8620
+ POINTS_COUNT = "Points/Vertices";
7763
8621
  TILES_GPU_MEMORY = "Tile Memory Use";
7764
8622
  Tileset3D = class {
7765
- constructor(json, options) {
7766
- assert2(json);
7767
- this.options = { ...DEFAULT_PROPS4, ...options };
7768
- this.tileset = json;
7769
- this.loader = json.loader;
7770
- this.type = json.type;
7771
- this.url = json.url;
7772
- this.basePath = json.basePath || path_exports.dirname(this.url);
7773
- this.modelMatrix = this.options.modelMatrix;
7774
- this.ellipsoid = this.options.ellipsoid;
7775
- this.lodMetricType = json.lodMetricType;
7776
- this.lodMetricValue = json.lodMetricValue;
7777
- this.refine = json.root.refine;
7778
- this.loadOptions = this.options.loadOptions || {};
8623
+ constructor(tileset, options) {
7779
8624
  this.root = null;
7780
8625
  this.roots = {};
8626
+ this.asset = {};
8627
+ this.description = "";
8628
+ this.extras = null;
8629
+ this.attributions = {};
8630
+ this.credits = {};
8631
+ this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
7781
8632
  this.cartographicCenter = null;
7782
8633
  this.cartesianCenter = null;
7783
8634
  this.zoom = 1;
7784
8635
  this.boundingVolume = null;
8636
+ this.dynamicScreenSpaceErrorComputedDensity = 0;
8637
+ this.maximumMemoryUsage = 32;
8638
+ this.gpuMemoryUsageInBytes = 0;
8639
+ this._frameNumber = 0;
8640
+ this._queryParams = {};
8641
+ this._extensionsUsed = [];
8642
+ this._tiles = {};
8643
+ this._pendingCount = 0;
8644
+ this.selectedTiles = [];
7785
8645
  this.traverseCounter = 0;
7786
8646
  this.geometricError = 0;
7787
- this._traverser = this._initializeTraverser();
8647
+ this.lastUpdatedVieports = null;
8648
+ this._requestedTiles = [];
8649
+ this._emptyTiles = [];
8650
+ this.frameStateData = {};
7788
8651
  this._cache = new TilesetCache();
8652
+ this.updatePromise = null;
8653
+ this.options = { ...DEFAULT_PROPS4, ...options };
8654
+ this.tileset = tileset;
8655
+ this.loader = tileset.loader;
8656
+ this.type = tileset.type;
8657
+ this.url = tileset.url;
8658
+ this.basePath = tileset.basePath || path_exports.dirname(this.url);
8659
+ this.modelMatrix = this.options.modelMatrix;
8660
+ this.ellipsoid = this.options.ellipsoid;
8661
+ this.lodMetricType = tileset.lodMetricType;
8662
+ this.lodMetricValue = tileset.lodMetricValue;
8663
+ this.refine = tileset.root.refine;
8664
+ this.loadOptions = this.options.loadOptions || {};
8665
+ this._traverser = this._initializeTraverser();
7789
8666
  this._requestScheduler = new RequestScheduler({
7790
8667
  throttleRequests: this.options.throttleRequests,
7791
8668
  maxRequests: this.options.maxRequests
7792
8669
  });
7793
- this._frameNumber = 0;
7794
- this._pendingCount = 0;
7795
- this._tiles = {};
7796
- this.selectedTiles = [];
7797
- this._emptyTiles = [];
7798
- this._requestedTiles = [];
7799
- this.frameStateData = {};
7800
- this.lastUpdatedVieports = null;
7801
- this._queryParams = {};
7802
- this._queryParamsString = "";
7803
- this.maximumMemoryUsage = this.options.maximumMemoryUsage || 32;
7804
- this.gpuMemoryUsageInBytes = 0;
7805
8670
  this.stats = new Stats({ id: this.url });
7806
8671
  this._initializeStats();
7807
- this._extensionsUsed = void 0;
7808
- this.dynamicScreenSpaceErrorComputedDensity = 0;
7809
- this.extras = null;
7810
- this.asset = {};
7811
- this.credits = {};
7812
- this.description = this.options.description || "";
7813
- this._initializeTileSet(json);
8672
+ this.tilesetInitializationPromise = this._initializeTileSet(tileset);
7814
8673
  }
7815
8674
  destroy() {
7816
8675
  this._destroy();
7817
8676
  }
7818
8677
  isLoaded() {
7819
- return this._pendingCount === 0 && this._frameNumber !== 0;
8678
+ return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;
7820
8679
  }
7821
8680
  get tiles() {
7822
8681
  return Object.values(this._tiles);
@@ -7825,10 +8684,7 @@
7825
8684
  return this._frameNumber;
7826
8685
  }
7827
8686
  get queryParams() {
7828
- if (!this._queryParamsString) {
7829
- this._queryParamsString = getQueryParamString(this._queryParams);
7830
- }
7831
- return this._queryParamsString;
8687
+ return new URLSearchParams(this._queryParams).toString();
7832
8688
  }
7833
8689
  setProps(props) {
7834
8690
  this.options = { ...this.options, ...props };
@@ -7841,31 +8697,54 @@
7841
8697
  if (isDataUrl) {
7842
8698
  return tilePath;
7843
8699
  }
7844
- return `${tilePath}${this.queryParams}`;
8700
+ return `${tilePath}${tilePath.includes("?") ? "&" : "?"}${this.queryParams}`;
7845
8701
  }
7846
8702
  hasExtension(extensionName) {
7847
- return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
8703
+ return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
8704
+ }
8705
+ update(viewports = null) {
8706
+ this.tilesetInitializationPromise.then(() => {
8707
+ if (!viewports && this.lastUpdatedVieports) {
8708
+ viewports = this.lastUpdatedVieports;
8709
+ } else {
8710
+ this.lastUpdatedVieports = viewports;
8711
+ }
8712
+ if (viewports) {
8713
+ this.doUpdate(viewports);
8714
+ }
8715
+ });
8716
+ }
8717
+ async selectTiles(viewports = null) {
8718
+ await this.tilesetInitializationPromise;
8719
+ if (viewports) {
8720
+ this.lastUpdatedVieports = viewports;
8721
+ }
8722
+ if (!this.updatePromise) {
8723
+ this.updatePromise = new Promise((resolve2) => {
8724
+ setTimeout(() => {
8725
+ if (this.lastUpdatedVieports) {
8726
+ this.doUpdate(this.lastUpdatedVieports);
8727
+ }
8728
+ resolve2(this._frameNumber);
8729
+ this.updatePromise = null;
8730
+ }, this.options.debounceTime);
8731
+ });
8732
+ }
8733
+ return this.updatePromise;
7848
8734
  }
7849
- update(viewports) {
8735
+ doUpdate(viewports) {
7850
8736
  if ("loadTiles" in this.options && !this.options.loadTiles) {
7851
8737
  return;
7852
8738
  }
7853
8739
  if (this.traverseCounter > 0) {
7854
8740
  return;
7855
8741
  }
7856
- if (!viewports && this.lastUpdatedVieports) {
7857
- viewports = this.lastUpdatedVieports;
7858
- } else {
7859
- this.lastUpdatedVieports = viewports;
7860
- }
7861
- if (!(viewports instanceof Array)) {
7862
- viewports = [viewports];
7863
- }
8742
+ const preparedViewports = viewports instanceof Array ? viewports : [viewports];
7864
8743
  this._cache.reset();
7865
8744
  this._frameNumber++;
7866
- this.traverseCounter = viewports.length;
8745
+ this.traverseCounter = preparedViewports.length;
7867
8746
  const viewportsToTraverse = [];
7868
- for (const viewport of viewports) {
8747
+ for (const viewport of preparedViewports) {
7869
8748
  const id = viewport.id;
7870
8749
  if (this._needTraverse(id)) {
7871
8750
  viewportsToTraverse.push(id);
@@ -7873,7 +8752,7 @@
7873
8752
  this.traverseCounter--;
7874
8753
  }
7875
8754
  }
7876
- for (const viewport of viewports) {
8755
+ for (const viewport of preparedViewports) {
7877
8756
  const id = viewport.id;
7878
8757
  if (!this.roots[id]) {
7879
8758
  this.roots[id] = this._initializeTileHeaders(this.tileset, null);
@@ -7902,7 +8781,11 @@
7902
8781
  }
7903
8782
  const currentFrameStateData = this.frameStateData[id];
7904
8783
  const selectedTiles = Object.values(this._traverser.selectedTiles);
7905
- currentFrameStateData.selectedTiles = selectedTiles;
8784
+ const [filteredSelectedTiles, unselectedTiles] = limitSelectedTiles(selectedTiles, frameState, this.options.maximumTilesSelected);
8785
+ currentFrameStateData.selectedTiles = filteredSelectedTiles;
8786
+ for (const tile of unselectedTiles) {
8787
+ tile.unselect();
8788
+ }
7906
8789
  currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
7907
8790
  currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
7908
8791
  this.traverseCounter--;
@@ -7957,6 +8840,8 @@
7957
8840
  tilesRenderable++;
7958
8841
  if (tile.content.pointCount) {
7959
8842
  pointsRenderable += tile.content.pointCount;
8843
+ } else {
8844
+ pointsRenderable += tile.content.vertexCount;
7960
8845
  }
7961
8846
  }
7962
8847
  }
@@ -7964,19 +8849,44 @@
7964
8849
  this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
7965
8850
  this.stats.get(POINTS_COUNT).count = pointsRenderable;
7966
8851
  }
7967
- _initializeTileSet(tilesetJson) {
8852
+ async _initializeTileSet(tilesetJson) {
8853
+ if (this.type === TILESET_TYPE.I3S) {
8854
+ this.calculateViewPropsI3S();
8855
+ tilesetJson.root = await tilesetJson.root;
8856
+ }
7968
8857
  this.root = this._initializeTileHeaders(tilesetJson, null);
7969
8858
  if (this.type === TILESET_TYPE.TILES3D) {
7970
- this._initializeCesiumTileset(tilesetJson);
8859
+ this._initializeTiles3DTileset(tilesetJson);
8860
+ this.calculateViewPropsTiles3D();
7971
8861
  }
7972
8862
  if (this.type === TILESET_TYPE.I3S) {
7973
8863
  this._initializeI3STileset();
7974
8864
  }
7975
- this._calculateViewProps();
7976
8865
  }
7977
- _calculateViewProps() {
8866
+ calculateViewPropsI3S() {
8867
+ const fullExtent = this.tileset.fullExtent;
8868
+ if (fullExtent) {
8869
+ const { xmin, xmax, ymin, ymax, zmin, zmax } = fullExtent;
8870
+ this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
8871
+ this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new Vector3());
8872
+ this.zoom = getZoomFromFullExtent(fullExtent, this.cartographicCenter, this.cartesianCenter);
8873
+ return;
8874
+ }
8875
+ const extent = this.tileset.store?.extent;
8876
+ if (extent) {
8877
+ const [xmin, ymin, xmax, ymax] = extent;
8878
+ this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
8879
+ this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new Vector3());
8880
+ this.zoom = getZoomFromExtent(extent, this.cartographicCenter, this.cartesianCenter);
8881
+ return;
8882
+ }
8883
+ console.warn("Extent is not defined in the tileset header");
8884
+ this.cartographicCenter = new Vector3();
8885
+ this.zoom = 1;
8886
+ return;
8887
+ }
8888
+ calculateViewPropsTiles3D() {
7978
8889
  const root = this.root;
7979
- assert2(root);
7980
8890
  const { center } = root.boundingVolume;
7981
8891
  if (!center) {
7982
8892
  console.warn("center was not pre-calculated for the root tile");
@@ -7984,9 +8894,13 @@
7984
8894
  this.zoom = 1;
7985
8895
  return;
7986
8896
  }
7987
- this.cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(center, new Vector3());
8897
+ if (center[0] !== 0 || center[1] !== 0 || center[2] !== 0) {
8898
+ this.cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(center, new Vector3());
8899
+ } else {
8900
+ this.cartographicCenter = new Vector3(0, 0, -Ellipsoid.WGS84.radii[0]);
8901
+ }
7988
8902
  this.cartesianCenter = center;
7989
- this.zoom = getZoomFromBoundingVolume(root.boundingVolume);
8903
+ this.zoom = getZoomFromBoundingVolume(root.boundingVolume, this.cartographicCenter);
7990
8904
  }
7991
8905
  _initializeStats() {
7992
8906
  this.stats.get(TILES_TOTAL);
@@ -7997,11 +8911,11 @@
7997
8911
  this.stats.get(TILES_LOADED);
7998
8912
  this.stats.get(TILES_UNLOADED);
7999
8913
  this.stats.get(TILES_LOAD_FAILED);
8000
- this.stats.get(POINTS_COUNT, "memory");
8914
+ this.stats.get(POINTS_COUNT);
8001
8915
  this.stats.get(TILES_GPU_MEMORY, "memory");
8002
8916
  }
8003
8917
  _initializeTileHeaders(tilesetJson, parentTileHeader) {
8004
- const rootTile = new TileHeader(this, tilesetJson.root, parentTileHeader);
8918
+ const rootTile = new Tile3D(this, tilesetJson.root, parentTileHeader);
8005
8919
  if (parentTileHeader) {
8006
8920
  parentTileHeader.children.push(rootTile);
8007
8921
  rootTile.depth = parentTileHeader.depth + 1;
@@ -8014,7 +8928,14 @@
8014
8928
  this.stats.get(TILES_TOTAL).incrementCount();
8015
8929
  const children = tile.header.children || [];
8016
8930
  for (const childHeader of children) {
8017
- const childTile = new TileHeader(this, childHeader, tile);
8931
+ const childTile = new Tile3D(this, childHeader, tile);
8932
+ if (childTile.contentUrl?.includes("?session=")) {
8933
+ const url = new URL(childTile.contentUrl);
8934
+ const session = url.searchParams.get("session");
8935
+ if (session) {
8936
+ this._queryParams.session = session;
8937
+ }
8938
+ }
8018
8939
  tile.children.push(childTile);
8019
8940
  childTile.depth = tile.depth + 1;
8020
8941
  stack.push(childTile);
@@ -8050,7 +8971,7 @@
8050
8971
  this._onStartTileLoading();
8051
8972
  loaded = await tile.loadContent();
8052
8973
  } catch (error) {
8053
- this._onTileLoadError(tile, error);
8974
+ this._onTileLoadError(tile, error instanceof Error ? error : new Error("load failed"));
8054
8975
  } finally {
8055
8976
  this._onEndTileLoading();
8056
8977
  this._onTileLoad(tile, loaded);
@@ -8067,12 +8988,45 @@
8067
8988
  if (!loaded) {
8068
8989
  return;
8069
8990
  }
8991
+ if (this.type === TILESET_TYPE.I3S) {
8992
+ const nodesInNodePages = this.tileset?.nodePagesTile?.nodesInNodePages || 0;
8993
+ this.stats.get(TILES_TOTAL).reset();
8994
+ this.stats.get(TILES_TOTAL).addCount(nodesInNodePages);
8995
+ }
8070
8996
  if (tile && tile.content) {
8071
8997
  calculateTransformProps(tile, tile.content);
8072
8998
  }
8999
+ this.updateContentTypes(tile);
8073
9000
  this._addTileToCache(tile);
8074
9001
  this.options.onTileLoad(tile);
8075
9002
  }
9003
+ updateContentTypes(tile) {
9004
+ if (this.type === TILESET_TYPE.I3S) {
9005
+ if (tile.header.isDracoGeometry) {
9006
+ this.contentFormats.draco = true;
9007
+ }
9008
+ switch (tile.header.textureFormat) {
9009
+ case "dds":
9010
+ this.contentFormats.dds = true;
9011
+ break;
9012
+ case "ktx2":
9013
+ this.contentFormats.ktx2 = true;
9014
+ break;
9015
+ default:
9016
+ }
9017
+ } else if (this.type === TILESET_TYPE.TILES3D) {
9018
+ const { extensionsRemoved = [] } = tile.content?.gltf || {};
9019
+ if (extensionsRemoved.includes("KHR_draco_mesh_compression")) {
9020
+ this.contentFormats.draco = true;
9021
+ }
9022
+ if (extensionsRemoved.includes("EXT_meshopt_compression")) {
9023
+ this.contentFormats.meshopt = true;
9024
+ }
9025
+ if (extensionsRemoved.includes("KHR_texture_basisu")) {
9026
+ this.contentFormats.ktx2 = true;
9027
+ }
9028
+ }
9029
+ }
8076
9030
  _onStartTileLoading() {
8077
9031
  this._pendingCount++;
8078
9032
  this.stats.get(TILES_LOADING).incrementCount();
@@ -8087,11 +9041,11 @@
8087
9041
  _updateCacheStats(tile) {
8088
9042
  this.stats.get(TILES_LOADED).incrementCount();
8089
9043
  this.stats.get(TILES_IN_MEMORY).incrementCount();
8090
- this.gpuMemoryUsageInBytes += tile.content.byteLength || 0;
9044
+ this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
8091
9045
  this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
8092
9046
  }
8093
9047
  _unloadTile(tile) {
8094
- this.gpuMemoryUsageInBytes -= tile.content && tile.content.byteLength || 0;
9048
+ this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
8095
9049
  this.stats.get(TILES_IN_MEMORY).decrementCount();
8096
9050
  this.stats.get(TILES_UNLOADED).incrementCount();
8097
9051
  this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
@@ -8132,12 +9086,17 @@
8132
9086
  this._unloadTile(tile);
8133
9087
  tile.destroy();
8134
9088
  }
8135
- _initializeCesiumTileset(tilesetJson) {
9089
+ _initializeTiles3DTileset(tilesetJson) {
9090
+ if (tilesetJson.queryString) {
9091
+ const searchParams = new URLSearchParams(tilesetJson.queryString);
9092
+ const queryParams = Object.fromEntries(searchParams.entries());
9093
+ this._queryParams = { ...this._queryParams, ...queryParams };
9094
+ }
8136
9095
  this.asset = tilesetJson.asset;
8137
9096
  if (!this.asset) {
8138
9097
  throw new Error("Tileset must have an asset property.");
8139
9098
  }
8140
- if (this.asset.version !== "0.0" && this.asset.version !== "1.0") {
9099
+ if (this.asset.version !== "0.0" && this.asset.version !== "1.0" && this.asset.version !== "1.1") {
8141
9100
  throw new Error("The tileset must be 3D Tiles version 0.0 or 1.0.");
8142
9101
  }
8143
9102
  if ("tilesetVersion" in this.asset) {
@@ -8149,7 +9108,7 @@
8149
9108
  this.description = this.options.description || "";
8150
9109
  this.properties = tilesetJson.properties;
8151
9110
  this.geometricError = tilesetJson.geometricError;
8152
- this._extensionsUsed = tilesetJson.extensionsUsed;
9111
+ this._extensionsUsed = tilesetJson.extensionsUsed || [];
8153
9112
  this.extras = tilesetJson.extras;
8154
9113
  }
8155
9114
  _initializeI3STileset() {
@@ -8169,7 +9128,7 @@
8169
9128
  TILE_CONTENT_STATE: () => TILE_CONTENT_STATE,
8170
9129
  TILE_REFINEMENT: () => TILE_REFINEMENT,
8171
9130
  TILE_TYPE: () => TILE_TYPE,
8172
- Tile3D: () => TileHeader,
9131
+ Tile3D: () => Tile3D,
8173
9132
  Tileset3D: () => Tileset3D,
8174
9133
  TilesetCache: () => TilesetCache,
8175
9134
  TilesetTraverser: () => TilesetTraverser,
@@ -8194,10 +9153,10 @@
8194
9153
 
8195
9154
  // src/bundle.ts
8196
9155
  var require_bundle = __commonJS({
8197
- "src/bundle.ts"(exports, module2) {
9156
+ "src/bundle.ts"(exports, module) {
8198
9157
  var moduleExports = (init_src4(), src_exports);
8199
9158
  globalThis.loaders = globalThis.loaders || {};
8200
- module2.exports = Object.assign(globalThis.loaders, moduleExports);
9159
+ module.exports = Object.assign(globalThis.loaders, moduleExports);
8201
9160
  }
8202
9161
  });
8203
9162
  require_bundle();