bruce-cesium 4.9.1 → 4.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
- import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, 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';
1
+ import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, DataLab, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, AbstractApi, Session, EntityAttachment, EntityAttachmentType, EntityAttribute } 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, HorizontalOrigin, VerticalOrigin, ConstantProperty, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } 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, SceneMode, GeoJsonDataSource, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  const TIME_LAG = 300;
6
6
  const POSITION_CHECK_TIMER = 950;
@@ -9362,19 +9362,6 @@ var CesiumAnimatedInOut;
9362
9362
  CesiumAnimatedInOut.AnimateOut = AnimateOut;
9363
9363
  })(CesiumAnimatedInOut || (CesiumAnimatedInOut = {}));
9364
9364
 
9365
- function debounce(fn, delay) {
9366
- let timeout = null;
9367
- let lastArgs;
9368
- return function (...args) {
9369
- lastArgs = args;
9370
- if (timeout !== null)
9371
- clearTimeout(timeout);
9372
- timeout = window.setTimeout(() => {
9373
- timeout = null;
9374
- fn(...lastArgs);
9375
- }, delay);
9376
- };
9377
- }
9378
9365
  /**
9379
9366
  * Returns if a given visual is alive and in the scene.
9380
9367
  * @param viewer
@@ -9647,16 +9634,7 @@ function unmarkEntity(visual, ignoreParent) {
9647
9634
  }
9648
9635
  }
9649
9636
  }
9650
- const STATE_DELIMITER = "\"";
9651
- function parseStateKey(key) {
9652
- return key.split(STATE_DELIMITER);
9653
- }
9654
- function constructStateKey(entityId, menuItemId) {
9655
- if (!menuItemId) {
9656
- return entityId;
9657
- }
9658
- return entityId + STATE_DELIMITER + menuItemId;
9659
- }
9637
+ const NO_MENU_ITEM_KEY = "";
9660
9638
  function getBlankState(entityId, menuItemId) {
9661
9639
  const state = {
9662
9640
  entityId: entityId
@@ -9706,7 +9684,8 @@ var VisualsRegister;
9706
9684
  this.disposed = false;
9707
9685
  this.rego = {};
9708
9686
  this.onUpdate = null;
9709
- // Entity ID + Menu Item ID -> State.
9687
+ // Entity ID -> Menu Item ID -> State.
9688
+ // When no Menu Item ID is set, then the second key is a blank string.
9710
9689
  // If an Entity ID state is set without a Menu Item ID, then it acts as a default for all Menu Items.
9711
9690
  this.states = {};
9712
9691
  // Queue of Entity updates to process in batches to avoid overloading the render loop.
@@ -9715,47 +9694,6 @@ var VisualsRegister;
9715
9694
  // This lets us modify the update without re-adding the item to the queue if it's already in it.
9716
9695
  this.updateQueueSettings = {};
9717
9696
  this.updateQueueInterval = null;
9718
- // public ClearHighlighted(params?: {
9719
- // // Default is true.
9720
- // requestRender?: boolean
9721
- // }): void {
9722
- // // Null all states.
9723
- // let entityIds: string[] = [];
9724
- // console.log("Clearing highlighted");
9725
- // this.ForEachState((state) => {
9726
- // if (state.highlighted) {
9727
- // delete state.highlighted;
9728
- // if (!entityIds.includes(state.entityId)) {
9729
- // entityIds.push(state.entityId);
9730
- // }
9731
- // }
9732
- // });
9733
- // console.log("Revert needed visual changes");
9734
- // // Revert needed visual changes.
9735
- // for (let i = 0; i < entityIds.length; i++) {
9736
- // const id = entityIds[i];
9737
- // const regos = this.rego[id];
9738
- // if (regos) {
9739
- // for (let i = 0; i < regos.length; i++) {
9740
- // const rego = regos[i];
9741
- // CesiumEntityStyler.Unhighlight({
9742
- // entity: rego.visual,
9743
- // viewer: this.viewer,
9744
- // requestRender: false
9745
- // });
9746
- // }
9747
- // }
9748
- // }
9749
- // console.log("Requesting render");
9750
- // if (params?.requestRender != false) {
9751
- // this.viewer.scene.requestRender();
9752
- // }
9753
- // console.log("Triggering update");
9754
- // }
9755
- // Debounced method to apply highlight changes
9756
- this.applyHighlightChanges = debounce((newEntitiesToHighlight) => {
9757
- this.updateHighlightedEntities(newEntitiesToHighlight);
9758
- }, 50);
9759
9697
  this.viewer = params.viewer;
9760
9698
  this.apiGetters = params.apiGetters;
9761
9699
  this.cameraCullerDispose = VisualRegisterCuller.Monitor({
@@ -9837,20 +9775,19 @@ var VisualsRegister;
9837
9775
  * @param params
9838
9776
  */
