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.
@@ -1,6 +1,6 @@
1
1
  import { BruceEvent, Cartes, Entity as Entity$1, ProjectViewTile, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, DataLab, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, AbstractApi, Session } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, ClassificationType, ArcType, CornerType, ShadowMode, ConstantProperty, ConstantPositionProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, Primitive, Cesium3DTileFeature, SceneMode, HorizontalOrigin, VerticalOrigin, GeoJsonDataSource, HeadingPitchRange, Ion, Cesium3DTileStyle, Cesium3DTileColorBlendMode, KmlDataSource, Quaternion, Matrix3, Matrix4, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, Cesium3DTileset, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, KmlDataSource, Quaternion, Matrix3, Matrix4, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  const TIME_LAG = 300;
6
6
  const POSITION_CHECK_TIMER = 950;
@@ -13964,56 +13964,32 @@ var EntitiesRenderManager;
13964
13964
  * @returns
13965
13965
  */
13966
13966
  async renderAsIndividuals(entities, force = false) {
13967
- var _a, _b, _c, _d, _e, _f, _g, _h;
13967
+ var _a, _b, _c, _d, _e, _f;
13968
+ // When live we just want to show the latest pos.
13969
+ // When not live, the user might scroll the timeline and want to see it a fluid animation between points in time.
13970
+ const isLive = ViewUtils.GetTimeDetails({
13971
+ viewer: this.viewer
13972
+ }).isLive;
13968
13973
  // Entity ID -> historic records array.
13969
13974
  // We load this as extra information when rendering historic records.
13970
13975
  // This way we know what to animate towards as time changes.
13971
13976
  let entitiesHistoric = {};
13972
- 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) {
13973
- // Interpolating.
13974
- // We will allow non-historic Entities as long as they have historic data in the range.
13975
- if (this.item.historicInterpolation) {
13976
- // We'll add/remove 1 second to ensure we cover all records.
13977
- const startTmp = JulianDate.toDate(this.viewer.clock.startTime);
13978
- const stopTmp = JulianDate.toDate(this.viewer.clock.stopTime);
13979
- const startStr = new Date(startTmp.getTime() - 1000).toISOString();
13980
- const stopStr = new Date(stopTmp.getTime() + 1000).toISOString();
13981
- const historicData = await EntityHistoricData.GetList({
13982
- attrKey: this.item.BruceEntity.historicAttrKey,
13983
- dateTimeFrom: startStr,
13984
- dateTimeTo: stopStr,
13985
- entityIds: entities.map(x => x.Bruce.ID),
13986
- api: this.apiGetter.getApi()
13987
- });
13988
- entitiesHistoric = historicData.recordsByIds;
13989
- // Remove ones with no historicAttrKey and no historic data.
13990
- 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);
13991
- for (let i = 0; i < toRemoveIds.length; i++) {
13992
- const removeId = toRemoveIds[i];
13993
- this.visualsManager.RemoveRegos({
13994
- entityId: removeId,
13995
- menuItemId: this.item.id,
13996
- requestRender: false
13997
- });
13998
- (_c = this.clustering) === null || _c === void 0 ? void 0 : _c.RemoveEntity(removeId, false);
13999
- }
14000
- entities = entities.filter(x => !toRemoveIds.includes(x.Bruce.ID));
14001
- }
14002
- // Not interpolating.
14003
- // So we'll see if the Entities have a historic key or not.
14004
- else {
14005
- const toRemoveIds = entities.filter(x => { var _a; return !((_a = x.Bruce) === null || _a === void 0 ? void 0 : _a.Outline); }).map(x => x.Bruce.ID);
14006
- for (let i = 0; i < toRemoveIds.length; i++) {
14007
- const removeId = toRemoveIds[i];
14008
- this.visualsManager.RemoveRegos({
14009
- entityId: removeId,
14010
- menuItemId: this.item.id,
14011
- requestRender: false
14012
- });
14013
- (_d = this.clustering) === null || _d === void 0 ? void 0 : _d.RemoveEntity(removeId, false);
14014
- }
14015
- entities = entities.filter(x => !toRemoveIds.includes(x.Bruce.ID));
14016
- }
13977
+ 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);
13978
+ // If we're interpolating then we request additional records to quickly swap between.
13979
+ if (!isLive && isHistoric && entities.length && this.item.historicInterpolation) {
13980
+ // We'll add/remove 1 second to ensure we cover all records.
13981
+ const startTmp = JulianDate.toDate(this.viewer.clock.startTime);
13982
+ const stopTmp = JulianDate.toDate(this.viewer.clock.stopTime);
13983
+ const startStr = new Date(startTmp.getTime() - 1000).toISOString();
13984
+ const stopStr = new Date(stopTmp.getTime() + 1000).toISOString();
13985
+ const historicData = await EntityHistoricData.GetList({
13986
+ attrKey: this.item.BruceEntity.historicAttrKey,
13987
+ dateTimeFrom: startStr,
13988
+ dateTimeTo: stopStr,
13989
+ entityIds: entities.map(x => x.Bruce.ID),
13990
+ api: this.apiGetter.getApi()
13991
+ });
13992
+ entitiesHistoric = historicData.recordsByIds;
14017
13993
  }
