bruce-cesium 7.8.5 → 7.8.7

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 * as Cesium from 'cesium';
2
- import { Cartographic, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, ColorMaterialProperty, Color, JulianDate, Quaternion, HeadingPitchRoll, HeightReference, ColorBlendMode, Entity, CallbackProperty, ConstantProperty, Model, ClassificationType, ConstantPositionProperty, DistanceDisplayCondition, ArcType, CornerType, Primitive, Cesium3DTileFeature, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, HorizontalOrigin, VerticalOrigin, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, FeatureDetection, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, Intersect, WebGLConstants, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CesiumInspector, ClockRange, ShadowMode, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, CustomDataSource, GeometryInstance, Event, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Geometry as Geometry$1, Bounds, ClientFileValueMap, Color as Color$1, ProjectView, ProjectViewBookmark, ZoomControl, Api, Assembly, EntityCoords, EntityRelation, BruceApi, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, ProjectViewBookmarkGroup, EntityAttachment, EntityAttribute, MathUtils } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, ShaderSource, Ellipsoid, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, ClassificationType, ArcType, CornerType, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, ColorBlendMode, Model, HorizontalOrigin, VerticalOrigin, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, KmlDataSource, Matrix3, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, IonResource, Cesium3DTileset, Intersect, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, WebGLConstants, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ShadowMode, CustomDataSource, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, GeometryInstance, Event, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, Geometry as Geometry$1, Bounds, ClientFileValueMap, Color as Color$1, EntityLod, UrlUtils, Api, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, BruceApi, EntityRelation, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -9689,6 +9689,11 @@ var EntityLabel;
9689
9689
  if (!entityIds.length) {
9690
9690
  return;
9691
9691
  }
9692
+ if (this.options.reportClick) {
9693
+ const keys = event;
9694
+ this.visualRegister.ClickLabelEntities(entityIds, Boolean(keys.ctrlKey || keys.metaKey || keys.shiftKey));
9695
+ return;
9696
+ }
9692
9697
  this.visualRegister.ClearSelected({ requestRender: false });
9693
9698
  this.visualRegister.SetSelected({ entityIds, selected: true });
9694
9699
  };
@@ -10359,7 +10364,7 @@ var EntityLabel;
10359
10364
  let displacement = { x: 0, y: 0 };
10360
10365
  let nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
