bruce-cesium 7.2.5 → 7.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14090,6 +14090,8 @@
14090
14090
  this.lastFoundDateTimes = new Map();
14091
14091
  // ID of Entity IDs that need to be requested.
14092
14092
  this.eIdQueue = [];
14093
+ // Membership mirror of eIdQueue for quick checks.
14094
+ this.eIdQueued = new Set();
14093
14095
  // Resolves where an Entity sits without reading its record, when the caller can say.
14094
14096
  // Unset leaves the queue in insertion order, which is what sources that bake no coordinates get.
14095
14097
  this.positionOf = null;
@@ -14199,6 +14201,7 @@
14199
14201
  return;
14200
14202
  }
14201
14203
  this.eIdQueue = [];
14204
+ this.eIdQueued.clear();
14202
14205
  this.priorityCount = 0;
14203
14206
  this.lastOrderFocus = null;
14204
14207
  this.allEIds.clear();
@@ -14210,6 +14213,7 @@
14210
14213
  return;
14211
14214
  }
14212
14215
  this.eIdQueue = Array.from(this.allEIds);
14216
+ this.eIdQueued = new Set(this.eIdQueue);
14213
14217
  this.priorityCount = 0;
14214
14218
  this.lastOrderFocus = null;
14215
14219
  }
@@ -14299,27 +14303,58 @@
14299
14303
  return;
14300
14304
  }
14301
14305
  let changes = 0;
