@loaders.gl/tiles 3.1.0 → 3.1.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.
package/dist/bundle.js CHANGED
@@ -3196,7 +3196,26 @@
3196
3196
  }
3197
3197
  });
3198
3198
 
3199
- // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
3199
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
3200
+ function _defineProperty(obj, key, value) {
3201
+ if (key in obj) {
3202
+ Object.defineProperty(obj, key, {
3203
+ value,
3204
+ enumerable: true,
3205
+ configurable: true,
3206
+ writable: true
3207
+ });
3208
+ } else {
3209
+ obj[key] = value;
3210
+ }
3211
+ return obj;
3212
+ }
3213
+ var init_defineProperty = __esm({
3214
+ "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
3215
+ }
3216
+ });
3217
+
3218
+ // node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
3200
3219
  function getHiResTimestamp() {
3201
3220
  let timestamp;
3202
3221
  if (typeof window !== "undefined" && window.performance) {
@@ -3210,20 +3229,34 @@
3210
3229
  return timestamp;
3211
3230
  }
3212
3231
  var init_hi_res_timestamp = __esm({
3213
- "../../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"() {
3214
3233
  }
3215
3234
  });
3216
3235
 
3217
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
3236
+ // node_modules/@probe.gl/stats/dist/esm/lib/stat.js
3218
3237
  var Stat;
3219
3238
  var init_stat = __esm({
3220
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
3239
+ "node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
3240
+ init_defineProperty();
3221
3241
  init_hi_res_timestamp();
3222
3242
  Stat = class {
3223
3243
  constructor(name, type) {
3244
+ _defineProperty(this, "name", void 0);
3245
+ _defineProperty(this, "type", void 0);
3246
+ _defineProperty(this, "sampleSize", 1);
3247
+ _defineProperty(this, "time", void 0);
3248
+ _defineProperty(this, "count", void 0);
3249
+ _defineProperty(this, "samples", void 0);
3250
+ _defineProperty(this, "lastTiming", void 0);
3251
+ _defineProperty(this, "lastSampleTime", void 0);
3252
+ _defineProperty(this, "lastSampleCount", void 0);
3253
+ _defineProperty(this, "_count", 0);
3254
+ _defineProperty(this, "_time", 0);
3255
+ _defineProperty(this, "_samples", 0);
3256
+ _defineProperty(this, "_startTime", 0);
3257
+ _defineProperty(this, "_timerPending", false);
3224
3258
  this.name = name;
3225
3259
  this.type = type;
3226
- this.sampleSize = 1;
3227
3260
  this.reset();
3228
3261
  }
3229
3262
  setSampleSize(samples) {
@@ -3319,22 +3352,23 @@
3319
3352
  }
3320
3353
  });
3321
3354
 
3322
- // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
3355
+ // node_modules/@probe.gl/stats/dist/esm/lib/stats.js
3323
3356
  var Stats;
3324
3357
  var init_stats = __esm({
3325
- "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
3358
+ "node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
3359
+ init_defineProperty();
3326
3360
  init_stat();
3327
3361
  Stats = class {
3328
- constructor({
3329
- id,
3330
- stats
3331
- }) {
3332
- this.id = id;
3362
+ constructor(options) {
3363
+ _defineProperty(this, "id", void 0);
3364
+ _defineProperty(this, "stats", {});
3365
+ this.id = options.id;
3333
3366
  this.stats = {};
3334
- this._initializeStats(stats);
3367
+ this._initializeStats(options.stats);
3335
3368
  Object.seal(this);
3336
3369
  }
3337
- get(name, type = "count") {
3370
+ get(name) {
3371
+ let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
3338
3372
  return this._getOrCreate({
3339
3373
  name,
3340
3374
  type
@@ -3366,7 +3400,8 @@
3366
3400
  });
3367
3401
  return table;
3368
3402
  }
3369
- _initializeStats(stats = []) {
3403
+ _initializeStats() {
3404
+ let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
3370
3405
  stats.forEach((stat) => this._getOrCreate(stat));
3371
3406
  }
3372
3407
  _getOrCreate(stat) {
@@ -3390,9 +3425,9 @@
3390
3425
  }
3391
3426
  });
3392
3427
 
3393
- // ../../node_modules/@probe.gl/stats/dist/esm/index.js
3428
+ // node_modules/@probe.gl/stats/dist/esm/index.js
3394
3429
  var init_esm3 = __esm({
3395
- "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
3430
+ "node_modules/@probe.gl/stats/dist/esm/index.js"() {
3396
3431
  init_stats();
3397
3432
  init_stat();
3398
3433
  init_hi_res_timestamp();
@@ -3434,7 +3469,7 @@
3434
3469
  var DEFAULT_VERSION, VERSION;
3435
3470
  var init_version = __esm({
3436
3471
  "../worker-utils/src/lib/env-utils/version.ts"() {
3437
- DEFAULT_VERSION = "beta";
3472
+ DEFAULT_VERSION = "latest";
3438
3473
  VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
3439
3474
  if (typeof __VERSION__ === "undefined") {
3440
3475
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
@@ -3869,7 +3904,7 @@
3869
3904
  var init_get_worker_url = __esm({
3870
3905
  "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
3871
3906
  init_assert3();
3872
- NPM_TAG = "beta";
3907
+ NPM_TAG = "latest";
3873
3908
  }
3874
3909
  });
3875
3910
 
@@ -4033,11 +4068,230 @@
4033
4068
  }
4034
4069
  });
4035
4070
 
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
+
4036
4290
  // ../loader-utils/src/lib/request-utils/request-scheduler.ts
4037
4291
  var STAT_QUEUED_REQUESTS, STAT_ACTIVE_REQUESTS, STAT_CANCELLED_REQUESTS, STAT_QUEUED_REQUESTS_EVER, STAT_ACTIVE_REQUESTS_EVER, DEFAULT_PROPS2, RequestScheduler;
4038
4292
  var init_request_scheduler = __esm({
4039
4293
  "../loader-utils/src/lib/request-utils/request-scheduler.ts"() {
4040
- init_esm3();
4294
+ init_esm4();
4041
4295
  STAT_QUEUED_REQUESTS = "Queued Requests";
4042
4296
  STAT_ACTIVE_REQUESTS = "Active Requests";
4043
4297
  STAT_CANCELLED_REQUESTS = "Cancelled Requests";
@@ -4055,7 +4309,7 @@
4055
4309
  this.requestMap = new Map();
4056
4310
  this.deferredUpdate = null;
4057
4311
  this.props = { ...DEFAULT_PROPS2, ...props };
4058
- this.stats = new Stats({ id: this.props.id });
4312
+ this.stats = new Stats2({ id: this.props.id });
4059
4313
  this.stats.get(STAT_QUEUED_REQUESTS);
4060
4314
  this.stats.get(STAT_ACTIVE_REQUESTS);
4061
4315
  this.stats.get(STAT_CANCELLED_REQUESTS);
@@ -4936,7 +5190,7 @@
4936
5190
  });
4937
5191
 
4938
5192
  // ../../node_modules/@math.gl/culling/dist/esm/index.js
4939
- var init_esm4 = __esm({
5193
+ var init_esm5 = __esm({
4940
5194
  "../../node_modules/@math.gl/culling/dist/esm/index.js"() {
4941
5195
  init_constants2();
4942
5196
  init_axis_aligned_bounding_box();
@@ -4958,7 +5212,7 @@
4958
5212
  function getFrameState(viewport, frameNumber) {
4959
5213
  const { cameraDirection, cameraUp, height } = viewport;
4960
5214
  const { metersPerUnit } = viewport.distanceScales;
4961
- const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
5215
+ const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
4962
5216
  const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new Vector3());
4963
5217
  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
4964
5218
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
@@ -4995,7 +5249,7 @@
4995
5249
  var init_frame_state = __esm({
4996
5250
  "src/tileset/helpers/frame-state.ts"() {
4997
5251
  init_esm();
4998
- init_esm4();
5252
+ init_esm5();
4999
5253
  init_esm2();
5000
5254
  scratchVector7 = new Vector3();
5001
5255
  scratchPosition3 = new Vector3();
@@ -5458,7 +5712,7 @@
5458
5712
  });
5459
5713
 
5460
5714
  // ../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js
5461
- function getHiResTimestamp2() {
5715
+ function getHiResTimestamp3() {
5462
5716
  let timestamp;
5463
5717
  if (isBrowser4 && window_3.performance) {
5464
5718
  timestamp = window_3.performance.now();
@@ -5470,7 +5724,7 @@
5470
5724
  }
5471
5725
  return timestamp;
5472
5726
  }
5473
- var init_hi_res_timestamp2 = __esm({
5727
+ var init_hi_res_timestamp3 = __esm({
5474
5728
  "../../node_modules/probe.gl/dist/esm/utils/hi-res-timestamp.js"() {
5475
5729
  init_globals4();
5476
5730
  }
@@ -5597,7 +5851,7 @@
5597
5851
  init_color();
5598
5852
  init_autobind();
5599
5853
  init_assert4();
5600
- init_hi_res_timestamp2();
5854
+ init_hi_res_timestamp3();
5601
5855
  originalConsole = {
5602
5856
  debug: isBrowser4 ? console.debug || console.log : console.log,
5603
5857
  log: console.log,
@@ -5621,8 +5875,8 @@
5621
5875
  }) {
5622
5876
  this.id = id;
5623
5877
  this.VERSION = VERSION2;
5624
- this._startTs = getHiResTimestamp2();
5625
- this._deltaTs = getHiResTimestamp2();
5878
+ this._startTs = getHiResTimestamp3();
5879
+ this._deltaTs = getHiResTimestamp3();
5626
5880
  this.LOG_THROTTLE_TIMEOUT = 0;
5627
5881
  this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_SETTINGS);
5628
5882
  this.userData = {};
@@ -5643,10 +5897,10 @@
5643
5897
  return this._storage.config.level;
5644
5898
  }
5645
5899
  getTotal() {
5646
- return Number((getHiResTimestamp2() - this._startTs).toPrecision(10));
5900
+ return Number((getHiResTimestamp3() - this._startTs).toPrecision(10));
5647
5901
  }
5648
5902
  getDelta() {
5649
- return Number((getHiResTimestamp2() - this._deltaTs).toPrecision(10));
5903
+ return Number((getHiResTimestamp3() - this._deltaTs).toPrecision(10));
5650
5904
  }
5651
5905
  set priority(newPriority) {
5652
5906
  this.level = newPriority;
@@ -5801,11 +6055,11 @@
5801
6055
  assert4(method);
5802
6056
  opts.total = this.getTotal();
5803
6057
  opts.delta = this.getDelta();
5804
- this._deltaTs = getHiResTimestamp2();
6058
+ this._deltaTs = getHiResTimestamp3();
5805
6059
  const tag = opts.tag || opts.message;
5806
6060
  if (opts.once) {
5807
6061
  if (!cache[tag]) {
5808
- cache[tag] = getHiResTimestamp2();
6062
+ cache[tag] = getHiResTimestamp3();
5809
6063
  } else {
5810
6064
  return noop2;
5811
6065
  }
@@ -5820,13 +6074,42 @@
5820
6074
  }
5821
6075
  });
5822
6076
 
6077
+ // ../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js
6078
+ var init_hi_res_timestamp4 = __esm({
6079
+ "../../node_modules/@probe.gl/stats/dist/esm/utils/hi-res-timestamp.js"() {
6080
+ }
6081
+ });
6082
+
6083
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js
6084
+ var init_stat3 = __esm({
6085
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stat.js"() {
6086
+ init_hi_res_timestamp4();
6087
+ }
6088
+ });
6089
+
6090
+ // ../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js
6091
+ var init_stats3 = __esm({
6092
+ "../../node_modules/@probe.gl/stats/dist/esm/lib/stats.js"() {
6093
+ init_stat3();
6094
+ }
6095
+ });
6096
+
6097
+ // ../../node_modules/@probe.gl/stats/dist/esm/index.js
6098
+ var init_esm6 = __esm({
6099
+ "../../node_modules/@probe.gl/stats/dist/esm/index.js"() {
6100
+ init_stats3();
6101
+ init_stat3();
6102
+ init_hi_res_timestamp4();
6103
+ }
6104
+ });
6105
+
5823
6106
  // ../../node_modules/probe.gl/dist/esm/index.js
5824
6107
  var esm_default;
5825
- var init_esm5 = __esm({
6108
+ var init_esm7 = __esm({
5826
6109
  "../../node_modules/probe.gl/dist/esm/index.js"() {
5827
6110
  init_log();
5828
6111
  init_log();
5829
- init_esm3();
6112
+ init_esm6();
5830
6113
  esm_default = new Log({
5831
6114
  id: "probe.gl"
5832
6115
  });
@@ -5837,7 +6120,7 @@
5837
6120
  var probeLog, NullLog, ConsoleLog;
5838
6121
  var init_loggers = __esm({
5839
6122
  "../core/src/lib/loader-utils/loggers.ts"() {
5840
- init_esm5();
6123
+ init_esm7();
5841
6124
  probeLog = new Log({ id: "loaders.gl" });
5842
6125
  NullLog = class {
5843
6126
  log() {
@@ -6695,7 +6978,7 @@
6695
6978
  var init_bounding_volume = __esm({
6696
6979
  "src/tileset/helpers/bounding-volume.ts"() {
6697
6980
  init_esm();
6698
- init_esm4();
6981
+ init_esm5();
6699
6982
  init_esm2();
6700
6983
  init_src2();
6701
6984
  scratchScale = new Vector3();
@@ -7128,7 +7411,7 @@
7128
7411
  var init_tile_3d = __esm({
7129
7412
  "src/tileset/tile-3d.ts"() {
7130
7413
  init_esm();
7131
- init_esm4();
7414
+ init_esm5();
7132
7415
  init_src3();
7133
7416
  init_constants3();
7134
7417
  init_bounding_volume();
@@ -20,7 +20,7 @@ function getFrameState(viewport, frameNumber) {
20
20
  cameraUp = viewport.cameraUp,
21
21
  height = viewport.height;
22
22
  var metersPerUnit = viewport.distanceScales.metersPerUnit;
23
- var viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
23
+ var viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
24
24
 
25
25
  var viewportCenterCartesian = _geospatial.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new _core.Vector3());
26
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","longitude","latitude","viewportCenterCartesian","Ellipsoid","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","center","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAeA,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,eAAe,GAAG,IAAID,aAAJ,EAAxB;AACA,IAAME,aAAa,GAAG,IAAIC,sBAAJ,CAAkB,CACtC,IAAIC,cAAJ,EADsC,EAEtC,IAAIA,cAAJ,EAFsC,EAGtC,IAAIA,cAAJ,EAHsC,EAItC,IAAIA,cAAJ,EAJsC,EAKtC,IAAIA,cAAJ,EALsC,EAMtC,IAAIA,cAAJ,EANsC,CAAlB,CAAtB;;AAWO,SAASC,aAAT,CAAuBC,QAAvB,EAAiCC,WAAjC,EAAkE;AAEvE,MAAOC,eAAP,GAA4CF,QAA5C,CAAOE,eAAP;AAAA,MAAwBC,QAAxB,GAA4CH,QAA5C,CAAwBG,QAAxB;AAAA,MAAkCC,MAAlC,GAA4CJ,QAA5C,CAAkCI,MAAlC;AACA,MAAOC,aAAP,GAAwBL,QAAQ,CAACM,cAAjC,CAAOD,aAAP;AAEA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AAVX,GAAP;AAYD;;AAED,SAASL,wBAAT,CAAkCzB,QAAlC,EAA4CU,uBAA5C,EAAqE;AAEnE,MAAMqB,aAAa,GAAG/B,QAAQ,CAACgC,gBAAT,EAAtB;AACA,MAAIC,CAAC,GAAG,CAAR;;AACA,OAAK,IAAMC,GAAX,IAAkBH,aAAlB,EAAiC;AAC/B,QAAMI,KAAK,GAAGJ,aAAa,CAACG,GAAD,CAA3B;AACA,QAAME,gBAAgB,GAAGD,KAAK,CAACE,MAAN,CAAaC,GAAb,CAAiBtC,QAAQ,CAACuC,MAA1B,CAAzB;AACA5C,IAAAA,eAAe,CACZ6C,IADH,CACQL,KAAK,CAACE,MADd,EAEGf,KAFH,CAESa,KAAK,CAACM,QAAN,GAAiBL,gBAF1B,EAGGM,GAHH,CAGO1C,QAAQ,CAACuC,MAHhB;AAIA,QAAMI,eAAe,GAAG3C,QAAQ,CAACiB,iBAAT,CAA2BtB,eAA3B,CAAxB;;AAEA,QAAMiD,YAAY,GAAGjC,sBAAUC,KAAV,CAAgBC,uBAAhB,CAAwC8B,eAAxC,EAAyD,IAAIjD,aAAJ,EAAzD,CAArB;;AAEAE,IAAAA,aAAa,CAACiD,MAAd,CAAqBZ,CAAC,EAAtB,EAA0Ba,eAA1B,CACEF,YADF,EAGEnD,aAAa,CAAC+C,IAAd,CAAmB9B,uBAAnB,EAA4CqC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
1
+ {"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["scratchVector","Vector3","scratchPosition","cullingVolume","CullingVolume","Plane","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","unprojectPosition","center","viewportCenterCartesian","Ellipsoid","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAeA,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,eAAe,GAAG,IAAID,aAAJ,EAAxB;AACA,IAAME,aAAa,GAAG,IAAIC,sBAAJ,CAAkB,CACtC,IAAIC,cAAJ,EADsC,EAEtC,IAAIA,cAAJ,EAFsC,EAGtC,IAAIA,cAAJ,EAHsC,EAItC,IAAIA,cAAJ,EAJsC,EAKtC,IAAIA,cAAJ,EALsC,EAMtC,IAAIA,cAAJ,EANsC,CAAlB,CAAtB;;AAWO,SAASC,aAAT,CAAuBC,QAAvB,EAA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A,SAAS,EAAER,wBAFL;AAGNS,MAAAA,EAAE,EAAEL;AAHE,KADH;AAMLvB,IAAAA,QAAQ,EAARA,QANK;AAOLI,IAAAA,MAAM,EAANA,MAPK;AAQLR,IAAAA,aAAa,EAAbA,aARK;AASLK,IAAAA,WAAW,EAAXA,WATK;AAUL4B,IAAAA,cAAc,EAAE;AAVX,GAAP;AAYD;;AAED,SAASL,wBAAT,CAAkCxB,QAAlC,EAA4CU,uBAA5C,EAAqE;AAEnE,MAAMoB,aAAa,GAAG9B,QAAQ,CAAC+B,gBAAT,EAAtB;AACA,MAAIC,CAAC,GAAG,CAAR;;AACA,OAAK,IAAMC,GAAX,IAAkBH,aAAlB,EAAiC;AAC/B,QAAMI,KAAK,GAAGJ,aAAa,CAACG,GAAD,CAA3B;AACA,QAAME,gBAAgB,GAAGD,KAAK,CAACE,MAAN,CAAaC,GAAb,CAAiBrC,QAAQ,CAACS,MAA1B,CAAzB;AACAd,IAAAA,eAAe,CACZ2C,IADH,CACQJ,KAAK,CAACE,MADd,EAEGf,KAFH,CAESa,KAAK,CAACK,QAAN,GAAiBJ,gBAF1B,EAGGK,GAHH,CAGOxC,QAAQ,CAACS,MAHhB;AAIA,QAAMgC,eAAe,GAAGzC,QAAQ,CAACQ,iBAAT,CAA2Bb,eAA3B,CAAxB;;AAEA,QAAM+C,YAAY,GAAG/B,sBAAUC,KAAV,CAAgBC,uBAAhB,CAAwC4B,eAAxC,EAAyD,IAAI/C,aAAJ,EAAzD,CAArB;;AAEAE,IAAAA,aAAa,CAAC+C,MAAd,CAAqBX,CAAC,EAAtB,EAA0BY,eAA1B,CACEF,YADF,EAGEjD,aAAa,CAAC6C,IAAd,CAAmB5B,uBAAnB,EAA4CmC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
@@ -13,7 +13,7 @@ export function getFrameState(viewport, frameNumber) {
13
13
  const {
14
14
  metersPerUnit
15
15
  } = viewport.distanceScales;
16
- const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
16
+ const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
17
17
  const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new Vector3());
18
18
  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
19
19
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["Vector3","CullingVolume","Plane","Ellipsoid","scratchVector","scratchPosition","cullingVolume","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","longitude","latitude","viewportCenterCartesian","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","unprojectPosition","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","center","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":"AAAA,SAAQA,OAAR,QAAsB,eAAtB;AACA,SAAQC,aAAR,EAAuBC,KAAvB,QAAmC,kBAAnC;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AAeA,MAAMC,aAAa,GAAG,IAAIJ,OAAJ,EAAtB;AACA,MAAMK,eAAe,GAAG,IAAIL,OAAJ,EAAxB;AACA,MAAMM,aAAa,GAAG,IAAIL,aAAJ,CAAkB,CACtC,IAAIC,KAAJ,EADsC,EAEtC,IAAIA,KAAJ,EAFsC,EAGtC,IAAIA,KAAJ,EAHsC,EAItC,IAAIA,KAAJ,EAJsC,EAKtC,IAAIA,KAAJ,EALsC,EAMtC,IAAIA,KAAJ,EANsC,CAAlB,CAAtB;AAWA,OAAO,SAASK,aAAT,CAAuBC,QAAvB,EAAiCC,WAAjC,EAAkE;AAEvE,QAAM;AAACC,IAAAA,eAAD;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA;AAA5B,MAAsCJ,QAA5C;AACA,QAAM;AAACK,IAAAA;AAAD,MAAkBL,QAAQ,CAACM,cAAjC;AAEA,QAAMC,0BAA0B,GAAG,CAACP,QAAQ,CAACQ,SAAV,EAAqBR,QAAQ,CAACS,QAA9B,EAAwC,CAAxC,CAAnC;AAGA,QAAMC,uBAAuB,GAAGf,SAAS,CAACgB,KAAV,CAAgBC,uBAAhB,CAC9BL,0BAD8B,EAE9B,IAAIf,OAAJ,EAF8B,CAAhC;AAIA,QAAMqB,mBAAmB,GAAGlB,SAAS,CAACgB,KAAV,CAAgBG,uBAAhB,CAAwCJ,uBAAxC,CAA5B;AAEA,QAAMK,0BAA0B,GAAGf,QAAQ,CAACgB,iB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H,CACQL,KAAK,CAACE,MADd,EAEGf,KAFH,CAESa,KAAK,CAACM,QAAN,GAAiBL,gBAF1B,EAGGM,GAHH,CAGOzC,QAAQ,CAACsC,MAHhB;AAIA,UAAMI,eAAe,GAAG1C,QAAQ,CAACgB,iBAAT,CAA2BnB,eAA3B,CAAxB;AAEA,UAAM8C,YAAY,GAAGhD,SAAS,CAACgB,KAAV,CAAgBC,uBAAhB,CAAwC8B,eAAxC,EAAyD,IAAIlD,OAAJ,EAAzD,CAArB;AAEAM,IAAAA,aAAa,CAAC8C,MAAd,CAAqBZ,CAAC,EAAtB,EAA0Ba,eAA1B,CACEF,YADF,EAGE/C,aAAa,CAAC2C,IAAd,CAAmB7B,uBAAnB,EAA4CoC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
1
+ {"version":3,"sources":["../../../../src/tileset/helpers/frame-state.ts"],"names":["Vector3","CullingVolume","Plane","Ellipsoid","scratchVector","scratchPosition","cullingVolume","getFrameState","viewport","frameNumber","cameraDirection","cameraUp","height","metersPerUnit","distanceScales","viewportCenterCartographic","unprojectPosition","center","viewportCenterCartesian","WGS84","cartographicToCartesian","enuToFixedTransform","eastNorthUpToFixedFrame","cameraPositionCartographic","cameraPosition","cameraPositionCartesian","cameraDirectionCartesian","transformAsVector","scale","normalize","cameraUpCartesian","commonSpacePlanesToWGS84","camera","position","direction","up","sseDenominator","frustumPlanes","getFrustumPlanes","i","dir","plane","distanceToCenter","normal","dot","copy","distance","add","cartographicPos","cartesianPos","planes","fromPointNormal","subtract"],"mappings":"AAAA,SAAQA,OAAR,QAAsB,eAAtB;AACA,SAAQC,aAAR,EAAuBC,KAAvB,QAAmC,kBAAnC;AACA,SAAQC,SAAR,QAAwB,qBAAxB;AAeA,MAAMC,aAAa,GAAG,IAAIJ,OAAJ,EAAtB;AACA,MAAMK,eAAe,GAAG,IAAIL,OAAJ,EAAxB;AACA,MAAMM,aAAa,GAAG,IAAIL,aAAJ,CAAkB,CACtC,IAAIC,KAAJ,EADsC,EAEtC,IAAIA,KAAJ,EAFsC,EAGtC,IAAIA,KAAJ,EAHsC,EAItC,IAAIA,KAAJ,EAJsC,EAKtC,IAAIA,KAAJ,EALsC,EAMtC,IAAIA,KAAJ,EANsC,CAAlB,CAAtB;AAWA,OAAO,SAASK,aAAT,CAAuBC,QAAvB,EAAiCC,WAAjC,EAAkE;AAEvE,QAAM;AAACC,IAAAA,eAAD;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA;AAA5B,MAAsCJ,QAA5C;AACA,QAAM;AAACK,IAAAA;AAAD,MAAkBL,QAAQ,CAACM,cAAjC;AAEA,QAAMC,0BAA0B,GAAGP,QAAQ,CAACQ,iBAAT,CAA2BR,QAAQ,CAACS,MAApC,CAAnC;AAGA,QAAMC,uBAAuB,GAAGf,SAAS,CA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MAAMC,GAAX,IAAkBH,aAAlB,EAAiC;AAC/B,UAAMI,KAAK,GAAGJ,aAAa,CAACG,GAAD,CAA3B;AACA,UAAME,gBAAgB,GAAGD,KAAK,CAACE,MAAN,CAAaC,GAAb,CAAiBpC,QAAQ,CAACS,MAA1B,CAAzB;AACAZ,IAAAA,eAAe,CACZwC,IADH,CACQJ,KAAK,CAACE,MADd,EAEGf,KAFH,CAESa,KAAK,CAACK,QAAN,GAAiBJ,gBAF1B,EAGGK,GAHH,CAGOvC,QAAQ,CAACS,MAHhB;AAIA,UAAM+B,eAAe,GAAGxC,QAAQ,CAACQ,iBAAT,CAA2BX,eAA3B,CAAxB;AAEA,UAAM4C,YAAY,GAAG9C,SAAS,CAACgB,KAAV,CAAgBC,uBAAhB,CAAwC4B,eAAxC,EAAyD,IAAIhD,OAAJ,EAAzD,CAArB;AAEAM,IAAAA,aAAa,CAAC4C,MAAd,CAAqBX,CAAC,EAAtB,EAA0BY,eAA1B,CACEF,YADF,EAGE7C,aAAa,CAACyC,IAAd,CAAmB3B,uBAAnB,EAA4CkC,QAA5C,CAAqDH,YAArD,CAHF;AAKD;AACF","sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\nexport type FrameState = {\n camera: {\n position: number[];\n direction: number[];\n up: number[];\n };\n viewport: {[key: string]: any};\n height: number;\n cullingVolume: CullingVolume;\n frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport, frameNumber: number): FrameState {\n // Traverse and and request. Update _selectedTiles so that we know what to render.\n const {cameraDirection, cameraUp, height} = viewport;\n const {metersPerUnit} = viewport.distanceScales;\n\n const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n viewportCenterCartographic,\n new Vector3()\n );\n const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n cameraPositionCartographic,\n new Vector3()\n );\n\n // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n const cameraDirectionCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n ).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n ).normalize();\n\n commonSpacePlanesToWGS84(viewport, viewportCenterCartesian);\n\n // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n return {\n camera: {\n position: cameraPositionCartesian,\n direction: cameraDirectionCartesian,\n up: cameraUpCartesian\n },\n viewport,\n height,\n cullingVolume,\n frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n sseDenominator: 1.15 // Assumes fovy = 60 degrees\n };\n}\n\nfunction commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\n let i = 0;\n for (const dir in frustumPlanes) {\n const plane = frustumPlanes[dir];\n const distanceToCenter = plane.normal.dot(viewport.center);\n scratchPosition\n .copy(plane.normal)\n .scale(plane.distance - distanceToCenter)\n .add(viewport.center);\n const cartographicPos = viewport.unprojectPosition(scratchPosition);\n\n const cartesianPos = Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, new Vector3());\n\n cullingVolume.planes[i++].fromPointNormal(\n cartesianPos,\n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(viewportCenterCartesian).subtract(cartesianPos)\n );\n }\n}\n"],"file":"frame-state.js"}
@@ -20,7 +20,7 @@ function getFrameState(viewport, frameNumber) {
20
20
  // Traverse and and request. Update _selectedTiles so that we know what to render.
21
21
  const { cameraDirection, cameraUp, height } = viewport;
22
22
  const { metersPerUnit } = viewport.distanceScales;
23
- const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
23
+ const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
24
24
  // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.
25
25
  // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?
26
26
  const viewportCenterCartesian = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(viewportCenterCartographic, new core_1.Vector3());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tiles",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Common components for different tiles loaders.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,16 +33,16 @@
33
33
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js"
34
34
  },
35
35
  "dependencies": {
36
- "@loaders.gl/loader-utils": "3.1.0",
37
- "@loaders.gl/math": "3.1.0",
36
+ "@loaders.gl/loader-utils": "3.1.1",
37
+ "@loaders.gl/math": "3.1.1",
38
38
  "@math.gl/core": "^3.5.1",
39
39
  "@math.gl/culling": "^3.5.1",
40
40
  "@math.gl/geospatial": "^3.5.1",
41
41
  "@math.gl/web-mercator": "^3.5.1",
42
- "@probe.gl/stats": "^3.4.0"
42
+ "@probe.gl/stats": "^3.5.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@loaders.gl/core": "3.1.0-beta.1"
45
+ "@loaders.gl/core": "3.1.0"
46
46
  },
47
- "gitHead": "b02a011b5a6d6aa6c5870819045c70db168cb930"
47
+ "gitHead": "ed3c238bcb68ab5a2d4ddc64319f6f4c02a20df7"
48
48
  }
@@ -33,7 +33,7 @@ export function getFrameState(viewport, frameNumber: number): FrameState {
33
33
  const {cameraDirection, cameraUp, height} = viewport;
34
34
  const {metersPerUnit} = viewport.distanceScales;
35
35
 
36
- const viewportCenterCartographic = [viewport.longitude, viewport.latitude, 0];
36
+ const viewportCenterCartographic = viewport.unprojectPosition(viewport.center);
37
37
  // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.
38
38
  // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?
39
39
  const viewportCenterCartesian = Ellipsoid.WGS84.cartographicToCartesian(