9839
9777
  GetState(params) {
9778
+ var _a, _b;
9840
9779
  const { entityId, menuItemId } = params;
9841
- const eStateKey = constructStateKey(entityId);
9842
- let eState = this.states[eStateKey];
9780
+ let eState = (_a = this.states[entityId]) === null || _a === void 0 ? void 0 : _a[NO_MENU_ITEM_KEY];
9843
9781
  if (eState && isBlankState(eState)) {
9844
9782
  eState = null;
9845
- delete this.states[eStateKey];
9783
+ delete this.states[entityId][NO_MENU_ITEM_KEY];
9846
9784
  }
9847
9785
  let mState;
9848
9786
  if (menuItemId) {
9849
- const mStateKey = constructStateKey(entityId, menuItemId);
9850
- mState = this.states[mStateKey];
9787
+ mState = (_b = this.states[entityId]) === null || _b === void 0 ? void 0 : _b[menuItemId];
9851
9788
  if (mState && isBlankState(mState)) {
9852
9789
  mState = null;
9853
- delete this.states[mStateKey];
9790
+ delete this.states[entityId][menuItemId];
9854
9791
  }
9855
9792
  }
9856
9793
  if (!mState && eState) {
@@ -10018,11 +9955,22 @@ var VisualsRegister;
10018
9955
  let keys = Object.keys(values);
10019
9956
  keys = keys.filter(k => k !== "entityId" && k !== "menuItemId");
10020
9957
  let changed = false;
10021
- const update = (key) => {
10022
- let state = this.states[key];
9958
+ const update = (entityId, menuItemId) => {
9959
+ if (!menuItemId) {
9960
+ menuItemId = NO_MENU_ITEM_KEY;
9961
+ }
9962
+ let state;
9963
+ let eStates = this.states[entityId];
9964
+ if (eStates) {
9965
+ state = eStates[menuItemId];
9966
+ }
10023
9967
  if (!state) {
10024
9968
  state = getBlankState(values.entityId, values.menuItemId);
10025
- this.states[key] = state;
9969
+ if (!eStates) {
9970
+ eStates = {};
9971
+ this.states[entityId] = eStates;
9972
+ }
9973
+ eStates[menuItemId] = state;
10026
9974
  }
10027
9975
  for (let i = 0; i < keys.length; i++) {
10028
9976
  const k = keys[i];
@@ -10035,11 +9983,21 @@ var VisualsRegister;
10035
9983
  }
10036
9984
  }
10037
9985
  if (isBlankState(state)) {
10038
- delete this.states[key];
9986
+ delete eStates[menuItemId];
9987
+ if (Object.keys(eStates).length === 0) {
9988
+ delete this.states[entityId];
9989
+ }
10039
9990
  }
10040
9991
  };
10041
- const strip = (key) => {
10042
- const state = this.states[key];
9992
+ const strip = (entityId, menuItemId) => {
9993
+ if (!menuItemId) {
9994
+ menuItemId = NO_MENU_ITEM_KEY;
9995
+ }
9996
+ const eStates = this.states[entityId];
9997
+ if (!eStates) {
9998
+ return;
9999
+ }
10000
+ const state = eStates[menuItemId];
10043
10001
  if (!state) {
10044
10002
  return;
10045
10003
  }
@@ -10050,17 +10008,21 @@ var VisualsRegister;
10050
10008
  }
10051
10009
  }
10052
10010
  if (isBlankState(state)) {
10053
- delete this.states[key];
10011
+ delete eStates[menuItemId];
10012
+ if (Object.keys(eStates).length === 0) {
10013
+ delete this.states[entityId];
10014
+ }
10054
10015
  }
10055
10016
  };
10056
- update(constructStateKey(values.entityId, values.menuItemId));
10017
+ update(values.entityId, values.menuItemId);
10057
10018
  // If there is no Menu Item ID, then we want to strip the settings we updated from the Menu Item specific settings.
10058
10019
  if (!values.menuItemId) {
10059
- const stateKeys = Object.keys(this.states);
10060
- for (let i = 0; i < stateKeys.length; i++) {
10061
- const split = parseStateKey(stateKeys[i]);
10062
- if (split[1] && split[0] === values.entityId) {
10063
- strip(stateKeys[i]);
10020
+ const eStates = this.states[values.entityId];
10021
+ if (eStates) {
10022
+ for (const key in eStates) {
10023
+ if (key !== NO_MENU_ITEM_KEY) {
10024
+ strip(values.entityId, key);
10025
+ }
10064
10026
  }
10065
10027
  }
10066
10028
  }
@@ -10071,14 +10033,31 @@ var VisualsRegister;
10071
10033
  * This is typically used for saving.
10072
10034
  */
10073
10035
  GetStates(params) {
10074
- if (!(params === null || params === void 0 ? void 0 : params.optimized)) {
10075
- return this.states;
10076
- }
10077
- const newStates = {};
10036
+ const states = [];
10037
+ // We flatten the dictionary into an array.
10078
10038
  const keys = Object.keys(this.states);
10079
10039
  for (let i = 0; i < keys.length; i++) {
10080
- const key = keys[i];
10081
- let state = this.states[key];
10040
+ const entityId = keys[i];
10041
+ const eStates = this.states[entityId];
10042
+ if (!eStates) {
10043
+ continue;
10044
+ }
10045
+ const mKeys = Object.keys(eStates);
10046
+ for (let j = 0; j < mKeys.length; j++) {
10047
+ const menuItemId = mKeys[j];
10048
+ const state = eStates[menuItemId];
10049
+ if (!state) {
10050
+ continue;
10051
+ }
10052
+ states.push(state);
10053
+ }
10054
+ }
10055
+ if (!(params === null || params === void 0 ? void 0 : params.optimized)) {
10056
+ return states;
10057
+ }
10058
+ const newStates = [];
10059
+ for (let i = 0; i < states.length; i++) {
10060
+ let state = states[i];
10082
10061
  // Dereference.
10083
10062
  state = {
10084
10063
  ...state
@@ -10104,7 +10083,7 @@ var VisualsRegister;
10104
10083
  if (isBlankState(state)) {
10105
10084
  continue;
10106
10085
  }
10107
- newStates[key] = state;
10086
+ newStates.push(state);
10108
10087
  }
10109
10088
  return newStates;
10110
10089
  }
@@ -10123,20 +10102,25 @@ var VisualsRegister;
10123
10102
  this.ClearHidden();
10124
10103
  this.states = {};
10125
10104
  let newStates = {};
10126
- if (Array.isArray(states)) {
10127
- for (let i = 0; i < states.length; i++) {
10128
- const state = states[i];
10129
- if (!state.menuItemId && state.hasOwnProperty("menuItemId")) {
10130
- delete state.menuItemId;
10131
- }
10132
- const key = constructStateKey(state.entityId, state.menuItemId);
10133
- newStates[key] = state;
10105
+ for (let i = 0; i < states.length; i++) {
10106
+ const state = states[i];
10107
+ if (!state.menuItemId && state.hasOwnProperty("menuItemId")) {
10108
+ delete state.menuItemId;
10134
10109
  }
10110
+ if (!state.entityId) {
10111
+ continue;
10112
+ }
10113
+ if (isBlankState(state)) {
10114
+ continue;
10115
+ }
10116
+ if (!newStates[state.entityId]) {
10117
+ newStates[state.entityId] = {};
10118
+ }
10119
+ newStates[state.entityId][state.menuItemId ? state.menuItemId : NO_MENU_ITEM_KEY] = {
10120
+ ...state
10121
+ };
10135
10122
  }
10136
- else {
10137
- newStates = states;
10138
- }
10139
- this.states = JSON.parse(JSON.stringify(newStates));
10123
+ this.states = newStates;
10140
10124
  // Reflect the rest of the changes.
10141
10125
  this.updateAllEntities();
10142
10126
  }
@@ -10150,13 +10134,20 @@ var VisualsRegister;
10150
10134
  const states = {};
10151
10135
  let entityIds = [];
10152
10136
  let entityIdsMenuItem = {};
10153
- for (const key in this.states) {
10154
- const state = this.states[key];
10155
- if (!entityIds.includes(state.entityId)) {
10156
- entityIds.push(state.entityId);
10137
+ for (const entityId in this.states) {
10138
+ const eStates = this.states[entityId];
10139
+ if (!eStates) {
10140
+ continue;
10157
10141
  }
10158
- if (state.menuItemId) {
10159
- entityIdsMenuItem[state.entityId] = state.menuItemId;
10142
+ if (!entityIds.includes(entityId)) {
10143
+ entityIds.push(entityId);
10144
+ }
10145
+ const mKeys = Object.keys(eStates);
10146
+ for (let i = 0; i < mKeys.length; i++) {
10147
+ const menuItemId = mKeys[i];
10148
+ if (menuItemId) {
10149
+ entityIdsMenuItem[entityId] = menuItemId;
10150
+ }
10160
10151
  }
10161
10152
  }
10162
10153
  for (let i = 0; i < entityIds.length; i++) {
@@ -10185,20 +10176,22 @@ var VisualsRegister;
10185
10176
  * @param callback
10186
10177
  */
10187
10178
  ForEachState(callback) {
10188
- for (const key in this.states) {
10189
- callback(this.states[key], key);
10190
- }
10191
- }
10192
- /**
10193
- * Utility to iterate over all states for a given Menu Item ID.
10194
- * @param params
10195
- */
10196
- ForEachMenuItemState(params) {
10197
- const { menuItemId, callback } = params;
10198
- for (const key in this.states) {
10199
- const parts = parseStateKey(key);
10200
- if (parts.length > 1 && parts[1] === menuItemId) {
10201
- callback(this.states[key], key);
10179
+ // Flatten and iterate.
10180
+ const keys = Object.keys(this.states);
10181
+ for (let i = 0; i < keys.length; i++) {
10182
+ const entityId = keys[i];
10183
+ const eStates = this.states[entityId];
10184
+ if (!eStates) {
10185
+ continue;
10186
+ }
10187
+ const mKeys = Object.keys(eStates);
10188
+ for (let j = 0; j < mKeys.length; j++) {
10189
+ const menuItemId = mKeys[j];
10190
+ const state = eStates[menuItemId];
10191
+ if (!state) {
10192
+ continue;
10193
+ }
10194
+ callback(state);
10202
10195
  }
10203
10196
  }
10204
10197
  }
@@ -10328,131 +10321,71 @@ var VisualsRegister;
10328
10321
  CesiumEntityStyler.UpdateColorSetting("highlight", color);
10329
10322
  }
10330
10323
  }
10331
- // public SetSelected(params: {
10332
- // selected: boolean;
10333
- // entityIds: string[];
10334
- // menuItemId?: string;
10335
- // refreshIfSelected?: boolean;
10336
- // // Default is true.
10337
- // requestRender?: boolean;
10338
- // }): void {
10339
- // let { entityIds, selected, refreshIfSelected, requestRender, menuItemId } = params;
10340
- // if (refreshIfSelected == null || refreshIfSelected === undefined) {
10341
- // refreshIfSelected = true;
10342
- // }
10343
- // for (let i = 0; i < entityIds.length; i++) {
10344
- // const id = entityIds[i];
10345
- // const state = this.GetState({
10346
- // entityId: id,
10347
- // menuItemId
10348
- // });
10349
- // // Checking if we need to refresh the selection.
10350
- // const doSelect = refreshIfSelected || (Boolean(state.selected) != selected);
10351
- // this.setStateValues({
10352
- // entityId: id,
10353
- // menuItemId: menuItemId,
10354
- // // Null means it will be deleted from the object.
10355
- // selected: selected ? true : null
10356
- // })
10357
- // if (selected) {
10358
- // if (doSelect) {
10359
- // const regos = this.rego[id];
10360
- // if (regos) {
10361
- // for (let i = 0; i < regos.length; i++) {
10362
- // const rego = regos[i];
10363
- // if (menuItemId && rego.menuItemId !== menuItemId) {
10364
- // continue;
10365
- // }
10366
- // CesiumEntityStyler.Select({
10367
- // entity: rego.visual,
10368
- // viewer: this.viewer,
10369
- // requestRender: false
10370
- // });
10371
- // }
10372
- // }
10373
- // }
10374
- // }
10375
- // else {
10376
- // if (doSelect) {
10377
- // const regos = this.rego[id];
10378
- // if (regos) {
10379
- // for (let i = 0; i < regos.length; i++) {
10380
- // const rego = regos[i];
10381
- // if (menuItemId && rego.menuItemId !== menuItemId) {
10382
- // continue;
10383
- // }
10384
- // CesiumEntityStyler.Deselect({
10385
- // entity: rego.visual,
10386
- // viewer: this.viewer,
10387
- // requestRender: false
10388
- // });
10389
- // }
10390
- // }
10391
- // }
10392
- // }
10393
- // this.onUpdate?.Trigger({
10394
- // entityId: id,
10395
- // type: EVisualUpdateType.Update,
10396
- // selected: selected
10397
- // });
10398
- // }
10399
- // if (requestRender != false) {
10400
- // this.viewer.scene.requestRender();
10401
- // }
10402
- // }
10403
10324
  SetSelected(params) {
10404
- const { entityIds, selected, refreshIfSelected = true, requestRender, menuItemId } = params;
10405
- const BATCH_SIZE = 1000;
10406
- let index = 0;
10407
- const updatedEntitiesInfo = [];
10408
- const entitiesToSelect = [];
10409
- const entitiesToDeselect = [];
10410
- const updatedEntities = new Set();
10411
- const processBatch = () => {
10412
- const end = Math.min(index + BATCH_SIZE, entityIds.length);
10413
- for (let i = index; i < end; i++) {
10414
- const id = entityIds[i];
10415
- const state = this.GetState({ entityId: id, menuItemId });
10416
- const doSelect = refreshIfSelected || Boolean(state.selected) !== selected;
10417
- if (!doSelect)
10418
- continue;
10419
- this.setStateValues({ entityId: id, menuItemId, selected: selected ? true : null });
10420
- const regos = this.rego[id];
10421
- if (regos) {
10422
- for (const rego of regos) {
10423
- if (menuItemId && rego.menuItemId !== menuItemId)
10424
- continue;
10425
- if (selected) {
10426
- entitiesToSelect.push(rego.visual);
10427
- }
10428
- else {
10429
- entitiesToDeselect.push(rego.visual);
10325
+ var _a;
10326
+ let { entityIds, selected, refreshIfSelected, requestRender, menuItemId } = params;
10327
+ if (refreshIfSelected == null || refreshIfSelected === undefined) {
10328
+ refreshIfSelected = true;
10329
+ }
10330
+ for (let i = 0; i < entityIds.length; i++) {
10331
+ const id = entityIds[i];
10332
+ const state = this.GetState({
10333
+ entityId: id,
10334
+ menuItemId
10335
+ });
10336
+ // Checking if we need to refresh the selection.
10337
+ const doSelect = refreshIfSelected || (Boolean(state.selected) != selected);
10338
+ this.setStateValues({
10339
+ entityId: id,
10340
+ menuItemId: menuItemId,
10341
+ // Null means it will be deleted from the object.
10342
+ selected: selected ? true : null
10343
+ });
10344
+ if (selected) {
10345
+ if (doSelect) {
10346
+ const regos = this.rego[id];
10347
+ if (regos) {
10348
+ for (let i = 0; i < regos.length; i++) {
10349
+ const rego = regos[i];
10350
+ if (menuItemId && rego.menuItemId !== menuItemId) {
10351
+ continue;
10352
+ }
10353
+ CesiumEntityStyler.Select({
10354
+ entity: rego.visual,
10355
+ viewer: this.viewer,
10356
+ requestRender: false
10357
+ });
10430
10358
  }
10431
10359
  }
10432
10360
  }
10433
- if (!updatedEntities.has(id)) {
10434
- updatedEntities.add(id);
10435
- updatedEntitiesInfo.push({ entityId: id, type: EVisualUpdateType.Update, selected });
10436
- }
10437
- }
10438
- index = end;
10439
- if (index < entityIds.length) {
10440
- setTimeout(processBatch, 0);
10441
10361
  }
10442
10362
  else {
10443
- // All done, now apply styling
10444
- for (const entity of entitiesToSelect) {
10445
- CesiumEntityStyler.Select({ entity, viewer: this.viewer, requestRender: false });
10446
- }
10447
- for (const entity of entitiesToDeselect) {
10448
- CesiumEntityStyler.Deselect({ entity, viewer: this.viewer, requestRender: false });
10449
- }
10450
- if (requestRender !== false) {
10451
- this.viewer.scene.requestRender();
10363
+ if (doSelect) {
10364
+ const regos = this.rego[id];
10365
+ if (regos) {
10366
+ for (let i = 0; i < regos.length; i++) {
10367
+ const rego = regos[i];
10368
+ if (menuItemId && rego.menuItemId !== menuItemId) {
10369
+ continue;
10370
+ }
10371
+ CesiumEntityStyler.Deselect({
10372
+ entity: rego.visual,
10373
+ viewer: this.viewer,
10374
+ requestRender: false
10375
+ });
10376
+ }
10377
+ }
10452
10378
  }
10453
10379
  }
10454
- };
10455
- processBatch();
10380
+ (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({
10381
+ entityId: id,
10382
+ type: EVisualUpdateType.Update,
10383
+ selected: selected
10384
+ });
10385
+ }
10386
+ if (requestRender != false) {
10387
+ this.viewer.scene.requestRender();
10388
+ }
10456
10389
  }
10457
10390
  GetIsSelected(params) {
10458
10391
  const { entityId: id, menuItemId } = params;
@@ -10465,7 +10398,7 @@ var VisualsRegister;
10465
10398
  ClearSelected(params) {
10466
10399
  var _a;
10467
10400
  const cleared = [];
10468
- this.ForEachState((state, key) => {
10401
+ this.ForEachState((state) => {
10469
10402
  if (state.selected == null || state.selected === undefined) {
10470
10403
  return;
10471
10404
  }
@@ -10573,110 +10506,33 @@ var VisualsRegister;
10573
10506
  });
10574
10507
  return state.highlighted === true;
10575
10508
  }
10576
- // Public method called when hover changes the highlight set
10577
- // Instead of clearing all highlights first and then setting new ones,
10578
- // we directly compute the difference between currently highlighted
10579
- // and newly required highlight sets.
10580
- HoverHighlight(params) {
10581
- const { newEntities } = params;
10582
- const newSet = new Set(newEntities);
10583
- // If very large updates happen frequently, rely on debounce to prevent rapid firing
10584
- if (newEntities.length > 1000) {
10585
- this.applyHighlightChanges(newSet);
10586
- }
10587
- else {
10588
- // Smaller updates can be processed immediately (or still use debounce if desired)
10589
- this.updateHighlightedEntities(newSet);
10590
- }
10591
- }
10592
- // Retrieve all currently highlighted entities by scanning states
10593
- getCurrentlyHighlightedEntities() {
10594
- const highlighted = new Set();
10509
+ ClearHighlighted(params) {
10510
+ // Null all states.
10511
+ let entityIds = [];
10595
10512
  this.ForEachState((state) => {
10596
- // Use GetIsHighlighted or directly check state if available
10597
- // If GetIsHighlighted expects params, we must call it for each entityId
10598
- if (this.GetIsHighlighted({ entityId: state.entityId })) {
10599
- highlighted.add(state.entityId);
10513
+ if (state.highlighted) {
10514
+ delete state.highlighted;
10515
+ if (!entityIds.includes(state.entityId)) {
10516
+ entityIds.push(state.entityId);
10517
+ }
10600
10518
  }
10601
10519
  });
10602
- return highlighted;
10603
- }
10604
- // Update highlighted entities by computing differences and applying only necessary changes
10605
- updateHighlightedEntities(newSet) {
10606
- // Get the current highlight set by scanning states
10607
- const currentlyHighlighted = this.getCurrentlyHighlightedEntities();
10608
- // Determine what needs to be unhighlighted
10609
- const entitiesToUnhighlight = new Set();
10610
- for (const oldId of currentlyHighlighted) {
10611
- if (!newSet.has(oldId)) {
10612
- entitiesToUnhighlight.add(oldId);
10613
- }
10614
- }
10615
- // Determine what needs to be highlighted
10616
- const entitiesToHighlight = new Set();
10617
- for (const newId of newSet) {
10618
- if (!currentlyHighlighted.has(newId)) {
10619
- entitiesToHighlight.add(newId);
10620
- }
10621
- }
10622
- // If no changes needed, return early
10623
- if (entitiesToUnhighlight.size === 0 && entitiesToHighlight.size === 0) {
10624
- return;
10625
- }
10626
- // Apply visual changes in batches
10627
- this.applyUnhighlight(entitiesToUnhighlight);
10628
- this.applyHighlight(entitiesToHighlight);
10629
- // Request one render after all updates
10630
- this.viewer.scene.requestRender();
10631
- }
10632
- // Apply Unhighlight in batch
10633
- applyUnhighlight(entityIds) {
10634
- if (entityIds.size === 0)
10635
- return;
10636
- const unhighlightBatch = [];
10637
- for (const id of entityIds) {
10638
- const regos = this.rego[id];
10639
- if (!regos)
10640
- continue;
10641
- for (const rego of regos) {
10642
- unhighlightBatch.push(rego.visual);
10643
- }
10644
- }
10645
- for (const entity of unhighlightBatch) {
10646
- CesiumEntityStyler.Unhighlight({
10647
- entity,
10648
- viewer: this.viewer,
10649
- requestRender: false
10650
- });
10651
- }
10652
- }
10653
- // Apply Highlight in batch
10654
- applyHighlight(entityIds) {
10655
- if (entityIds.size === 0)
10656
- return;
10657
- const highlightBatch = [];
10658
- for (const id of entityIds) {
10520
+ // Revert needed visual changes.
10521
+ for (let i = 0; i < entityIds.length; i++) {
10522
+ const id = entityIds[i];
10659
10523
  const regos = this.rego[id];
10660
- if (!regos)
10661
- continue;
10662
- for (const rego of regos) {
10663
- highlightBatch.push(rego.visual);
10524
+ if (regos) {
10525
+ for (let i = 0; i < regos.length; i++) {
10526
+ const rego = regos[i];
10527
+ CesiumEntityStyler.Unhighlight({
10528
+ entity: rego.visual,
10529
+ viewer: this.viewer,
10530
+ requestRender: false
10531
+ });
10532
+ }
10664
10533
  }
10665
10534
  }
10666
- for (const entity of highlightBatch) {
10667
- CesiumEntityStyler.Highlight({
10668
- entity,
10669
- viewer: this.viewer,
10670
- requestRender: false
10671
- });
10672
- }
10673
- }
10674
- // Clear all highlighted entities
10675
- ClearHighlighted(params) {
10676
- // Get all currently highlighted entities from states
10677
- const currentlyHighlighted = this.getCurrentlyHighlightedEntities();
10678
- this.applyUnhighlight(currentlyHighlighted);
10679
- if ((params === null || params === void 0 ? void 0 : params.requestRender) !== false) {
10535
+ if ((params === null || params === void 0 ? void 0 : params.requestRender) != false) {
10680
10536
  this.viewer.scene.requestRender();
10681
10537
  }
10682
10538
  }
@@ -11178,7 +11034,7 @@ var VisualsRegister;
11178
11034
  }
11179
11035
  ClearOpacity(params) {
11180
11036
  const clearedIds = [];
11181
- this.ForEachState((state, key) => {
11037
+ this.ForEachState((state) => {
11182
11038
  if (!clearedIds.includes(state.entityId) && state.opacity != null) {
11183
11039
  this.queueUpdate({
11184
11040
  entityId: state.entityId,
@@ -28477,7 +28333,7 @@ class WidgetViewBar extends Widget.AWidget {
28477
28333
  }
28478
28334
  }
28479
28335
 
28480
- const VERSION = "4.9.1";
28336
+ const VERSION = "4.9.2";
28481
28337
 
28482
28338
  export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, 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 };
28483
28339
  //# sourceMappingURL=bruce-cesium.es5.js.map