14018
13994
  if (this.disposed) {
14019
13995
  this.doDispose();
@@ -14048,7 +14024,7 @@ var EntitiesRenderManager;
14048
14024
  menuItemId: this.item.id
14049
14025
  });
14050
14026
  // The baseline data source must be editable.
14051
- const canEdit = !((_e = entity.Bruce.Outline) === null || _e === void 0 ? void 0 : _e.find(x => x.Baseline && !x.Editable));
14027
+ const canEdit = !((_c = entity.Bruce.Outline) === null || _c === void 0 ? void 0 : _c.find(x => x.Baseline && !x.Editable));
14052
14028
  const visual = rego === null || rego === void 0 ? void 0 : rego.visual;
14053
14029
  if (!visual || visual != cEntity) {
14054
14030
  const wasClustered = this.clustering ? this.clustering.AddEntity(id, cEntity, false) : false;
@@ -14079,9 +14055,9 @@ var EntitiesRenderManager;
14079
14055
  rego.visual = cEntity;
14080
14056
  rego.entityTypeId = entity.Bruce["EntityType.ID"];
14081
14057
  rego.tagIds = entity.Bruce["Layer.ID"] ? [].concat(entity.Bruce["Layer.ID"]) : [];
14082
- rego.outline = (_f = entity.Bruce) === null || _f === void 0 ? void 0 : _f.Outline;
14058
+ rego.outline = (_d = entity.Bruce) === null || _d === void 0 ? void 0 : _d.Outline;
14083
14059
  rego.cdn = this.item.cdnEnabled;
14084
- rego.schema = (_g = entity.Bruce) === null || _g === void 0 ? void 0 : _g.Schema;
14060
+ rego.schema = (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.Schema;
14085
14061
  rego.canEdit = canEdit;
14086
14062
  // Marked as stale meaning some change was performed that requires a refresh.
14087
14063
  // This usually means a new sibling was added that we need to update.
@@ -14112,7 +14088,7 @@ var EntitiesRenderManager;
14112
14088
  menuItemId: this.item.id,
14113
14089
  requestRender: false
14114
14090
  });
14115
- (_h = this.clustering) === null || _h === void 0 ? void 0 : _h.RemoveEntity(id, false);
14091
+ (_f = this.clustering) === null || _f === void 0 ? void 0 : _f.RemoveEntity(id, false);
14116
14092
  }
14117
14093
  }
14118
14094
  this.viewer.scene.requestRender();
@@ -15183,9 +15159,14 @@ var EntitiesIdsRenderManager;
15183
15159
  if (this.disposed || this.viewer.isDestroyed() || !entities.length) {
15184
15160
  return;
15185
15161
  }
