bruce-cesium 5.9.0 → 5.9.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.
@@ -13926,56 +13926,32 @@
13926
13926
  * @returns
13927
13927
  */
13928
13928
  async renderAsIndividuals(entities, force = false) {
13929
- var _a, _b, _c, _d, _e, _f, _g, _h;
13929
+ var _a, _b, _c, _d, _e, _f;
13930
+ // When live we just want to show the latest pos.
13931
+ // When not live, the user might scroll the timeline and want to see it a fluid animation between points in time.
13932
+ const isLive = exports.ViewUtils.GetTimeDetails({
13933
+ viewer: this.viewer
13934
+ }).isLive;
13930
13935
  // Entity ID -> historic records array.
13931
13936
  // We load this as extra information when rendering historic records.
13932
13937
  // This way we know what to animate towards as time changes.
13933
13938
  let entitiesHistoric = {};
13934
- if ((((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historic) || ((_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b.historicAttrKey)) && entities.length) {
13935
- // Interpolating.
13936
- // We will allow non-historic Entities as long as they have historic data in the range.
13937
- if (this.item.historicInterpolation) {
13938
- // We'll add/remove 1 second to ensure we cover all records.
13939
- const startTmp = Cesium.JulianDate.toDate(this.viewer.clock.startTime);
13940
- const stopTmp = Cesium.JulianDate.toDate(this.viewer.clock.stopTime);
13941
- const startStr = new Date(startTmp.getTime() - 1000).toISOString();
13942
- const stopStr = new Date(stopTmp.getTime() + 1000).toISOString();
13943
- const historicData = await BModels.EntityHistoricData.GetList({
13944
- attrKey: this.item.BruceEntity.historicAttrKey,
13945
- dateTimeFrom: startStr,
13946
- dateTimeTo: stopStr,
13947
- entityIds: entities.map(x => x.Bruce.ID),
13948
- api: this.apiGetter.getApi()
13949
- });
13950
- entitiesHistoric = historicData.recordsByIds;
13951
- // Remove ones with no historicAttrKey and no historic data.
13952
- const toRemoveIds = entities.filter(x => { var _a, _b; return !((_b = (_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.Outline) === null || _b === void 0 ? void 0 : _b.length) && !entitiesHistoric[x.Bruce.ID]; }).map(x => x.Bruce.ID);
13953
- for (let i = 0; i < toRemoveIds.length; i++) {
13954
- const removeId = toRemoveIds[i];
13955
- this.visualsManager.RemoveRegos({
13956
- entityId: removeId,
13957
- menuItemId: this.item.id,
13958
- requestRender: false
13959
- });
13960
- (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.RemoveEntity(removeId, false);
13961
- }
13962
- entities = entities.filter(x => !toRemoveIds.includes(x.Bruce.ID));
13963
- }
13964
- // Not interpolating.
13965
- // So we'll see if the Entities have a historic key or not.
13966
- else {
13967
- const toRemoveIds = entities.filter(x => { var _a; return !((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.Outline); }).map(x => x.Bruce.ID);
13968
- for (let i = 0; i < toRemoveIds.length; i++) {
13969
- const removeId = toRemoveIds[i];
13970
- this.visualsManager.RemoveRegos({
13971
- entityId: removeId,
13972
- menuItemId: this.item.id,
13973
- requestRender: false
13974
- });
13975
- (_d = this.clustering) === null || _d === void 0 ? void 0 : _d.RemoveEntity(removeId, false);
13976
- }
13977
- entities = entities.filter(x => !toRemoveIds.includes(x.Bruce.ID));
13978
- }
13939
+ const isHistoric = ((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historic) || ((_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b.historicAttrKey);
13940
+ // If we're interpolating then we request additional records to quickly swap between.
13941
+ if (!isLive && isHistoric && entities.length && this.item.historicInterpolation) {
13942
+ // We'll add/remove 1 second to ensure we cover all records.
13943
+ const startTmp = Cesium.JulianDate.toDate(this.viewer.clock.startTime);
13944
+ const stopTmp = Cesium.JulianDate.toDate(this.viewer.clock.stopTime);
13945
+ const startStr = new Date(startTmp.getTime() - 1000).toISOString();
13946
+ const stopStr = new Date(stopTmp.getTime() + 1000).toISOString();
13947
+ const historicData = await BModels.EntityHistoricData.GetList({
13948
+ attrKey: this.item.BruceEntity.historicAttrKey,
13949
+ dateTimeFrom: startStr,
13950
+ dateTimeTo: stopStr,
13951
+ entityIds: entities.map(x => x.Bruce.ID),
13952
+ api: this.apiGetter.getApi()
13953
+ });
13954
+ entitiesHistoric = historicData.recordsByIds;
13979
13955
  }
13980
13956
  if (this.disposed) {
13981
13957
  this.doDispose();
@@ -14010,7 +13986,7 @@
14010
13986
  menuItemId: this.item.id
14011
13987
  });
14012
13988
  // The baseline data source must be editable.
14013
- const canEdit = !((_e = entity.Bruce.Outline) === null || _e === void 0 ? void 0 : _e.find(x => x.Baseline && !x.Editable));
13989
+ const canEdit = !((_c = entity.Bruce.Outline) === null || _c === void 0 ? void 0 : _c.find(x => x.Baseline && !x.Editable));
14014
13990
  const visual = rego === null || rego === void 0 ? void 0 : rego.visual;
14015
13991
  if (!visual || visual != cEntity) {
14016
13992
  const wasClustered = this.clustering ? this.clustering.AddEntity(id, cEntity, false) : false;
@@ -14041,9 +14017,9 @@
14041
14017
  rego.visual = cEntity;
14042
14018
  rego.entityTypeId = entity.Bruce["EntityType.ID"];
14043
14019
  rego.tagIds = entity.Bruce["Layer.ID"] ? [].concat(entity.Bruce["Layer.ID"]) : [];
14044
- rego.outline = (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.Outline;
14020
+ rego.outline = (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d.Outline;
14045
14021
  rego.cdn = this.item.cdnEnabled;
14046
- rego.schema = (_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g.Schema;
14022
+ rego.schema = (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.Schema;
14047
14023
  rego.canEdit = canEdit;
14048
14024
  // Marked as stale meaning some change was performed that requires a refresh.
14049
14025
  // This usually means a new sibling was added that we need to update.
@@ -14074,7 +14050,7 @@
14074
14050
  menuItemId: this.item.id,
14075
14051
  requestRender: false
14076
14052
  });
14077
- (_h = this.clustering) === null || _h === void 0 ? void 0 : _h.RemoveEntity(id, false);
14053
+ (_f = this.clustering) === null || _f === void 0 ? void 0 : _f.RemoveEntity(id, false);
14078
14054
  }
14079
14055
  }
14080
14056
  this.viewer.scene.requestRender();
@@ -15134,9 +15110,14 @@
15134
15110
  if (this.disposed || this.viewer.isDestroyed() || !entities.length) {
15135
15111
  return;
15136
15112
  }
15113
+ // When live we just want to show the latest pos.
15114
+ // When not live, the user might scroll the timeline and want to see it a fluid animation between points in time.
15115
+ const isLive = exports.ViewUtils.GetTimeDetails({
15116
+ viewer: this.viewer,
15117
+ }).isLive;
15137
15118
  let entitiesHistoric = {};
15138
15119
  let changed = false;
15139
- if ((this.item.BruceEntity.historic || this.item.BruceEntity.historicAttrKey) && entities.length) {
15120
+ if (!isLive && (this.item.BruceEntity.historic || this.item.BruceEntity.historicAttrKey) && entities.length) {
15140
15121
  const res = await this.getHistoricInfo(entities);
15141
15122
  changed = res[0];
15142
15123
  entitiesHistoric = res[1];
@@ -15634,7 +15615,13 @@
15634
15615
  tickDelay = null;
15635
15616
  });
15636
15617
  // React to clock changes and request new Entities.
15618
+ let prevTime = null;
15637
15619
  this.hDisposals.push(this.viewer.clock.onTick.addEventListener(() => {
15620
+ const curTime = this.viewer.clock.currentTime.toString();
15621
+ if (curTime === prevTime) {
15622
+ return;
15623
+ }
15624
+ prevTime = curTime;
15638
15625
  if (tickDelay) {
15639
15626
  tickDelay.Call();
15640
15627
  }
@@ -18339,7 +18326,7 @@
18339
18326
  mapTilesetFeature(feature, add) {
18340
18327
  var _a, _b, _c, _d, _e, _f;
18341
18328
  const accountId = (_b = ((_a = this.item.tileset) === null || _a === void 0 ? void 0 : _a.ClientAccountID)) !== null && _b !== void 0 ? _b : this.getters.GetAccountId();
18342
- const canEdit = accountId === this.getters.GetAccountId() && !this.modelSpace && !((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historic);
18329
+ const canEdit = accountId === this.getters.GetAccountId() && !((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historic);
18343
18330
  let rego = {
18344
18331
  canEdit: canEdit,
18345
18332
  entityId: null,
@@ -19019,6 +19006,7 @@
19019
19006
  return await this.historicPossesLoadingProm;
19020
19007
  };
19021
19008
  // Last known timeline range. Helps us detect changes.
19009
+ let lastTime = this.viewer.clock.currentTime.toString();
19022
19010
  let lastStartTime = this.viewer.clock.startTime.toString();
19023
19011
  let lastStopTime = this.viewer.clock.stopTime.toString();
19024
19012
  let clockTickRemoval;
@@ -19058,9 +19046,11 @@
19058
19046
  clockTickRemoval = this.viewer.clock.onTick.addEventListener(() => {
19059
19047
  const startTime = this.viewer.clock.startTime.toString();
19060
19048
  const stopTime = this.viewer.clock.stopTime.toString();
19061
- if (startTime !== lastStartTime || stopTime !== lastStopTime) {
19049
+ const curTime = this.viewer.clock.currentTime.toString();
19050
+ if (startTime !== lastStartTime || stopTime !== lastStopTime || curTime !== lastTime) {
19062
19051
  lastStartTime = startTime;
19063
19052
  lastStopTime = stopTime;
19053
+ lastTime = curTime;
19064
19054
  this.historicAnimation.onRangeChange();
19065
19055
  }
19066
19056
  });
@@ -21488,7 +21478,13 @@
21488
21478
  if (this.viewer.clock) {
21489
21479
  const pHeadingIndex = pHeaders.findIndex(x => x.toLowerCase().includes("head"));
21490
21480
  let errorsInARow = 0;
21481
+ let prevTime = null;
21491
21482
  const removal = this.viewer.clock.onTick.addEventListener(() => {
21483
+ const curTime = this.viewer.clock.currentTime.toString();
21484
+ if (curTime === prevTime) {
21485
+ return;
21486
+ }
21487
+ prevTime = curTime;
21492
21488
  const vehicle = source.entities.getById(vehicleCesiumId);
21493
21489
  if (vehicle) {
21494
21490
  try {
@@ -22381,7 +22377,7 @@
22381
22377
  }
22382
22378
  };
22383
22379
  if (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.Root) {
22384
- traverseHierarchy(hierarchy.Root, true);
22380
+ traverseHierarchy(hierarchy.Root, false);
22385
22381
  rootId = hierarchy.Root.ID;
22386
22382
  }
22387
22383
  }
@@ -22405,14 +22401,14 @@
22405
22401
  * @returns
22406
22402
  */
22407
22403
  async processEntityIds(entityIds) {
22408
- var _a, _b, _c;
22404
+ var _a, _b;
22409
22405
  if (!entityIds || !entityIds.length) {
22410
22406
  return;
22411
22407
  }
22412
22408
  else if (this.disposed) {
22413
22409
  return;
22414
22410
  }
22415
- const BATCH_SIZE = 200;
22411
+ const BATCH_SIZE = 50;
22416
22412
  let batches = Math.ceil(entityIds.length / BATCH_SIZE);
22417
22413
  for (let i = 0; i < batches; i++) {
22418
22414
  const batch = entityIds.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE);
@@ -22429,8 +22425,24 @@
22429
22425
  return;
22430
22426
  }
22431
22427
  for (const entity of fetched) {
22432
- const lod = entity.Bruce.LOD ? entity.Bruce.LOD[0] : null;
22433
- if (!lod || !((_a = lod["ClientFile"]) === null || _a === void 0 ? void 0 : _a.URL)) {
22428
+ // Filter for valid LODs then take the highest quality one (lowest level).
22429
+ let lods = entity.Bruce.LOD || [];
22430
+ lods = lods.filter(lod => { var _a; return ((_a = lod["ClientFile"]) === null || _a === void 0 ? void 0 : _a.URL) && lod["LODCategory.Key"] && lod["LODCategory.Key"].toLowerCase() == "glb"; });
22431
+ let lod = lods.sort((a, b) => {
22432
+ const aLevel = a.Level;
22433
+ const bLevel = b.Level;
22434
+ if (aLevel == null && bLevel == null) {
22435
+ return 0;
22436
+ }
22437
+ else if (aLevel == null) {
22438
+ return 1;
22439
+ }
22440
+ else if (bLevel == null) {
22441
+ return -1;
22442
+ }
22443
+ return aLevel - bLevel;
22444
+ })[0];
22445
+ if (!lod) {
22434
22446
  // Won't bother with vector data for this experiment.
22435
22447
  continue;
22436
22448
  }
@@ -22471,7 +22483,7 @@
22471
22483
  entityTypeId: entity.Bruce["EntityType.ID"],
22472
22484
  name: entity.Bruce.Name,
22473
22485
  rootId: this.rootId,
22474
- parentId: (_c = (_b = this.hierarchyNodeByEntityId) === null || _b === void 0 ? void 0 : _b[entity.Bruce.ID]) === null || _c === void 0 ? void 0 : _c.parentId
22486
+ parentId: (_b = (_a = this.hierarchyNodeByEntityId) === null || _a === void 0 ? void 0 : _a[entity.Bruce.ID]) === null || _b === void 0 ? void 0 : _b.parentId
22475
22487
  },
22476
22488
  requestRender: false
22477
22489
  });
@@ -33011,7 +33023,7 @@
33011
33023
  }
33012
33024
  }
33013
33025
 
33014
- const VERSION = "5.9.0";
33026
+ const VERSION = "5.9.2";
33015
33027
 
33016
33028
  exports.VERSION = VERSION;
33017
33029
  exports.isOutlineChanged = isOutlineChanged;