@loaders.gl/tiles 3.1.8 → 3.2.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/dist.min.js +315 -320
  2. package/dist/es5/tileset/helpers/frame-state.js +79 -0
  3. package/dist/es5/tileset/helpers/frame-state.js.map +1 -1
  4. package/dist/es5/tileset/helpers/i3s-lod.js +17 -26
  5. package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -1
  6. package/dist/es5/tileset/helpers/zoom.js +32 -0
  7. package/dist/es5/tileset/helpers/zoom.js.map +1 -1
  8. package/dist/es5/tileset/tile-3d.js +5 -0
  9. package/dist/es5/tileset/tile-3d.js.map +1 -1
  10. package/dist/es5/tileset/tileset-3d.js +247 -86
  11. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  12. package/dist/es5/tileset/traversers/i3s-frame-counter.js +45 -0
  13. package/dist/es5/tileset/traversers/i3s-frame-counter.js.map +1 -0
  14. package/dist/es5/tileset/traversers/i3s-tile-manager.js +17 -0
  15. package/dist/es5/tileset/traversers/i3s-tile-manager.js.map +1 -1
  16. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js +6 -1
  17. package/dist/es5/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  18. package/dist/es5/tileset/traversers/tileset-traverser.js +13 -1
  19. package/dist/es5/tileset/traversers/tileset-traverser.js.map +1 -1
  20. package/dist/esm/tileset/helpers/frame-state.js +52 -0
  21. package/dist/esm/tileset/helpers/frame-state.js.map +1 -1
  22. package/dist/esm/tileset/helpers/i3s-lod.js +17 -27
  23. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
  24. package/dist/esm/tileset/helpers/zoom.js +17 -0
  25. package/dist/esm/tileset/helpers/zoom.js.map +1 -1
  26. package/dist/esm/tileset/tile-3d.js +4 -0
  27. package/dist/esm/tileset/tile-3d.js.map +1 -1
  28. package/dist/esm/tileset/tileset-3d.js +98 -18
  29. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  30. package/dist/esm/tileset/traversers/i3s-frame-counter.js +23 -0
  31. package/dist/esm/tileset/traversers/i3s-frame-counter.js.map +1 -0
  32. package/dist/esm/tileset/traversers/i3s-tile-manager.js +15 -0
  33. package/dist/esm/tileset/traversers/i3s-tile-manager.js.map +1 -1
  34. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js +5 -1
  35. package/dist/esm/tileset/traversers/i3s-tileset-traverser.js.map +1 -1
  36. package/dist/esm/tileset/traversers/tileset-traverser.js +14 -1
  37. package/dist/esm/tileset/traversers/tileset-traverser.js.map +1 -1
  38. package/dist/tileset/helpers/frame-state.d.ts +14 -0
  39. package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
  40. package/dist/tileset/helpers/frame-state.js +49 -1
  41. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -1
  42. package/dist/tileset/helpers/i3s-lod.js +17 -16
  43. package/dist/tileset/helpers/zoom.d.ts +35 -0
  44. package/dist/tileset/helpers/zoom.d.ts.map +1 -1
  45. package/dist/tileset/helpers/zoom.js +41 -1
  46. package/dist/tileset/tile-3d.d.ts +5 -0
  47. package/dist/tileset/tile-3d.d.ts.map +1 -1
  48. package/dist/tileset/tile-3d.js +7 -0
  49. package/dist/tileset/tileset-3d.d.ts +36 -4
  50. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  51. package/dist/tileset/tileset-3d.js +104 -21
  52. package/dist/tileset/traversers/i3s-frame-counter.d.ts +24 -0
  53. package/dist/tileset/traversers/i3s-frame-counter.d.ts.map +1 -0
  54. package/dist/tileset/traversers/i3s-frame-counter.js +37 -0
  55. package/dist/tileset/traversers/i3s-tile-manager.d.ts +10 -2
  56. package/dist/tileset/traversers/i3s-tile-manager.d.ts.map +1 -1
  57. package/dist/tileset/traversers/i3s-tile-manager.js +24 -0
  58. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts +9 -2
  59. package/dist/tileset/traversers/i3s-tileset-traverser.d.ts.map +1 -1
  60. package/dist/tileset/traversers/i3s-tileset-traverser.js +10 -1
  61. package/dist/tileset/traversers/tileset-traverser.d.ts +5 -1
  62. package/dist/tileset/traversers/tileset-traverser.d.ts.map +1 -1
  63. package/dist/tileset/traversers/tileset-traverser.js +10 -1
  64. package/package.json +5 -5
  65. package/src/tileset/helpers/frame-state.ts +56 -0
  66. package/src/tileset/helpers/i3s-lod.ts +18 -19
  67. package/src/tileset/helpers/zoom.ts +64 -0
  68. package/src/tileset/tile-3d.ts +8 -0
  69. package/src/tileset/tileset-3d.ts +127 -22
  70. package/src/tileset/traversers/i3s-frame-counter.ts +35 -0
  71. package/src/tileset/traversers/i3s-tile-manager.ts +26 -2
  72. package/src/tileset/traversers/i3s-tileset-traverser.ts +16 -3
  73. package/src/tileset/traversers/tileset-traverser.ts +13 -2
package/dist/dist.min.js CHANGED
@@ -3215,7 +3215,7 @@
3215
3215
  }
3216
3216
  });
3217
3217
 
3218
- // node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
3218
+ // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
3219
3219
  function getHiResTimestamp() {
3220
3220
  let timestamp;
3221
3221
  if (typeof window !== "undefined" && window.performance) {
@@ -3229,14 +3229,14 @@
3229
3229
  return timestamp;
3230
3230
  }
3231
3231
  var init_hi_res_timestamp = __esm({
3232
- "node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
3232
+ "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
3233
3233
  }
3234
3234
  });
3235
3235
 
3236
- // node_modules/@probe.gl/stats/dist/esm/lib/stat.js
3236
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
3237
3237
  var Stat;
3238
3238
  var init_stat = __esm({
3239
- "node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
3239
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
3240
3240
  init_defineProperty();
3241
3241
  init_hi_res_timestamp();
3242
3242
  Stat = class {
@@ -3352,10 +3352,10 @@
3352
3352
  }
3353
3353
  });
3354
3354
 
3355
- // node_modules/@probe.gl/stats/dist/esm/lib/stats.js
3355
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
3356
3356
  var Stats;
3357
3357
  var init_stats = __esm({
3358
- "node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
3358
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
3359
3359
  init_defineProperty();
3360
3360
  init_stat();
3361
3361
  Stats = class {
@@ -3425,9 +3425,9 @@
3425
3425
  }
3426
3426
  });
3427
3427
 