14302
- for (let i = 0; i < entityIds.length; i++) {
14303
- const eId = entityIds[i];
14304
- const index = this.eIdQueue.indexOf(eId);
14305
- if (topOfQueue) {
14306
- // If we want it to be at the top of the queue, remove it from the queue first.
14307
- if (index !== -1) {
14308
- this.eIdQueue.splice(index, 1);
14309
- if (index < this.priorityCount) {
14310
- this.priorityCount -= 1;
14311
- }
14312
- }
14313
- this.eIdQueue.unshift(eId);
14314
- this.priorityCount += 1;
14315
- changes += 1;
14306
+ if (topOfQueue) {
14307
+ // Walked back to front so a repeated ID keeps the position of its last occurrence, then
14308
+ // laid down in that order, which is where inserting one at a time leaves them.
14309
+ const toFront = [];
14310
+ const promoting = new Set();
14311
+ let anyAlreadyQueued = false;
14312
+ for (let i = entityIds.length - 1; i >= 0; i--) {
14313
+ const eId = entityIds[i];
14314
+ this.allEIds.add(eId);
14315
+ if (promoting.has(eId)) {
14316
+ continue;
14317
+ }
14318
+ promoting.add(eId);
14319
+ toFront.push(eId);
14320
+ if (this.eIdQueued.has(eId)) {
14321
+ anyAlreadyQueued = true;
14322
+ }
14323
+ }
14324
+ if (anyAlreadyQueued && this.eIdQueue.length) {
14325
+ const kept = [];
14326
+ let removedFromPriority = 0;
14327
+ for (let i = 0; i < this.eIdQueue.length; i++) {
14328
+ const eId = this.eIdQueue[i];
14329
+ if (promoting.has(eId)) {
14330
+ if (i < this.priorityCount) {
14331
+ removedFromPriority += 1;
14332
+ }
14333
+ continue;
14334
+ }
14335
+ kept.push(eId);
14336
+ }
14337
+ this.eIdQueue = kept;
14338
+ this.priorityCount = Math.max(0, this.priorityCount - removedFromPriority);
14316
14339
  }
14317
- else if (index === -1) {
14340
+ this.eIdQueue = toFront.concat(this.eIdQueue);
14341
+ this.priorityCount += toFront.length;
14342
+ for (let i = 0; i < toFront.length; i++) {
14343
+ this.eIdQueued.add(toFront[i]);
14344
+ }
14345
+ changes = toFront.length;
14346
+ }
14347
+ else {
14348
+ for (let i = 0; i < entityIds.length; i++) {
14349
+ const eId = entityIds[i];
14350
+ this.allEIds.add(eId);
14351
+ if (this.eIdQueued.has(eId)) {
14352
+ continue;
14353
+ }
14354
+ this.eIdQueued.add(eId);
14318
14355
  this.eIdQueue.push(eId);
14319
14356
  changes += 1;
14320
14357
  }
14321
- // Flag that we've seen this ID.
14322
- this.allEIds.add(entityIds[i]);
14323
14358
  }
14324
14359
  if (!changes) {
14325
14360
  return;
@@ -14453,7 +14488,7 @@
14453
14488
  this.emitEntities(toEmit, tags);
14454
14489
  };
14455
14490
  const QUEUE_BATCH_SIZE = 500;
14456
- const requestedIds = [];
14491
+ const requestedIds = new Set();
14457
14492
  // If we have a queue, we need to request those first.
14458
14493
  if (this.eIdQueue.length) {
14459
14494
  const total = this.eIdQueue.length;
@@ -14465,6 +14500,9 @@
14465
14500
  this.orderQueueByCamera();
14466
14501
  const batch = this.eIdQueue.splice(0, QUEUE_BATCH_SIZE);
14467
14502
  this.priorityCount = Math.max(0, this.priorityCount - batch.length);
14503
+ for (let i = 0; i < batch.length; i++) {
14504
+ this.eIdQueued.delete(batch[i]);
14505
+ }
14468
14506
  const { entities } = await BModels.Entity.GetListByIds({
14469
14507
  entityIds: batch,
14470
14508
  historicPoint: this.historic ? rTime : null,
@@ -14473,7 +14511,9 @@
14473
14511
  maxSearchTimeSec: 60 * 2
14474
14512
  });
14475
14513
  handleResponse(batch, entities);
14476
- requestedIds.push(...batch);
14514
+ for (let i = 0; i < batch.length; i++) {
14515
+ requestedIds.add(batch[i]);
14516
+ }
14477
14517
  done += batch.length;
14478
14518
  if (this._onQueueProgress) {
14479
14519
  let progress = (done / total) * 100;
@@ -14493,8 +14533,8 @@
14493
14533
  // Now run through all IDs that we've seen and request them.
14494
14534
  // We'll skip those that we just requested.
14495
14535
  let allEIds = Array.from(this.allEIds);
14496
- if (requestedIds.length) {
14497
- allEIds = allEIds.filter((eId) => requestedIds.indexOf(eId) === -1);
14536
+ if (requestedIds.size) {
14537
+ allEIds = allEIds.filter((eId) => !requestedIds.has(eId));
14498
14538
  }
14499
14539
  if (allEIds.length) {
14500
14540
  // A historic tick re-reads the whole set, so the near ones are worth resolving
@@ -14513,7 +14553,9 @@
14513
14553
  maxSearchTimeSec: 60 * 2
14514
14554
  });
14515
14555
  handleResponse(batch, entities);
14516
- requestedIds.push(...batch);
14556
+ for (let i = 0; i < batch.length; i++) {
14557
+ requestedIds.add(batch[i]);
14558
+ }
14517
14559
  }
14518
14560
  }
14519
14561
  // If we had leftovers because we stopped early, we need to re-run the tick.
@@ -42483,7 +42525,11 @@ void main() {
42483
42525
  // Value zero sits at the polygon's own altitude, plus the terrain underneath when the polygon
42484
42526
  // is following the ground rather than absolutely positioned.
42485
42527
  float ground = sampleGround(st) * u_groundWeight;
42486
- float displacement = u_baseHeight + ground + metres * texel.a - skirt * u_skirtDepth;
42528
+
42529
+ // Coverage scales the displacement only where it is measured from the terrain, because there a
42530
+ // zero means the surface sits on the ground.
42531
+ float coverageScale = mix(1.0, texel.a, u_groundWeight);
42532
+ float displacement = u_baseHeight + ground + metres * coverageScale - skirt * u_skirtDepth;
42487
42533
 
42488
42534
  // Added to the LOW half of the encoded position: a metre-scale offset added to the high half
42489
42535
  // would be lost to float32 rounding at an earth radius.
@@ -45773,7 +45819,7 @@ void main() {
45773
45819
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
45774
45820
  })(exports.StyleUtils || (exports.StyleUtils = {}));
45775
45821
 
45776
- const VERSION = "7.2.5";
45822
+ const VERSION = "7.2.7";
45777
45823
  /**
45778
45824
  * Updates the environment instance used by bruce-cesium to one specified.
45779
45825
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.