bruce-cesium 6.2.1 → 6.2.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, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, HorizontalOrigin, VerticalOrigin, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, HeadingPitchRange, Ion, Cesium3DTileStyle, Cesium3DTileColorBlendMode, KmlDataSource, Quaternion, Matrix3, Matrix4, SceneTransforms, NearFarScalar, OrthographicFrustum, EasingFunction, Cesium3DTileset, IonResource, PolygonPipeline, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, 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, NearFarScalar, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  const TIME_LAG = 300;
6
6
  const POSITION_CHECK_TIMER = 950;
@@ -11544,41 +11544,172 @@ var VisualsRegister;
11544
11544
  return newStates;
11545
11545
  }
11546
11546
  /**
11547
- * Applies a set of new states to override the existing ones.
11548
- * This can be a costly operation as it will update all visuals.
11547
+ * Calculates the difference between current states and new states.
11548
+ * Returns what needs to be added, removed, and updated.
11549
+ */
11550
+ calculateStateDifference(newStates) {
11551
+ const toAdd = [];
11552
+ const toRemove = [];
11553
+ const toUpdate = [];
11554
+ const affectedEntityIds = new Set();
11555
+ // State map for quick lookups.
11556
+ const newStatesMap = new Map();
11557
+ for (const state of newStates) {
11558
+ if (!state.entityId || isBlankState(state)) {
11559
+ continue;
11560
+ }
11561
+ const key = `${state.entityId}::${state.menuItemId || NO_MENU_ITEM_KEY}`;
11562
+ newStatesMap.set(key, state);
11563
+ }
11564
+ // Track existing states.
11565
+ const existingKeys = new Set();
11566
+ // Check existing states to see if they need removal or updating.
11567
+ this.ForEachState((existingState) => {
11568
+ const key = `${existingState.entityId}::${existingState.menuItemId || NO_MENU_ITEM_KEY}`;
11569
+ existingKeys.add(key);
11570
+ const newState = newStatesMap.get(key);
11571
+ // State exists in current but not in new.
11572
+ if (!newState) {
11573
+ toRemove.push({ ...existingState });
11574
+ affectedEntityIds.add(existingState.entityId);
11575
+ }
11576
+ // State exists in both.
11577
+ // See if changed.
11578
+ else {
11579
+ if (this.isStateDifferent(existingState, newState)) {
11580
+ toUpdate.push({ ...newState });
11581
+ affectedEntityIds.add(existingState.entityId);
11582
+ }
11583
+ }
11584
+ });
11585
+ // Check for new states that don't exist currently.
11586
+ for (const [key, newState] of newStatesMap) {
11587
+ if (!existingKeys.has(key)) {
11588
+ toAdd.push({ ...newState });
11589
+ affectedEntityIds.add(newState.entityId);
11590
+ }
11591
+ }
11592
+ return { toAdd, toRemove, toUpdate, affectedEntityIds };
11593
+ }
11594
+ /**
11595
+ * Compares two states to determine if they're different.
11596
+ * Only compares meaningful properties (not entityId/menuItemId).
11597
+ */
11598
+ isStateDifferent(state1, state2) {
11599
+ const keys1 = Object.keys(state1).filter(k => k !== "entityId" && k !== "menuItemId");
11600
+ const keys2 = Object.keys(state2).filter(k => k !== "entityId" && k !== "menuItemId");
11601
+ // Different number of properties.
11602
+ if (keys1.length !== keys2.length) {
11603
+ return true;
11604
+ }
11605
+ // Check if any property values differ.
11606
+ for (const key of keys1) {
11607
+ if (state1[key] !== state2[key]) {
11608
+ return true;
11609
+ }
11610
+ }
11611
+ return false;
11612
+ }
11613
+ /**
11614
+ * Applies a set of new states to override the existing ones using differential updates.
11615
+ * This is more efficient than clearing and re-applying all states.
11549
11616
  * @param states
11550
11617
  */