3428
- // node_modules/@probe.gl/stats/dist/esm/index.js
3428
+ // ../../node_modules/@probe.gl/stats/dist/esm/index.js
3429
3429
  var init_esm3 = __esm({
3430
- "node_modules/@probe.gl/stats/dist/esm/index.js"() {
3430
+ "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
3431
3431
  init_stats();
3432
3432
  init_stat();
3433
3433
  init_hi_res_timestamp();
@@ -3469,7 +3469,7 @@
3469
3469
  var DEFAULT_VERSION, VERSION;
3470
3470
  var init_version = __esm({
3471
3471
  "../worker-utils/src/lib/env-utils/version.ts"() {
3472
- DEFAULT_VERSION = "latest";
3472
+ DEFAULT_VERSION = "beta";
3473
3473
  VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
3474
3474
  if (typeof __VERSION__ === "undefined") {
3475
3475
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
@@ -3516,13 +3516,13 @@
3516
3516
  init_assert3();
3517
3517
  WorkerJob = class {
3518
3518
  constructor(jobName, workerThread) {
3519
- this.name = jobName;
3520
- this.workerThread = workerThread;
3521
3519
  this.isRunning = true;
3522
3520
  this._resolve = () => {
3523
3521
  };
3524
3522
  this._reject = () => {
3525
3523
  };
3524
+ this.name = jobName;
3525
+ this.workerThread = workerThread;
3526
3526
  this.result = new Promise((resolve, reject) => {
3527
3527
  this._resolve = resolve;
3528
3528
  this._reject = reject;
@@ -3549,6 +3549,21 @@
3549
3549
  }
3550
3550
  });
3551
3551
 
3552
+ // ../worker-utils/src/lib/node/worker_threads-browser.js
3553
+ var Worker2;
3554
+ var init_worker_threads_browser = __esm({
3555
+ "../worker-utils/src/lib/node/worker_threads-browser.js"() {
3556
+ Worker2 = class {
3557
+ on(message, cb) {
3558
+ }
3559
+ postMessage(...args) {
3560
+ }
3561
+ terminate() {
3562
+ }
3563
+ };
3564
+ }
3565
+ });
3566
+
3552
3567
  // ../worker-utils/src/lib/worker-utils/get-loadable-worker-url.ts
3553
3568
  function getLoadableWorkerURL(props) {
3554
3569
  assert3(props.source && !props.url || !props.source && props.url);
@@ -3636,6 +3651,8 @@
3636
3651
  var NOOP, WorkerThread;
3637
3652
  var init_worker_thread = __esm({
3638
3653
  "../worker-utils/src/lib/worker-farm/worker-thread.ts"() {
3654
+ init_worker_threads_browser();
3655
+ init_globals2();
3639
3656
  init_assert3();
3640
3657
  init_get_loadable_worker_url();
3641
3658
  init_get_transfer_list();
@@ -3652,10 +3669,10 @@
3652
3669
  this.url = url;
3653
3670
  this.onMessage = NOOP;
3654
3671
  this.onError = (error) => console.log(error);
3655
- this.worker = this._createBrowserWorker();
3672
+ this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
3656
3673
  }
3657
3674
  static isSupported() {
3658
- return typeof Worker !== "undefined";
3675
+ return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== void 0;
3659
3676
  }
3660
3677
  destroy() {
3661
3678
  this.onMessage = NOOP;
@@ -3698,6 +3715,27 @@
3698
3715
  worker.onmessageerror = (event) => console.error(event);
3699
3716
  return worker;
3700
3717
  }
3718
+ _createNodeWorker() {
3719
+ let worker;
3720
+ if (this.url) {
3721
+ const absolute = this.url.includes(":/") || this.url.startsWith("/");
3722
+ const url = absolute ? this.url : `./${this.url}`;
3723
+ worker = new Worker2(url, { eval: false });
3724
+ } else if (this.source) {
3725
+ worker = new Worker2(this.source, { eval: true });
3726
+ } else {
3727
+ throw new Error("no worker");
3728
+ }
3729
+ worker.on("message", (data) => {
3730
+ this.onMessage(data);
3731
+ });
3732
+ worker.on("error", (error) => {
3733
+ this.onError(error);
3734
+ });
3735
+ worker.on("exit", (code) => {
3736
+ });
3737
+ return worker;
3738
+ }
3701
3739
  };
3702
3740
  }
3703
3741
  });
@@ -3726,6 +3764,9 @@
3726
3764
  this.url = props.url;
3727
3765
  this.setProps(props);
3728
3766
  }
3767
+ static isSupported() {
3768
+ return WorkerThread.isSupported();
3769
+ }
3729
3770
  destroy() {
3730
3771
  this.idleQueue.forEach((worker) => worker.destroy());
3731
3772
  this.isDestroyed = true;
@@ -3822,9 +3863,9 @@
3822
3863
  DEFAULT_PROPS = {
3823
3864
  maxConcurrency: 3,
3824
3865
  maxMobileConcurrency: 1,
3866
+ reuseWorkers: true,
3825
3867
  onDebug: () => {
3826
- },
3827
- reuseWorkers: true
3868
+ }
3828
3869
  };
3829
3870
  WorkerFarm = class {
3830
3871
  constructor(props) {
@@ -3845,6 +3886,7 @@
3845
3886
  for (const workerPool of this.workerPools.values()) {
3846
3887
  workerPool.destroy();
3847
3888
  }
3889
+ this.workerPools = new Map();
3848
3890
  }
3849
3891
  setProps(props) {
3850
3892
  this.props = { ...this.props, ...props };
@@ -3904,7 +3946,7 @@
3904
3946
  var init_get_worker_url = __esm({
3905
3947
  "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
3906
3948
  init_assert3();
3907
- NPM_TAG = "latest";
3949
+ NPM_TAG = "beta";
3908
3950
  }
3909
3951
  });
3910
3952
 
@@ -3928,6 +3970,7 @@
3928
3970
  var init_src = __esm({
3929
3971
  "../worker-utils/src/index.ts"() {
3930
3972
  init_assert3();
3973
+ init_globals2();
3931
3974
  init_worker_farm();
3932
3975
  init_get_worker_url();
3933
3976
  init_validate_worker_version();
@@ -3939,6 +3982,9 @@
3939
3982
  if (!WorkerFarm.isSupported()) {
3940
3983
  return false;
3941
3984
  }
3985
+ if (!isBrowser2 && !options?._nodeWorkers) {
3986
+ return false;
3987
+ }
3942
3988
  return loader.worker && options?.worker;
3943
3989
  }
3944
3990
  async function parseWithWorker(loader, data, options, context, parseOnMainThread) {
@@ -3947,10 +3993,12 @@
3947
3993
  const workerFarm = WorkerFarm.getWorkerFarm(options);
3948
3994
  const workerPool = workerFarm.getWorkerPool({ name, url });
3949
3995
  options = JSON.parse(JSON.stringify(options));
3996
+ context = JSON.parse(JSON.stringify(context || {}));
3950
3997
  const job = await workerPool.startJob("process-on-worker", onMessage.bind(null, parseOnMainThread));
3951
3998
  job.postMessage("process", {
3952
3999
  input: data,
3953
- options
4000
+ options,
4001
+ context
3954
4002
  });
3955
4003
  const result = await job.result;
3956
4004
  return await result.result;
@@ -3980,6 +4028,7 @@
3980
4028
  var init_parse_with_worker = __esm({
3981
4029
  "../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
3982
4030
  init_src();
4031
+ init_src();
3983
4032
  }
3984
4033
  });
3985
4034
 
@@ -4068,230 +4117,11 @@
4068
4117
  }
4069
4118
  });
4070
4119
 
4071
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
4072
- function getHiResTimestamp2() {
4073
- let timestamp;
4074
- if (typeof window !== "undefined" && window.performance) {
4075
- timestamp = window.performance.now();
4076
- } else if (typeof process !== "undefined" && process.hrtime) {
4077
- const timeParts = process.hrtime();
4078
- timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
4079
- } else {
4080
- timestamp = Date.now();
4081
- }
4082
- return timestamp;
4083
- }
4084
- var init_hi_res_timestamp2 = __esm({
4085
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
4086
- }
4087
- });
4088
-
4089
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stat.js
4090
- var Stat2;
4091
- var init_stat2 = __esm({
4092
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
4093
- init_defineProperty();
4094
- init_hi_res_timestamp2();
4095
- Stat2 = class {
4096
- constructor(name, type) {
4097
- _defineProperty(this, "name", void 0);
4098
- _defineProperty(this, "type", void 0);
4099
- _defineProperty(this, "sampleSize", 1);
4100
- _defineProperty(this, "time", void 0);
4101
- _defineProperty(this, "count", void 0);
4102
- _defineProperty(this, "samples", void 0);
4103
- _defineProperty(this, "lastTiming", void 0);
4104
- _defineProperty(this, "lastSampleTime", void 0);
4105
- _defineProperty(this, "lastSampleCount", void 0);
4106
- _defineProperty(this, "_count", 0);
4107
- _defineProperty(this, "_time", 0);
4108
- _defineProperty(this, "_samples", 0);
4109
- _defineProperty(this, "_startTime", 0);
4110
- _defineProperty(this, "_timerPending", false);
4111
- this.name = name;
4112
- this.type = type;
4113
- this.reset();
4114
- }
4115
- setSampleSize(samples) {
4116
- this.sampleSize = samples;
4117
- return this;
4118
- }
4119
- incrementCount() {
4120
- this.addCount(1);
4121
- return this;
4122
- }
4123
- decrementCount() {
4124
- this.subtractCount(1);
4125
- return this;
4126
- }
4127
- addCount(value) {
4128
- this._count += value;
4129
- this._samples++;
4130
- this._checkSampling();
4131
- return this;
4132
- }
4133
- subtractCount(value) {
4134
- this._count -= value;
4135
- this._samples++;
4136
- this._checkSampling();
4137
- return this;
4138
- }
4139
- addTime(time) {
4140
- this._time += time;
4141
- this.lastTiming = time;
4142
- this._samples++;
4143
- this._checkSampling();
4144
- return this;
4145
- }
4146
- timeStart() {
4147
- this._startTime = getHiResTimestamp2();
4148
- this._timerPending = true;
4149
- return this;
4150
- }
4151
- timeEnd() {
4152
- if (!this._timerPending) {
4153
- return this;
4154
- }
4155
- this.addTime(getHiResTimestamp2() - this._startTime);
4156
- this._timerPending = false;
4157
- this._checkSampling();
4158
- return this;
4159
- }
4160
- getSampleAverageCount() {
4161
- return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
4162
- }
4163
- getSampleAverageTime() {
4164
- return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
4165
- }
4166
- getSampleHz() {
4167
- return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
4168
- }
4169
- getAverageCount() {
4170
- return this.samples > 0 ? this.count / this.samples : 0;
4171
- }
4172
- getAverageTime() {
4173
- return this.samples > 0 ? this.time / this.samples : 0;
4174
- }
4175
- getHz() {
4176
- return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
4177
- }
4178
- reset() {
4179
- this.time = 0;
4180
- this.count = 0;
4181
- this.samples = 0;
4182
- this.lastTiming = 0;
4183
- this.lastSampleTime = 0;
4184
- this.lastSampleCount = 0;
4185
- this._count = 0;
4186
- this._time = 0;
4187
- this._samples = 0;
4188
- this._startTime = 0;
4189
- this._timerPending = false;
4190
- return this;
4191
- }
4192
- _checkSampling() {
4193
- if (this._samples === this.sampleSize) {
4194
- this.lastSampleTime = this._time;
4195
- this.lastSampleCount = this._count;
4196
- this.count += this._count;
4197
- this.time += this._time;
4198
- this.samples += this._samples;
4199
- this._time = 0;
4200
- this._count = 0;
4201
- this._samples = 0;
4202
- }
4203
- }
4204
- };
4205
- }
4206
- });
4207
-
4208
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stats.js
4209
- var Stats2;
4210
- var init_stats2 = __esm({
4211
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
4212
- init_defineProperty();
4213
- init_stat2();
4214
- Stats2 = class {
4215
- constructor(options) {
4216
- _defineProperty(this, "id", void 0);
4217
- _defineProperty(this, "stats", {});
4218
- this.id = options.id;
4219
- this.stats = {};
4220
- this._initializeStats(options.stats);
4221
- Object.seal(this);
4222
- }
4223
- get(name) {
4224
- let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
4225
- return this._getOrCreate({
4226
- name,
4227
- type
4228
- });
4229
- }
4230
- get size() {
4231
- return Object.keys(this.stats).length;
4232
- }
4233
- reset() {
4234
- for (const key in this.stats) {
4235
- this.stats[key].reset();
4236
- }
4237
- return this;
4238
- }
4239
- forEach(fn) {
4240
- for (const key in this.stats) {
4241
- fn(this.stats[key]);
4242
- }
4243
- }
4244
- getTable() {
4245
- const table = {};
4246
- this.forEach((stat) => {
4247
- table[stat.name] = {
4248
- time: stat.time || 0,
4249
- count: stat.count || 0,
4250
- average: stat.getAverageTime() || 0,
4251
- hz: stat.getHz() || 0
4252
- };
4253
- });
4254
- return table;
4255
- }
4256
- _initializeStats() {
4257
- let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
4258
- stats.forEach((stat) => this._getOrCreate(stat));
4259
- }
4260
- _getOrCreate(stat) {
4261
- if (!stat || !stat.name) {
4262
- return null;
4263
- }
4264
- const {
4265
- name,
4266
- type
4267
- } = stat;
4268
- if (!this.stats[name]) {
4269
- if (stat instanceof Stat2) {
4270
- this.stats[name] = stat;
4271
- } else {
4272
- this.stats[name] = new Stat2(name, type);
4273
- }
4274
- }
4275
- return this.stats[name];
4276
- }
4277
- };
4278
- }
4279
- });
4280
-
4281
- // ../loader-utils/node_modules/@probe.gl/stats/dist/esm/index.js
4282
- var init_esm4 = __esm({
4283
- "../loader-utils/node_modules/@probe.gl/stats/dist/esm/index.js"() {
4284
- init_stats2();
4285
- init_stat2();
4286
- init_hi_res_timestamp2();
4287
- }
4288
- });
4289
-
4290
4120
  // ../loader-utils/src/lib/request-utils/request-scheduler.ts
4291
4121
  var STAT_QUEUED_REQUESTS, STAT_ACTIVE_REQUESTS, STAT_CANCELLED_REQUESTS, STAT_QUEUED_REQUESTS_EVER, STAT_ACTIVE_REQUESTS_EVER, DEFAULT_PROPS2, RequestScheduler;
4292
4122
  var init_request_scheduler = __esm({
4293
4123
  "../loader-utils/src/lib/request-utils/request-scheduler.ts"() {
4294
- init_esm4();
4124
+ init_esm3();
4295
4125
  STAT_QUEUED_REQUESTS = "Queued Requests";
4296
4126
  STAT_ACTIVE_REQUESTS = "Active Requests";
4297
4127
  STAT_CANCELLED_REQUESTS = "Cancelled Requests";
@@ -4309,7 +4139,7 @@
4309
4139
  this.requestMap = new Map();
4310
4140
  this.deferredUpdate = null;
4311
4141
  this.props = { ...DEFAULT_PROPS2, ...props };
4312
- this.stats = new Stats2({ id: this.props.id });
4142
+ this.stats = new Stats({ id: this.props.id });
4313
4143
  this.stats.get(STAT_QUEUED_REQUESTS);
4314
4144
  this.stats.get(STAT_ACTIVE_REQUESTS);
4315
4145
  this.stats.get(STAT_CANCELLED_REQUESTS);
@@ -5190,7 +5020,7 @@
5190
5020
  });
5191
5021
 
5192
5022
  // ../../node_modules/@math.gl/culling/dist/esm/index.js
5193
- var init_esm5 = __esm({
5023
+ var init_esm4 = __esm({
5194
5024
  "../../node_modules/@math.gl/culling/dist/esm/index.js"() {
5195
5025
  init_constants2();
5196
5026
  init_axis_aligned_bounding_box();
@@ -5216,23 +5046,59 @@
5216
5046
  const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new Vector3());
5217
5047
  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
5218
5048
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
5219
- const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
5049
+ const cameraPositionCartesian2 = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
5220
5050
  const cameraDirectionCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))).normalize();
5221
5051
  const cameraUpCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))).normalize();
5222
5052
  commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
5053
+ const ViewportClass = viewport.constructor;
5054
+ const { longitude, latitude, width, bearing, zoom } = viewport;
5055
+ const topDownViewport = new ViewportClass({
5056
+ longitude,
5057
+ latitude,
5058
+ height,
5059
+ width,
5060
+ bearing,
5061
+ zoom,
5062
+ pitch: 0
5063
+ });
5223
5064
  return {
5224
5065
  camera: {
5225
- position: cameraPositionCartesian,
5066
+ position: cameraPositionCartesian2,
5226
5067
  direction: cameraDirectionCartesian,
5227
5068
  up: cameraUpCartesian
5228
5069
  },
5229
5070
  viewport,
5071
+ topDownViewport,
5230
5072
  height,
5231
5073
  cullingVolume,
5232
5074
  frameNumber,
5233
5075
  sseDenominator: 1.15
5234
5076
  };
5235
5077
  }
5078
+ function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
5079
+ if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {
5080
+ return [tiles, []];
5081
+ }
5082
+ const tuples = [];
5083
+ const { longitude: viewportLongitude, latitude: viewportLatitude } = frameState.viewport;
5084
+ for (const [index, tile] of tiles.entries()) {
5085
+ const [longitude, latitude] = tile.header.mbs;
5086
+ const deltaLon = Math.abs(viewportLongitude - longitude);
5087
+ const deltaLat = Math.abs(viewportLatitude - latitude);
5088
+ const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);
5089
+ tuples.push([index, distance]);
5090
+ }
5091
+ const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);
5092
+ const selectedTiles = [];
5093
+ for (let i = 0; i < maximumTilesSelected; i++) {
5094
+ selectedTiles.push(tiles[tuplesSorted[i][0]]);
5095
+ }
5096
+ const unselectedTiles = [];
5097
+ for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {
5098
+ unselectedTiles.push(tiles[tuplesSorted[i][0]]);
5099
+ }
5100
+ return [selectedTiles, unselectedTiles];
5101
+ }
5236
5102
  function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
