@loaders.gl/tiles 3.1.6 → 3.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/dist.min.js +834 -294
  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/tile-3d.js +5 -0
  7. package/dist/es5/tileset/tile-3d.js.map +1 -1
  8. package/dist/es5/tileset/tileset-3d.js +152 -71
  9. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  10. package/dist/esm/tileset/helpers/frame-state.js +52 -0
  11. package/dist/esm/tileset/helpers/frame-state.js.map +1 -1
  12. package/dist/esm/tileset/helpers/i3s-lod.js +17 -27
  13. package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -1
  14. package/dist/esm/tileset/tile-3d.js +4 -0
  15. package/dist/esm/tileset/tile-3d.js.map +1 -1
  16. package/dist/esm/tileset/tileset-3d.js +41 -9
  17. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  18. package/dist/tileset/helpers/frame-state.d.ts +14 -0
  19. package/dist/tileset/helpers/frame-state.d.ts.map +1 -1
  20. package/dist/tileset/helpers/frame-state.js +49 -1
  21. package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -1
  22. package/dist/tileset/helpers/i3s-lod.js +17 -16
  23. package/dist/tileset/tile-3d.d.ts +5 -0
  24. package/dist/tileset/tile-3d.d.ts.map +1 -1
  25. package/dist/tileset/tile-3d.js +7 -0
  26. package/dist/tileset/tileset-3d.d.ts +19 -1
  27. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  28. package/dist/tileset/tileset-3d.js +46 -8
  29. package/package.json +5 -5
  30. package/src/tileset/helpers/frame-state.ts +56 -0
  31. package/src/tileset/helpers/i3s-lod.ts +18 -19
  32. package/src/tileset/tile-3d.ts +8 -0
  33. package/src/tileset/tileset-3d.ts +57 -8
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;
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) {
@@ -3980,6 +4026,7 @@
3980
4026
  var init_parse_with_worker = __esm({
3981
4027
  "../loader-utils/src/lib/worker-loader-utils/parse-with-worker.ts"() {
3982
4028
  init_src();
4029
+ init_src();
3983
4030
  }
3984
4031
  });
3985
4032
 
@@ -4068,230 +4115,11 @@
4068
4115
  }
4069
4116
  });
4070
4117
 
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
4118
  // ../loader-utils/src/lib/request-utils/request-scheduler.ts
4291
4119
  var STAT_QUEUED_REQUESTS, STAT_ACTIVE_REQUESTS, STAT_CANCELLED_REQUESTS, STAT_QUEUED_REQUESTS_EVER, STAT_ACTIVE_REQUESTS_EVER, DEFAULT_PROPS2, RequestScheduler;
4292
4120
  var init_request_scheduler = __esm({
4293
4121
  "../loader-utils/src/lib/request-utils/request-scheduler.ts"() {
4294
- init_esm4();
4122
+ init_esm3();
4295
4123
  STAT_QUEUED_REQUESTS = "Queued Requests";
4296
4124
  STAT_ACTIVE_REQUESTS = "Active Requests";
4297
4125
  STAT_CANCELLED_REQUESTS = "Cancelled Requests";
@@ -4309,7 +4137,7 @@
4309
4137
  this.requestMap = new Map();
4310
4138
  this.deferredUpdate = null;
4311
4139
  this.props = { ...DEFAULT_PROPS2, ...props };
4312
- this.stats = new Stats2({ id: this.props.id });
4140
+ this.stats = new Stats({ id: this.props.id });
4313
4141
  this.stats.get(STAT_QUEUED_REQUESTS);
4314
4142
  this.stats.get(STAT_ACTIVE_REQUESTS);
4315
4143
  this.stats.get(STAT_CANCELLED_REQUESTS);
@@ -5190,7 +5018,7 @@
5190
5018
  });
5191
5019
 
5192
5020
  // ../../node_modules/@math.gl/culling/dist/esm/index.js
5193
- var init_esm5 = __esm({
5021
+ var init_esm4 = __esm({
5194
5022
  "../../node_modules/@math.gl/culling/dist/esm/index.js"() {
5195
5023
  init_constants2();
5196
5024
  init_axis_aligned_bounding_box();
@@ -5216,23 +5044,59 @@
5216
5044
  const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new Vector3());
5217
5045
  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
5218
5046
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
5219
- const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
5047
+ const cameraPositionCartesian2 = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
5220
5048
  const cameraDirectionCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))).normalize();
5221
5049
  const cameraUpCartesian = new Vector3(enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))).normalize();
5222
5050
  commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);
5051
+ const ViewportClass = viewport.constructor;
5052
+ const { longitude, latitude, width, bearing, zoom } = viewport;
5053
+ const topDownViewport = new ViewportClass({
5054
+ longitude,
5055
+ latitude,
5056
+ height,
5057
+ width,
5058
+ bearing,
5059
+ zoom,
5060
+ pitch: 0
5061
+ });
5223
5062
  return {
5224
5063
  camera: {
5225
- position: cameraPositionCartesian,
5064
+ position: cameraPositionCartesian2,
5226
5065
  direction: cameraDirectionCartesian,
5227
5066
  up: cameraUpCartesian
5228
5067
  },
5229
5068
  viewport,
5069
+ topDownViewport,
5230
5070
  height,
5231
5071
  cullingVolume,
5232
5072
  frameNumber,
5233
5073
  sseDenominator: 1.15
5234
5074
  };
5235
5075
  }
