bruce-cesium 4.7.0 → 4.7.2

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.
@@ -14974,6 +14974,11 @@
14974
14974
  this.runningQueues = 0;
14975
14975
  this.recordLoadQueue = [];
14976
14976
  this.recordCheckQueue = [];
14977
+ // % progress for how many Entities have been styled so far.
14978
+ // This can change as Tiles load in and more queue.
14979
+ this._styleProgress = 0;
14980
+ // Event for when the style progress changes.
14981
+ this.OnStyleProgress = new BModels.BruceEvent();
14977
14982
  this.viewer = viewer;
14978
14983
  this.api = api;
14979
14984
  this.cTileset = cTileset;
@@ -15006,6 +15011,13 @@
15006
15011
  enumerable: false,
15007
15012
  configurable: true
15008
15013
  });
15014
+ Object.defineProperty(Styler.prototype, "StyleProgress", {
15015
+ get: function () {
15016
+ return this._styleProgress;
15017
+ },
15018
+ enumerable: false,
15019
+ configurable: true
15020
+ });
15009
15021
  /**
15010
15022
  * Updates style mapping and fallback style.
15011
15023
  * This will trigger a re-style of all entities, and will stop existing style loads.
@@ -15048,6 +15060,8 @@
15048
15060
  var regos = this.register.GetRegos({
15049
15061
  menuItemId: this.menuItemId
15050
15062
  });
15063
+ // Reset progress.
15064
+ this.updateStyleProgress();
15051
15065
  this.styleMappingLoaded = false;
15052
15066
  this.styleMappingsLoaded = {};
15053
15067
  this.QueueEntities(regos);
@@ -15162,9 +15176,37 @@
15162
15176
  });
15163
15177
  };
15164
15178
  Styler.prototype.getEntityIdsForQueue = function () {
15165
- var BATCH_SIZE = this.expandSources ? 200 : 500;
15179
+ var BATCH_SIZE = this.expandSources ? 100 : 500;
15166
15180
  return this.recordLoadQueue.splice(0, BATCH_SIZE);
15167
15181
  };
15182
+ /**
15183
+ * Calculates the current progress % and updates the progress if there is a change.
15184
+ */
15185
+ Styler.prototype.updateStyleProgress = function () {
15186
+ var progress = 100; // Done when idling.
15187
+ if (this.recordCheckQueue.length || this.recordLoadQueue.length) {
15188
+ var total = Object.keys(this.styledEntityIds).length;
15189
+ // Done is the total minus the amount left.
15190
+ // We have to ensure the same ID isn't counted within or across these arrays as well.
15191
+ var uniqueSet = new Set(this.recordCheckQueue.concat(this.recordLoadQueue));
15192
+ var done = total - uniqueSet.size;
15193
+ progress = done / total * 100;
15194
+ // Round to 2dp, 0, or 100.
15195
+ if (progress < 0) {
15196
+ progress = 0;
15197
+ }
15198
+ else if (progress < 100) {
15199
+ progress = Math.round(progress * 100) / 100;
15200
+ }
15201
+ else if (progress > 100) {
15202
+ progress = 100;
15203
+ }
15204
+ }
15205
+ if (this._styleProgress != progress) {
15206
+ this._styleProgress = progress;
15207
+ this.OnStyleProgress.Trigger(progress);
15208
+ }
15209
+ };
15168
15210
  Styler.prototype.getEntityRego = function (entityId) {
15169
15211
  return this.register.GetRego({
15170
15212
  entityId: entityId,
@@ -15402,8 +15444,8 @@
15402
15444
  }
15403
15445
  }
15404
15446
  var _loop_3 = function (i) {
15405
- var hash = batch[i];
15406
- var index = _this.recordCheckQueue.findIndex(function (x) { return x == hash; });
15447
+ var entityId = batch[i];
15448
+ var index = _this.recordCheckQueue.findIndex(function (x) { return x == entityId; });
15407
15449
  if (index > -1) {
15408
15450
  _this.recordCheckQueue.splice(index, 1);
15409
15451
  }
@@ -15432,6 +15474,11 @@
15432
15474
  });
15433
15475
  };
15434
15476
  Styler.prototype.queueTilesetFeatureStyle = function (entity, highPriority) {
15477
+ // Add to the style dict if not already there.
15478
+ // This helps us know the styling progress for things that have loaded in so far.
15479
+ if (!this.styledEntityIds[entity.entityId]) {
15480
+ this.styledEntityIds[entity.entityId] = null;
15481
+ }
15435
15482
  if (this.styleMappingLoaded || this.styleMappingsLoaded[entity.entityTypeId] == true) {
15436
15483
  var needsData = this.getTilesetFeatureNeedsFullData(entity.entityId, entity.entityTypeId);
15437
15484
  if (needsData) {
@@ -15477,6 +15524,7 @@
15477
15524
  override: this.styledEntityIds[entity.entityId] == true
15478
15525
  });
15479
15526
  this.styledEntityIds[entity.entityId] = true;
15527
+ this.updateStyleProgress();
15480
15528
  };
15481
15529
  Styler.prototype.getTilesetFeatureStyle = function (entityId, entityTypeId) {
15482
15530
  var _a, _b, _c, _d;
@@ -28136,7 +28184,7 @@
28136
28184
  return WidgetViewBar;
28137
28185
  }(exports.Widget.AWidget));
28138
28186
 
28139
- var VERSION = "4.7.0";
28187
+ var VERSION = "4.7.2";
28140
28188
 
28141
28189
  exports.VERSION = VERSION;
28142
28190
  exports.CesiumParabola = CesiumParabola;