5237
5103
  const frustumPlanes = viewport.getFrustumPlanes();
5238
5104
  let i = 0;
@@ -5249,7 +5115,7 @@
5249
5115
  var init_frame_state = __esm({
5250
5116
  "src/tileset/helpers/frame-state.ts"() {
5251
5117
  init_esm();
5252
- init_esm5();
5118
+ init_esm4();
5253
5119
  init_esm2();
5254
5120
  scratchVector7 = new Vector3();
5255
5121
  scratchPosition3 = new Vector3();
@@ -5281,6 +5147,15 @@
5281
5147
  }
5282
5148
  return 1;
5283
5149
  }
5150
+ function getZoomFromFullExtent(fullExtent, cartorgraphicCenter, cartesianCenter) {
5151
+ const extentVertex = Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], new Vector3());
5152
+ 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));
5153
+ return Math.log2(WGS84_RADIUS_Z2 / (extentSize + cartorgraphicCenter[2]));
5154
+ }
5155
+ function getZoomFromExtent(extent, cartorgraphicCenter, cartesianCenter) {
5156
+ const [xmin, ymin, xmax, ymax] = extent;
5157
+ return getZoomFromFullExtent({ xmin, xmax, ymin, ymax, zmin: 0, zmax: 0 }, cartorgraphicCenter, cartesianCenter);
5158
+ }
5284
5159
  function getObbSize(halfAxes) {
5285
5160
  halfAxes.getColumn(0, scratchVector8);
5286
5161
  const axeY = halfAxes.getColumn(1);
@@ -5293,7 +5168,8 @@
5293
5168
  var init_zoom = __esm({
5294
5169
  "src/tileset/helpers/zoom.ts"() {
5295
5170
  init_esm();
5296
- init_esm5();
5171
+ init_esm4();
5172
+ init_esm2();
5297
5173
  WGS84_RADIUS_X2 = 6378137;
5298
5174
  WGS84_RADIUS_Y2 = 6378137;
5299
5175
  WGS84_RADIUS_Z2 = 6356752314245179e-9;
@@ -5440,7 +5316,7 @@
5440
5316
  text += ` ${await response.text()}`;
5441
5317
  }
5442
5318
  message += text;
5443
- message = message.length > 60 ? `${message.slice(60)}...` : message;
5319
+ message = message.length > 60 ? `${message.slice(0, 60)}...` : message;
5444
5320
  } catch (error) {
5445
5321
  }
5446
5322
  return message;
@@ -5715,7 +5591,7 @@
5715
5591
  });
