bruce-cesium 3.2.3 → 3.2.5

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, Entity, Primitive, Cesium3DTileFeature, JulianDate, SceneMode, DistanceDisplayCondition, NearFarScalar, Model, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, OrthographicFrustum, EasingFunction, SceneTransforms, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, PolygonPipeline, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, BoundingSphere, GeometryInstance, CesiumInspector, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, Primitive, Cesium3DTileFeature, SceneMode, DistanceDisplayCondition, NearFarScalar, Model, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, Cesium3DTileStyle, KmlDataSource, Cesium3DTileset, Matrix4, Matrix3, IonResource, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, SceneTransforms, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ColorMaterialProperty, Intersect } 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
+ }
772
948
  }
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);
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);
781
993
  }
782
- entity[graphicKey][ORG_OPACITY_KEY] = null;
783
994
  }
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;
995
+ }
996
+ if (requestRender != false) {
997
+ viewer.scene.requestRender();
998
+ }
801
999
  }
802
- }
803
- function applyOpacityToEntity(viewer, opacity, entity) {
804
- if (!isAlive(viewer, entity)) {
805
- return;
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);
1040
+ }
1041
+ }
1042
+ }
1043
+ return null;
806
1044
  }
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;
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
+ });
1058
+ }
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));
1086
+ }
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));
816
1098
  }
817
- if (orgOpacity == null) {
818
- orgOpacity = 1;
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
+ }
1116
+ }
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;
1127
+ }
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
+ }
1171
+ }
1172
+ if (requestRender != false) {
1173
+ viewer.scene.requestRender();
1174
+ }
830
1175
  }
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;
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;
835
1186
  }
836
- if (!orgOpacity) {
837
- orgOpacity = 1;
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
+ }
838
1229
  }
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;
1230
+ if (requestRender != false) {
1231
+ viewer.scene.requestRender();
843
1232
  }
844
- entity.color = color;
845
1233
  }
846
- }
847
- function findOpacity(entity) {
848
- return entity ? entity[NEW_OPACITY_KEY] : null;
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) {
@@ -973,43 +1429,20 @@ var EntityUtils;
973
1429
  });
974
1430
  }); };