5076
+ function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
5077
+ if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {
5078
+ return [tiles, []];
5079
+ }
5080
+ const tuples = [];
5081
+ const { longitude: viewportLongitude, latitude: viewportLatitude } = frameState.viewport;
5082
+ for (const [index, tile] of tiles.entries()) {
5083
+ const [longitude, latitude] = tile.header.mbs;
5084
+ const deltaLon = Math.abs(viewportLongitude - longitude);
5085
+ const deltaLat = Math.abs(viewportLatitude - latitude);
5086
+ const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);
5087
+ tuples.push([index, distance]);
5088
+ }
5089
+ const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);
5090
+ const selectedTiles = [];
5091
+ for (let i = 0; i < maximumTilesSelected; i++) {
5092
+ selectedTiles.push(tiles[tuplesSorted[i][0]]);
5093
+ }
5094
+ const unselectedTiles = [];
5095
+ for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {
5096
+ unselectedTiles.push(tiles[tuplesSorted[i][0]]);
5097
+ }
5098
+ return [selectedTiles, unselectedTiles];
5099
+ }
5236
5100
  function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
5237
5101
  const frustumPlanes = viewport.getFrustumPlanes();
5238
5102
  let i = 0;
@@ -5249,7 +5113,7 @@
5249
5113
  var init_frame_state = __esm({
5250
5114
  "src/tileset/helpers/frame-state.ts"() {
5251
5115
  init_esm();
5252
- init_esm5();
5116
+ init_esm4();
5253
5117
  init_esm2();
5254
5118
  scratchVector7 = new Vector3();
5255
5119
  scratchPosition3 = new Vector3();
@@ -5293,7 +5157,7 @@
5293
5157
  var init_zoom = __esm({
5294
5158
  "src/tileset/helpers/zoom.ts"() {
5295
5159
  init_esm();
5296
- init_esm5();
5160
+ init_esm4();
5297
5161
  WGS84_RADIUS_X2 = 6378137;
5298
5162
  WGS84_RADIUS_Y2 = 6378137;
5299
5163
  WGS84_RADIUS_Z2 = 6356752314245179e-9;
@@ -5715,7 +5579,7 @@
5715
5579
  });
5716
5580
 
5717
5581
  // ../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js
5718
- function getHiResTimestamp3() {
5582
+ function getHiResTimestamp2() {
5719
5583
  let timestamp;
5720
5584
  if (isBrowser4 && window_3.performance) {
5721
5585
  timestamp = window_3.performance.now();
@@ -5727,7 +5591,7 @@
5727
5591
  }
5728
5592
  return timestamp;
5729
5593
  }
5730
- var init_hi_res_timestamp3 = __esm({
5594
+ var init_hi_res_timestamp2 = __esm({
5731
5595
  "../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js"() {
5732
5596
  init_globals4();
5733
5597
  }
@@ -5854,7 +5718,7 @@
5854
5718
  init_color();
5855
5719
  init_autobind();
5856
5720
  init_assert4();
5857
- init_hi_res_timestamp3();
5721
+ init_hi_res_timestamp2();
5858
5722
  originalConsole = {
5859
5723
  debug: isBrowser4 ? console.debug || console.log : console.log,
5860
5724
  log: console.log,
@@ -5878,8 +5742,8 @@
5878
5742
  }) {
5879
5743
  this.id = id;
5880
5744
  this.VERSION = VERSION2;
5881
- this._startTs = getHiResTimestamp3();
5882
- this._deltaTs = getHiResTimestamp3();
5745
+ this._startTs = getHiResTimestamp2();
5746
+ this._deltaTs = getHiResTimestamp2();
5883
5747
  this.LOG_THROTTLE_TIMEOUT = 0;
5884
5748
  this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS);
5885
5749
  this.userData = {};
@@ -5900,10 +5764,10 @@
5900
5764
  return this._storage.config.level;
5901
5765
  }
5902
5766
  getTotal() {
5903
- return Number((getHiResTimestamp3() - this._startTs).toPrecision(10));
5767
+ return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
5904
5768
  }
5905
5769
  getDelta() {
5906
- return Number((getHiResTimestamp3() - this._deltaTs).toPrecision(10));
5770
+ return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
5907
5771
  }
5908
5772
  set priority(newPriority) {
5909
5773
  this.level = newPriority;
@@ -6058,11 +5922,11 @@
6058
5922
  assert4(method);
6059
5923
  opts.total = this.getTotal();
6060
5924
  opts.delta = this.getDelta();
6061
- this._deltaTs = getHiResTimestamp3();
5925
+ this._deltaTs = getHiResTimestamp2();
6062
5926
  const tag = opts.tag || opts.message;
6063
5927
  if (opts.once) {
6064
5928
  if (!cache[tag]) {
6065
- cache[tag] = getHiResTimestamp3();
5929
+ cache[tag] = getHiResTimestamp2();
6066
5930
  } else {
6067
5931
  return noop2;
6068
5932
  }
@@ -6077,42 +5941,42 @@
6077
5941
  }
6078
5942
  });
6079
5943
 
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"() {
5944
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
5945
+ var init_hi_res_timestamp3 = __esm({
5946
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
6083
5947
  }
6084
5948
  });
6085
5949
 
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();
5950
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js
5951
+ var init_stat2 = __esm({
5952
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
5953
+ init_hi_res_timestamp3();
6090
5954
  }
6091
5955
  });
6092
5956
 
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();
5957
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js
5958
+ var init_stats2 = __esm({
5959
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
5960
+ init_stat2();
6097
5961
  }
6098
5962
  });
6099
5963
 
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();
5964
+ // ../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js
5965
+ var init_esm5 = __esm({
5966
+ "../../node_modules/probe.gl/node_modules/@probe.gl/stats/dist/esm/index.js"() {
5967
+ init_stats2();
5968
+ init_stat2();
5969
+ init_hi_res_timestamp3();
6106
5970
  }
6107
5971
  });
6108
5972
 
6109
5973
  // ../../node_modules/probe.gl/dist/esm/index.js
6110
5974
  var esm_default;
6111
- var init_esm7 = __esm({
5975
+ var init_esm6 = __esm({
6112
5976
  "../../node_modules/probe.gl/dist/esm/index.js"() {
6113
5977
  init_log();
6114
5978
  init_log();
6115
- init_esm6();
5979
+ init_esm5();
6116
5980
  esm_default = new Log({
6117
5981
  id: "probe.gl"
6118
5982
  });
@@ -6123,7 +5987,7 @@
6123
5987
  var probeLog, NullLog, ConsoleLog;
6124
5988
  var init_loggers = __esm({
6125
5989
  "../core/src/lib/loader-utils/loggers.ts"() {
6126
- init_esm7();
5990
+ init_esm6();
6127
5991
  probeLog = new Log({ id: "loaders.gl" });
6128
5992
  NullLog = class {
6129
5993
  log() {
@@ -6167,6 +6031,7 @@
6167
6031
  var DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS;
6168
6032
  var init_option_defaults = __esm({
6169
6033
  "../core/src/lib/loader-utils/option-defaults.ts"() {
6034
+ init_src2();
6170
6035
  init_loggers();
6171
6036
  DEFAULT_LOADER_OPTIONS = {
6172
6037
  fetch: null,
@@ -6177,7 +6042,8 @@
6177
6042
  worker: true,
6178
6043
  maxConcurrency: 3,
6179
6044
  maxMobileConcurrency: 1,
6180
- reuseWorkers: true,
6045
+ reuseWorkers: isBrowser,
6046
+ _nodeWorkers: false,
6181
6047
  _workerType: "",
6182
6048
  limit: 0,
6183
6049
  _limitMB: 0,
@@ -6375,6 +6241,638 @@
6375
6241
  }
6376
6242
  });
6377
6243
 
6244
+ // ../../node_modules/@probe.gl/env/dist/esm/lib/is-electron.js
6245
+ function isElectron2(mockUserAgent) {
6246
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
6247
+ return true;
6248
+ }
6249
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions.electron)) {
6250
+ return true;
6251
+ }
6252
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
6253
+ const userAgent = mockUserAgent || realUserAgent;
6254
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
6255
+ return true;
6256
+ }
6257
+ return false;
6258
+ }
6259
+ var init_is_electron2 = __esm({
6260
+ "../../node_modules/@probe.gl/env/dist/esm/lib/is-electron.js"() {
6261
+ }
6262
+ });
6263
+
6264
+ // ../../node_modules/@probe.gl/env/dist/esm/lib/is-browser.js
6265
+ function isBrowser5() {
6266
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
6267
+ return !isNode || isElectron2();
6268
+ }
6269
+ var init_is_browser2 = __esm({
6270
+ "../../node_modules/@probe.gl/env/dist/esm/lib/is-browser.js"() {
6271
+ init_is_electron2();
6272
+ }
6273
+ });
6274
+
6275
+ // ../../node_modules/@probe.gl/env/dist/esm/lib/globals.js
6276
+ var globals5, self_4, window_4, document_4, process_2;
6277
+ var init_globals5 = __esm({
6278
+ "../../node_modules/@probe.gl/env/dist/esm/lib/globals.js"() {
6279
+ globals5 = {
6280
+ self: typeof self !== "undefined" && self,
6281
+ window: typeof window !== "undefined" && window,
6282
+ global: typeof global !== "undefined" && global,
6283
+ document: typeof document !== "undefined" && document,
6284
+ process: typeof process === "object" && process
6285
+ };
6286
+ self_4 = globals5.self || globals5.window || globals5.global;
6287
+ window_4 = globals5.window || globals5.self || globals5.global;
6288
+ document_4 = globals5.document || {};
6289
+ process_2 = globals5.process || {};
6290
+ }
6291
+ });
6292
+
6293
+ // ../../node_modules/@probe.gl/env/dist/esm/utils/globals.js
6294
+ var VERSION3, isBrowser6;
6295
+ var init_globals6 = __esm({
6296
+ "../../node_modules/@probe.gl/env/dist/esm/utils/globals.js"() {
6297
+ init_is_browser2();
6298
+ VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
6299
+ isBrowser6 = isBrowser5();
6300
+ }
6301
+ });
6302
+
6303
+ // ../../node_modules/@probe.gl/env/dist/esm/index.js
6304
+ var init_esm7 = __esm({
6305
+ "../../node_modules/@probe.gl/env/dist/esm/index.js"() {
6306
+ init_globals6();
6307
+ init_globals5();
6308
+ init_is_browser2();
6309
+ }
6310
+ });
6311
+
6312
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/local-storage.js
6313
+ function getStorage2(type) {
6314
+ try {
6315
+ const storage = window[type];
6316
+ const x = "__storage_test__";
6317
+ storage.setItem(x, x);
6318
+ storage.removeItem(x);
6319
+ return storage;
6320
+ } catch (e) {
6321
+ return null;
6322
+ }
6323
+ }
6324
+ var LocalStorage2;
6325
+ var init_local_storage2 = __esm({
6326
+ "../../node_modules/@probe.gl/log/dist/esm/utils/local-storage.js"() {
6327
+ init_defineProperty();
6328
+ LocalStorage2 = class {
6329
+ constructor(id) {
6330
+ let defaultSettings = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6331
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
6332
+ _defineProperty(this, "storage", void 0);
6333
+ _defineProperty(this, "id", void 0);
6334
+ _defineProperty(this, "config", {});
6335
+ this.storage = getStorage2(type);
6336
+ this.id = id;
6337
+ this.config = {};
6338
+ Object.assign(this.config, defaultSettings);
6339
+ this._loadConfiguration();
6340
+ }
6341
+ getConfiguration() {
6342
+ return this.config;
6343
+ }
6344
+ setConfiguration(configuration) {
6345
+ this.config = {};
6346
+ return this.updateConfiguration(configuration);
6347
+ }
6348
+ updateConfiguration(configuration) {
6349
+ Object.assign(this.config, configuration);
6350
+ if (this.storage) {
6351
+ const serialized = JSON.stringify(this.config);
6352
+ this.storage.setItem(this.id, serialized);
6353
+ }
6354
+ return this;
6355
+ }
6356
+ _loadConfiguration() {
6357
+ let configuration = {};
6358
+ if (this.storage) {
6359
+ const serializedConfiguration = this.storage.getItem(this.id);
6360
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
6361
+ }
6362
+ Object.assign(this.config, configuration);
6363
+ return this;
6364
+ }
6365
+ };
6366
+ }
6367
+ });
6368
+
6369
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/formatters.js
6370
+ function formatTime2(ms) {
6371
+ let formatted;
6372
+ if (ms < 10) {
6373
+ formatted = "".concat(ms.toFixed(2), "ms");
6374
+ } else if (ms < 100) {
6375
+ formatted = "".concat(ms.toFixed(1), "ms");
6376
+ } else if (ms < 1e3) {
6377
+ formatted = "".concat(ms.toFixed(0), "ms");
6378
+ } else {
6379
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
6380
+ }
6381
+ return formatted;
6382
+ }
6383
+ function leftPad2(string) {
6384
+ let length4 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
6385
+ const padLength = Math.max(length4 - string.length, 0);
6386
+ return "".concat(" ".repeat(padLength)).concat(string);
6387
+ }
6388
+ function formatImage2(image, message, scale5) {
6389
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
6390
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
6391
+ if (image.width > maxWidth) {
6392
+ scale5 = Math.min(scale5, maxWidth / image.width);
6393
+ }
6394
+ const width = image.width * scale5;
6395
+ const height = image.height * scale5;
6396
+ const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
6397
+ return ["".concat(message, " %c+"), style];
6398
+ }
6399
+ var init_formatters2 = __esm({
6400
+ "../../node_modules/@probe.gl/log/dist/esm/utils/formatters.js"() {
6401
+ }
6402
+ });
6403
+
6404
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/color.js
6405
+ function getColor2(color) {
6406
+ return typeof color === "string" ? COLOR2[color.toUpperCase()] || COLOR2.WHITE : color;
6407
+ }
6408
+ function addColor2(string, color, background) {
6409
+ if (!isBrowser5 && typeof string === "string") {
6410
+ if (color) {
6411
+ color = getColor2(color);
6412
+ string = "[".concat(color, "m").concat(string, "");
6413
+ }
6414
+ if (background) {
6415
+ color = getColor2(background);
6416
+ string = "[".concat(background + 10, "m").concat(string, "");
6417
+ }
6418
+ }
6419
+ return string;
6420
+ }
6421
+ var COLOR2;
6422
+ var init_color2 = __esm({
6423
+ "../../node_modules/@probe.gl/log/dist/esm/utils/color.js"() {
6424
+ init_esm7();
6425
+ (function(COLOR3) {
6426
+ COLOR3[COLOR3["BLACK"] = 30] = "BLACK";
6427
+ COLOR3[COLOR3["RED"] = 31] = "RED";
6428
+ COLOR3[COLOR3["GREEN"] = 32] = "GREEN";
6429
+ COLOR3[COLOR3["YELLOW"] = 33] = "YELLOW";
6430
+ COLOR3[COLOR3["BLUE"] = 34] = "BLUE";
6431
+ COLOR3[COLOR3["MAGENTA"] = 35] = "MAGENTA";
6432
+ COLOR3[COLOR3["CYAN"] = 36] = "CYAN";
6433
+ COLOR3[COLOR3["WHITE"] = 37] = "WHITE";
6434
+ COLOR3[COLOR3["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
6435
+ COLOR3[COLOR3["BRIGHT_RED"] = 91] = "BRIGHT_RED";
6436
+ COLOR3[COLOR3["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
6437
+ COLOR3[COLOR3["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
6438
+ COLOR3[COLOR3["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
6439
+ COLOR3[COLOR3["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
6440
+ COLOR3[COLOR3["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
6441
+ COLOR3[COLOR3["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
6442
+ })(COLOR2 || (COLOR2 = {}));
6443
+ }
6444
+ });
6445
+
6446
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/autobind.js
6447
+ function autobind2(obj) {
6448
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
6449
+ const proto = Object.getPrototypeOf(obj);
6450
+ const propNames = Object.getOwnPropertyNames(proto);
6451
+ for (const key of propNames) {
6452
+ if (typeof obj[key] === "function") {
6453
+ if (!predefined.find((name) => key === name)) {
6454
+ obj[key] = obj[key].bind(obj);
6455
+ }
6456
+ }
6457
+ }
6458
+ }
6459
+ var init_autobind2 = __esm({
6460
+ "../../node_modules/@probe.gl/log/dist/esm/utils/autobind.js"() {
6461
+ }
6462
+ });
6463
+
6464
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/assert.js
6465
+ function assert5(condition, message) {
6466
+ if (!condition) {
6467
+ throw new Error(message || "Assertion failed");
6468
+ }
6469
+ }
6470
+ var init_assert5 = __esm({
6471
+ "../../node_modules/@probe.gl/log/dist/esm/utils/assert.js"() {
6472
+ }
6473
+ });
6474
+
6475
+ // ../../node_modules/@probe.gl/log/dist/esm/utils/hi-res-timestamp.js
6476
+ function getHiResTimestamp4() {
6477
+ let timestamp;
6478
+ if (isBrowser5 && "performance" in window_4) {
6479
+ var _window$performance, _window$performance$n;
6480
+ timestamp = window_4 === null || window_4 === void 0 ? void 0 : (_window$performance = window_4.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);
6481
+ } else if ("hrtime" in process_2) {
6482
+ var _process$hrtime;
6483
+ const timeParts = process_2 === null || process_2 === void 0 ? void 0 : (_process$hrtime = process_2.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_2);
6484
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
6485
+ } else {
6486
+ timestamp = Date.now();
6487
+ }
6488
+ return timestamp;
6489
+ }
6490
+ var init_hi_res_timestamp4 = __esm({
6491
+ "../../node_modules/@probe.gl/log/dist/esm/utils/hi-res-timestamp.js"() {
6492
+ init_esm7();
6493
+ }
6494
+ });
6495
+
6496
+ // ../../node_modules/@probe.gl/log/dist/esm/log.js
6497
+ function noop3() {
6498
+ }
6499
+ function normalizeLogLevel2(logLevel) {
6500
+ if (!logLevel) {
6501
+ return 0;
6502
+ }
6503
+ let resolvedLevel;
6504
+ switch (typeof logLevel) {
6505
+ case "number":
6506
+ resolvedLevel = logLevel;
6507
+ break;
6508
+ case "object":
6509
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
6510
+ break;
6511
+ default:
6512
+ return 0;
6513
+ }
6514
+ assert5(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
6515
+ return resolvedLevel;
6516
+ }
6517
+ function normalizeArguments2(opts) {
6518
+ const {
6519
+ logLevel,
6520
+ message
6521
+ } = opts;
6522
+ opts.logLevel = normalizeLogLevel2(logLevel);
6523
+ const args = opts.args ? Array.from(opts.args) : [];
6524
+ while (args.length && args.shift() !== message) {
6525
+ }
6526
+ switch (typeof logLevel) {
6527
+ case "string":
6528
+ case "function":
6529
+ if (message !== void 0) {
6530
+ args.unshift(message);
6531
+ }
6532
+ opts.message = logLevel;
6533
+ break;
6534
+ case "object":
6535
+ Object.assign(opts, logLevel);
6536
+ break;
6537
+ default:
6538
+ }
6539
+ if (typeof opts.message === "function") {
6540
+ opts.message = opts.message();
6541
+ }
6542
+ const messageType = typeof opts.message;
6543
+ assert5(messageType === "string" || messageType === "object");
6544
+ return Object.assign(opts, {
6545
+ args
6546
+ }, opts.opts);
6547
+ }
6548
+ function decorateMessage2(id, message, opts) {
6549
+ if (typeof message === "string") {
6550
+ const time = opts.time ? leftPad2(formatTime2(opts.total)) : "";
6551
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
6552
+ message = addColor2(message, opts.color, opts.background);
6553
+ }
6554
+ return message;
6555
+ }
6556
+ function logImageInNode2(_ref2) {
6557
+ let {
6558
+ image,
6559
+ message = "",
6560
+ scale: scale5 = 1
6561
+ } = _ref2;
6562
+ let asciify = null;
6563
+ try {
6564
+ asciify = module.require("asciify-image");
6565
+ } catch (error) {
6566
+ }
6567
+ if (asciify) {
6568
+ return () => asciify(image, {
6569
+ fit: "box",
6570
+ width: "".concat(Math.round(80 * scale5), "%")
6571
+ }).then((data) => console.log(data));
6572
+ }
6573
+ return noop3;
6574
+ }
6575
+ function logImageInBrowser2(_ref3) {
6576
+ let {
6577
+ image,
6578
+ message = "",
6579
+ scale: scale5 = 1
6580
+ } = _ref3;
6581
+ if (typeof image === "string") {
6582
+ const img = new Image();
6583
+ img.onload = () => {
6584
+ const args = formatImage2(img, message, scale5);
6585
+ console.log(...args);
6586
+ };
6587
+ img.src = image;
6588
+ return noop3;
6589
+ }
6590
+ const element = image.nodeName || "";
6591
+ if (element.toLowerCase() === "img") {
6592
+ console.log(...formatImage2(image, message, scale5));
6593
+ return noop3;
6594
+ }
6595
+ if (element.toLowerCase() === "canvas") {
6596
+ const img = new Image();
6597
+ img.onload = () => console.log(...formatImage2(img, message, scale5));
6598
+ img.src = image.toDataURL();
6599
+ return noop3;
6600
+ }
6601
+ return noop3;
6602
+ }
6603
+ function getTableHeader2(table) {
6604
+ for (const key in table) {
6605
+ for (const title in table[key]) {
6606
+ return title || "untitled";
6607
+ }
6608
+ }
6609
+ return "empty";
6610
+ }
6611
+ var originalConsole2, DEFAULT_SETTINGS2, cache2, ONCE2, Log2;
6612
+ var init_log2 = __esm({
6613
+ "../../node_modules/@probe.gl/log/dist/esm/log.js"() {
6614
+ init_defineProperty();
6615
+ init_esm7();
6616
+ init_local_storage2();
6617
+ init_formatters2();
6618
+ init_color2();
6619
+ init_autobind2();
6620
+ init_assert5();
6621
+ init_hi_res_timestamp4();
6622
+ originalConsole2 = {
6623
+ debug: isBrowser5 ? console.debug || console.log : console.log,
6624
+ log: console.log,
6625
+ info: console.info,
6626
+ warn: console.warn,
6627
+ error: console.error
6628
+ };
6629
+ DEFAULT_SETTINGS2 = {
6630
+ enabled: true,
6631
+ level: 0
6632
+ };
6633
+ cache2 = {};
6634
+ ONCE2 = {
6635
+ once: true
6636
+ };
6637
+ Log2 = class {
6638
+ constructor() {
6639
+ let {
6640
+ id
6641
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
6642
+ id: ""
6643
+ };
6644
+ _defineProperty(this, "id", void 0);
6645
+ _defineProperty(this, "VERSION", VERSION3);
6646
+ _defineProperty(this, "_startTs", getHiResTimestamp4());
6647
+ _defineProperty(this, "_deltaTs", getHiResTimestamp4());
6648
+ _defineProperty(this, "_storage", void 0);
6649
+ _defineProperty(this, "userData", {});
6650
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
6651
+ this.id = id;
6652
+ this._storage = new LocalStorage2("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS2);
6653
+ this.userData = {};
6654
+ this.timeStamp("".concat(this.id, " started"));
6655
+ autobind2(this);
6656
+ Object.seal(this);
6657
+ }
6658
+ set level(newLevel) {
6659
+ this.setLevel(newLevel);
6660
+ }
6661
+ get level() {
6662
+ return this.getLevel();
6663
+ }
6664
+ isEnabled() {
6665
+ return this._storage.config.enabled;
6666
+ }
6667
+ getLevel() {
6668
+ return this._storage.config.level;
6669
+ }
6670
+ getTotal() {
6671
+ return Number((getHiResTimestamp4() - this._startTs).toPrecision(10));
6672
+ }
6673
+ getDelta() {
6674
+ return Number((getHiResTimestamp4() - this._deltaTs).toPrecision(10));
6675
+ }
6676
+ set priority(newPriority) {
6677
+ this.level = newPriority;
6678
+ }
6679
+ get priority() {
6680
+ return this.level;
6681
+ }
6682
+ getPriority() {
6683
+ return this.level;
6684
+ }
6685
+ enable() {
6686
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
6687
+ this._storage.updateConfiguration({
6688
+ enabled
6689
+ });
6690
+ return this;
6691
+ }
6692
+ setLevel(level) {
6693
+ this._storage.updateConfiguration({
6694
+ level
6695
+ });
6696
+ return this;
6697
+ }
6698
+ get(setting) {
6699
+ return this._storage.config[setting];
6700
+ }
6701
+ set(setting, value) {
6702
+ this._storage.updateConfiguration({
6703
+ [setting]: value
6704
+ });
6705
+ }
6706
+ settings() {
6707
+ if (console.table) {
6708
+ console.table(this._storage.config);
6709
+ } else {
6710
+ console.log(this._storage.config);
6711
+ }
6712
+ }
6713
+ assert(condition, message) {
6714
+ assert5(condition, message);
6715
+ }
6716
+ warn(message) {
6717
+ return this._getLogFunction(0, message, originalConsole2.warn, arguments, ONCE2);
6718
+ }
6719
+ error(message) {
6720
+ return this._getLogFunction(0, message, originalConsole2.error, arguments);
6721
+ }
6722
+ deprecated(oldUsage, newUsage) {
6723
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
6724
+ }
6725
+ removed(oldUsage, newUsage) {
6726
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
6727
+ }
6728
+ probe(logLevel, message) {
6729
+ return this._getLogFunction(logLevel, message, originalConsole2.log, arguments, {
6730
+ time: true,
6731
+ once: true
6732
+ });
6733
+ }
6734
+ log(logLevel, message) {
6735
+ return this._getLogFunction(logLevel, message, originalConsole2.debug, arguments);
6736
+ }
6737
+ info(logLevel, message) {
6738
+ return this._getLogFunction(logLevel, message, console.info, arguments);
6739
+ }
6740
+ once(logLevel, message) {
6741
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
6742
+ args[_key - 2] = arguments[_key];
6743
+ }
6744
+ return this._getLogFunction(logLevel, message, originalConsole2.debug || originalConsole2.info, arguments, ONCE2);
6745
+ }
6746
+ table(logLevel, table, columns) {
6747
+ if (table) {
6748
+ return this._getLogFunction(logLevel, table, console.table || noop3, columns && [columns], {
6749
+ tag: getTableHeader2(table)
6750
+ });
6751
+ }
6752
+ return noop3;
6753
+ }
6754
+ image(_ref) {
6755
+ let {
6756
+ logLevel,
6757
+ priority,
6758
+ image,
6759
+ message = "",
6760
+ scale: scale5 = 1
6761
+ } = _ref;
6762
+ if (!this._shouldLog(logLevel || priority)) {
6763
+ return noop3;
6764
+ }
6765
+ return isBrowser5 ? logImageInBrowser2({
6766
+ image,
6767
+ message,
6768
+ scale: scale5
6769
+ }) : logImageInNode2({
6770
+ image,
6771
+ message,
6772
+ scale: scale5
6773
+ });
6774
+ }
6775
+ time(logLevel, message) {
6776
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
6777
+ }
6778
+ timeEnd(logLevel, message) {
6779
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
6780
+ }
6781
+ timeStamp(logLevel, message) {
6782
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop3);
6783
+ }
6784
+ group(logLevel, message) {
6785
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
6786
+ collapsed: false
6787
+ };
6788
+ const options = normalizeArguments2({
6789
+ logLevel,
6790
+ message,
6791
+ opts
6792
+ });
6793
+ const {
6794
+ collapsed
6795
+ } = opts;
6796
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
6797
+ return this._getLogFunction(options);
6798
+ }
6799
+ groupCollapsed(logLevel, message) {
6800
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6801
+ return this.group(logLevel, message, Object.assign({}, opts, {
6802
+ collapsed: true
6803
+ }));
6804
+ }
6805
+ groupEnd(logLevel) {
6806
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop3);
6807
+ }
6808
+ withGroup(logLevel, message, func) {
6809
+ this.group(logLevel, message)();
6810
+ try {
6811
+ func();
6812
+ } finally {
6813
+ this.groupEnd(logLevel)();
6814
+ }
6815
+ }
6816
+ trace() {
6817
+ if (console.trace) {
6818
+ console.trace();
6819
+ }
6820
+ }
6821
+ _shouldLog(logLevel) {
6822
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel2(logLevel);
6823
+ }
6824
+ _getLogFunction(logLevel, message, method, args, opts) {
6825
+ if (this._shouldLog(logLevel)) {
6826
+ opts = normalizeArguments2({
6827
+ logLevel,
6828
+ message,
6829
+ args,
6830
+ opts
6831
+ });
6832
+ method = method || opts.method;
6833
+ assert5(method);
6834
+ opts.total = this.getTotal();
6835
+ opts.delta = this.getDelta();
6836
+ this._deltaTs = getHiResTimestamp4();
6837
+ const tag = opts.tag || opts.message;
6838
+ if (opts.once) {
6839
+ if (!cache2[tag]) {
6840
+ cache2[tag] = getHiResTimestamp4();
6841
+ } else {
6842
+ return noop3;
6843
+ }
6844
+ }
6845
+ message = decorateMessage2(this.id, opts.message, opts);
6846
+ return method.bind(console, message, ...opts.args);
6847
+ }
6848
+ return noop3;
6849
+ }
6850
+ };
6851
+ _defineProperty(Log2, "VERSION", VERSION3);
6852
+ }
6853
+ });
6854
+
6855
+ // ../../node_modules/@probe.gl/log/dist/esm/index.js
6856
+ var esm_default2;
6857
+ var init_esm8 = __esm({
6858
+ "../../node_modules/@probe.gl/log/dist/esm/index.js"() {
6859
+ init_log2();
6860
+ init_log2();
6861
+ esm_default2 = new Log2({
6862
+ id: "@probe.gl/log"
6863
+ });
6864
+ }
6865
+ });
6866
+
6867
+ // ../core/src/lib/utils/log.ts
6868
+ var log;
6869
+ var init_log3 = __esm({
6870
+ "../core/src/lib/utils/log.ts"() {
6871
+ init_esm8();
6872
+ log = new Log2({ id: "loaders.gl" });
6873
+ }
6874
+ });
6875
+
6378
6876
  // ../core/src/lib/api/select-loader.ts
6379
6877
  async function selectLoader(data, loaders = [], options, context) {
6380
6878
  if (!validHTTPResponse(data)) {
@@ -6418,13 +6916,22 @@
6418
6916
  const { url, type } = getResourceUrlAndType(data);
6419
6917
  const testUrl = url || context?.url;
6420
6918
  let loader = null;
6919
+ let reason = "";
6421
6920
  if (options?.mimeType) {
6422
6921
  loader = findLoaderByMIMEType(loaders, options?.mimeType);
6922
+ reason = `match forced by supplied MIME type ${options?.mimeType}`;
6423
6923
  }
6424
6924
  loader = loader || findLoaderByUrl(loaders, testUrl);
6925
+ reason = reason || (loader ? `matched url ${testUrl}` : "");
6425
6926
  loader = loader || findLoaderByMIMEType(loaders, type);
6927
+ reason = reason || (loader ? `matched MIME type ${type}` : "");
6426
6928
  loader = loader || findLoaderByInitialBytes(loaders, data);
6929
+ reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
6427
6930
  loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6931
+ reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6932
+ if (reason) {
6933
+ log.log(1, `selectLoader selected ${loader?.name}: ${reason}.`);
6934
+ }
6428
6935
  return loader;
6429
6936
  }
6430
6937
  function validHTTPResponse(data) {
@@ -6551,6 +7058,7 @@
6551
7058
  "../core/src/lib/api/select-loader.ts"() {
6552
7059
  init_src2();
6553
7060
  init_normalize_loader();
7061
+ init_log3();
6554
7062
  init_resource_utils();
6555
7063
  init_register_loaders();
6556
7064
  init_is_type();
@@ -6981,7 +7489,7 @@
6981
7489
  var init_bounding_volume = __esm({
6982
7490
  "src/tileset/helpers/bounding-volume.ts"() {
6983
7491
  init_esm();
6984
- init_esm5();
7492
+ init_esm4();
6985
7493
  init_esm2();
6986
7494
  init_src2();
6987
7495
  scratchScale = new Vector3();
@@ -7048,39 +7556,43 @@
7048
7556
  return "OUT";
7049
7557
  }
7050
7558
  function getProjectedRadius(tile, frameState) {
7051
- const originalViewport = frameState.viewport;
7052
- const ViewportClass = originalViewport.constructor;
7053
- const { longitude, latitude, height, width, bearing, zoom } = originalViewport;
7054
- const viewport = new ViewportClass({ longitude, latitude, height, width, bearing, zoom, pitch: 0 });
7559
+ const { topDownViewport: viewport } = frameState;
7055
7560
  const mbsLat = tile.header.mbs[1];
7056
7561
  const mbsLon = tile.header.mbs[0];
7057
7562
  const mbsZ = tile.header.mbs[2];
7058
7563
  const mbsR = tile.header.mbs[3];
7059
7564
  const mbsCenterCartesian = [...tile.boundingVolume.center];
7060
7565
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
7061
- const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());
7062
- const toEye = new Vector3(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
7063
- const enuToCartesianMatrix = new Matrix4();
7566
+ Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);
7567
+ toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();
7064
7568
  Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);
7065
- const cartesianToEnuMatrix = new Matrix4(enuToCartesianMatrix).invert();
7066
- const cameraPositionEnu = new Vector3(cameraPositionCartesian).transform(cartesianToEnuMatrix);
7569
+ cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();
7570
+ cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);
7067
7571
  const projection = Math.sqrt(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);
7068
7572
  const extraZ = projection * projection / cameraPositionEnu[2];
7069
- const extraVertexEnu = new Vector3([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
7573
+ extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);
7070
7574
  const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);
7071
- const extraVectorCartesian = new Vector3(extraVertexCartesian).subtract(mbsCenterCartesian).normalize();
7575
+ const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();
7072
7576
  const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);
7073
- const sphereMbsBorderVertexCartesian = new Vector3(mbsCenterCartesian).add(radiusVector);
7577
+ const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);
7074
7578
  const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(sphereMbsBorderVertexCartesian);
7075
7579
  const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);
7076
7580
  const projectedMbsBorderVertex = viewport.project(sphereMbsBorderVertexCartographic);
7077
- const projectedRadius = new Vector3(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
7581
+ const projectedRadius = projectedOriginVector.copy(projectedOrigin).subtract(projectedMbsBorderVertex).magnitude();
7078
7582
  return projectedRadius;
7079
7583
  }
7584
+ var cameraPositionCartesian, toEye, cameraPositionEnu, extraVertexEnu, projectedOriginVector, enuToCartesianMatrix, cartesianToEnuMatrix;
7080
7585
  var init_i3s_lod = __esm({
7081
7586
  "src/tileset/helpers/i3s-lod.ts"() {
7082
7587
  init_esm();
7083
7588
  init_esm2();
7589
+ cameraPositionCartesian = new Vector3();
7590
+ toEye = new Vector3();
7591
+ cameraPositionEnu = new Vector3();
7592
+ extraVertexEnu = new Vector3();
7593
+ projectedOriginVector = new Vector3();
7594
+ enuToCartesianMatrix = new Matrix4();
7595
+ cartesianToEnuMatrix = new Matrix4();
7084
7596
  }
7085
7597
  });
7086
7598
 
@@ -7414,7 +7926,7 @@
7414
7926
  var init_tile_3d = __esm({
7415
7927
  "src/tileset/tile-3d.ts"() {
7416
7928
  init_esm();
7417
- init_esm5();
7929
+ init_esm4();
7418
7930
  init_src3();
7419
7931
  init_constants3();
7420
7932
  init_bounding_volume();
@@ -7524,6 +8036,9 @@
7524
8036
  throw new Error("Unsupported tileset type");
7525
8037
  }
7526
8038
  }
8039
+ unselect() {
8040
+ this._selectedFrame = 0;
8041
+ }
7527
8042
  _getPriority() {
7528
8043
  const traverser = this.tileset._traverser;
7529
8044
  const { skipLevelOfDetail } = traverser.options;
@@ -7955,6 +8470,8 @@
7955
8470
  throttleRequests: true,
7956
8471
  maxRequests: 64,
7957
8472
  maximumMemoryUsage: 32,
8473
+ maximumTilesSelected: 0,
8474
+ debounceTime: 0,
7958
8475
  onTileLoad: () => {
7959
8476
  },
7960
8477
  onTileUnload: () => {
@@ -7985,6 +8502,7 @@
7985
8502
  TILES_GPU_MEMORY = "Tile Memory Use";
7986
8503
  Tileset3D = class {
7987
8504
  constructor(json, options) {
8505
+ this.updatePromise = null;
7988
8506
  assert2(json);
7989
8507
  this.options = { ...DEFAULT_PROPS4, ...options };
7990
8508
  this.tileset = json;
@@ -8068,18 +8586,36 @@
8068
8586
  hasExtension(extensionName) {
8069
8587
  return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
8070
8588
  }
8071
- update(viewports) {
8589
+ update(viewports = null) {
8590
+ if (!viewports && this.lastUpdatedVieports) {
8591
+ viewports = this.lastUpdatedVieports;
8592
+ } else {
8593
+ this.lastUpdatedVieports = viewports;
8594
+ }
8595
+ this.doUpdate(viewports);
8596
+ }
8597
+ async selectTiles(viewports = null) {
8598
+ if (viewports) {
8599
+ this.lastUpdatedVieports = viewports;
8600
+ }
8601
+ if (!this.updatePromise) {
8602
+ this.updatePromise = new Promise((resolve) => {
8603
+ setTimeout(() => {
8604
+ this.doUpdate(this.lastUpdatedVieports);
8605
+ resolve(this._frameNumber);
8606
+ this.updatePromise = null;
8607
+ }, this.options.debounceTime);
8608
+ });
8609
+ }
8610
+ return this.updatePromise;
8611
+ }
8612
+ doUpdate(viewports = null) {
8072
8613
  if ("loadTiles" in this.options && !this.options.loadTiles) {
8073
8614
  return;
8074
8615
  }
8075
8616
  if (this.traverseCounter > 0) {
8076
8617
  return;
8077
8618
  }
8078
- if (!viewports && this.lastUpdatedVieports) {
8079
- viewports = this.lastUpdatedVieports;
8080
- } else {
8081
- this.lastUpdatedVieports = viewports;
8082
- }
8083
8619
  if (!(viewports instanceof Array)) {
8084
8620
  viewports = [viewports];
8085
8621
  }
@@ -8124,7 +8660,11 @@
8124
8660
  }
8125
8661
  const currentFrameStateData = this.frameStateData[id];
8126
8662
  const selectedTiles = Object.values(this._traverser.selectedTiles);
8127
- currentFrameStateData.selectedTiles = selectedTiles;
8663
+ const [filteredSelectedTiles, unselectedTiles] = limitSelectedTiles(selectedTiles, frameState, this.options.maximumTilesSelected);
8664
+ currentFrameStateData.selectedTiles = filteredSelectedTiles;
8665
+ for (const tile of unselectedTiles) {
8666
+ tile.unselect();
8667
+ }
8128
8668
  currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
8129
8669
  currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
8130
8670
  this.traverseCounter--;