5716
5592
 
5717
5593
  // ../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js
5718
- function getHiResTimestamp3() {
5594
+ function getHiResTimestamp2() {
5719
5595
  let timestamp;
5720
5596
  if (isBrowser4 && window_3.performance) {
5721
5597
  timestamp = window_3.performance.now();
@@ -5727,7 +5603,7 @@
5727
5603
  }
5728
5604
  return timestamp;
5729
5605
  }
5730
- var init_hi_res_timestamp3 = __esm({
5606
+ var init_hi_res_timestamp2 = __esm({
5731
5607
  "../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js"() {
5732
5608
  init_globals4();
5733
5609
  }
@@ -5854,7 +5730,7 @@
5854
5730
  init_color();
5855
5731
  init_autobind();
5856
5732
  init_assert4();
5857
- init_hi_res_timestamp3();
5733
+ init_hi_res_timestamp2();
5858
5734
  originalConsole = {
5859
5735
  debug: isBrowser4 ? console.debug || console.log : console.log,
5860
5736
  log: console.log,
@@ -5878,8 +5754,8 @@
5878
5754
  }) {
5879
5755
  this.id = id;
5880
5756
  this.VERSION = VERSION2;
5881
- this._startTs = getHiResTimestamp3();
5882
- this._deltaTs = getHiResTimestamp3();
5757
+ this._startTs = getHiResTimestamp2();
5758
+ this._deltaTs = getHiResTimestamp2();
5883
5759
  this.LOG_THROTTLE_TIMEOUT = 0;
5884
5760
  this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS);
5885
5761
  this.userData = {};
@@ -5900,10 +5776,10 @@
5900
5776
  return this._storage.config.level;
5901
5777
  }
5902
5778
  getTotal() {
5903
- return Number((getHiResTimestamp3() - this._startTs).toPrecision(10));
5779
+ return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
5904
5780
  }
5905
5781
  getDelta() {
5906
- return Number((getHiResTimestamp3() - this._deltaTs).toPrecision(10));
5782
+ return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
5907
5783
  }
5908
5784
  set priority(newPriority) {
5909
5785
  this.level = newPriority;
@@ -6058,11 +5934,11 @@
6058
5934
  assert4(method);
6059
5935
  opts.total = this.getTotal();
6060
5936
  opts.delta = this.getDelta();
6061
- this._deltaTs = getHiResTimestamp3();
5937
+ this._deltaTs = getHiResTimestamp2();
6062
5938
  const tag = opts.tag || opts.message;
6063
5939
  if (opts.once) {
6064
5940
  if (!cache[tag]) {
6065
- cache[tag] = getHiResTimestamp3();
5941
+ cache[tag] = getHiResTimestamp2();
6066
5942
  } else {
6067
5943
  return noop2;
6068
5944
  }
@@ -6077,42 +5953,42 @@
6077
5953
  }
6078
5954
  });
6079
5955
 
6080
- // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
6081
- var init_hi_res_timestamp4 = __esm({
6082
- "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
5956
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
5957
+ var init_hi_res_timestamp3 = __esm({
5958
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
6083
5959
  }
6084
5960
  });
6085
5961
 
6086
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
6087
- var init_stat3 = __esm({
6088
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
6089
- init_hi_res_timestamp4();
5962
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js
5963
+ var init_stat2 = __esm({
5964
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
5965
+ init_hi_res_timestamp3();
6090
5966
  }
6091
5967
  });
6092
5968
 
6093
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
6094
- var init_stats3 = __esm({
6095
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
6096
- init_stat3();
5969
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js
5970
+ var init_stats2 = __esm({
5971
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
5972
+ init_stat2();
6097
5973
  }
6098
5974
  });
6099
5975
 
6100
- // ../../node_modules/@probe.gl/stats/dist/esm/index.js
6101
- var init_esm6 = __esm({
6102
- "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
6103
- init_stats3();
6104
- init_stat3();
6105
- init_hi_res_timestamp4();
5976
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js
5977
+ var init_esm5 = __esm({
5978
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js"() {
5979
+ init_stats2();
5980
+ init_stat2();
5981
+ init_hi_res_timestamp3();
6106
5982
  }
6107
5983
  });
6108
5984
 
6109
5985
  // ../../node_modules/probe.gl/dist/esm/index.js
6110
5986
  var esm_default;
6111
- var init_esm7 = __esm({
5987
+ var init_esm6 = __esm({
6112
5988
  "../../node_modules/probe.gl/dist/esm/index.js"() {
6113
5989
  init_log();
6114
5990
  init_log();
6115
- init_esm6();
5991
+ init_esm5();
6116
5992
  esm_default = new Log({
6117
5993
  id: "probe.gl"
6118
5994
  });
@@ -6123,7 +5999,7 @@
6123
5999
  var probeLog, NullLog, ConsoleLog;
6124
6000
  var init_loggers = __esm({
6125
6001
  "../core/src/lib/loader-utils/loggers.ts"() {
6126
- init_esm7();
6002
+ init_esm6();
6127
6003
  probeLog = new Log({ id: "loaders.gl" });
6128
6004
  NullLog = class {
6129
6005
  log() {
@@ -6167,6 +6043,7 @@
6167
6043
  var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
6168
6044
  var init_option_defaults = __esm({
6169
6045
  "../core/src/lib/loader-utils/option-defaults.ts"() {
6046
+ init_src2();
6170
6047
  init_loggers();
6171
6048
  DEFAULT_LOADER_OPTIONS = {
6172
6049
  fetch: null,
@@ -6177,7 +6054,8 @@
6177
6054
  worker: true,
6178
6055
  maxConcurrency: 3,
6179
6056
  maxMobileConcurrency: 1,
6180
- reuseWorkers: true,
6057
+ reuseWorkers: isBrowser,
6058
+ _nodeWorkers: false,
6181
6059
  _workerType: "",
6182
6060
  limit: 0,
6183
6061
  _limitMB: 0,
@@ -6435,7 +6313,7 @@
6435
6313
  });
6436
6314
 
6437
6315
  // ../../node_modules/@probe.gl/env/dist/esm/index.js
6438
- var init_esm8 = __esm({
6316
+ var init_esm7 = __esm({
6439
6317
  "../../node_modules/@probe.gl/env/dist/esm/index.js"() {
6440
6318
  init_globals6();
6441
6319
  init_globals5();
@@ -6555,7 +6433,7 @@
6555
6433
  var COLOR2;
6556
6434
  var init_color2 = __esm({
6557
6435
  "../../node_modules/@probe.gl/log/dist/esm/utils/color.js"() {
6558
- init_esm8();
6436
+ init_esm7();
6559
6437
  (function(COLOR3) {
6560
6438
  COLOR3[COLOR3["BLACK"] = 30] = "BLACK";
6561
6439
  COLOR3[COLOR3["RED"] = 31] = "RED";
@@ -6607,7 +6485,7 @@
6607
6485
  });
6608
6486
 
6609
6487
  // ../../node_modules/@probe.gl/log/dist/esm/utils/hi-res-timestamp.js
6610
- function getHiResTimestamp5() {
6488
+ function getHiResTimestamp4() {
6611
6489
  let timestamp;
6612
6490
  if (isBrowser5 && "performance" in window_4) {
6613
6491
  var _window$performance, _window$performance$n;
@@ -6621,9 +6499,9 @@
6621
6499
  }
6622
6500
  return timestamp;
6623
6501
  }
6624
- var init_hi_res_timestamp5 = __esm({
6502
+ var init_hi_res_timestamp4 = __esm({
6625
6503
  "../../node_modules/@probe.gl/log/dist/esm/utils/hi-res-timestamp.js"() {
6626
- init_esm8();
6504
+ init_esm7();
6627
6505
  }
6628
6506
  });
6629
6507
 
@@ -6746,13 +6624,13 @@
6746
6624
  var init_log2 = __esm({
6747
6625
  "../../node_modules/@probe.gl/log/dist/esm/log.js"() {
6748
6626
  init_defineProperty();
6749
- init_esm8();
6627
+ init_esm7();
6750
6628
  init_local_storage2();
6751
6629
  init_formatters2();
6752
6630
  init_color2();
6753
6631
  init_autobind2();
6754
6632
  init_assert5();
6755
- init_hi_res_timestamp5();
6633
+ init_hi_res_timestamp4();
6756
6634
  originalConsole2 = {
6757
6635
  debug: isBrowser5 ? console.debug || console.log : console.log,
6758
6636
  log: console.log,
@@ -6777,8 +6655,8 @@
6777
6655
  };
6778
6656
  _defineProperty(this, "id", void 0);
6779
6657
  _defineProperty(this, "VERSION", VERSION3);
6780
- _defineProperty(this, "_startTs", getHiResTimestamp5());
6781
- _defineProperty(this, "_deltaTs", getHiResTimestamp5());
6658
+ _defineProperty(this, "_startTs", getHiResTimestamp4());
6659
+ _defineProperty(this, "_deltaTs", getHiResTimestamp4());
6782
6660
  _defineProperty(this, "_storage", void 0);
6783
6661
  _defineProperty(this, "userData", {});
6784
6662
  _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
@@ -6802,10 +6680,10 @@
6802
6680
  return this._storage.config.level;
6803
6681
  }
6804
6682
  getTotal() {
6805
- return Number((getHiResTimestamp5() - this._startTs).toPrecision(10));
6683
+ return Number((getHiResTimestamp4() - this._startTs).toPrecision(10));
6806
6684
  }
6807
6685
  getDelta() {
6808
- return Number((getHiResTimestamp5() - this._deltaTs).toPrecision(10));
6686
+ return Number((getHiResTimestamp4() - this._deltaTs).toPrecision(10));
6809
6687
  }
6810
6688
  set priority(newPriority) {
6811
6689
  this.level = newPriority;
@@ -6967,11 +6845,11 @@
6967
6845
  assert5(method);
6968
6846
  opts.total = this.getTotal();
6969
6847
  opts.delta = this.getDelta();
6970
- this._deltaTs = getHiResTimestamp5();
6848
+ this._deltaTs = getHiResTimestamp4();
6971
6849
  const tag = opts.tag || opts.message;
6972
6850
  if (opts.once) {
6973
6851
  if (!cache2[tag]) {
6974
- cache2[tag] = getHiResTimestamp5();
6852
+ cache2[tag] = getHiResTimestamp4();
6975
6853
  } else {
6976
6854
  return noop3;
6977
6855
  }
@@ -6988,7 +6866,7 @@
6988
6866
 
6989
6867
  // ../../node_modules/@probe.gl/log/dist/esm/index.js
6990
6868
  var esm_default2;
6991
- var init_esm9 = __esm({
6869
+ var init_esm8 = __esm({
6992
6870
  "../../node_modules/@probe.gl/log/dist/esm/index.js"() {
6993
6871
  init_log2();
6994
6872
  init_log2();
@@ -7002,7 +6880,7 @@
7002
6880
  var log;
7003
6881
  var init_log3 = __esm({
7004
6882
  "../core/src/lib/utils/log.ts"() {
7005
- init_esm9();
6883
+ init_esm8();
7006
6884
  log = new Log2({ id: "loaders.gl" });
7007
6885
  }
7008
6886
  });
@@ -7441,6 +7319,12 @@
7441
7319
  }
7442
7320
  async function parseWithLoader(loader, data, options, context) {
7443
7321
  validateWorkerVersion(loader);
7322
+ if (isResponse(data)) {
7323
+ const response = data;
7324
+ const { ok, redirected, status, statusText, type, url } = response;
7325
+ const headers = Object.fromEntries(response.headers.entries());
7326
+ context.response = { headers, ok, redirected, status, statusText, type, url };
7327
+ }
7444
7328
  data = await getArrayBufferOrStringFromData(data, loader, options);
7445
7329
  if (loader.parseTextSync && typeof data === "string") {
7446
7330
  options.dataType = "text";
@@ -7463,6 +7347,7 @@
7463
7347
  init_src();
7464
7348
  init_src2();
7465
7349
  init_normalize_loader();
7350
+ init_is_type();
7466
7351
  init_option_utils();
7467
7352
  init_get_data();
7468
7353
  init_loader_context();
@@ -7623,7 +7508,7 @@
7623
7508
  var init_bounding_volume = __esm({
7624
7509
  "src/tileset/helpers/bounding-volume.ts"() {
7625
7510
  init_esm();
7626
- init_esm5();
7511
+ init_esm4();
7627
7512
  init_esm2();
7628
7513
  init_src2();
7629
7514
  scratchScale = new Vector3();
@@ -7690,39 +7575,43 @@
7690
7575
  return "OUT";
7691
7576
  }
7692
7577
  function getProjectedRadius(tile, frameState) {
7693
- const originalViewport = frameState.viewport;
7694
- const ViewportClass = originalViewport.constructor;
7695
- const { longitude, latitude, height, width, bearing, zoom } = originalViewport;
7696
- const viewport = new ViewportClass({ longitude, latitude, height, width, bearing, zoom, pitch: 0 });
7578
+ const { topDownViewport: viewport } = frameState;
7697
7579
  const mbsLat = tile.header.mbs[1];
7698
7580
  const mbsLon = tile.header.mbs[0];
7699
7581
  const mbsZ = tile.header.mbs[2];
7700
7582
  const mbsR = tile.header.mbs[3];
7701
7583
  const mbsCenterCartesian = [...tile.boundingVolume.center];
7702
7584
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
7703
- const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
7704
- const toEye = new Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
7705
- const enuToCartesianMatrix = new Matrix4();
7585
+ Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);
7586
+ toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
7706
7587
  Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
7707
- const cartesianToEnuMatrix = new Matrix4(enuToCartesianMatrix).invert();
7708
- const cameraPositionEnu = new Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
7588
+ cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();
7589
+ cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);
7709
7590
  const projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
7710
7591
  const extraZ = projection * projection / cameraPositionEnu[2];
7711
- const extraVertexEnu = new Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
7592
+ extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
7712
7593
  const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
7713
- const extraVectorCartesian = new Vector3(extraVertexCartesian).subtract(mbsCenterCartesian).normalize();
7594
+ const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();
7714
7595
  const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
7715
- const sphereMbsBorderVertexCartesian = new Vector3(mbsCenterCartesian).add(radiusVector);
7596
+ const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);
7716
7597
  const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
7717
7598
  const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
7718
7599
  const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
7719
- const projectedRadius = new Vector3(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
7600
+ const projectedRadius = projectedOriginVector.copy(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
7720
7601
  return projectedRadius;
7721
7602
  }
7603
+ var cameraPositionCartesian, toEye, cameraPositionEnu, extraVertexEnu, projectedOriginVector, enuToCartesianMatrix, cartesianToEnuMatrix;
7722
7604
  var init_i3s_lod = __esm({
7723
7605
  "src/tileset/helpers/i3s-lod.ts"() {
7724
7606
  init_esm();
7725
7607
  init_esm2();
7608
+ cameraPositionCartesian = new Vector3();
7609
+ toEye = new Vector3();
7610
+ cameraPositionEnu = new Vector3();
7611
+ extraVertexEnu = new Vector3();
7612
+ projectedOriginVector = new Vector3();
7613
+ enuToCartesianMatrix = new Matrix4();
7614
+ cartesianToEnuMatrix = new Matrix4();
7726
7615
  }
7727
7616
  });
7728
7617
 
@@ -7844,6 +7733,8 @@
7844
7733
  };
7845
7734
  TilesetTraverser = class {
7846
7735
  constructor(options) {
7736
+ this.lastUpdate = new Date().getTime();
7737
+ this.updateDebounceTime = 1e3;
7847
7738
  this.options = { ...DEFAULT_PROPS3, ...options };
7848
7739
  this._traversalStack = new ManagedArray();
7849
7740
  this._emptyTraversalStack = new ManagedArray();
@@ -7853,6 +7744,9 @@
7853
7744
  this.requestedTiles = {};
7854
7745
  this.emptyTiles = {};
7855
7746
  }
7747
+ get traversalFinished() {
7748
+ return true;
7749
+ }
7856
7750
  traverse(root, frameState, options) {
7857
7751
  this.root = root;
7858
7752
  this.options = { ...this.options, ...options };
@@ -7900,7 +7794,11 @@
7900
7794
  this.touchTile(tile, frameState);
7901
7795
  tile._shouldRefine = shouldRefine && parentRefines;
7902
7796
  }
7903
- this.options.onTraversalEnd(frameState);
7797
+ const newTime = new Date().getTime();
7798
+ if (this.traversalFinished || newTime - this.lastUpdate > this.updateDebounceTime) {
7799
+ this.lastUpdate = newTime;
7800
+ this.options.onTraversalEnd(frameState);
7801
+ }
7904
7802
  }
7905
7803
  updateChildTiles(tile, frameState) {
7906
7804
  const children = tile.children;
@@ -8056,7 +7954,7 @@
8056
7954
  var init_tile_3d = __esm({
8057
7955
  "src/tileset/tile-3d.ts"() {
8058
7956
  init_esm();
8059
- init_esm5();
7957
+ init_esm4();
8060
7958
  init_src3();
8061
7959
  init_constants3();
8062
7960
  init_bounding_volume();
@@ -8166,6 +8064,9 @@
8166
8064
  throw new Error("Unsupported tileset type");
8167
8065
  }
8168
8066
  }
8067
+ unselect() {
8068
+ this._selectedFrame = 0;
8069
+ }
8169
8070
  _getPriority() {
8170
8071
  const traverser = this.tileset._traverser;
8171
8072
  const { skipLevelOfDetail } = traverser.options;
@@ -8454,10 +8355,35 @@
8454
8355
  }
8455
8356
  });
8456
8357
 
8358
+ // src/tileset/traversers/i3s-frame-counter.ts
8359
+ var I3SPendingTilesRegister;
8360
+ var init_i3s_frame_counter = __esm({
8361
+ "src/tileset/traversers/i3s-frame-counter.ts"() {
8362
+ I3SPendingTilesRegister = class {
8363
+ constructor() {
8364
+ this.frameNumberMap = new Map();
8365
+ }
8366
+ register(frameNumber) {
8367
+ const oldCount = this.frameNumberMap.get(frameNumber) || 0;
8368
+ this.frameNumberMap.set(frameNumber, (oldCount || 0) + 1);
8369
+ }
8370
+ deregister(frameNumber) {
8371
+ const oldCount = this.frameNumberMap.get(frameNumber) || 1;
8372
+ this.frameNumberMap.set(frameNumber, (oldCount || 0) - 1);
8373
+ }
8374
+ isZero(frameNumber) {
8375
+ const count = this.frameNumberMap.get(frameNumber) || 0;
8376
+ return count === 0;
8377
+ }
8378
+ };
8379
+ }
8380
+ });
8381
+
8457
8382
  // src/tileset/traversers/i3s-tile-manager.ts
8458
8383
  var STATUS, I3STileManager;
8459
8384
  var init_i3s_tile_manager = __esm({
8460
8385
  "src/tileset/traversers/i3s-tile-manager.ts"() {
8386
+ init_i3s_frame_counter();
8461
8387
  STATUS = {
8462
8388
  REQUESTED: "REQUESTED",
8463
8389
  COMPLETED: "COMPLETED",
@@ -8465,28 +8391,38 @@
8465
8391
  };
8466
8392
  I3STileManager = class {
8467
8393
  constructor() {
8394
+ this.pendingTilesRegister = new I3SPendingTilesRegister();
8468
8395
  this._statusMap = {};
8469
8396
  }
8470
8397
  add(request, key, callback, frameState) {
8471
8398
  if (!this._statusMap[key]) {
8399
+ const { frameNumber } = frameState;
8472
8400
  this._statusMap[key] = { request, callback, key, frameState, status: STATUS.REQUESTED };
8401
+ this.pendingTilesRegister.register(frameNumber);
8473
8402
  request().then((data) => {
8474
8403
  this._statusMap[key].status = STATUS.COMPLETED;
8404
+ this.pendingTilesRegister.deregister(frameNumber);
8475
8405
  this._statusMap[key].callback(data, frameState);
8476
8406
  }).catch((error) => {
8477
8407
  this._statusMap[key].status = STATUS.ERROR;
8408
+ this.pendingTilesRegister.deregister(frameNumber);
8478
8409
  callback(error);
8479
8410
  });
8480
8411
  }
8481
8412
  }
8482
8413
  update(key, frameState) {
8483
8414
  if (this._statusMap[key]) {
8415
+ this.pendingTilesRegister.deregister(this._statusMap[key].frameState.frameNumber);
8416
+ this.pendingTilesRegister.register(frameState.frameNumber);
8484
8417
  this._statusMap[key].frameState = frameState;
8485
8418
  }
8486
8419
  }
8487
8420
  find(key) {
8488
8421
  return this._statusMap[key];
8489
8422
  }
8423
+ hasPendingTiles(frameNumber) {
8424
+ return !this.pendingTilesRegister.isZero(frameNumber);
8425
+ }
8490
8426
  };
8491
8427
  }
8492
8428
  });
@@ -8501,6 +8437,9 @@
8501
8437
  init_tile_3d();
8502
8438
  init_i3s_tile_manager();
8503
8439
  I3STilesetTraverser = class extends TilesetTraverser {
8440
+ get traversalFinished() {
8441
+ return !this._tileManager.hasPendingTiles(this._frameNumber || 0);
8442
+ }
8504
8443
  constructor(options) {
8505
8444
  super(options);
8506
8445
  this._tileManager = new I3STileManager();
@@ -8551,7 +8490,7 @@
8551
8490
  tile.children.push(childTile);
8552
8491
  const frameState = this._tileManager.find(childTile.id).frameState;
8553
8492
  this.updateTile(childTile, frameState);
8554
- if (this._frameNumber === frameState.frameNumber) {
8493
+ if (this._frameNumber === frameState.frameNumber && (this.traversalFinished || new Date().getTime() - this.lastUpdate > this.updateDebounceTime)) {
8555
8494
  this.executeTraversal(childTile, frameState);
8556
8495
  }
8557
8496
  }
@@ -8597,6 +8536,8 @@
8597
8536
  throttleRequests: true,
8598
8537
  maxRequests: 64,
8599
8538
  maximumMemoryUsage: 32,
8539
+ maximumTilesSelected: 0,
8540
+ debounceTime: 0,
8600
8541
  onTileLoad: () => {
8601
8542
  },
8602
8543
  onTileUnload: () => {
@@ -8623,10 +8564,11 @@
8623
8564
  TILES_LOADING = "Tiles Loading";
8624
8565
  TILES_UNLOADED = "Tiles Unloaded";
8625
8566
  TILES_LOAD_FAILED = "Failed Tile Loads";
8626
- POINTS_COUNT = "Points";
8567
+ POINTS_COUNT = "Points/Vertices";
8627
8568
  TILES_GPU_MEMORY = "Tile Memory Use";
8628
8569
  Tileset3D = class {
8629
8570
  constructor(json, options) {
8571
+ this.updatePromise = null;
8630
8572
  assert2(json);
8631
8573
  this.options = { ...DEFAULT_PROPS4, ...options };
8632
8574
  this.tileset = json;
@@ -8674,7 +8616,7 @@
8674
8616
  this.asset = {};
8675
8617
  this.credits = {};
8676
8618
  this.description = this.options.description || "";
8677
- this._initializeTileSet(json);
8619
+ this.tilesetInitializationPromise = this._initializeTileSet(json);
8678
8620
  }
8679
8621
  destroy() {
8680
8622
  this._destroy();
@@ -8710,18 +8652,39 @@
8710
8652
  hasExtension(extensionName) {
8711
8653
  return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
8712
8654
  }
8713
- update(viewports) {
8655
+ update(viewports = null) {
8656
+ this.tilesetInitializationPromise.then(() => {
8657
+ if (!viewports && this.lastUpdatedVieports) {
8658
+ viewports = this.lastUpdatedVieports;
8659
+ } else {
8660
+ this.lastUpdatedVieports = viewports;
8661
+ }
8662
+ this.doUpdate(viewports);
8663
+ });
8664
+ }
8665
+ async selectTiles(viewports = null) {
8666
+ await this.tilesetInitializationPromise;
8667
+ if (viewports) {
8668
+ this.lastUpdatedVieports = viewports;
8669
+ }
8670
+ if (!this.updatePromise) {
8671
+ this.updatePromise = new Promise((resolve) => {
8672
+ setTimeout(() => {
8673
+ this.doUpdate(this.lastUpdatedVieports);
8674
+ resolve(this._frameNumber);
8675
+ this.updatePromise = null;
8676
+ }, this.options.debounceTime);
8677
+ });
8678
+ }
8679
+ return this.updatePromise;
8680
+ }
8681
+ doUpdate(viewports = null) {
8714
8682
  if ("loadTiles" in this.options && !this.options.loadTiles) {
8715
8683
  return;
8716
8684
  }
8717
8685
  if (this.traverseCounter > 0) {
8718
8686
  return;
8719
8687
  }
8720
- if (!viewports && this.lastUpdatedVieports) {
8721
- viewports = this.lastUpdatedVieports;
8722
- } else {
8723
- this.lastUpdatedVieports = viewports;
8724
- }
8725
8688
  if (!(viewports instanceof Array)) {
8726
8689
  viewports = [viewports];
8727
8690
  }
@@ -8766,7 +8729,11 @@
8766
8729
  }
8767
8730
  const currentFrameStateData = this.frameStateData[id];
8768
8731
  const selectedTiles = Object.values(this._traverser.selectedTiles);
8769
- currentFrameStateData.selectedTiles = selectedTiles;
8732
+ const [filteredSelectedTiles, unselectedTiles] = limitSelectedTiles(selectedTiles, frameState, this.options.maximumTilesSelected);
8733
+ currentFrameStateData.selectedTiles = filteredSelectedTiles;
8734
+ for (const tile of unselectedTiles) {
8735
+ tile.unselect();
8736
+ }
8770
8737
  currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
8771
8738
  currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
8772
8739
  this.traverseCounter--;
@@ -8821,6 +8788,8 @@
8821
8788
  tilesRenderable++;
8822
8789
  if (tile.content.pointCount) {
8823
8790
  pointsRenderable += tile.content.pointCount;
8791
+ } else {
8792
+ pointsRenderable += tile.content.vertexCount;
8824
8793
  }
8825
8794
  }
8826
8795
  }
@@ -8828,17 +8797,43 @@
8828
8797
  this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
8829
8798
  this.stats.get(POINTS_COUNT).count = pointsRenderable;
8830
8799
  }
8831
- _initializeTileSet(tilesetJson) {
8800
+ async _initializeTileSet(tilesetJson) {
8801
+ if (this.type === TILESET_TYPE.I3S) {
8802
+ this.calculateViewPropsI3S();
8803
+ tilesetJson.root = await tilesetJson.root;
8804
+ }
8832
8805
  this.root = this._initializeTileHeaders(tilesetJson, null);
8833
8806
  if (this.type === TILESET_TYPE.TILES3D) {
8834
- this._initializeCesiumTileset(tilesetJson);
8807
+ this._initializeTiles3DTileset(tilesetJson);
8808
+ this.calculateViewPropsTiles3D();
8835
8809
  }
8836
8810
  if (this.type === TILESET_TYPE.I3S) {
8837
8811
  this._initializeI3STileset();
8838
8812
  }
8839
- this._calculateViewProps();
8840
8813
  }
8841
- _calculateViewProps() {
8814
+ calculateViewPropsI3S() {
8815
+ const fullExtent = this.tileset.fullExtent;
8816
+ if (fullExtent) {
8817
+ const { xmin, xmax, ymin, ymax, zmin, zmax } = fullExtent;
8818
+ this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
8819
+ this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new Vector3());
8820
+ this.zoom = getZoomFromFullExtent(fullExtent, this.cartographicCenter, this.cartesianCenter);
8821
+ return;
8822
+ }
8823
+ const extent = this.tileset.store?.extent;
8824
+ if (extent) {
8825
+ const [xmin, ymin, xmax, ymax] = extent;
8826
+ this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
8827
+ this.cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new Vector3());
8828
+ this.zoom = getZoomFromExtent(extent, this.cartographicCenter, this.cartesianCenter);
8829
+ return;
8830
+ }
8831
+ console.warn("Extent is not defined in the tileset header");
8832
+ this.cartographicCenter = new Vector3();
8833
+ this.zoom = 1;
8834
+ return;
8835
+ }
8836
+ calculateViewPropsTiles3D() {
8842
8837
  const root = this.root;
8843
8838
  assert2(root);
8844
8839
  const { center } = root.boundingVolume;
@@ -8996,7 +8991,7 @@
8996
8991
  this._unloadTile(tile);
8997
8992
  tile.destroy();
8998
8993
  }
8999
- _initializeCesiumTileset(tilesetJson) {
8994
+ _initializeTiles3DTileset(tilesetJson) {
9000
8995
  this.asset = tilesetJson.asset;
9001
8996
  if (!this.asset) {
9002
8997
  throw new Error("Tileset must have an asset property.");