975
1431
  getEntityPositions = function (sample) { return __awaiter(_this, void 0, void 0, function () {
976
- var entityId, entity, tileset, tilesetId, e_1, evaluateRendered, evaluateRecord, renderedPosses, recordPosses, e_2, tSettings, pos3d, alt, alt, heading, pitch, roll, matrix4, offset, m1, hpr, transform, transformedOffset;
1432
+ var entityId, entity, tileset, tilesetId, evaluateRendered, evaluateRecord, renderedPosses, e_1, recordPosses, e_2, tSettings, pos3d, alt, alt, heading, pitch, roll, matrix4, offset, m1, hpr, transform, transformedOffset;
977
1433
  var _this = this;
978
1434
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
979
1435
  return __generator(this, function (_l) {
980
1436
  switch (_l.label) {
981
1437
  case 0:
982
1438
  entityId = sample.entityId, entity = sample.entity, tileset = sample.tileset, tilesetId = sample.tilesetId;
983
- if (!!entity) return [3 /*break*/, 4];
984
- if (!(apiCalls < MAX_API_CALLS)) return [3 /*break*/, 4];
985
- apiCalls += 1;
986
- _l.label = 1;
987
- case 1:
988
- _l.trys.push([1, 3, , 4]);
989
- return [4 /*yield*/, Entity$1.Get({
990
- api: api,
991
- entityId: entityId,
992
- // Not expanding relative positions at first to see if the entity has valid location just by itself.
993
- expandLocation: false
994
- })];
995
- case 2:
996
- entity = (_l.sent()).entity;
997
- return [3 /*break*/, 4];
998
- case 3:
999
- e_1 = _l.sent();
1000
- console.error(e_1);
1001
- return [3 /*break*/, 4];
1002
- case 4:
1003
- if (!entity) {
1004
- return [2 /*return*/, []];
1005
- }
1006
1439
  evaluateRendered = function () { return __awaiter(_this, void 0, void 0, function () {
1007
- var rego, posses, visual, visualHeightRef, hierarchy, hPosses, hPossesSample, step, i, pPosses, pPossesSample, step, i, pPosses, pPossesSample, step, i, pos3d_1, modelExt, sphere;
1440
+ var rego, posses, visual, visualHeightRef, hierarchy, hPosses, hPossesSample, step, i, pPosses, pPossesSample, step, i, pPosses, pPossesSample, step, i, pos3d_1, toAdjust, modelExt, sphere;
1008
1441
  return __generator(this, function (_a) {
1009
1442
  switch (_a.label) {
1010
1443
  case 0:
1011
1444
  rego = visualRegister ? visualRegister.GetRego({
1012
- entityId: entity.Bruce.ID,
1445
+ entityId: sample.entityId,
1013
1446
  }) : null;
1014
1447
  posses = [];
1015
1448
  if (!((rego === null || rego === void 0 ? void 0 : rego.visual) instanceof Entity)) return [3 /*break*/, 14];
@@ -1087,15 +1520,11 @@ var EntityUtils;
1087
1520
  case 12:
1088
1521
  pos3d_1 = GetValue(viewer, visual.position);
1089
1522
  if (!(pos3d_1 === null || pos3d_1 === void 0 ? void 0 : pos3d_1.x)) return [3 /*break*/, 14];
1090
- pos3d_1 = DrawingUtils.EnsurePosHeight({
1091
- desiredHeightRef: sample.returnHeightRef,
1092
- heightRef: visualHeightRef,
1093
- pos3d: pos3d_1,
1094
- viewer: viewer
1095
- });
1096
- return [4 /*yield*/, processPosHeight(pos3d_1, sample.returnHeightRef)];
1523
+ toAdjust = [pos3d_1];
1524
+ return [4 /*yield*/, ensureHeightRefs(toAdjust, __assign(__assign({}, sample), { heightRef: visualHeightRef }))];
1097
1525
  case 13:
1098
- pos3d_1 = _a.sent();
1526
+ _a.sent();
1527
+ pos3d_1 = toAdjust[0];
1099
1528
  posses.push(pos3d_1);
1100
1529
  if (visual.model) {
1101
1530
  modelExt = visual.model;
@@ -1180,11 +1609,34 @@ var EntityUtils;
1180
1609
  });
1181
1610
  }); };
1182
1611
  return [4 /*yield*/, evaluateRendered()];
1183
- case 5:
1612
+ case 1:
1184
1613
  renderedPosses = _l.sent();
1185
1614
  if (renderedPosses === null || renderedPosses === void 0 ? void 0 : renderedPosses.length) {
1186
1615
  return [2 /*return*/, renderedPosses];
1187
1616
  }
1617
+ if (!!entity) return [3 /*break*/, 5];
1618
+ if (!(apiCalls < MAX_API_CALLS)) return [3 /*break*/, 5];
1619
+ apiCalls += 1;
1620
+ _l.label = 2;
1621
+ case 2:
1622
+ _l.trys.push([2, 4, , 5]);
1623
+ return [4 /*yield*/, Entity$1.Get({
1624
+ api: api,
1625
+ entityId: entityId,
1626
+ // Not expanding relative positions at first to see if the entity has valid location just by itself.
1627
+ expandLocation: false
1628
+ })];
1629
+ case 3:
1630
+ entity = (_l.sent()).entity;
1631
+ return [3 /*break*/, 5];
1632
+ case 4:
1633
+ e_1 = _l.sent();
1634
+ console.error(e_1);
1635
+ return [3 /*break*/, 5];
1636
+ case 5:
1637
+ if (!entity) {
1638
+ return [2 /*return*/, []];
1639
+ }
1188
1640
  return [4 /*yield*/, evaluateRecord()];
1189
1641
  case 6:
1190
1642
  recordPosses = _l.sent();
@@ -1812,10 +2264,12 @@ var EntityUtils;
1812
2264
  */
1813
2265
  function SetOpacity(params) {
1814
2266
  var viewer = params.viewer, entity = params.entity, opacity = params.opacity, requestRender = params.requestRender;
1815
- applyOpacityToEntity(viewer, opacity, entity);
1816
- if (requestRender != false) {
1817
- viewer.scene.requestRender();
1818
- }
2267
+ CesiumEntityStyler.SetOpacity({
2268
+ entity: entity,
2269
+ opacity: opacity,
2270
+ viewer: viewer,
2271
+ requestRender: requestRender
2272
+ });
1819
2273
  }
1820
2274
  EntityUtils.SetOpacity = SetOpacity;
1821
2275
  /**
@@ -1826,10 +2280,11 @@ var EntityUtils;
1826
2280
  */
1827
2281
  function RevertOpacity(params) {
1828
2282
  var viewer = params.viewer, entity = params.entity, requestRender = params.requestRender;
1829
- revertAppliedEntityOpacity(viewer, entity);
1830
- if (requestRender != false) {
1831
- viewer.scene.requestRender();
1832
- }
2283
+ CesiumEntityStyler.ClearOpacity({
2284
+ entity: entity,
2285
+ viewer: viewer,
2286
+ requestRender: requestRender
2287
+ });
1833
2288
  }
1834
2289
  EntityUtils.RevertOpacity = RevertOpacity;
1835
2290
  /**
@@ -1841,7 +2296,9 @@ var EntityUtils;
1841
2296
  */
1842
2297
  function GetOpacity(params) {
1843
2298
  var entity = params.entity;
1844
- return findOpacity(entity);
2299
+ return CesiumEntityStyler.GetOpacity({
2300
+ entity: entity
2301
+ });
1845
2302
  }
1846
2303
  EntityUtils.GetOpacity = GetOpacity;
1847
2304
  })(EntityUtils || (EntityUtils = {}));
@@ -2470,8 +2927,13 @@ function runCullChecker(register) {
2470
2927
  var parts = EntityUtils.GatherEntity({
2471
2928
  entity: rego.visual
2472
2929
  });
2930
+ var isolatedIds = register.GetIsolated();
2931
+ var hiddenIds = register.GetHidden();
2473
2932
  for (var i_1 = 0; i_1 < parts.length; i_1++) {
2474
2933
  var part = parts[i_1];
2934
+ if (!(part instanceof Entity)) {
2935
+ continue;
2936
+ }
2475
2937
  var shouldCull = shouldCullEntity(viewer, part);
2476
2938
  if (shouldCull) {
2477
2939
  part[VisualRegisterCuller.VISUAL_CULL_KEY] = true;
@@ -2481,7 +2943,11 @@ function runCullChecker(register) {
2481
2943
  }
2482
2944
  else {
2483
2945
  delete part[VisualRegisterCuller.VISUAL_CULL_KEY];
2484
- 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))) {
2485
2951
  viewer.entities.add(part);
2486
2952
  }
2487
2953
  }
@@ -5646,137 +6112,6 @@ function unmarkEntity(visual, ignoreParent) {
5646
6112
  }
5647
6113
  }
5648
6114
  }
5649
- var ORG_COLOR_KEY = "_org_color_";
5650
- function select(viewer, visual, color, reqRender) {
5651
- var _a;
5652
- if (!color) {
5653
- color = Color.fromAlpha(Color.YELLOW, 0.5);
5654
- }
5655
- if (visual instanceof Entity) {
5656
- if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
5657
- return;
5658
- }
5659
- var entities = EntityUtils.GatherEntity({
5660
- entity: visual
5661
- });
5662
- var keyMapping = {
5663
- "point": "color",
5664
- "polygon": "material",
5665
- "polyline": "material",
5666
- "model": "color",
5667
- "billboard": "color",
5668
- "corridor": "material",
5669
- "ellipse": "material"
5670
- };
5671
- var _loop_1 = function (i) {
5672
- var entity = entities[i];
5673
- var processGraphic = function (graphicKey, materialKey) {
5674
- if (entity[graphicKey]) {
5675
- if (entity[graphicKey][ORG_COLOR_KEY] == null) {
5676
- var orgColor = entity[graphicKey][materialKey];
5677
- if (!orgColor) {
5678
- orgColor = Color.WHITE;
5679
- }
5680
- entity[graphicKey][ORG_COLOR_KEY] = orgColor.clone ? orgColor.clone() : orgColor;
5681
- }
5682
- entity[graphicKey][materialKey] = color.clone();
5683
- }
5684
- };
5685
- for (var key in keyMapping) {
5686
- var map = keyMapping[key];
5687
- processGraphic(key, map);
5688
- }
5689
- };
5690
- for (var i = 0; i < entities.length; i++) {
5691
- _loop_1(i);
5692
- }
5693
- }
5694
- if (visual instanceof Primitive) ;
5695
- else if (visual instanceof Cesium3DTileFeature) {
5696
- if (!isAlive$1(viewer, visual)) {
5697
- return;
5698
- }
5699
- var orgColor = visual[ORG_COLOR_KEY];
5700
- if (orgColor == null) {
5701
- orgColor = visual.color;
5702
- visual[ORG_COLOR_KEY] = (_a = orgColor === null || orgColor === void 0 ? void 0 : orgColor.clone) === null || _a === void 0 ? void 0 : _a.call(orgColor);
5703
- }
5704
- visual.color = color.clone();
5705
- }
5706
- var opacity = EntityUtils.GetOpacity({
5707
- entity: visual
5708
- });
5709
- if (opacity != null) {
5710
- EntityUtils.SetOpacity({
5711
- viewer: viewer,
5712
- entity: visual,
5713
- opacity: opacity,
5714
- requestRender: false
5715
- });
5716
- }
5717
- if (reqRender != false) {
5718
- viewer.scene.requestRender();
5719
- }
5720
- }
5721
- function deselect(viewer, visual, reqRender) {
5722
- if (visual instanceof Entity) {
5723
- if (!(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
5724
- return;
5725
- }
5726
- var entities = EntityUtils.GatherEntity({
5727
- entity: visual
5728
- });
5729
- var keyMapping = {
5730
- "point": "color",
5731
- "polygon": "material",
5732
- "polyline": "material",
5733
- "model": "color",
5734
- "billboard": "color",
5735
- "corridor": "material",
5736
- "ellipse": "material"
5737
- };
5738
- var _loop_2 = function (i) {
5739
- var entity = entities[i];
5740
- var processGraphic = function (graphicKey, materialKey) {
5741
- var _a;
5742
- if ((_a = entity[graphicKey]) === null || _a === void 0 ? void 0 : _a[ORG_COLOR_KEY]) {
5743
- entity[graphicKey][materialKey] = entity[graphicKey][ORG_COLOR_KEY];
5744
- }
5745
- };
5746
- for (var key in keyMapping) {
5747
- var map = keyMapping[key];
5748
- processGraphic(key, map);
5749
- }
5750
- };
5751
- for (var i = 0; i < entities.length; i++) {
5752
- _loop_2(i);
5753
- }
5754
- }
5755
- if (visual instanceof Primitive) ;
5756
- else if (visual instanceof Cesium3DTileFeature) {
5757
- if (!isAlive$1(viewer, visual)) {
5758
- return;
5759
- }
5760
- var orgColor = visual[ORG_COLOR_KEY];
5761
- if (orgColor != null) {
5762
- visual.color = orgColor;
5763
- }
5764
- }
5765
- var opacity = EntityUtils.GetOpacity({
5766
- entity: visual
5767
- });
5768
- if (opacity != null) {
5769
- EntityUtils.SetOpacity({
5770
- viewer: viewer,
5771
- entity: visual,
5772
- opacity: opacity,
5773
- requestRender: false
5774
- });
5775
- }
5776
- if (reqRender != false) {
5777
- viewer.scene.requestRender();
5778
- }
5779
- }
5780
6115
  /**
5781
6116
  * Manages a registry of all Bruce visuals being rendered by menu items.
5782
6117
  * If multiple stuff is registered with the same entity id, only the "best" one is left visible.
@@ -5798,6 +6133,7 @@ var VisualsRegister;
5798
6133
  this.selectedIds = [];
5799
6134
  this.isolatedIds = [];
5800
6135
  this.hiddenIds = [];
6136
+ this.highlightedIds = [];
5801
6137
  // Entity id -> opacity for visual.
5802
6138
  this.opacity = {};
5803
6139
  // Array of entity ids for entities who have labels drawn for them.
@@ -5868,7 +6204,7 @@ var VisualsRegister;
5868
6204
  */
5869
6205
  Register.prototype.SetLabelled = function (params) {
5870
6206
  var labelled = params.labelled, entityIds = params.entityIds, requestRender = params.requestRender;
5871
- var _loop_3 = function (i) {
6207
+ var _loop_1 = function (i) {
5872
6208
  var id = entityIds[i];
5873
6209
  var index = this_1.labelledEntityIds.findIndex(function (x) { return x == id; });
5874
6210
  if (labelled) {
@@ -5886,7 +6222,7 @@ var VisualsRegister;
5886
6222
  };
5887
6223
  var this_1 = this;
5888
6224
  for (var i = 0; i < entityIds.length; i++) {
5889
- _loop_3(i);
6225
+ _loop_1(i);
5890
6226
  }
5891
6227
  if (requestRender != false) {
5892
6228
  this.viewer.scene.requestRender();
@@ -5927,7 +6263,9 @@ var VisualsRegister;
5927
6263
  * @param color
5928
6264
  */
5929
6265
  Register.prototype.SetSelectionColor = function (color) {
5930
- this.selectionColor = color;
6266
+ if (color) {
6267
+ CesiumEntityStyler.UpdateColorSetting("select", color);
6268
+ }
5931
6269
  };
5932
6270
  Register.prototype.SetSelected = function (params) {
5933
6271
  var _a;
@@ -5948,7 +6286,11 @@ var VisualsRegister;
5948
6286
  if (regos) {
5949
6287
  for (var i_1 = 0; i_1 < regos.length; i_1++) {
5950
6288
  var rego = regos[i_1];
5951
- select(this.viewer, rego.visual, this.selectionColor, false);
6289
+ CesiumEntityStyler.Select({
6290
+ entity: rego.visual,
6291
+ viewer: this.viewer,
6292
+ requestRender: false
6293
+ });
5952
6294
  }
5953
6295
  }
5954
6296
  }
@@ -5961,7 +6303,11 @@ var VisualsRegister;
5961
6303
  if (regos) {
5962
6304
  for (var i_2 = 0; i_2 < regos.length; i_2++) {
5963
6305
  var rego = regos[i_2];
5964
- deselect(this.viewer, rego.visual, false);
6306
+ CesiumEntityStyler.Deselect({
6307
+ entity: rego.visual,
6308
+ viewer: this.viewer,
6309
+ requestRender: false
6310
+ });
5965
6311
  }
5966
6312
  }
5967
6313
  }
@@ -5988,7 +6334,11 @@ var VisualsRegister;
5988
6334
  if (regos) {
5989
6335
  for (var i_3 = 0; i_3 < regos.length; i_3++) {
5990
6336
  var rego = regos[i_3];
5991
- deselect(this.viewer, rego.visual, false);
6337
+ CesiumEntityStyler.Deselect({
6338
+ entity: rego.visual,
6339
+ viewer: this.viewer,
6340
+ requestRender: false
6341
+ });
5992
6342
  }
5993
6343
  }
5994
6344
  }
@@ -6003,6 +6353,82 @@ var VisualsRegister;
6003
6353
  Register.prototype.GetSelected = function () {
6004
6354
  return this.selectedIds;
6005
6355
  };
6356
+ Register.prototype.SetHighlighted = function (params) {
6357
+ var entityIds = params.entityIds, highlighted = params.highlighted, refreshIfHighlighted = params.refreshIfHighlighted, requestRender = params.requestRender;
6358
+ if (refreshIfHighlighted == null) {
6359
+ refreshIfHighlighted = true;
6360
+ }
6361
+ for (var i = 0; i < entityIds.length; i++) {
6362
+ var id = entityIds[i];
6363
+ if (highlighted) {
6364
+ var doHighlight = refreshIfHighlighted;
6365
+ if (this.highlightedIds.indexOf(id) === -1) {
6366
+ this.highlightedIds.push(id);
6367
+ doHighlight = true;
6368
+ }
6369
+ if (doHighlight) {
6370
+ var regos = this.rego[id];
6371
+ if (regos) {
6372
+ for (var i_4 = 0; i_4 < regos.length; i_4++) {
6373
+ var rego = regos[i_4];
6374
+ CesiumEntityStyler.Highlight({
6375
+ entity: rego.visual,
6376
+ viewer: this.viewer,
6377
+ requestRender: false
6378
+ });
6379
+ }
6380
+ }
6381
+ }
6382
+ }
6383
+ else {
6384
+ var index = this.highlightedIds.indexOf(id);
6385
+ if (index !== -1) {
6386
+ this.highlightedIds.splice(index, 1);
6387
+ var regos = this.rego[id];
6388
+ if (regos) {
6389
+ for (var i_5 = 0; i_5 < regos.length; i_5++) {
6390
+ var rego = regos[i_5];
6391
+ CesiumEntityStyler.Unhighlight({
6392
+ entity: rego.visual,
6393
+ viewer: this.viewer,
6394
+ requestRender: false
6395
+ });
6396
+ }
6397
+ }
6398
+ }
6399
+ }
6400
+ }
6401
+ if (requestRender != false) {
6402
+ this.viewer.scene.requestRender();
6403
+ }
6404
+ };
6405
+ Register.prototype.GetIsHighlighted = function (params) {
6406
+ var id = params.entityId;
6407
+ return this.highlightedIds.indexOf(id) !== -1;
6408
+ };
6409
+ Register.prototype.ClearHighlighted = function (params) {
6410
+ for (var i = 0; i < this.highlightedIds.length; i++) {
6411
+ var id = this.highlightedIds[i];
6412
+ var regos = this.rego[id];
6413
+ if (regos) {
6414
+ for (var i_6 = 0; i_6 < regos.length; i_6++) {
6415
+ var rego = regos[i_6];
6416
+ CesiumEntityStyler.Unhighlight({
6417
+ entity: rego.visual,
6418
+ viewer: this.viewer,
6419
+ requestRender: false
6420
+ });
6421
+ }
6422
+ }
6423
+ }
6424
+ this.highlightedIds = [];
6425
+ if ((params === null || params === void 0 ? void 0 : params.requestRender) != false) {
6426
+ this.viewer.scene.requestRender();
6427
+ }
6428
+ };
6429
+ Register.prototype.GetHighlighted = function () {
6430
+ return this.highlightedIds;
6431
+ };
6006
6432
  Register.prototype.SetIsolated = function (params) {
6007
6433
  var _a;
6008
6434
  var entityIds = params.entityIds, isolate = params.isolated, requestRender = params.requestRender;
@@ -6113,7 +6539,12 @@ var VisualsRegister;
6113
6539
  updateEntity(this.viewer, entityId, this);
6114
6540
  var selected = this.selectedIds.includes(entityId);
6115
6541
  if (selected) {
6116
- select(this.viewer, rego.visual, this.selectionColor, false);
6542
+ // select(this.viewer, rego.visual, this.selectionColor, false);
6543
+ CesiumEntityStyler.Select({
6544
+ entity: rego.visual,
6545
+ viewer: this.viewer,
6546
+ requestRender: false
6547
+ });
6117
6548
  }
6118
6549
  var opacity = this.opacity[entityId];
6119
6550
  if (opacity != null && opacity != 1) {
@@ -6254,7 +6685,7 @@ var VisualsRegister;
6254
6685
  return;
6255
6686
  }
6256
6687
  var menuItems = menuItemId ? [menuItemId] : entityRegos.map(function (x) { return x.menuItemId; });
6257
- var _loop_4 = function (i) {
6688
+ var _loop_2 = function (i) {
6258
6689
  var menuItemId_2 = menuItems[i];
6259
6690
  var rego = entityRegos.find(function (r) { return r.menuItemId === menuItemId_2; });
6260
6691
  if (!rego) {
@@ -6276,7 +6707,7 @@ var VisualsRegister;
6276
6707
  };
6277
6708
  var this_2 = this;
6278
6709
  for (var i = 0; i < menuItems.length; i++) {
6279
- var state_1 = _loop_4(i);
6710
+ var state_1 = _loop_2(i);
6280
6711
  if (typeof state_1 === "object")
6281
6712
  return state_1.value;
6282
6713
  }
@@ -6324,7 +6755,7 @@ var VisualsRegister;
6324
6755
  var height = Math.ceil(EnsureNumber(params.height, 5));
6325
6756
  var pickLimit = Math.ceil(EnsureNumber(params.pickLimit, 5));
6326
6757
  var picked = this.viewer.scene.drillPick(new Cartesian2(cursor.x, cursor.y), pickLimit, width, height);
6327
- var _loop_5 = function (i) {
6758
+ var _loop_3 = function (i) {
6328
6759
  var object = picked[i];
6329
6760
  var entity = (object && object.id && object.id instanceof Entity ? object.id : object);
6330
6761
  var visual = entity;
@@ -6337,7 +6768,7 @@ var VisualsRegister;
6337
6768
  };
6338
6769
  var this_3 = this;
6339
6770
  for (var i = 0; i < picked.length; i++) {
6340
- _loop_5(i);
6771
+ _loop_3(i);
6341
6772
  }
6342
6773
  return {
6343
6774
  regos: found
@@ -6398,6 +6829,7 @@ var VisualsRegister;
6398
6829
  var entityIds = params.entityIds, menuItemIds = params.menuItemId, requestRender = params.requestRender;
6399
6830
  for (var _i = 0, entityIds_2 = entityIds; _i < entityIds_2.length; _i++) {
6400
6831
  var entityId = entityIds_2[_i];
6832
+ this.opacity[entityId] = params.opacity;
6401
6833
  var regos = this.rego[entityId];
6402
6834
  if (regos && regos.length) {
6403
6835
  for (var _b = 0, regos_2 = regos; _b < regos_2.length; _b++) {
@@ -6419,7 +6851,6 @@ var VisualsRegister;
6419
6851
  requestRender: false
6420
6852
  });
6421
6853
  }
6422
- this.opacity[rego.entityId] = params.opacity;
6423
6854
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({
6424
6855
  rego: rego,
6425
6856
  type: EVisualUpdateType.Update,
@@ -14870,11 +15301,15 @@ var WidgetCursorBar = /** @class */ (function (_super) {
14870
15301
  this._disposeCesiumEvent();
14871
15302
  var events = new ScreenSpaceEventHandler(this._viewer.scene.canvas);
14872
15303
  var lastHoverPos = null;
15304
+ var lastHoveredEntityId = null;
15305
+ var unhighlightTimeout = null;
14873
15306
  var process2dCursor = function (pos2d, isHover) {
14874
15307
  try {
14875
15308
  var regos = _this._manager.VisualsRegister.GetRegosFromCursor({
14876
15309
  cursor: pos2d
14877
15310
  }).regos;
15311
+ var first = regos.length ? regos[0] : null;
15312
+ var firstId_1 = first === null || first === void 0 ? void 0 : first.entityId;
14878
15313
  if (isHover) {
14879
15314
  if (regos.length) {
14880
15315
  _this._viewer.canvas.style.cursor = "pointer";
@@ -14882,13 +15317,37 @@ var WidgetCursorBar = /** @class */ (function (_super) {
14882
15317
  else if (_this._viewer.canvas.style.cursor) {
14883
15318
  _this._viewer.canvas.style.removeProperty("cursor");
14884
15319
  }
15320
+ clearTimeout(unhighlightTimeout);
15321
+ if (lastHoveredEntityId && lastHoveredEntityId != firstId_1) {
15322
+ _this._manager.VisualsRegister.SetHighlighted({
15323
+ entityIds: [lastHoveredEntityId],
15324
+ highlighted: false
15325
+ });
15326
+ }
15327
+ if (firstId_1) {
15328
+ unhighlightTimeout = setTimeout(function () {
15329
+ if (lastHoveredEntityId == firstId_1) {
15330
+ _this._manager.VisualsRegister.SetHighlighted({
15331
+ entityIds: [firstId_1],
15332
+ highlighted: false
15333
+ });
15334
+ lastHoveredEntityId = null;
15335
+ }
15336
+ }, 5000);
15337
+ if (lastHoveredEntityId != firstId_1) {
15338
+ _this._manager.VisualsRegister.SetHighlighted({
15339
+ entityIds: [firstId_1],
15340
+ highlighted: true
15341
+ });
15342
+ }
15343
+ }
15344
+ lastHoveredEntityId = firstId_1;
14885
15345
  }
14886
15346
  else {
14887
- var first = regos.length ? regos[0] : null;
14888
15347
  _this._manager.VisualsRegister.ClearSelected();
14889
15348
  if (first) {
14890
15349
  _this._manager.VisualsRegister.SetSelected({
14891
- entityIds: [first.entityId],
15350
+ entityIds: [firstId_1],
14892
15351
  selected: true
14893
15352
  });
14894
15353
  }
@@ -15537,6 +15996,7 @@ var WidgetBookmarks = /** @class */ (function (_super) {
15537
15996
  var isFirstEnabled = !this._lastEnabledBookmarkId;
15538
15997
  this._lastEnabledBookmarkId = bookmark.ID;
15539
15998
  this._updateBookmark();
15999
+ // console.log("render bookmark", bookmark.ID);
15540
16000
  ViewRenderEngine.Render({
15541
16001
  apiGetter: this._apiGetters.GetBruceGetter(),
15542
16002
  bookmark: bookmark,
@@ -15563,6 +16023,20 @@ var WidgetBookmarks = /** @class */ (function (_super) {
15563
16023
  var record = index > -1 ? this.bookmarks[index] : null;
15564
16024
  this._name.innerText = record ? record.Title ? record.Title : "Unnamed bookmark" : "Unknown bookmark";
15565
16025
  this._chip.innerText = "".concat(index > -1 ? (index + 1) + "/" : "").concat(this.bookmarks.length);
16026
+ // Scroll the selected bookmark into view.
16027
+ var selected = this._row.querySelector(".NextspaceBookmarksRowItem[is-selected='true']");
16028
+ if (selected) {
16029
+ var scrollLeft = this._row.scrollLeft;
16030
+ var scrollRight = scrollLeft + this._row.clientWidth;
16031
+ var left = selected.offsetLeft;
16032
+ var right = left + selected.clientWidth;
16033
+ if (left < scrollLeft) {
16034
+ this._row.scrollLeft = left;
16035
+ }
16036
+ else if (right > scrollRight) {
16037
+ this._row.scrollLeft = right - this._row.clientWidth;
16038
+ }
16039
+ }
15566
16040
  };
15567
16041
  return WidgetBookmarks;
15568
16042
  }(Widget.AWidget));
@@ -19415,7 +19889,7 @@ var CesiumViewMonitor;
19415
19889
  CesiumViewMonitor$$1.Monitor = Monitor;
19416
19890
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
19417
19891
 
19418
- var VERSION$1 = "3.2.3";
19892
+ var VERSION$1 = "3.2.5";
19419
19893
 
19420
19894
  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 };
19421
19895
  //# sourceMappingURL=bruce-cesium.es5.js.map