10361
10366
  const apply = (placement) => {
10362
- var _a, _b, _c, _d, _e;
10367
+ var _a, _b, _c, _d, _e, _f;
10363
10368
  const show = (placement === null || placement === void 0 ? void 0 : placement.visible) && placement.opacity > 0;
10364
10369
  if (!show && hiddenLast) {
10365
10370
  return;
@@ -10420,6 +10425,11 @@ var EntityLabel;
10420
10425
  ele.style.opacity = String(opacity);
10421
10426
  ele.style.zIndex = String(placement.zIndex);
10422
10427
  ele.dataset.clusterCount = String(placement.members.length || 1);
10428
+ // Every Entity a cluster stands for, so a box selection takes them all, not only the one drawn.
10429
+ const clusterIds = placement.members.length ? placement.entityIds.join(" ") : "";
10430
+ if (((_d = ele.dataset.clusterIds) !== null && _d !== void 0 ? _d : "") !== clusterIds) {
10431
+ ele.dataset.clusterIds = clusterIds;
10432
+ }
10423
10433
  countElement.style.display = placement.members.length ? "block" : "none";
10424
10434
  countElement.style.order = placement.textSide === "left" ? "-1" : "0";
10425
10435
  const count = placement.members.length ? String(placement.members.length) : "";
@@ -10432,9 +10442,9 @@ var EntityLabel;
10432
10442
  const stack = JSON.stringify(placement.icons || []);
10433
10443
  if (iconStack && stack !== displayedStack) {
10434
10444
  displayedStack = stack;
10435
- const looks = ((_d = placement.icons) === null || _d === void 0 ? void 0 : _d.length) ? [iconLook(this.options), ...placement.icons] : [];
10445
+ const looks = ((_e = placement.icons) === null || _e === void 0 ? void 0 : _e.length) ? [iconLook(this.options), ...placement.icons] : [];
10436
10446
  // One small size for all, so no icon in the arrangement reads as more important than another.
10437
- const size = (this.options.iconSize || 24) * ((_e = this.options.iconScale) !== null && _e !== void 0 ? _e : 1) * ICON_STACK_SCALE;
10447
+ const size = (this.options.iconSize || 24) * ((_f = this.options.iconScale) !== null && _f !== void 0 ? _f : 1) * ICON_STACK_SCALE;
10438
10448
  const built = looks.map(look => this.buildIcon({ ...(pin ? pinLook(look) : look), iconSize: size }, counter));
10439
10449
  // A stack is on show already, so its photos load straight away.
10440
10450
  built.forEach(({ start }) => start === null || start === void 0 ? void 0 : start());
@@ -11192,6 +11202,35 @@ var EntityLabel;
11192
11202
 
11193
11203
  var EntityLabelGroup;
11194
11204
  (function (EntityLabelGroup) {
11205
+ // Prefixes that make an icon value name its kind, so one mapping can send Entities to icons of different kinds.
11206
+ EntityLabelGroup.ICON_PREFIX = {
11207
+ // A Font Awesome class, "FA:fas fa-cube".
11208
+ FontAwesome: "FA:",
11209
+ // A client file by id, or an image by URL, "CF:<file id or URL>".
11210
+ ClientFile: "CF:"
11211
+ };
11212
+ /*
11213
+ * The icon a prefixed value names, as a class or an image URL, or null for a value with no known prefix.
11214
+ */
11215
+ function ParseIcon(value, api) {
11216
+ if (typeof value !== "string") {
11217
+ return null;
11218
+ }
11219
+ const named = value.trim();
11220
+ if (named.startsWith(EntityLabelGroup.ICON_PREFIX.FontAwesome)) {
11221
+ const iconClass = named.slice(EntityLabelGroup.ICON_PREFIX.FontAwesome.length).trim();
11222
+ return iconClass ? { iconClass } : null;
11223
+ }
11224
+ if (named.startsWith(EntityLabelGroup.ICON_PREFIX.ClientFile)) {
11225
+ const file = named.slice(EntityLabelGroup.ICON_PREFIX.ClientFile.length).trim();
11226
+ if (!file) {
11227
+ return null;
11228
+ }
11229
+ return { iconUrl: /^[a-z][a-z0-9+.-]*:/i.test(file) ? file : ClientFile.GetUrl({ api, fileId: file, viaCdn: true }) };
11230
+ }
11231
+ return null;
11232
+ }
11233
+ EntityLabelGroup.ParseIcon = ParseIcon;
11195
11234
  // The glow a selected place is drawn with.
11196
11235
  const PLACE_SELECTED_COLOR = "#33B1FF";
11197
11236
  // Keys places share the entity bookkeeping under, scoped to their group so a copied group keeps its own.
@@ -11415,6 +11454,10 @@ var EntityLabelGroup;
11415
11454
  this.imagesAsking = new Set();
11416
11455
  this.imagesTimer = null;
11417
11456
  this.placesInteractive = false;
11457
+ // Whether a click on an Entity label is reported to the app instead of selecting the Entity.
11458
+ this.entitiesInteractive = false;
11459
+ // The Entity labels the app has picked, by group, drawn with the same glow as a picked place.
11460
+ this.selectedEntities = new Map();
11418
11461
  }
11419
11462
  notify() {
11420
11463
  try {
@@ -11617,6 +11660,42 @@ var EntityLabelGroup;
11617
11660
  }
11618
11661
  this.refresh(keys);
11619
11662
  }
11663
+ /*
11664
+ * Whether a click on an Entity label is reported to the app rather than selecting its Entity.
11665
+ */
11666
+ SetEntitiesInteractive(on) {
11667
+ if (this.entitiesInteractive === on) {
11668
+ return;
11669
+ }
11670
+ this.entitiesInteractive = on;
11671
+ const keys = new Set();
11672
+ for (const group of this.active.values()) {
11673
+ for (const [key, item] of group.items) {
11674
+ if (!item.placeId) {
11675
+ keys.add(key);
11676
+ }
11677
+ }
11678
+ }
11679
+ this.refresh(keys);
11680
+ }
11681
+ /*
11682
+ * Replaces which of a group's Entity labels glow as picked, redrawing only those that changed.
11683
+ */
11684
+ SetSelectedEntities(id, entityIds) {
11685
+ var _a;
11686
+ const before = (_a = this.selectedEntities.get(id)) !== null && _a !== void 0 ? _a : new Set();
11687
+ const after = new Set((entityIds !== null && entityIds !== void 0 ? entityIds : []).filter(key => typeof key === "string" && key && !IsPlaceKey(key)));
11688
+ const changed = new Set([...before, ...after].filter(key => before.has(key) !== after.has(key)));
11689
+ if (after.size) {
11690
+ this.selectedEntities.set(id, after);
11691
+ }
11692
+ else {
11693
+ this.selectedEntities.delete(id);
11694
+ }
11695
+ if (changed.size && this.active.has(id)) {
11696
+ this.refresh(changed);
11697
+ }
11698
+ }
11620
11699
  Get() {
11621
11700
  return Array.from(this.definitions.keys(), id => {
11622
11701
  var _a;
@@ -11667,7 +11746,7 @@ var EntityLabelGroup;
11667
11746
  * One member's label settings, with any image its own text links to but before its default image.
11668
11747
  */
11669
11748
  compose(group, entityId, menuItemId) {
11670
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
11749
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
11671
11750
  const item = group.items.get(entityId);
11672
11751
  const entity = (_a = item.entity) !== null && _a !== void 0 ? _a : { Bruce: { ID: entityId, Name: item.text } };
11673
11752
  let iconPriority = (_b = group.definition.options) === null || _b === void 0 ? void 0 : _b.iconPriority;
@@ -11718,6 +11797,20 @@ var EntityLabelGroup;
11718
11797
  iconPriority: Number.isFinite(iconPriority) ? iconPriority : item.iconPriority,
11719
11798
  iconStatus: (_p = resolveIcon((_o = group.definition.options) === null || _o === void 0 ? void 0 : _o.iconStatus, entity)) !== null && _p !== void 0 ? _p : item.iconStatus
11720
11799
  };
11800
+ // A prefixed icon names its kind and replaces the group's others; an unprefixed one stays the glyph it was.
11801
+ const named = ParseIcon(options.icon, (_q = this.register.ApiGetters) === null || _q === void 0 ? void 0 : _q.GetBruceApi());
11802
+ if (named) {
11803
+ options.icon = undefined;
11804
+ options.iconClass = named.iconClass;
11805
+ options.iconUrl = named.iconUrl;
11806
+ }
11807
+ if (!item.placeId && this.entitiesInteractive) {
11808
+ options.selectOnClick = true;
11809
+ options.reportClick = true;
11810
+ }
11811
+ if (!item.placeId && ((_r = this.selectedEntities.get(group.definition.id)) === null || _r === void 0 ? void 0 : _r.has(entityId))) {
11812
+ options.highlightColor = PLACE_SELECTED_COLOR;
11813
+ }
11721
11814
  if (item.placeId) {
11722
11815
  // Clickable only when the app asks, and reported then, as there is no Entity to select.
11723
11816
  options.selectOnClick = this.placesInteractive;
@@ -11728,16 +11821,19 @@ var EntityLabelGroup;
11728
11821
  options.iconUrl = look.iconUrl || undefined;
11729
11822
  options.iconClass = look.iconUrl ? undefined : look.iconClass;
11730
11823
  }
11731
- if (look === null || look === void 0 ? void 0 : look.iconColor) {
11732
- options.iconColor = look.iconColor;
11824
+ if ((look === null || look === void 0 ? void 0 : look.iconColor) != null) {
11825
+ options.iconColor = look.iconColor || undefined;
11733
11826
  }
11734
11827
  if ((look === null || look === void 0 ? void 0 : look.iconBackground) != null) {
11735
11828
  options.iconBackground = look.iconBackground;
11736
11829
  }
11830
+ if ((look === null || look === void 0 ? void 0 : look.iconScale) > 0) {
11831
+ options.iconScale = look.iconScale;
11832
+ }
11737
11833
  }
11738
11834
  if (options.attributes && item.entity && !(expression && resolvedText != null)) {
11739
11835
  options.text = [
11740
- (_s = (_q = options.text) !== null && _q !== void 0 ? _q : (_r = item.entity.Bruce) === null || _r === void 0 ? void 0 : _r.Name) !== null && _s !== void 0 ? _s : entityId,
11836
+ (_u = (_s = options.text) !== null && _s !== void 0 ? _s : (_t = item.entity.Bruce) === null || _t === void 0 ? void 0 : _t.Name) !== null && _u !== void 0 ? _u : entityId,
11741
11837
  ...options.attributes.map(path => Entity$1.GetValue({ entity: item.entity, path })).filter(value => value != null).map(String)
11742
11838
  ].join("\n");
11743
11839
  }
@@ -11899,6 +11995,7 @@ var EntityLabelGroup;
11899
11995
  Remove(id) {
11900
11996
  var _a;
11901
11997
  const known = this.definitions.delete(id);
11998
+ this.selectedEntities.delete(id);
11902
11999
  this.visibility.delete(id);
11903
12000
  this.errors.delete(id);
11904
12001
  (_a = this.pending.get(id)) === null || _a === void 0 ? void 0 : _a.abort();
@@ -11931,6 +12028,7 @@ var EntityLabelGroup;
11931
12028
  this.active.clear();
11932
12029
  this.members.clear();
11933
12030
  this.definitions.clear();
12031
+ this.selectedEntities.clear();
11934
12032
  this.visibility.clear();
11935
12033
  this.errors.clear();
11936
12034
  this.refresh(affected);
@@ -11950,6 +12048,7 @@ var EntityLabelGroup;
11950
12048
  this.active.clear();
11951
12049
  this.members.clear();
11952
12050
  this.definitions.clear();
12051
+ this.selectedEntities.clear();
11953
12052
  this.visibility.clear();
11954
12053
  this.errors.clear();
11955
12054
  }
@@ -13888,6 +13987,7 @@ var VisualsRegister;
13888
13987
  }
13889
13988
  get OnLabelGroupsChanged() { return this.labelGroupsChanged; }
13890
13989
  get OnLabelPlaceClick() { return this.labelPlaceClicked; }
13990
+ get OnLabelEntityClick() { return this.labelEntityClicked; }
13891
13991
  constructor(params) {
13892
13992
  var _a, _b, _c, _d, _e, _f, _g;
13893
13993
  this.id = ObjectUtils.UId();
@@ -13942,6 +14042,7 @@ var VisualsRegister;
13942
14042
  this.shadowsRemoval = null;
13943
14043
  this.labelGroupsChanged = new BruceEvent();
13944
14044
  this.labelPlaceClicked = new BruceEvent();
14045
+ this.labelEntityClicked = new BruceEvent();
13945
14046
  this.hoverRingState = {};
13946
14047
  this.retiringHoverLabels = new Map();
13947
14048
  /*
@@ -14942,6 +15043,7 @@ var VisualsRegister;
14942
15043
  (_c = this.labelGroups) === null || _c === void 0 ? void 0 : _c.Dispose();
14943
15044
  this.labelGroupsChanged.Clear();
14944
15045
  this.labelPlaceClicked.Clear();
15046
+ this.labelEntityClicked.Clear();
14945
15047
  for (const regos of Object.values(this.rego)) {
14946
15048
  for (const rego of regos)
14947
15049
  EntityLabel.Detatch({ rego, force: true });
@@ -16737,6 +16839,35 @@ var VisualsRegister;
16737
16839
  this.labelPlaceClicked.Trigger({ places, additive });
16738
16840
  }
16739
16841
  }
16842
+ /*
16843
+ * Whether Entity label clicks go to OnLabelEntityClick rather than selecting. Off by default.
16844
+ */
16845
+ SetLabelEntitiesInteractive(on) {
16846
+ if (this.disposed) {
16847
+ return;
16848
+ }
16849
+ if (!this.labelGroups) {
16850
+ this.labelGroups = new EntityLabelGroup.Manager(this, () => this.labelGroupsChanged.Trigger(undefined));
16851
+ }
16852
+ this.labelGroups.SetEntitiesInteractive(on);
16853
+ }
16854
+ /*
16855
+ * Called by a label clicked while Entity labels are interactive, with the Entities it stands for.
16856
+ */
16857
+ ClickLabelEntities(entityIds, additive) {
16858
+ const labels = entityIds.map(entityId => { var _a; return ({ groupId: (_a = this.GetLabelGroupFor(entityId)) === null || _a === void 0 ? void 0 : _a.groupId, entityId }); })
16859
+ .filter(label => label.groupId);
16860
+ if (labels.length) {
16861
+ this.labelEntityClicked.Trigger({ labels, additive });
16862
+ }
16863
+ }
16864
+ /*
16865
+ * Which of a group's Entity labels glow as picked by the app.
16866
+ */
16867
+ SetLabelGroupSelected(id, entityIds) {
16868
+ var _a;
16869
+ (_a = this.labelGroups) === null || _a === void 0 ? void 0 : _a.SetSelectedEntities(id, entityIds);
16870
+ }
16740
16871
  /*
16741
16872
  * Replaces a group's places without reading its source again. False when no such group was set.
16742
16873
  */
@@ -61029,7 +61160,7 @@ var StyleUtils;
61029
61160
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
61030
61161
  })(StyleUtils || (StyleUtils = {}));
61031
61162
 
61032
- const VERSION = "7.8.5";
61163
+ const VERSION = "7.8.7";
61033
61164
  /**
61034
61165
  * Updates the environment instance used by bruce-cesium to one specified.
61035
61166
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.