bruce-cesium 3.2.4 → 3.2.6

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 { Cartes, ProjectViewTile, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, BruceEvent, EntityCoords, Api, EntitySource, MenuItem, EntityRelation, ProgramKey, ENVIRONMENT, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, Camera } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, SceneMode, JulianDate, Entity, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, NearFarScalar, Model, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, CesiumInspector, defined, EllipsoidGeodesic, sampleTerrainMostDetailed, Cesium3DTileset, Matrix4, Matrix3, IonResource, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, BoundingSphere, GeometryInstance, PolygonPipeline, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, Cesium3DTileset, CesiumInspector, Matrix4, Matrix3, IonResource, PolygonPipeline, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ColorMaterialProperty } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -692,7 +692,7 @@ var ViewUtils;
692
692
  })(ViewUtils || (ViewUtils = {}));
693
693
 
694
694
  /**
695
- * Returns if a given visual is alive and in the scene.
695
+ * Returns if a given visual can be styled by this utility.
696
696
  * @param viewer
697
697
  * @param visual
698
698
  * @returns
@@ -702,10 +702,10 @@ function isAlive(viewer, visual) {
702
702
  return false;
703
703
  }
704
704
  if (visual instanceof Entity) {
705
- return viewer.entities.contains(visual);
705
+ return true;
706
706
  }
707
707
  else if (visual instanceof Primitive) {
708
- return viewer.scene.primitives.contains(visual);
708
+ return true;
709
709
  }
710
710
  else if (visual instanceof Cesium3DTileFeature) {
711
711
  var cTileset = visual === null || visual === void 0 ? void 0 : visual.tileset;
@@ -719,133 +719,589 @@ function isAlive(viewer, visual) {
719
719
  }
720
720
  return false;
721
721
  }
722
- function traverseEntity(cEntity, arr, ignoreParent) {
723
- if (cEntity._parentEntity && !ignoreParent) {
724
- traverseEntity(cEntity._parentEntity, arr, false);
722
+ var _selectColor = Color.fromAlpha(Color.YELLOW, 0.5);
723
+ var _highlightColor = Color.fromCssColorString("#33b1ff").withAlpha(0.5);
724
+ var STORE_COLOR_PREFIX = "_storeColor_";
725
+ function getStoreKey(key) {
726
+ return STORE_COLOR_PREFIX + key;
727
+ }
728
+ var STORE_KEY_STATE_PREFIX = "_storeKeyState_";
729
+ function getStoreStateKey(key) {
730
+ return STORE_KEY_STATE_PREFIX + key;
731
+ }
732
+ var LAST_APPLIED_OPACITY_KEY = "_lastAppliedOpacityKey";
733
+ /**
734
+ * Returns a color property from a graphic.
735
+ * This will turn materials properties into colors before returning them.
736
+ * @param viewer
737
+ * @param prop
738
+ * @returns
739
+ */
740
+ function getCesiumColorValue(viewer, prop) {
741
+ if (!prop) {
742
+ return Color.WHITE;
725
743
  }
726
- if (cEntity._siblingGraphics) {
727
- for (var i = 0; i < cEntity._siblingGraphics.length; i++) {
728
- var sibling = cEntity._siblingGraphics[i];
729
- traverseEntity(sibling, arr, true);
730
- }
744
+ if (prop.getValue) {
745
+ prop = prop.getValue(viewer.scene.lastRenderTime);
731
746
  }
732
- arr.push(cEntity);
747
+ if (prop instanceof Color) {
748
+ return prop;
749
+ }
750
+ var tmp = prop === null || prop === void 0 ? void 0 : prop.color;
751
+ if (tmp === null || tmp === void 0 ? void 0 : tmp.getValue) {
752
+ tmp = tmp.getValue(viewer.scene.lastRenderTime);
753
+ }
754
+ return tmp ? tmp : Color.WHITE;
733
755
  }
734
- var ORG_OPACITY_KEY = "_org_opacity_";
735
- var NEW_OPACITY_KEY = "_new_opacity_";
736
- function getColor(viewer, material) {
737
- var _a, _b;
738
- function findColor() {
739
- if (!material) {
740
- return Color.WHITE;
756
+ /**
757
+ * Returns the current color of a graphic.
758
+ * @param viewer
759
+ * @param graphic
760
+ * @returns
761
+ */
762
+ function calculateCurColor(viewer, graphic) {
763
+ var _a, _b, _c, _d, _e, _f, _g, _h;
764
+ var color;
765
+ if (graphic instanceof Cesium3DTileFeature) {
766
+ color = (_a = graphic.color) !== null && _a !== void 0 ? _a : new Color();
767
+ }
768
+ else if (graphic instanceof ModelGraphics) {
769
+ color = (_b = getCesiumColorValue(viewer, graphic.color)) !== null && _b !== void 0 ? _b : new Color();
770
+ }
771
+ else if (graphic instanceof PolygonGraphics) {
772
+ color = (_c = getCesiumColorValue(viewer, graphic.material)) !== null && _c !== void 0 ? _c : new Color();
773
+ }
774
+ else if (graphic instanceof PolylineGraphics) {
775
+ color = (_d = getCesiumColorValue(viewer, graphic.material)) !== null && _d !== void 0 ? _d : new Color();
776
+ }
777
+ else if (graphic instanceof CorridorGraphics) {
778
+ color = (_e = getCesiumColorValue(viewer, graphic.material)) !== null && _e !== void 0 ? _e : new Color();
779
+ }
780
+ else if (graphic instanceof PointGraphics) {
781
+ color = (_f = getCesiumColorValue(viewer, graphic.color)) !== null && _f !== void 0 ? _f : new Color();
782
+ }
783
+ else if (graphic instanceof BillboardGraphics) {
784
+ color = (_g = getCesiumColorValue(viewer, graphic.color)) !== null && _g !== void 0 ? _g : new Color();
785
+ }
786
+ else if (graphic instanceof EllipseGraphics) {
787
+ color = (_h = getCesiumColorValue(viewer, graphic.material)) !== null && _h !== void 0 ? _h : new Color();
788
+ }
789
+ return color;
790
+ }
791
+ /**
792
+ * Stores a copy of the color against a key within the graphic.
793
+ * This lets us refer to it later if we need to change to it.
794
+ * @param viewer
795
+ * @param key
796
+ * @param color
797
+ * @param graphic
798
+ */
799
+ function storeColor(viewer, key, color, graphic) {
800
+ graphic[getStoreKey(key)] = (color === null || color === void 0 ? void 0 : color.clone) ? color.clone() : color;
801
+ }
802
+ /**
803
+ * Returns a stored color for a graphic.
804
+ * If no color is stored, it will calculate and store the default color.
805
+ * @param viewer
806
+ * @param key
807
+ * @param graphic
808
+ * @returns
809
+ */
810
+ function getColor(viewer, key, graphic) {
811
+ var color = graphic[getStoreKey(key)];
812
+ // If no color is stored for the default color, we'll calculate and store it.
813
+ if (!color) {
814
+ if (key == "default") {
815
+ color = calculateCurColor(viewer, graphic);
741
816
  }
742
- if (material.getValue) {
743
- material = material.getValue(viewer.scene.lastRenderTime);
817
+ else if (key == "select") {
818
+ color = _selectColor;
744
819
  }
745
- if (material instanceof Color) {
746
- return material;
820
+ else if (key == "highlight") {
821
+ color = _highlightColor;
747
822
  }
748
- var tmp = material === null || material === void 0 ? void 0 : material.color;
749
- if (tmp === null || tmp === void 0 ? void 0 : tmp.getValue) {
750
- tmp = tmp.getValue(viewer.scene.lastRenderTime);
823
+ if (color) {
824
+ storeColor(viewer, key, color, graphic);
751
825
  }
752
- return tmp ? tmp : Color.WHITE;
753
- }
754
- return (_b = (_a = findColor()) === null || _a === void 0 ? void 0 : _a.clone) === null || _b === void 0 ? void 0 : _b.call(_a);
755
- }
756
- function applyOpacityToColor(viewer, opacity, material) {
757
- var color = getColor(viewer, material);
758
- if (color) {
759
- color.alpha = opacity;
760
826
  }
761
827
  return color;
762
828
  }
763
- function applyOpacityToGraphic(viewer, entity, graphicKey, materialKey, opacity) {
764
- var color = applyOpacityToColor(viewer, opacity, entity[graphicKey][materialKey]);
765
- if (color) {
766
- entity[graphicKey][materialKey] = materialKey == "material" ? new ColorMaterialProperty(color) : color;
829
+ /**
830
+ * Applies opacity to current color.
831
+ * @param viewer
832
+ * @param opacity
833
+ * @param graphic
834
+ */
835
+ function applyOpacity(viewer, opacity, graphic) {
836
+ refreshColor(viewer, graphic, opacity);
837
+ }
838
+ /**
839
+ * Applies a color to a graphic based on the current key states.
840
+ * Eg: if the graphic is selected, it will apply the selected color.
841
+ * @param viewer
842
+ * @param graphic
843
+ * @param opacity
844
+ */
845
+ function refreshColor(viewer, graphic, opacity) {
846
+ var _a;
847
+ // Calculate what color key we should apply.
848
+ var key = "default";
849
+ if (getKeyState(graphic, "select")) {
850
+ key = "select";
851
+ }
852
+ else if (getKeyState(graphic, "highlight")) {
853
+ key = "highlight";
854
+ }
855
+ // This ensures that the default color is always stored prior to applying a new color.
856
+ if (key != "default") {
857
+ getColor(viewer, "default", graphic);
858
+ }
859
+ var color = (_a = getColor(viewer, key, graphic)) !== null && _a !== void 0 ? _a : Color.WHITE;
860
+ // If we're highlighting and it's selected, don't change the color.
861
+ if (key != "highlight" || getKeyState(graphic, "select") == false) {
862
+ color = color.clone();
863
+ // Multiply opacity if one is set.
864
+ if (opacity != null) {
865
+ // Not sure if this will ever be needed.
866
+ // The original code had a null-check but I suspect it was because it may not been a Cesium color instance.
867
+ if (color.alpha == null) {
868
+ color.alpha = 1;
869
+ }
870
+ color.alpha *= opacity;
871
+ // Cesium ignores pure white so if we want opacity and it's white, we'll set a tiny blue value.
872
+ if (color.equals(Color.WHITE)) {
873
+ color.blue = 0.0001;
874
+ }
875
+ }
876
+ if (graphic instanceof Cesium3DTileFeature) {
877
+ graphic.color = color;
878
+ }
879
+ else if (graphic instanceof ModelGraphics) {
880
+ graphic.color = color;
881
+ }
882
+ else if (graphic instanceof PolygonGraphics) {
883
+ graphic.material = new ColorMaterialProperty(color);
884
+ }
885
+ else if (graphic instanceof PolylineGraphics) {
886
+ graphic.material = new ColorMaterialProperty(color);
887
+ }
888
+ else if (graphic instanceof CorridorGraphics) {
889
+ graphic.material = new ColorMaterialProperty(color);
890
+ }
891
+ else if (graphic instanceof PointGraphics) {
892
+ graphic.color = color;
893
+ }
894
+ else if (graphic instanceof BillboardGraphics) {
895
+ graphic.color = color;
896
+ }
897
+ else if (graphic instanceof EllipseGraphics) {
898
+ graphic.material = new ColorMaterialProperty(color);
899
+ }
900
+ graphic[LAST_APPLIED_OPACITY_KEY] = opacity;
901
+ }
902
+ // Record the state of the current key.
903
+ graphic[getStoreStateKey(key)] = true;
904
+ // This means other keys are false.
905
+ if (key == "default") {
906
+ graphic[getStoreStateKey("select")] = false;
907
+ graphic[getStoreStateKey("highlight")] = false;
908
+ }
909
+ // This means 'default' is false.
910
+ else {
911
+ graphic[getStoreStateKey("default")] = false;
767
912
  }
768
913
  }
769
- function revertAppliedEntityOpacity(viewer, entity) {
770
- if (!isAlive(viewer, entity)) {
771
- return;
914
+ /**
915
+ * Returns the last applied opacity for a graphic.
916
+ * This is used to ensure that we don't lose the opacity when we change color.
917
+ * @param graphic
918
+ * @returns
919
+ */
920
+ function getAppliedOpacity(graphic) {
921
+ return isNaN(graphic[LAST_APPLIED_OPACITY_KEY]) ? null : graphic[LAST_APPLIED_OPACITY_KEY];
922
+ }
923
+ /**
924
+ * Returns the state of a key for a graphic.
925
+ * Eg: if the graphic is selected, this will return true for the select key.
926
+ * A graphic may have multiple active states, but only one color can be applied at a time.
927
+ * @param graphic
928
+ * @param key
929
+ * @returns
930
+ */
931
+ function getKeyState(graphic, key) {
932
+ var value = graphic[getStoreStateKey(key)];
933
+ return value == null ? false : value;
934
+ }
935
+ /**
936
+ * Internal utility to help with managing Cesium Entity styling.
937
+ * Do not expose this to public as it will likely be killed and replaced with something that do animated changes.
938
+ */
939
+ var CesiumEntityStyler;
940
+ (function (CesiumEntityStyler) {
941
+ function UpdateColorSetting(key, color) {
942
+ if (key == "select") {
943
+ _selectColor = color.clone();
944
+ }
945
+ else if (key == "highlight") {
946
+ _highlightColor = color.clone();
947
+ }
948
+ }
949
+ CesiumEntityStyler.UpdateColorSetting = UpdateColorSetting;
950
+ /**
951
+ * Updates the opacity of the graphic.
952
+ * This will multiply against the current colour's opacity before applying.
953
+ * @param params
954
+ * @returns
955
+ */
956
+ function SetOpacity(params) {
957
+ var viewer = params.viewer, entity = params.entity, opacity = params.opacity, requestRender = params.requestRender;
958
+ if (!entity) {
959
+ return;
960
+ }
961
+ var parts = EntityUtils.GatherEntity({
962
+ entity: entity
963
+ });
964
+ for (var i = 0; i < parts.length; i++) {
965
+ var part = parts[i];
966
+ if (!isAlive(viewer, part)) {
967
+ continue;
968
+ }
969
+ if (part instanceof Cesium3DTileFeature) {
970
+ applyOpacity(viewer, opacity, part);
971
+ }
972
+ else if (part instanceof Entity) {
973
+ if (part.billboard) {
974
+ applyOpacity(viewer, opacity, part.billboard);
975
+ }
976
+ if (part.model) {
977
+ applyOpacity(viewer, opacity, part.model);
978
+ }
979
+ if (part.polyline) {
980
+ applyOpacity(viewer, opacity, part.polyline);
981
+ }
982
+ if (part.polygon) {
983
+ applyOpacity(viewer, opacity, part.polygon);
984
+ }
985
+ if (part.corridor) {
986
+ applyOpacity(viewer, opacity, part.corridor);
987
+ }
988
+ if (part.point) {
989
+ applyOpacity(viewer, opacity, part.point);
990
+ }
991
+ if (part.ellipse) {
992
+ applyOpacity(viewer, opacity, part.ellipse);
993
+ }
994
+ }
995
+ }
996
+ if (requestRender != false) {
997
+ viewer.scene.requestRender();
998
+ }
772
999
  }
773
- entity[NEW_OPACITY_KEY] = null;
774
- if (entity instanceof Entity) {
775
- var processKey = function (graphicKey, materialKey) {
776
- if (materialKey === void 0) { materialKey = "material"; }
777
- if (entity[graphicKey]) {
778
- var orgOpacity = entity[graphicKey][ORG_OPACITY_KEY];
779
- if (orgOpacity != null) {
780
- applyOpacityToGraphic(viewer, entity, graphicKey, materialKey, orgOpacity);
1000
+ CesiumEntityStyler.SetOpacity = SetOpacity;
1001
+ /**
1002
+ * Returns the opacity of a graphic.
1003
+ * This will return the last applied opacity. If no opacity has been applied, it will return null.
1004
+ * @param params
1005
+ */
1006
+ function GetOpacity(params) {
1007
+ var entity = params.entity;
1008
+ if (!entity) {
1009
+ return null;
1010
+ }
1011
+ var parts = EntityUtils.GatherEntity({
1012
+ entity: entity
1013
+ });
1014
+ for (var i = 0; i < parts.length; i++) {
1015
+ var part = parts[i];
1016
+ if (part instanceof Cesium3DTileFeature) {
1017
+ return getAppliedOpacity(part);
1018
+ }
1019
+ else if (part instanceof Entity) {
1020
+ if (part.billboard) {
1021
+ return getAppliedOpacity(part.billboard);
1022
+ }
1023
+ if (part.model) {
1024
+ return getAppliedOpacity(part.model);
1025
+ }
1026
+ if (part.polyline) {
1027
+ return getAppliedOpacity(part.polyline);
1028
+ }
1029
+ if (part.polygon) {
1030
+ return getAppliedOpacity(part.polygon);
1031
+ }
1032
+ if (part.corridor) {
1033
+ return getAppliedOpacity(part.corridor);
1034
+ }
1035
+ if (part.point) {
1036
+ return getAppliedOpacity(part.point);
1037
+ }
1038
+ if (part.ellipse) {
1039
+ return getAppliedOpacity(part.ellipse);
781
1040
  }
782
- entity[graphicKey][ORG_OPACITY_KEY] = null;
783
1041
  }
784
- };
785
- processKey("polygon");
786
- processKey("polyline");
787
- processKey("point", "color");
788
- processKey("ellipse");
789
- processKey("model", "color");
790
- processKey("corridor");
791
- processKey("billboard", "color");
792
- }
793
- else if (entity instanceof Cesium3DTileFeature) {
794
- var orgOpacity = entity[ORG_OPACITY_KEY];
795
- if (orgOpacity != null) {
796
- var color = entity.color ? entity.color.clone() : new Color();
797
- color.alpha = orgOpacity;
798
- entity.color = color;
799
- }
800
- entity[ORG_OPACITY_KEY] = null;
1042
+ }
1043
+ return null;
801
1044
  }
802
- }
803
- function applyOpacityToEntity(viewer, opacity, entity) {
804
- if (!isAlive(viewer, entity)) {
805
- return;
1045
+ CesiumEntityStyler.GetOpacity = GetOpacity;
1046
+ /**
1047
+ * Clears the opacity from a graphic and refreshes it.
1048
+ * Eg: if it is selected it will change the color to the selected color with the original selection opacity.
1049
+ * @param params
1050
+ */
1051
+ function ClearOpacity(params) {
1052
+ SetOpacity({
1053
+ viewer: params.viewer,
1054
+ entity: params.entity,
1055
+ opacity: null,
1056
+ requestRender: params.requestRender
1057
+ });
806
1058
  }
807
- entity[NEW_OPACITY_KEY] = opacity;
808
- if (entity instanceof Entity) {
809
- var processKey = function (graphicKey, materialKey) {
810
- var _a;
811
- if (materialKey === void 0) { materialKey = "material"; }
812
- if (entity[graphicKey]) {
813
- var orgOpacity = entity[graphicKey][ORG_OPACITY_KEY];
814
- if (orgOpacity == null) {
815
- entity[graphicKey][ORG_OPACITY_KEY] = (_a = getColor(viewer, entity[graphicKey][materialKey])) === null || _a === void 0 ? void 0 : _a.alpha;
1059
+ CesiumEntityStyler.ClearOpacity = ClearOpacity;
1060
+ /**
1061
+ * Selects a graphic and refreshes it.
1062
+ * @param params
1063
+ */
1064
+ function Select(params) {
1065
+ var viewer = params.viewer, entity = params.entity, requestRender = params.requestRender;
1066
+ if (!entity) {
1067
+ return;
1068
+ }
1069
+ var parts = EntityUtils.GatherEntity({
1070
+ entity: entity
1071
+ });
1072
+ for (var i = 0; i < parts.length; i++) {
1073
+ var part = parts[i];
1074
+ if (!isAlive(viewer, part)) {
1075
+ continue;
1076
+ }
1077
+ if (part instanceof Cesium3DTileFeature) {
1078
+ var opacity = getAppliedOpacity(part);
1079
+ part[getStoreStateKey("select")] = true;
1080
+ refreshColor(viewer, part, opacity);
1081
+ }
1082
+ else if (part instanceof Entity) {
1083
+ if (part.billboard) {
1084
+ part.billboard[getStoreStateKey("select")] = true;
1085
+ refreshColor(viewer, part.billboard, getAppliedOpacity(part.billboard));
816
1086
  }
817
- if (orgOpacity == null) {
818
- orgOpacity = 1;
1087
+ if (part.model) {
1088
+ part.model[getStoreStateKey("select")] = true;
1089
+ refreshColor(viewer, part.model, getAppliedOpacity(part.model));
1090
+ }
1091
+ if (part.polyline) {
1092
+ part.polyline[getStoreStateKey("select")] = true;
1093
+ refreshColor(viewer, part.polyline, getAppliedOpacity(part.polyline));
1094
+ }
1095
+ if (part.polygon) {
1096
+ part.polygon[getStoreStateKey("select")] = true;
1097
+ refreshColor(viewer, part.polygon, getAppliedOpacity(part.polygon));
1098
+ }
1099
+ if (part.corridor) {
1100
+ part.corridor[getStoreStateKey("select")] = true;
1101
+ refreshColor(viewer, part.corridor, getAppliedOpacity(part.corridor));
1102
+ }
1103
+ if (part.point) {
1104
+ part.point[getStoreStateKey("select")] = true;
1105
+ refreshColor(viewer, part.point, getAppliedOpacity(part.point));
1106
+ }
1107
+ if (part.ellipse) {
1108
+ part.ellipse[getStoreStateKey("select")] = true;
1109
+ refreshColor(viewer, part.ellipse, getAppliedOpacity(part.ellipse));
819
1110
  }
820
- applyOpacityToGraphic(viewer, entity, graphicKey, materialKey, opacity * orgOpacity);
821
1111
  }
822
- };
823
- processKey("polygon");
824
- processKey("polyline");
825
- processKey("point", "color");
826
- processKey("ellipse");
827
- processKey("model", "color");
828
- processKey("corridor");
829
- processKey("billboard", "color");
1112
+ }
1113
+ if (requestRender != false) {
1114
+ viewer.scene.requestRender();
1115
+ }
830
1116
  }
831
- else if (entity instanceof Cesium3DTileFeature) {
832
- var orgOpacity = entity[ORG_OPACITY_KEY];
833
- if (orgOpacity == null) {
834
- entity[ORG_OPACITY_KEY] = entity.color ? entity.color.alpha : 1;
1117
+ CesiumEntityStyler.Select = Select;
1118
+ /**
1119
+ * Deselects a graphic and refreshes it.
1120
+ * If the graphic is highlighted, it will change the color to the highlighted color.
1121
+ * @param params
1122
+ */
1123
+ function Deselect(params) {
1124
+ var viewer = params.viewer, entity = params.entity, requestRender = params.requestRender;
1125
+ if (!entity) {
1126
+ return;
835
1127
  }
836
- if (!orgOpacity) {
837
- orgOpacity = 1;
1128
+ var parts = EntityUtils.GatherEntity({
1129
+ entity: entity
1130
+ });
1131
+ for (var i = 0; i < parts.length; i++) {
1132
+ var part = parts[i];
1133
+ if (!isAlive(viewer, part)) {
1134
+ continue;
1135
+ }
1136
+ if (part instanceof Cesium3DTileFeature) {
1137
+ var opacity = getAppliedOpacity(part);
1138
+ part[getStoreStateKey("select")] = false;
1139
+ refreshColor(viewer, part, opacity);
1140
+ }
1141
+ else if (part instanceof Entity) {
1142
+ if (part.billboard) {
1143
+ part.billboard[getStoreStateKey("select")] = false;
1144
+ refreshColor(viewer, part.billboard, getAppliedOpacity(part.billboard));
1145
+ }
1146
+ if (part.model) {
1147
+ part.model[getStoreStateKey("select")] = false;
1148
+ refreshColor(viewer, part.model, getAppliedOpacity(part.model));
1149
+ }
1150
+ if (part.polyline) {
1151
+ part.polyline[getStoreStateKey("select")] = false;
1152
+ refreshColor(viewer, part.polyline, getAppliedOpacity(part.polyline));
1153
+ }
1154
+ if (part.polygon) {
1155
+ part.polygon[getStoreStateKey("select")] = false;
1156
+ refreshColor(viewer, part.polygon, getAppliedOpacity(part.polygon));
1157
+ }
1158
+ if (part.corridor) {
1159
+ part.corridor[getStoreStateKey("select")] = false;
1160
+ refreshColor(viewer, part.corridor, getAppliedOpacity(part.corridor));
1161
+ }
1162
+ if (part.point) {
1163
+ part.point[getStoreStateKey("select")] = false;
1164
+ refreshColor(viewer, part.point, getAppliedOpacity(part.point));
1165
+ }
1166
+ if (part.ellipse) {
1167
+ part.ellipse[getStoreStateKey("select")] = false;
1168
+ refreshColor(viewer, part.ellipse, getAppliedOpacity(part.ellipse));
1169
+ }
1170
+ }
838
1171
  }
839
- var color = entity.color ? entity.color.clone() : new Color();
840
- color.alpha = opacity * orgOpacity;
841
- if (color.equals(Color.WHITE)) {
842
- color.blue = 0.0001;
1172
+ if (requestRender != false) {
1173
+ viewer.scene.requestRender();
843
1174
  }
844
- entity.color = color;
845
1175
  }
846
- }
847
- function findOpacity(entity) {
848
- return entity ? entity[NEW_OPACITY_KEY] : null;
1176
+ CesiumEntityStyler.Deselect = Deselect;
1177
+ /**
1178
+ * Highlights a graphic and refreshes it.
1179
+ * If the graphic is selected, it will not change the color.
1180
+ * @param params
1181
+ */
1182
+ function Highlight(params) {
1183
+ var viewer = params.viewer, entity = params.entity, requestRender = params.requestRender;
1184
+ if (!entity) {
1185
+ return;
1186
+ }
1187
+ var parts = EntityUtils.GatherEntity({
1188
+ entity: entity
1189
+ });
1190
+ for (var i = 0; i < parts.length; i++) {
1191
+ var part = parts[i];
1192
+ if (!isAlive(viewer, part)) {
1193
+ continue;
1194
+ }
1195
+ if (part instanceof Cesium3DTileFeature) {
1196
+ part[getStoreStateKey("highlight")] = true;
1197
+ refreshColor(viewer, part, getAppliedOpacity(part));
1198
+ }
1199
+ else if (part instanceof Entity) {
1200
+ if (part.billboard) {
1201
+ part.billboard[getStoreStateKey("highlight")] = true;
1202
+ refreshColor(viewer, part.billboard, getAppliedOpacity(part.billboard));
1203
+ }
1204
+ if (part.model) {
1205
+ part.model[getStoreStateKey("highlight")] = true;
1206
+ refreshColor(viewer, part.model, getAppliedOpacity(part.model));
1207
+ }
1208
+ if (part.polyline) {
1209
+ part.polyline[getStoreStateKey("highlight")] = true;
1210
+ refreshColor(viewer, part.polyline, getAppliedOpacity(part.polyline));
1211
+ }
1212
+ if (part.polygon) {
1213
+ part.polygon[getStoreStateKey("highlight")] = true;
1214
+ refreshColor(viewer, part.polygon, getAppliedOpacity(part.polygon));
1215
+ }
1216
+ if (part.corridor) {
1217
+ part.corridor[getStoreStateKey("highlight")] = true;
1218
+ refreshColor(viewer, part.corridor, getAppliedOpacity(part.corridor));
1219
+ }
1220
+ if (part.point) {
1221
+ part.point[getStoreStateKey("highlight")] = true;
1222
+ refreshColor(viewer, part.point, getAppliedOpacity(part.point));
1223
+ }
1224
+ if (part.ellipse) {
1225
+ part.ellipse[getStoreStateKey("highlight")] = true;
1226
+ refreshColor(viewer, part.ellipse, getAppliedOpacity(part.ellipse));
1227
+ }
1228
+ }
1229
+ }
1230
+ if (requestRender != false) {
1231
+ viewer.scene.requestRender();
1232
+ }
1233
+ }
1234
+ CesiumEntityStyler.Highlight = Highlight;
1235
+ /**
1236
+ * Removes the highlight from a graphic and refreshes it.
1237
+ * @param params
1238
+ */
1239
+ function Unhighlight(params) {
1240
+ var viewer = params.viewer, entity = params.entity, requestRender = params.requestRender;
1241
+ if (!entity) {
1242
+ return;
1243
+ }
1244
+ var parts = EntityUtils.GatherEntity({
1245
+ entity: entity
1246
+ });
1247
+ for (var i = 0; i < parts.length; i++) {
1248
+ var part = parts[i];
1249
+ if (!isAlive(viewer, part)) {
1250
+ continue;
1251
+ }
1252
+ if (part instanceof Cesium3DTileFeature) {
1253
+ part[getStoreStateKey("highlight")] = false;
1254
+ refreshColor(viewer, part, getAppliedOpacity(part));
1255
+ }
1256
+ else if (part instanceof Entity) {
1257
+ if (part.billboard) {
1258
+ part.billboard[getStoreStateKey("highlight")] = false;
1259
+ refreshColor(viewer, part.billboard, getAppliedOpacity(part.billboard));
1260
+ }
1261
+ if (part.model) {
1262
+ part.model[getStoreStateKey("highlight")] = false;
1263
+ refreshColor(viewer, part.model, getAppliedOpacity(part.model));
1264
+ }
1265
+ if (part.polyline) {
1266
+ part.polyline[getStoreStateKey("highlight")] = false;
1267
+ refreshColor(viewer, part.polyline, getAppliedOpacity(part.polyline));
1268
+ }
1269
+ if (part.polygon) {
1270
+ part.polygon[getStoreStateKey("highlight")] = false;
1271
+ refreshColor(viewer, part.polygon, getAppliedOpacity(part.polygon));
1272
+ }
1273
+ if (part.corridor) {
1274
+ part.corridor[getStoreStateKey("highlight")] = false;
1275
+ refreshColor(viewer, part.corridor, getAppliedOpacity(part.corridor));
1276
+ }
1277
+ if (part.point) {
1278
+ part.point[getStoreStateKey("highlight")] = false;
1279
+ refreshColor(viewer, part.point, getAppliedOpacity(part.point));
1280
+ }
1281
+ if (part.ellipse) {
1282
+ part.ellipse[getStoreStateKey("highlight")] = false;
1283
+ refreshColor(viewer, part.ellipse, getAppliedOpacity(part.ellipse));
1284
+ }
1285
+ }
1286
+ }
1287
+ if (requestRender != false) {
1288
+ viewer.scene.requestRender();
1289
+ }
1290
+ }
1291
+ CesiumEntityStyler.Unhighlight = Unhighlight;
1292
+ })(CesiumEntityStyler || (CesiumEntityStyler = {}));
1293
+
1294
+ function traverseEntity(cEntity, arr, ignoreParent) {
1295
+ if (cEntity._parentEntity && !ignoreParent) {
1296
+ traverseEntity(cEntity._parentEntity, arr, false);
1297
+ }
1298
+ if (cEntity._siblingGraphics) {
1299
+ for (var i = 0; i < cEntity._siblingGraphics.length; i++) {
1300
+ var sibling = cEntity._siblingGraphics[i];
1301
+ traverseEntity(sibling, arr, true);
1302
+ }
1303
+ }
1304
+ arr.push(cEntity);
849
1305
  }
850
1306
  function GetValue(viewer, obj) {
851
1307
  if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
@@ -1808,10 +2264,12 @@ var EntityUtils;
1808
2264
  */
1809
2265
  function SetOpacity(params) {
1810
2266
  var viewer = params.viewer, entity = params.entity, opacity = params.opacity, requestRender = params.requestRender;
1811
- applyOpacityToEntity(viewer, opacity, entity);
1812
- if (requestRender != false) {
1813
- viewer.scene.requestRender();
1814
- }
2267
+ CesiumEntityStyler.SetOpacity({
2268
+ entity: entity,
2269
+ opacity: opacity,
2270
+ viewer: viewer,
2271
+ requestRender: requestRender
2272
+ });
1815
2273
  }
1816
2274
  EntityUtils.SetOpacity = SetOpacity;
1817
2275
  /**
@@ -1822,10 +2280,11 @@ var EntityUtils;
1822
2280
  */
1823
2281
  function RevertOpacity(params) {
1824
2282
  var viewer = params.viewer, entity = params.entity, requestRender = params.requestRender;
1825
- revertAppliedEntityOpacity(viewer, entity);
1826
- if (requestRender != false) {
1827
- viewer.scene.requestRender();
1828
- }
2283
+ CesiumEntityStyler.ClearOpacity({
2284
+ entity: entity,
2285
+ viewer: viewer,
2286
+ requestRender: requestRender
2287
+ });
1829
2288
  }
1830
2289
  EntityUtils.RevertOpacity = RevertOpacity;
1831
2290
  /**
@@ -1837,7 +2296,9 @@ var EntityUtils;
1837
2296
  */
1838
2297
  function GetOpacity(params) {
1839
2298
  var entity = params.entity;
1840
- return findOpacity(entity);
2299
+ return CesiumEntityStyler.GetOpacity({
2300
+ entity: entity
2301
+ });
1841
2302
  }
1842
2303
  EntityUtils.GetOpacity = GetOpacity;
1843
2304
  })(EntityUtils || (EntityUtils = {}));
@@ -2466,8 +2927,13 @@ function runCullChecker(register) {
2466
2927
  var parts = EntityUtils.GatherEntity({
2467
2928
  entity: rego.visual
2468
2929
  });
2930
+ var isolatedIds = register.GetIsolated();
2931
+ var hiddenIds = register.GetHidden();
2469
2932
  for (var i_1 = 0; i_1 < parts.length; i_1++) {
2470
2933
  var part = parts[i_1];
2934
+ if (!(part instanceof Entity)) {
2935
+ continue;
2936
+ }
2471
2937
  var shouldCull = shouldCullEntity(viewer, part);
2472
2938
  if (shouldCull) {
2473
2939
  part[VisualRegisterCuller.VISUAL_CULL_KEY] = true;
@@ -2477,7 +2943,11 @@ function runCullChecker(register) {
2477
2943
  }
2478
2944
  else {
2479
2945
  delete part[VisualRegisterCuller.VISUAL_CULL_KEY];
2480
- if (!rego.overrideShow && rego.best && !viewer.entities.contains(part)) {
2946
+ if (rego.overrideShow != false &&
2947
+ rego.best &&
2948
+ !viewer.entities.contains(part) &&
2949
+ !hiddenIds.includes(entityId) &&
2950
+ (isolatedIds.length <= 0 || isolatedIds.includes(entityId))) {
2481
2951
  viewer.entities.add(part);
2482
2952
  }
2483
2953
  }
@@ -5642,137 +6112,6 @@ function unmarkEntity(visual, ignoreParent) {
5642
6112
  }
5643
6113
  }
5644
6114
  }
5645
- var ORG_COLOR_KEY = "_org_color_";
5646
- function select(viewer, visual, color, reqRender) {
5647
- var _a;
5648
- if (!color) {
5649
- color = Color.fromAlpha(Color.YELLOW, 0.5);
5650
- }
5651
- if (visual instanceof Entity) {
5652
- if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
5653
- return;
5654
- }
5655
- var entities = EntityUtils.GatherEntity({
5656
- entity: visual
5657
- });
5658
- var keyMapping = {
5659
- "point": "color",
5660
- "polygon": "material",
5661
- "polyline": "material",
5662
- "model": "color",
5663
- "billboard": "color",
5664
- "corridor": "material",
5665
- "ellipse": "material"
5666
- };
5667
- var _loop_1 = function (i) {
5668
- var entity = entities[i];
5669
- var processGraphic = function (graphicKey, materialKey) {
5670
- if (entity[graphicKey]) {
5671
- if (entity[graphicKey][ORG_COLOR_KEY] == null) {
5672
- var orgColor = entity[graphicKey][materialKey];
5673
- if (!orgColor) {
5674
- orgColor = Color.WHITE;
5675
- }
5676
- entity[graphicKey][ORG_COLOR_KEY] = orgColor.clone ? orgColor.clone() : orgColor;
5677
- }
5678
- entity[graphicKey][materialKey] = color.clone();
5679
- }
5680
- };
5681
- for (var key in keyMapping) {
5682
- var map = keyMapping[key];
5683
- processGraphic(key, map);
5684
- }
5685
- };
5686
- for (var i = 0; i < entities.length; i++) {
5687
- _loop_1(i);
5688
- }
5689
- }
5690
- if (visual instanceof Primitive) ;
5691
- else if (visual instanceof Cesium3DTileFeature) {
5692
- if (!isAlive$1(viewer, visual)) {
5693
- return;
5694
- }
5695
- var orgColor = visual[ORG_COLOR_KEY];
5696
- if (orgColor == null) {
5697
- orgColor = visual.color;
5698
- visual[ORG_COLOR_KEY] = (_a = orgColor === null || orgColor === void 0 ? void 0 : orgColor.clone) === null || _a === void 0 ? void 0 : _a.call(orgColor);
5699
- }
5700
- visual.color = color.clone();
5701
- }
5702
- var opacity = EntityUtils.GetOpacity({
5703
- entity: visual
5704
- });
5705
- if (opacity != null) {
5706
- EntityUtils.SetOpacity({
5707
- viewer: viewer,
5708
- entity: visual,
5709
- opacity: opacity,
5710
- requestRender: false
5711
- });
5712
- }
5713
- if (reqRender != false) {
5714
- viewer.scene.requestRender();
5715
- }
5716
- }
5717
- function deselect(viewer, visual, reqRender) {
5718
- if (visual instanceof Entity) {
5719
- if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
5720
- return;
5721
- }
5722
- var entities = EntityUtils.GatherEntity({
5723
- entity: visual
5724
- });
5725
- var keyMapping = {
5726
- "point": "color",
5727
- "polygon": "material",
5728
- "polyline": "material",
5729
- "model": "color",
5730
- "billboard": "color",
5731
- "corridor": "material",
5732
- "ellipse": "material"
5733
- };
5734
- var _loop_2 = function (i) {
5735
- var entity = entities[i];
5736
- var processGraphic = function (graphicKey, materialKey) {
5737
- var _a;
5738
- if ((_a = entity[graphicKey]) === null || _a === void 0 ? void 0 : _a[ORG_COLOR_KEY]) {
5739
- entity[graphicKey][materialKey] = entity[graphicKey][ORG_COLOR_KEY];
5740
- }
5741
- };
5742
- for (var key in keyMapping) {
5743
- var map = keyMapping[key];
5744
- processGraphic(key, map);
5745
- }
5746
- };
5747
- for (var i = 0; i < entities.length; i++) {
5748
- _loop_2(i);
5749
- }
5750
- }
5751
- if (visual instanceof Primitive) ;
5752
- else if (visual instanceof Cesium3DTileFeature) {
5753
- if (!isAlive$1(viewer, visual)) {
5754
- return;
5755
- }
5756
- var orgColor = visual[ORG_COLOR_KEY];
5757
- if (orgColor != null) {
5758
- visual.color = orgColor;
5759
- }
5760
- }
5761
- var opacity = EntityUtils.GetOpacity({
5762
- entity: visual
5763
- });
5764
- if (opacity != null) {
5765
- EntityUtils.SetOpacity({
5766
- viewer: viewer,
5767
- entity: visual,
5768
- opacity: opacity,
5769
- requestRender: false
5770
- });
5771
- }
5772
- if (reqRender != false) {
5773
- viewer.scene.requestRender();
5774
- }
5775
- }
5776
6115
  /**
5777
6116
  * Manages a registry of all Bruce visuals being rendered by menu items.
5778
6117
  * If multiple stuff is registered with the same entity id, only the "best" one is left visible.
@@ -5794,6 +6133,7 @@ var VisualsRegister;
5794
6133
  this.selectedIds = [];
5795
6134
  this.isolatedIds = [];
5796
6135
  this.hiddenIds = [];
6136
+ this.highlightedIds = [];
5797
6137
  // Entity id -> opacity for visual.
5798
6138
  this.opacity = {};
5799
6139
  // Array of entity ids for entities who have labels drawn for them.
@@ -5864,7 +6204,7 @@ var VisualsRegister;
5864
6204
  */
5865
6205
  Register.prototype.SetLabelled = function (params) {
5866
6206
  var labelled = params.labelled, entityIds = params.entityIds, requestRender = params.requestRender;
5867
- var _loop_3 = function (i) {
6207
+ var _loop_1 = function (i) {
5868
6208
  var id = entityIds[i];
5869
6209
  var index = this_1.labelledEntityIds.findIndex(function (x) { return x == id; });
5870
6210
  if (labelled) {
@@ -5882,7 +6222,7 @@ var VisualsRegister;
5882
6222
  };
5883
6223
  var this_1 = this;
5884
6224
  for (var i = 0; i < entityIds.length; i++) {
5885
- _loop_3(i);
6225
+ _loop_1(i);
5886
6226
  }
5887
6227
  if (requestRender != false) {
5888
6228
  this.viewer.scene.requestRender();
@@ -5923,7 +6263,19 @@ var VisualsRegister;
5923
6263
  * @param color
5924
6264
  */
5925
6265
  Register.prototype.SetSelectionColor = function (color) {
5926
- this.selectionColor = color;
6266
+ if (color) {
6267
+ CesiumEntityStyler.UpdateColorSetting("select", color);
6268
+ }
6269
+ };
6270
+ /**
6271
+ * Updates the highlight color.
6272
+ * This will not update the highlight color for already highlighted entities.
6273
+ * @param color
6274
+ */
6275
+ Register.prototype.SetHighlightColor = function (color) {
6276
+ if (color) {
6277
+ CesiumEntityStyler.UpdateColorSetting("highlight", color);
6278
+ }
5927
6279
  };
5928
6280
  Register.prototype.SetSelected = function (params) {
5929
6281
  var _a;
@@ -5944,7 +6296,11 @@ var VisualsRegister;
5944
6296
  if (regos) {
5945
6297
  for (var i_1 = 0; i_1 < regos.length; i_1++) {
5946
6298
  var rego = regos[i_1];
5947
- select(this.viewer, rego.visual, this.selectionColor, false);
6299
+ CesiumEntityStyler.Select({
6300
+ entity: rego.visual,
6301
+ viewer: this.viewer,
6302
+ requestRender: false
6303
+ });
5948
6304
  }
5949
6305
  }
5950
6306
  }
@@ -5957,7 +6313,11 @@ var VisualsRegister;
5957
6313
  if (regos) {
5958
6314
  for (var i_2 = 0; i_2 < regos.length; i_2++) {
5959
6315
  var rego = regos[i_2];
5960
- deselect(this.viewer, rego.visual, false);
6316
+ CesiumEntityStyler.Deselect({
6317
+ entity: rego.visual,
6318
+ viewer: this.viewer,
6319
+ requestRender: false
6320
+ });
5961
6321
  }
5962
6322
  }
5963
6323
  }
@@ -5984,7 +6344,11 @@ var VisualsRegister;
5984
6344
  if (regos) {
5985
6345
  for (var i_3 = 0; i_3 < regos.length; i_3++) {
5986
6346
  var rego = regos[i_3];
5987
- deselect(this.viewer, rego.visual, false);
6347
+ CesiumEntityStyler.Deselect({
6348
+ entity: rego.visual,
6349
+ viewer: this.viewer,
6350
+ requestRender: false
6351
+ });
5988
6352
  }
5989
6353
  }
5990
6354
  }
@@ -5999,6 +6363,82 @@ var VisualsRegister;
5999
6363
  Register.prototype.GetSelected = function () {
6000
6364
  return this.selectedIds;
6001
6365
  };
6366
+ Register.prototype.SetHighlighted = function (params) {
6367
+ var entityIds = params.entityIds, highlighted = params.highlighted, refreshIfHighlighted = params.refreshIfHighlighted, requestRender = params.requestRender;
6368
+ if (refreshIfHighlighted == null) {
6369
+ refreshIfHighlighted = true;
6370
+ }
6371
+ for (var i = 0; i < entityIds.length; i++) {
6372
+ var id = entityIds[i];
6373
+ if (highlighted) {
6374
+ var doHighlight = refreshIfHighlighted;
6375
+ if (this.highlightedIds.indexOf(id) === -1) {
6376
+ this.highlightedIds.push(id);
6377
+ doHighlight = true;
6378
+ }
6379
+ if (doHighlight) {
6380
+ var regos = this.rego[id];
6381
+ if (regos) {
6382
+ for (var i_4 = 0; i_4 < regos.length; i_4++) {
6383
+ var rego = regos[i_4];
6384
+ CesiumEntityStyler.Highlight({
6385
+ entity: rego.visual,
6386
+ viewer: this.viewer,
6387
+ requestRender: false
6388
+ });
6389
+ }
6390
+ }
6391
+ }
6392
+ }
6393
+ else {
6394
+ var index = this.highlightedIds.indexOf(id);
6395
+ if (index !== -1) {
6396
+ this.highlightedIds.splice(index, 1);
6397
+ var regos = this.rego[id];
6398
+ if (regos) {
6399
+ for (var i_5 = 0; i_5 < regos.length; i_5++) {
6400
+ var rego = regos[i_5];
6401
+ CesiumEntityStyler.Unhighlight({
6402
+ entity: rego.visual,
6403
+ viewer: this.viewer,
6404
+ requestRender: false
6405
+ });
6406
+ }
6407
+ }
6408
+ }
6409
+ }
6410
+ }
6411
+ if (requestRender != false) {
6412
+ this.viewer.scene.requestRender();
6413
+ }
6414
+ };
6415
+ Register.prototype.GetIsHighlighted = function (params) {
6416
+ var id = params.entityId;
6417
+ return this.highlightedIds.indexOf(id) !== -1;
6418
+ };
6419
+ Register.prototype.ClearHighlighted = function (params) {
6420
+ for (var i = 0; i < this.highlightedIds.length; i++) {
6421
+ var id = this.highlightedIds[i];
6422
+ var regos = this.rego[id];
6423
+ if (regos) {
6424
+ for (var i_6 = 0; i_6 < regos.length; i_6++) {
6425
+ var rego = regos[i_6];
6426
+ CesiumEntityStyler.Unhighlight({
6427
+ entity: rego.visual,
6428
+ viewer: this.viewer,
6429
+ requestRender: false
6430
+ });
6431
+ }
6432
+ }
6433
+ }
6434
+ this.highlightedIds = [];
6435
+ if ((params === null || params === void 0 ? void 0 : params.requestRender) != false) {
6436
+ this.viewer.scene.requestRender();
6437
+ }
6438
+ };
6439
+ Register.prototype.GetHighlighted = function () {
6440
+ return this.highlightedIds;
6441
+ };
6002
6442
  Register.prototype.SetIsolated = function (params) {
6003
6443
  var _a;
6004
6444
  var entityIds = params.entityIds, isolate = params.isolated, requestRender = params.requestRender;
@@ -6109,7 +6549,12 @@ var VisualsRegister;
6109
6549
  updateEntity(this.viewer, entityId, this);
6110
6550
  var selected = this.selectedIds.includes(entityId);
6111
6551
  if (selected) {
6112
- select(this.viewer, rego.visual, this.selectionColor, false);
6552
+ // select(this.viewer, rego.visual, this.selectionColor, false);
6553
+ CesiumEntityStyler.Select({
6554
+ entity: rego.visual,
6555
+ viewer: this.viewer,
6556
+ requestRender: false
6557
+ });
6113
6558
  }
6114
6559
  var opacity = this.opacity[entityId];
6115
6560
  if (opacity != null && opacity != 1) {
@@ -6250,7 +6695,7 @@ var VisualsRegister;
6250
6695
  return;
6251
6696
  }
6252
6697
  var menuItems = menuItemId ? [menuItemId] : entityRegos.map(function (x) { return x.menuItemId; });
6253
- var _loop_4 = function (i) {
6698
+ var _loop_2 = function (i) {
6254
6699
  var menuItemId_2 = menuItems[i];
6255
6700
  var rego = entityRegos.find(function (r) { return r.menuItemId === menuItemId_2; });
6256
6701
  if (!rego) {
@@ -6272,7 +6717,7 @@ var VisualsRegister;
6272
6717
  };
6273
6718
  var this_2 = this;
6274
6719
  for (var i = 0; i < menuItems.length; i++) {
6275
- var state_1 = _loop_4(i);
6720
+ var state_1 = _loop_2(i);
6276
6721
  if (typeof state_1 === "object")
6277
6722
  return state_1.value;
6278
6723
  }
@@ -6320,7 +6765,7 @@ var VisualsRegister;
6320
6765
  var height = Math.ceil(EnsureNumber(params.height, 5));
6321
6766
  var pickLimit = Math.ceil(EnsureNumber(params.pickLimit, 5));
6322
6767
  var picked = this.viewer.scene.drillPick(new Cartesian2(cursor.x, cursor.y), pickLimit, width, height);
6323
- var _loop_5 = function (i) {
6768
+ var _loop_3 = function (i) {
6324
6769
  var object = picked[i];
6325
6770
  var entity = (object && object.id && object.id instanceof Entity ? object.id : object);
6326
6771
  var visual = entity;
@@ -6333,7 +6778,7 @@ var VisualsRegister;
6333
6778
  };
6334
6779
  var this_3 = this;
6335
6780
  for (var i = 0; i < picked.length; i++) {
6336
- _loop_5(i);
6781
+ _loop_3(i);
6337
6782
  }
6338
6783
  return {
6339
6784
  regos: found
@@ -6394,6 +6839,7 @@ var VisualsRegister;
6394
6839
  var entityIds = params.entityIds, menuItemIds = params.menuItemId, requestRender = params.requestRender;
6395
6840
  for (var _i = 0, entityIds_2 = entityIds; _i < entityIds_2.length; _i++) {
6396
6841
  var entityId = entityIds_2[_i];
6842
+ this.opacity[entityId] = params.opacity;
6397
6843
  var regos = this.rego[entityId];
6398
6844
  if (regos && regos.length) {
6399
6845
  for (var _b = 0, regos_2 = regos; _b < regos_2.length; _b++) {
@@ -6415,7 +6861,6 @@ var VisualsRegister;
6415
6861
  requestRender: false
6416
6862
  });
6417
6863
  }
6418
- this.opacity[rego.entityId] = params.opacity;
6419
6864
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({
6420
6865
  rego: rego,
6421
6866
  type: EVisualUpdateType.Update,
@@ -14866,11 +15311,15 @@ var WidgetCursorBar = /** @class */ (function (_super) {
14866
15311
  this._disposeCesiumEvent();
14867
15312
  var events = new ScreenSpaceEventHandler(this._viewer.scene.canvas);
14868
15313
  var lastHoverPos = null;
15314
+ var lastHoveredEntityId = null;
15315
+ var unhighlightTimeout = null;
14869
15316
  var process2dCursor = function (pos2d, isHover) {
14870
15317
  try {
14871
15318
  var regos = _this._manager.VisualsRegister.GetRegosFromCursor({
14872
15319
  cursor: pos2d
14873
15320
  }).regos;
15321
+ var first = regos.length ? regos[0] : null;
15322
+ var firstId_1 = first === null || first === void 0 ? void 0 : first.entityId;
14874
15323
  if (isHover) {
14875
15324
  if (regos.length) {
14876
15325
  _this._viewer.canvas.style.cursor = "pointer";
@@ -14878,13 +15327,37 @@ var WidgetCursorBar = /** @class */ (function (_super) {
14878
15327
  else if (_this._viewer.canvas.style.cursor) {
14879
15328
  _this._viewer.canvas.style.removeProperty("cursor");
14880
15329
  }
15330
+ clearTimeout(unhighlightTimeout);
15331
+ if (lastHoveredEntityId && lastHoveredEntityId != firstId_1) {
15332
+ _this._manager.VisualsRegister.SetHighlighted({
15333
+ entityIds: [lastHoveredEntityId],
15334
+ highlighted: false
15335
+ });
15336
+ }
15337
+ if (firstId_1) {
15338
+ unhighlightTimeout = setTimeout(function () {
15339
+ if (lastHoveredEntityId == firstId_1) {
15340
+ _this._manager.VisualsRegister.SetHighlighted({
15341
+ entityIds: [firstId_1],
15342
+ highlighted: false
15343
+ });
15344
+ lastHoveredEntityId = null;
15345
+ }
15346
+ }, 5000);
15347
+ if (lastHoveredEntityId != firstId_1) {
15348
+ _this._manager.VisualsRegister.SetHighlighted({
15349
+ entityIds: [firstId_1],
15350
+ highlighted: true
15351
+ });
15352
+ }
15353
+ }
15354
+ lastHoveredEntityId = firstId_1;
14881
15355
  }
14882
15356
  else {
14883
- var first = regos.length ? regos[0] : null;
14884
15357
  _this._manager.VisualsRegister.ClearSelected();
14885
15358
  if (first) {
14886
15359
  _this._manager.VisualsRegister.SetSelected({
14887
- entityIds: [first.entityId],
15360
+ entityIds: [firstId_1],
14888
15361
  selected: true
14889
15362
  });
14890
15363
  }
@@ -15533,6 +16006,7 @@ var WidgetBookmarks = /** @class */ (function (_super) {
15533
16006
  var isFirstEnabled = !this._lastEnabledBookmarkId;
15534
16007
  this._lastEnabledBookmarkId = bookmark.ID;
15535
16008
  this._updateBookmark();
16009
+ // console.log("render bookmark", bookmark.ID);
15536
16010
  ViewRenderEngine.Render({
15537
16011
  apiGetter: this._apiGetters.GetBruceGetter(),
15538
16012
  bookmark: bookmark,
@@ -15559,6 +16033,20 @@ var WidgetBookmarks = /** @class */ (function (_super) {
15559
16033
  var record = index > -1 ? this.bookmarks[index] : null;
15560
16034
  this._name.innerText = record ? record.Title ? record.Title : "Unnamed bookmark" : "Unknown bookmark";
15561
16035
  this._chip.innerText = "".concat(index > -1 ? (index + 1) + "/" : "").concat(this.bookmarks.length);
16036
+ // Scroll the selected bookmark into view.
16037
+ var selected = this._row.querySelector(".NextspaceBookmarksRowItem[is-selected='true']");
16038
+ if (selected) {
16039
+ var scrollLeft = this._row.scrollLeft;
16040
+ var scrollRight = scrollLeft + this._row.clientWidth;
16041
+ var left = selected.offsetLeft;
16042
+ var right = left + selected.clientWidth;
16043
+ if (left < scrollLeft) {
16044
+ this._row.scrollLeft = left;
16045
+ }
16046
+ else if (right > scrollRight) {
16047
+ this._row.scrollLeft = right - this._row.clientWidth;
16048
+ }
16049
+ }
15562
16050
  };
15563
16051
  return WidgetBookmarks;
15564
16052
  }(Widget.AWidget));
@@ -19411,7 +19899,7 @@ var CesiumViewMonitor;
19411
19899
  CesiumViewMonitor$$1.Monitor = Monitor;
19412
19900
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
19413
19901
 
19414
- var VERSION$1 = "3.2.4";
19902
+ var VERSION$1 = "3.2.6";
19415
19903
 
19416
19904
  export { VERSION$1 as VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, Draw3dPolygon, Draw3dPolyline };
19417
19905
  //# sourceMappingURL=bruce-cesium.es5.js.map