11551
11618
  OverrideStates(states) {
11552
- // Clear current states.
11553
- this.ClearOpacity();
11554
- this.ClearLabelled();
11555
- this.ClearSelected();
11556
- this.ClearHighlighted();
11557
- this.ClearIsolated();
11558
- this.ClearHidden();
11559
- this.states = {};
11560
- let newStates = {};
11561
- for (let i = 0; i < states.length; i++) {
11562
- const state = states[i];
11563
- if (!state.menuItemId && state.hasOwnProperty("menuItemId")) {
11564
- delete state.menuItemId;
11619
+ // Calculate what needs to change.
11620
+ const diff = this.calculateStateDifference(states);
11621
+ // If nothing changed, exit early.
11622
+ if (diff.toAdd.length === 0 && diff.toRemove.length === 0 && diff.toUpdate.length === 0) {
11623
+ return;
11624
+ }
11625
+ // Track which visual properties need refreshing per entity.
11626
+ const refreshMap = new Map();
11627
+ const updateRefreshForEntity = (entityId, props) => {
11628
+ const existing = refreshMap.get(entityId) || {};
11629
+ refreshMap.set(entityId, {
11630
+ highlighted: existing.highlighted || props.highlighted || false,
11631
+ selected: existing.selected || props.selected || false,
11632
+ opacity: existing.opacity || props.opacity || false
11633
+ });
11634
+ };
11635
+ // Process removals.
11636
+ for (const state of diff.toRemove) {
11637
+ // Create a state with inverted/cleared values.
11638
+ const clearState = {
11639
+ entityId: state.entityId,
11640
+ menuItemId: state.menuItemId
11641
+ };
11642
+ // For each property that exists, set it to null to clear it.
11643
+ // This will cause setStateValues to delete the property.
11644
+ if (state.highlighted != null) {
11645
+ clearState.highlighted = null;
11646
+ updateRefreshForEntity(state.entityId, {
11647
+ highlighted: true
11648
+ });
11565
11649
  }
11566
- if (!state.entityId) {
11567
- continue;
11650
+ if (state.selected != null) {
11651
+ clearState.selected = null;
11652
+ updateRefreshForEntity(state.entityId, {
11653
+ selected: true
11654
+ });
11568
11655
  }
11569
- if (isBlankState(state)) {
11570
- continue;
11656
+ if (state.opacity != null) {
11657
+ clearState.opacity = null;
11658
+ updateRefreshForEntity(state.entityId, {
11659
+ opacity: true
11660
+ });
11571
11661
  }
11572
- if (!newStates[state.entityId]) {
11573
- newStates[state.entityId] = {};
11662
+ if (state.labelled != null) {
11663
+ clearState.labelled = null;
11664
+ updateRefreshForEntity(state.entityId, {});
11574
11665
  }
11575
- newStates[state.entityId][state.menuItemId ? state.menuItemId : NO_MENU_ITEM_KEY] = {
11576
- ...state
11577
- };
11666
+ if (state.hidden != null) {
11667
+ clearState.hidden = null;
11668
+ updateRefreshForEntity(state.entityId, {});
11669
+ }
11670
+ if (state.isolated != null) {
11671
+ clearState.isolated = null;
11672
+ updateRefreshForEntity(state.entityId, {});
11673
+ }
11674
+ this.setStateValues(clearState);
11675
+ }
11676
+ // Process additions and updates.
11677
+ const statesToSet = [...diff.toAdd, ...diff.toUpdate];
11678
+ for (const state of statesToSet) {
11679
+ // Determine what needs visual refresh based on what's changing.
11680
+ if (state.hasOwnProperty("highlighted")) {
11681
+ updateRefreshForEntity(state.entityId, {
11682
+ highlighted: true
11683
+ });
11684
+ }
11685
+ if (state.hasOwnProperty("selected")) {
11686
+ updateRefreshForEntity(state.entityId, {
11687
+ selected: true
11688
+ });
11689
+ }
11690
+ if (state.hasOwnProperty("opacity")) {
11691
+ updateRefreshForEntity(state.entityId, {
11692
+ opacity: true
11693
+ });
11694
+ }
11695
+ if (state.hasOwnProperty("labelled")) {
11696
+ updateRefreshForEntity(state.entityId, {});
11697
+ }
11698
+ if (state.hasOwnProperty("hidden") || state.hasOwnProperty("isolated")) {
11699
+ updateRefreshForEntity(state.entityId, {});
11700
+ }
11701
+ this.setStateValues(state);
11578
11702
  }
11579
- this.states = newStates;
11580
- // Reflect the rest of the changes.
11581
- this.updateAllEntities();
11703
+ // Queue updates for all affected entities.
11704
+ // TODO: if a massive list we should async batch this.
11705
+ for (const entityId of diff.affectedEntityIds) {
11706
+ const refresh = refreshMap.get(entityId);
11707
+ this.queueUpdate({
11708
+ entityId: entityId,
11709
+ refresh: refresh || true
11710
+ });
11711
+ }
11712
+ this.viewer.scene.requestRender();
11582
11713
  }
11583
11714
  /**
11584
11715
  * Returns all states with the first detected Menu Item ID settings included.
@@ -12026,7 +12157,7 @@ var VisualsRegister;
12026
12157
  }
12027
12158
  SetIsolated(params) {
12028
12159
  var _a;
12029
- const { entityIds, isolated: isolate, requestRender, menuItemId, source } = params;
12160
+ const { entityIds, isolated: isolate, requestRender, menuItemId, source, doUpdate } = params;
12030
12161
  for (let i = 0; i < entityIds.length; i++) {
12031
12162
  const entityId = entityIds[i];
12032
12163
  this.setStateValues({
@@ -12047,12 +12178,14 @@ var VisualsRegister;
12047
12178
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(update);
12048
12179
  }
12049
12180
  }
12050
- this.updateAllEntities({
12051
- requestRender: false,
12052
- refresh: isolate
12053
- });
12054
- if (requestRender != false) {
12055
- this.viewer.scene.requestRender();
12181
+ if (doUpdate !== false) {
12182
+ this.updateAllEntities({
12183
+ requestRender: false,
12184
+ refresh: isolate
12185
+ });
12186
+ if (requestRender != false) {
12187
+ this.viewer.scene.requestRender();
12188
+ }
12056
12189
  }
12057
12190
  }
12058
12191
  GetIsIsolated(params) {
@@ -12088,7 +12221,7 @@ var VisualsRegister;
12088
12221
  }
12089
12222
  delete state.isolated;
12090
12223
  });
12091
- if (changed) {
12224
+ if (changed && params.doUpdate !== false) {
12092
12225
  this.updateAllEntities({
12093
12226
  requestRender: params === null || params === void 0 ? void 0 : params.requestRender,
12094
12227
  refresh: true
@@ -12142,7 +12275,7 @@ var VisualsRegister;
12142
12275
  }
12143
12276
  delete state.hidden;
12144
12277
  });
12145
- if (changed) {
12278
+ if (changed && params.doUpdate !== false) {
12146
12279
  this.updateAllEntities({
12147
12280
  requestRender: params === null || params === void 0 ? void 0 : params.requestRender,
12148
12281
  refresh: true
@@ -12536,16 +12669,27 @@ var VisualsRegister;
12536
12669
  }
12537
12670
  }
12538
12671
  }
12539
- updateAllEntities(params) {
12540
- for (const entityId in this.rego) {
12541
- const regos = this.rego[entityId];
12542
- if (regos && regos.length) {
12543
- this.queueUpdate({
12544
- entityId: entityId,
12545
- refresh: (params === null || params === void 0 ? void 0 : params.refresh) == null ? true : params.refresh
12546
- });
12672
+ async updateAllEntities(params) {
12673
+ const ids = Object.keys(this.rego);
12674
+ const interval = setInterval(() => {
12675
+ const batch = ids.splice(0, 3000);
12676
+ if (!batch.length || (params.isCancelled && params.isCancelled())) {
12677
+ clearInterval(interval);
12678
+ return;
12547
12679
  }
12548
- }
12680
+ for (const entityId of batch) {
12681
+ const regos = this.rego[entityId];
12682
+ if (regos && regos.length) {
12683
+ this.queueUpdate({
12684
+ entityId: entityId,
12685
+ refresh: (params === null || params === void 0 ? void 0 : params.refresh) == null ? true : params.refresh
12686
+ });
12687
+ }
12688
+ }
12689
+ if ((params === null || params === void 0 ? void 0 : params.requestRender) !== false) {
12690
+ this.viewer.scene.requestRender();
12691
+ }
12692
+ }, 10);
12549
12693
  }
12550
12694
  /**
12551
12695
  * Sets opacity for given set of entities.
@@ -34322,7 +34466,7 @@ class WidgetViewBar extends Widget.AWidget {
34322
34466
  }
34323
34467
  }
34324
34468
 
34325
- const VERSION = "6.2.1";
34469
+ const VERSION = "6.2.2";
34326
34470
 
34327
34471
  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, LiveCursor, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_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 };
34328
34472
  //# sourceMappingURL=bruce-cesium.es5.js.map