15162
+ // When live we just want to show the latest pos.
15163
+ // When not live, the user might scroll the timeline and want to see it a fluid animation between points in time.
15164
+ const isLive = ViewUtils.GetTimeDetails({
15165
+ viewer: this.viewer,
15166
+ }).isLive;
15186
15167
  let entitiesHistoric = {};
15187
15168
  let changed = false;
15188
- if ((this.item.BruceEntity.historic || this.item.BruceEntity.historicAttrKey) && entities.length) {
15169
+ if (!isLive && (this.item.BruceEntity.historic || this.item.BruceEntity.historicAttrKey) && entities.length) {
15189
15170
  const res = await this.getHistoricInfo(entities);
15190
15171
  changed = res[0];
15191
15172
  entitiesHistoric = res[1];
@@ -15687,7 +15668,13 @@ class EntityGatherer {
15687
15668
  tickDelay = null;
15688
15669
  });
15689
15670
  // React to clock changes and request new Entities.
15671
+ let prevTime = null;
15690
15672
  this.hDisposals.push(this.viewer.clock.onTick.addEventListener(() => {
15673
+ const curTime = this.viewer.clock.currentTime.toString();
15674
+ if (curTime === prevTime) {
15675
+ return;
15676
+ }
15677
+ prevTime = curTime;
15691
15678
  if (tickDelay) {
15692
15679
  tickDelay.Call();
15693
15680
  }
@@ -18399,7 +18386,7 @@ var TilesetCadRenderManager;
18399
18386
  mapTilesetFeature(feature, add) {
18400
18387
  var _a, _b, _c, _d, _e, _f;
18401
18388
  const accountId = (_b = ((_a = this.item.tileset) === null || _a === void 0 ? void 0 : _a.ClientAccountID)) !== null && _b !== void 0 ? _b : this.getters.GetAccountId();
18402
- const canEdit = accountId === this.getters.GetAccountId() && !this.modelSpace && !((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historic);
18389
+ const canEdit = accountId === this.getters.GetAccountId() && !((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historic);
18403
18390
  let rego = {
18404
18391
  canEdit: canEdit,
18405
18392
  entityId: null,
@@ -19079,6 +19066,7 @@ var TilesetCadRenderManager;
19079
19066
  return await this.historicPossesLoadingProm;
19080
19067
  };
19081
19068
  // Last known timeline range. Helps us detect changes.
19069
+ let lastTime = this.viewer.clock.currentTime.toString();
19082
19070
  let lastStartTime = this.viewer.clock.startTime.toString();
19083
19071
  let lastStopTime = this.viewer.clock.stopTime.toString();
19084
19072
  let clockTickRemoval;
@@ -19118,9 +19106,11 @@ var TilesetCadRenderManager;
19118
19106
  clockTickRemoval = this.viewer.clock.onTick.addEventListener(() => {
19119
19107
  const startTime = this.viewer.clock.startTime.toString();
19120
19108
  const stopTime = this.viewer.clock.stopTime.toString();
19121
- if (startTime !== lastStartTime || stopTime !== lastStopTime) {
19109
+ const curTime = this.viewer.clock.currentTime.toString();
19110
+ if (startTime !== lastStartTime || stopTime !== lastStopTime || curTime !== lastTime) {
19122
19111
  lastStartTime = startTime;
19123
19112
  lastStopTime = stopTime;
19113
+ lastTime = curTime;
19124
19114
  this.historicAnimation.onRangeChange();
19125
19115
  }
19126
19116
  });
@@ -21556,7 +21546,13 @@ var DataSourceStaticCsvManager;
21556
21546
  if (this.viewer.clock) {
21557
21547
  const pHeadingIndex = pHeaders.findIndex(x => x.toLowerCase().includes("head"));
21558
21548
  let errorsInARow = 0;
21549
+ let prevTime = null;
21559
21550
  const removal = this.viewer.clock.onTick.addEventListener(() => {
21551
+ const curTime = this.viewer.clock.currentTime.toString();
21552
+ if (curTime === prevTime) {
21553
+ return;
21554
+ }
21555
+ prevTime = curTime;
21560
21556
  const vehicle = source.entities.getById(vehicleCesiumId);
21561
21557
  if (vehicle) {
21562
21558
  try {
@@ -22457,7 +22453,7 @@ var AssemblyRenderManager;
22457
22453
  }
22458
22454
  };
22459
22455
  if (hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.Root) {
22460
- traverseHierarchy(hierarchy.Root, true);
22456
+ traverseHierarchy(hierarchy.Root, false);
22461
22457
  rootId = hierarchy.Root.ID;
22462
22458
  }
22463
22459
  }
@@ -22481,14 +22477,14 @@ var AssemblyRenderManager;
22481
22477
  * @returns
22482
22478
  */
22483
22479
  async processEntityIds(entityIds) {
22484
- var _a, _b, _c;
22480
+ var _a, _b;
22485
22481
  if (!entityIds || !entityIds.length) {
22486
22482
  return;
22487
22483
  }
22488
22484
  else if (this.disposed) {
22489
22485
  return;
22490
22486
  }
22491
- const BATCH_SIZE = 200;
22487
+ const BATCH_SIZE = 50;
22492
22488
  let batches = Math.ceil(entityIds.length / BATCH_SIZE);
22493
22489
  for (let i = 0; i < batches; i++) {
22494
22490
  const batch = entityIds.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE);
@@ -22505,8 +22501,24 @@ var AssemblyRenderManager;
22505
22501
  return;
22506
22502
  }
22507
22503
  for (const entity of fetched) {
22508
- const lod = entity.Bruce.LOD ? entity.Bruce.LOD[0] : null;
22509
- if (!lod || !((_a = lod["ClientFile"]) === null || _a === void 0 ? void 0 : _a.URL)) {
22504
+ // Filter for valid LODs then take the highest quality one (lowest level).
22505
+ let lods = entity.Bruce.LOD || [];
22506
+ 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"; });
22507
+ let lod = lods.sort((a, b) => {
22508
+ const aLevel = a.Level;
22509
+ const bLevel = b.Level;
22510
+ if (aLevel == null && bLevel == null) {
22511
+ return 0;
22512
+ }
22513
+ else if (aLevel == null) {
22514
+ return 1;
22515
+ }
22516
+ else if (bLevel == null) {
22517
+ return -1;
22518
+ }
22519
+ return aLevel - bLevel;
22520
+ })[0];
22521
+ if (!lod) {
22510
22522
  // Won't bother with vector data for this experiment.
22511
22523
  continue;
22512
22524
  }
@@ -22547,7 +22559,7 @@ var AssemblyRenderManager;
22547
22559
  entityTypeId: entity.Bruce["EntityType.ID"],
22548
22560
  name: entity.Bruce.Name,
22549
22561
  rootId: this.rootId,
22550
- parentId: (_c = (_b = this.hierarchyNodeByEntityId) === null || _b === void 0 ? void 0 : _b[entity.Bruce.ID]) === null || _c === void 0 ? void 0 : _c.parentId
22562
+ parentId: (_b = (_a = this.hierarchyNodeByEntityId) === null || _a === void 0 ? void 0 : _a[entity.Bruce.ID]) === null || _b === void 0 ? void 0 : _b.parentId
22551
22563
  },
22552
22564
  requestRender: false
22553
22565
  });
@@ -33115,7 +33127,7 @@ class WidgetViewBar extends Widget.AWidget {
33115
33127
  }
33116
33128
  }
33117
33129
 
33118
- const VERSION = "5.9.0";
33130
+ const VERSION = "5.9.2";
33119
33131
 
33120
33132
  export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, isOutlineChanged, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, AssemblyRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar, WidgetControlViewBar, WidgetControlViewBarSearch, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
33121
33133
  //# sourceMappingURL=bruce-cesium.es5.js.map