bruce-cesium 7.8.2 → 7.8.4

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.
@@ -9660,8 +9660,18 @@
9660
9660
  if (!selectOnClick || this.disposed || this.counter !== counter || !clickEntityIds.length || !this.visualRegister) {
9661
9661
  return;
9662
9662
  }
9663
+ // A group's places name no Entity to select, so the app is told about them instead.
9664
+ const places = clickEntityIds.filter(id => { var _a, _b; return (_b = (_a = this.visualRegister.GetLabelGroupFor(id)) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.placeId; });
9665
+ if (places.length) {
9666
+ const keys = event;
9667
+ this.visualRegister.ClickLabelPlaces(places, Boolean(keys.ctrlKey || keys.metaKey || keys.shiftKey));
9668
+ }
9669
+ const entityIds = clickEntityIds.filter(id => !places.includes(id));
9670
+ if (!entityIds.length) {
9671
+ return;
9672
+ }
9663
9673
  this.visualRegister.ClearSelected({ requestRender: false });
9664
- this.visualRegister.SetSelected({ entityIds: clickEntityIds, selected: true });
9674
+ this.visualRegister.SetSelected({ entityIds, selected: true });
9665
9675
  };
9666
9676
  const makeClickable = (target) => {
9667
9677
  if (!selectOnClick || !this.visualRegister) {
@@ -9835,6 +9845,9 @@
9835
9845
  ele.style.width = "max-content";
9836
9846
  layer.element.appendChild(ele);
9837
9847
  }
9848
+ // Follows the drawn shape, so a pin glows as a pin rather than as its box.
9849
+ const glow = this.options.highlightColor;
9850
+ ele.style.filter = glow ? `drop-shadow(0 0 1.5px ${glow}) drop-shadow(0 0 1.5px ${glow}) drop-shadow(0 0 4px ${glow})` : "";
9838
9851
  if (this.line) {
9839
9852
  lineEle = this.line;
9840
9853
  runEle = this.leaderRun;
@@ -11159,6 +11172,39 @@
11159
11172
  })(exports.EntityLabel || (exports.EntityLabel = {}));
11160
11173
 
11161
11174
  (function (EntityLabelGroup) {
11175
+ // The glow a selected place is drawn with.
11176
+ const PLACE_SELECTED_COLOR = "#33B1FF";
11177
+ // Keys places share the entity bookkeeping under, scoped to their group so a copied group keeps its own.
11178
+ const PLACE_KEY_PREFIX = "place:";
11179
+ function GetPlaceKey(groupId, placeId) {
11180
+ return `${PLACE_KEY_PREFIX}${groupId}:${placeId}`;
11181
+ }
11182
+ EntityLabelGroup.GetPlaceKey = GetPlaceKey;
11183
+ function IsPlaceKey(key) {
11184
+ return typeof key === "string" && key.startsWith(PLACE_KEY_PREFIX);
11185
+ }
11186
+ EntityLabelGroup.IsPlaceKey = IsPlaceKey;
11187
+ /*
11188
+ * A group's places as label items, leaving out any without an id or a position on the globe.
11189
+ */
11190
+ function FromPlaces(groupId, places) {
11191
+ return (Array.isArray(places) ? places : []).filter(place => {
11192
+ var _a;
11193
+ return typeof (place === null || place === void 0 ? void 0 : place.id) === "string" && place.id &&
11194
+ [place.longitude, place.latitude, (_a = place.altitude) !== null && _a !== void 0 ? _a : 0].every(Number.isFinite) &&
11195
+ Math.abs(place.latitude) <= 90;
11196
+ }).map(place => ({
11197
+ entityId: GetPlaceKey(groupId, place.id),
11198
+ placeId: place.id,
11199
+ text: place.text,
11200
+ longitude: place.longitude,
11201
+ latitude: place.latitude,
11202
+ altitude: place.altitude,
11203
+ look: place.look,
11204
+ selected: place.selected || undefined
11205
+ }));
11206
+ }
11207
+ EntityLabelGroup.FromPlaces = FromPlaces;
11162
11208
  /*
11163
11209
  * Keeps the query response useful even when the Entity has no loaded visual yet.
11164
11210
  * An Assembly part is placed from its record when shown (Manager.RefreshEntity); Location is its fallback.
@@ -11348,6 +11394,7 @@
11348
11394
  this.imagesQueued = new Set();
11349
11395
  this.imagesAsking = new Set();
11350
11396
  this.imagesTimer = null;
11397
+ this.placesInteractive = false;
11351
11398
  }
11352
11399
  notify() {
11353
11400
  try {
@@ -11375,7 +11422,7 @@
11375
11422
  return true;
11376
11423
  }
11377
11424
  async Set(definition) {
11378
- var _a, _b, _c, _d, _e, _f, _g, _h;
11425
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
11379
11426
  if (!(definition === null || definition === void 0 ? void 0 : definition.id) || !definition.source) {
11380
11427
  throw new Error("Label group requires id and source");
11381
11428
  }
@@ -11397,7 +11444,7 @@
11397
11444
  }
11398
11445
  this.errors.delete(definition.id);
11399
11446
  this.notify();
11400
- const cancelled = () => ({ id: definition.id, entityIds: [], truncated: false, cancelled: true });
11447
+ const cancelled = () => ({ id: definition.id, entityIds: [], placeIds: [], truncated: false, cancelled: true });
11401
11448
  const items = new Map();
11402
11449
  let truncated = false;
11403
11450
  try {
@@ -11439,6 +11486,11 @@
11439
11486
  }
11440
11487
  offset = next;
11441
11488
  }
11489
+ // Placed by hand, so outside maxItems; read again as SetPlaces may change them during the load.
11490
+ definition = (_j = this.definitions.get(definition.id)) !== null && _j !== void 0 ? _j : definition;
11491
+ for (const place of FromPlaces(definition.id, definition.places)) {
11492
+ items.set(place.entityId, place);
11493
+ }
11442
11494
  const previous = this.active.get(definition.id);
11443
11495
  const affected = new Set([...((previous === null || previous === void 0 ? void 0 : previous.items.keys()) || []), ...items.keys()]);
11444
11496
  this.unindex(definition.id);
@@ -11452,7 +11504,7 @@
11452
11504
  this.members.get(id).add(definition.id);
11453
11505
  }
11454
11506
  this.refresh(affected);
11455
- return { id: definition.id, entityIds: Array.from(items.keys()), truncated, cancelled: false };
11507
+ return { id: definition.id, ...splitKeys(items), truncated, cancelled: false };
11456
11508
  }
11457
11509
  catch (error) {
11458
11510
  if (controller.signal.aborted || this.register.Disposed) {
@@ -11468,13 +11520,90 @@
11468
11520
  }
11469
11521
  }
11470
11522
  }
11523
+ /*
11524
+ * Replaces a group's places without reading its source again, redrawing only the places that changed.
11525
+ */
11526
+ SetPlaces(id, places) {
11527
+ var _a, _b;
11528
+ const definition = this.definitions.get(id);
11529
+ if (!definition) {
11530
+ return false;
11531
+ }
11532
+ this.definitions.set(id, { ...definition, places: copyOptions(places) });
11533
+ const group = this.active.get(id);
11534
+ if (!group) {
11535
+ // Still loading, and Set takes them from the definition when it commits.
11536
+ return true;
11537
+ }
11538
+ group.definition = this.definitions.get(id);
11539
+ const next = new Map(FromPlaces(id, places).map(item => [item.entityId, item]));
11540
+ const changed = new Set();
11541
+ for (const [key, item] of group.items) {
11542
+ if (item.placeId && JSON.stringify(item) !== JSON.stringify(next.get(key))) {
11543
+ changed.add(key);
11544
+ }
11545
+ }
11546
+ for (const [key, item] of next) {
11547
+ if (JSON.stringify(item) !== JSON.stringify(group.items.get(key))) {
11548
+ changed.add(key);
11549
+ }
11550
+ }
11551
+ if (!changed.size) {
11552
+ return true;
11553
+ }
11554
+ for (const key of changed) {
11555
+ const item = next.get(key);
11556
+ if (item) {
11557
+ group.items.set(key, item);
11558
+ if (!this.members.has(key)) {
11559
+ this.members.set(key, new Set());
11560
+ }
11561
+ this.members.get(key).add(id);
11562
+ }
11563
+ else {
11564
+ group.items.delete(key);
11565
+ (_a = this.members.get(key)) === null || _a === void 0 ? void 0 : _a.delete(id);
11566
+ if (!((_b = this.members.get(key)) === null || _b === void 0 ? void 0 : _b.size)) {
11567
+ this.members.delete(key);
11568
+ }
11569
+ }
11570
+ }
11571
+ // A place that stays where it is takes its new look in place, so a highlight or a colour never flickers it.
11572
+ const moved = new Set([...changed].filter(key => !SameSpot(this.standaloneItems.get(key), group.items.get(key))));
11573
+ this.refresh(moved);
11574
+ for (const key of changed) {
11575
+ if (!moved.has(key)) {
11576
+ this.RefreshEntity(key);
11577
+ }
11578
+ }
11579
+ this.notify();
11580
+ return true;
11581
+ }
11582
+ /*
11583
+ * Whether a click on a place is reported to the app, as it is while the app lets its markup be edited.
11584
+ */
11585
+ SetPlacesInteractive(on) {
11586
+ if (this.placesInteractive === on) {
11587
+ return;
11588
+ }
11589
+ this.placesInteractive = on;
11590
+ const keys = new Set();
11591
+ for (const group of this.active.values()) {
11592
+ for (const [key, item] of group.items) {
11593
+ if (item.placeId) {
11594
+ keys.add(key);
11595
+ }
11596
+ }
11597
+ }
11598
+ this.refresh(keys);
11599
+ }
11471
11600
  Get() {
11472
11601
  return Array.from(this.definitions.keys(), id => {
11473
11602
  var _a;
11474
11603
  const group = this.active.get(id);
11475
11604
  return {
11476
11605
  id,
11477
- entityIds: Array.from((group === null || group === void 0 ? void 0 : group.items.keys()) || []),
11606
+ ...splitKeys(group === null || group === void 0 ? void 0 : group.items),
11478
11607
  truncated: (_a = group === null || group === void 0 ? void 0 : group.truncated) !== null && _a !== void 0 ? _a : false,
11479
11608
  cancelled: false,
11480
11609
  visible: this.visibility.get(id) !== false,
@@ -11493,21 +11622,22 @@
11493
11622
  return false;
11494
11623
  }
11495
11624
  Resolve(entityId, menuItemId) {
11496
- var _a, _b, _c, _d, _e;
11625
+ var _a, _b, _c, _d, _e, _f;
11497
11626
  const ids = Array.from(this.members.get(entityId) || []).reverse();
11498
11627
  for (const id of ids) {
11499
11628
  const group = this.active.get(id);
11500
11629
  if (this.visibility.get(id) === false) {
11501
11630
  continue;
11502
11631
  }
11503
- if (group.definition.menuItemId && group.definition.menuItemId !== menuItemId) {
11632
+ // A place belongs to its group alone, never to a menu item's Entities.
11633
+ if (group.definition.menuItemId && group.definition.menuItemId !== menuItemId && !((_a = group.items.get(entityId)) === null || _a === void 0 ? void 0 : _a.placeId)) {
11504
11634
  continue;
11505
11635
  }
11506
11636
  const options = this.compose(group, entityId, menuItemId);
11507
11637
  const item = group.items.get(entityId);
11508
- const image = (_a = this.images.get(entityId)) !== null && _a !== void 0 ? _a : (Array.isArray((_c = (_b = item.entity) === null || _b === void 0 ? void 0 : _b.Bruce) === null || _c === void 0 ? void 0 : _c.Attachment) ? exports.EntityLabel.GetDefaultImageUrl(item.entity, (_d = this.register.ApiGetters) === null || _d === void 0 ? void 0 : _d.GetBruceApi()) : null);
11638
+ const image = (_b = this.images.get(entityId)) !== null && _b !== void 0 ? _b : (Array.isArray((_d = (_c = item.entity) === null || _c === void 0 ? void 0 : _c.Bruce) === null || _d === void 0 ? void 0 : _d.Attachment) ? exports.EntityLabel.GetDefaultImageUrl(item.entity, (_e = this.register.ApiGetters) === null || _e === void 0 ? void 0 : _e.GetBruceApi()) : null);
11509
11639
  if (image && !exports.EntityLabel.HasIcon(options)) {
11510
- (_e = options.photo) !== null && _e !== void 0 ? _e : (options.photo = image);
11640
+ (_f = options.photo) !== null && _f !== void 0 ? _f : (options.photo = image);
11511
11641
  }
11512
11642
  return { groupId: id, options, item };
11513
11643
  }
@@ -11517,7 +11647,7 @@
11517
11647
  * One member's label settings, with any image its own text links to but before its default image.
11518
11648
  */
11519
11649
  compose(group, entityId, menuItemId) {
11520
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
11650
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
11521
11651
  const item = group.items.get(entityId);
11522
11652
  const entity = (_a = item.entity) !== null && _a !== void 0 ? _a : { Bruce: { ID: entityId, Name: item.text } };
11523
11653
  let iconPriority = (_b = group.definition.options) === null || _b === void 0 ? void 0 : _b.iconPriority;
@@ -11552,21 +11682,42 @@
11552
11682
  }
11553
11683
  const fallbackText = [item.text, (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e.Name, (_f = this.register.GetRego({ entityId, menuItemId })) === null || _f === void 0 ? void 0 : _f.name, entityId]
11554
11684
  .find(text => typeof text === "string" && text.trim().length > 0);
11685
+ if (item.placeId) {
11686
+ // A place says what it was given: its key is no name, and an expression has no record to read.
11687
+ resolvedText = (_g = item.text) !== null && _g !== void 0 ? _g : "";
11688
+ }
11555
11689
  const options = {
11556
11690
  ...group.definition.options,
11557
11691
  text: resolvedText !== null && resolvedText !== void 0 ? resolvedText : fallbackText,
11558
11692
  iconScale: iconScale,
11559
- icon: resolveIcon((_g = group.definition.options) === null || _g === void 0 ? void 0 : _g.icon, entity),
11560
- iconUrl: resolveIcon((_h = group.definition.options) === null || _h === void 0 ? void 0 : _h.iconUrl, entity),
11561
- iconClass: resolveIcon((_j = group.definition.options) === null || _j === void 0 ? void 0 : _j.iconClass, entity),
11562
- iconColor: resolveIcon((_k = group.definition.options) === null || _k === void 0 ? void 0 : _k.iconColor, entity),
11563
- iconBackground: resolveBackground((_l = group.definition.options) === null || _l === void 0 ? void 0 : _l.iconBackground, entity),
11693
+ icon: resolveIcon((_h = group.definition.options) === null || _h === void 0 ? void 0 : _h.icon, entity),
11694
+ iconUrl: resolveIcon((_j = group.definition.options) === null || _j === void 0 ? void 0 : _j.iconUrl, entity),
11695
+ iconClass: resolveIcon((_k = group.definition.options) === null || _k === void 0 ? void 0 : _k.iconClass, entity),
11696
+ iconColor: resolveIcon((_l = group.definition.options) === null || _l === void 0 ? void 0 : _l.iconColor, entity),
11697
+ iconBackground: resolveBackground((_m = group.definition.options) === null || _m === void 0 ? void 0 : _m.iconBackground, entity),
11564
11698
  iconPriority: Number.isFinite(iconPriority) ? iconPriority : item.iconPriority,
11565
- iconStatus: (_o = resolveIcon((_m = group.definition.options) === null || _m === void 0 ? void 0 : _m.iconStatus, entity)) !== null && _o !== void 0 ? _o : item.iconStatus
11699
+ iconStatus: (_p = resolveIcon((_o = group.definition.options) === null || _o === void 0 ? void 0 : _o.iconStatus, entity)) !== null && _p !== void 0 ? _p : item.iconStatus
11566
11700
  };
11701
+ if (item.placeId) {
11702
+ // Clickable only when the app asks, and reported then, as there is no Entity to select.
11703
+ options.selectOnClick = this.placesInteractive;
11704
+ options.highlightColor = item.selected ? PLACE_SELECTED_COLOR : undefined;
11705
+ const look = item.look;
11706
+ if ((look === null || look === void 0 ? void 0 : look.iconUrl) || (look === null || look === void 0 ? void 0 : look.iconClass)) {
11707
+ options.icon = undefined;
11708
+ options.iconUrl = look.iconUrl || undefined;
11709
+ options.iconClass = look.iconUrl ? undefined : look.iconClass;
11710
+ }
11711
+ if (look === null || look === void 0 ? void 0 : look.iconColor) {
11712
+ options.iconColor = look.iconColor;
11713
+ }
11714
+ if ((look === null || look === void 0 ? void 0 : look.iconBackground) != null) {
11715
+ options.iconBackground = look.iconBackground;
11716
+ }
11717
+ }
11567
11718
  if (options.attributes && item.entity && !(expression && resolvedText != null)) {
11568
11719
  options.text = [
11569
- (_r = (_p = options.text) !== null && _p !== void 0 ? _p : (_q = item.entity.Bruce) === null || _q === void 0 ? void 0 : _q.Name) !== null && _r !== void 0 ? _r : entityId,
11720
+ (_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,
11570
11721
  ...options.attributes.map(path => BModels.Entity.GetValue({ entity: item.entity, path })).filter(value => value != null).map(String)
11571
11722
  ].join("\n");
11572
11723
  }
@@ -11588,7 +11739,7 @@
11588
11739
  RequestImage(entityId) {
11589
11740
  var _a, _b, _c, _d, _e, _f;
11590
11741
  const api = (_a = this.register.ApiGetters) === null || _a === void 0 ? void 0 : _a.GetBruceApi();
11591
- if (!api || !entityId || this.images.has(entityId) || this.imagesAsking.has(entityId)) {
11742
+ if (!api || !entityId || IsPlaceKey(entityId) || this.images.has(entityId) || this.imagesAsking.has(entityId)) {
11592
11743
  return;
11593
11744
  }
11594
11745
  // Members read with their attachments already know their image, or that they have none.
@@ -11647,8 +11798,9 @@
11647
11798
  var _a, _b, _c, _d, _e, _f, _g, _h;
11648
11799
  const match = this.Resolve(entityId);
11649
11800
  const registered = this.register.GetRego({ entityId });
11650
- if (!registered && match && this.standalone.has(entityId) && this.standaloneItems.get(entityId) === match.item) {
11801
+ if (!registered && match && this.standalone.has(entityId) && SameSpot(this.standaloneItems.get(entityId), match.item)) {
11651
11802
  this.standalone.get(entityId).Configure({ ...match.options, text: (_b = (_a = match.options.text) !== null && _a !== void 0 ? _a : match.item.text) !== null && _b !== void 0 ? _b : entityId }, match.groupId);
11803
+ this.standaloneItems.set(entityId, match.item);
11652
11804
  return;
11653
11805
  }
11654
11806
  (_c = this.standalone.get(entityId)) === null || _c === void 0 ? void 0 : _c.Dispose();
@@ -11661,7 +11813,7 @@
11661
11813
  return;
11662
11814
  }
11663
11815
  const item = match.item;
11664
- const position = (_d = this.assemblyPosition(item.entity)) !== null && _d !== void 0 ? _d : ([item.longitude, item.latitude, (_e = item.altitude) !== null && _e !== void 0 ? _e : 0].every(Number.isFinite) && Math.abs(item.latitude) <= 90
11816
+ const position = (_d = (item.placeId ? null : this.assemblyPosition(item.entity))) !== null && _d !== void 0 ? _d : ([item.longitude, item.latitude, (_e = item.altitude) !== null && _e !== void 0 ? _e : 0].every(Number.isFinite) && Math.abs(item.latitude) <= 90
11665
11817
  ? Cesium.Cartesian3.fromDegrees(item.longitude, item.latitude, item.altitude || 0)
11666
11818
  : null);
11667
11819
  if (!position) {
@@ -11679,6 +11831,10 @@
11679
11831
  options: { ...match.options, text: (_h = (_g = match.options.text) !== null && _g !== void 0 ? _g : item.text) !== null && _h !== void 0 ? _h : entityId },
11680
11832
  groupId: match.groupId,
11681
11833
  visible: () => {
11834
+ // A place is markup, which isolating Entities leaves alone.
11835
+ if (item.placeId) {
11836
+ return true;
11837
+ }
11682
11838
  const state = this.register.GetState({ entityId });
11683
11839
  return !state.hidden && (!this.register.GetIsIsolatedAny() || state.isolated || this.register.GetIsolationOpacity() != null);
11684
11840
  }
@@ -11802,11 +11958,49 @@
11802
11958
  this.standalone.delete(id);
11803
11959
  this.standaloneItems.delete(id);
11804
11960
  }
11805
- this.register.ForceUpdate({ entityIds: Array.from(ids) });
11961
+ const all = Array.from(ids);
11962
+ this.register.ForceUpdate({ entityIds: all.filter(id => !IsPlaceKey(id)) });
11963
+ // Places skip the register, whose update events would announce them to the app as Entities.
11964
+ for (const id of all.filter(IsPlaceKey)) {
11965
+ this.RefreshEntity(id);
11966
+ }
11806
11967
  this.register.Viewer.scene.requestRender();
11807
11968
  }
11808
11969
  }
11809
11970
  EntityLabelGroup.Manager = Manager;
11971
+ /*
11972
+ * Whether a standalone label already drawn for one item can be reconfigured for the other rather than drawn again.
11973
+ */
11974
+ function SameSpot(drawn, item) {
11975
+ var _a, _b;
11976
+ if (!drawn || !item) {
11977
+ return false;
11978
+ }
11979
+ if (drawn === item) {
11980
+ return true;
11981
+ }
11982
+ return Boolean(drawn.placeId &&
11983
+ drawn.placeId === item.placeId &&
11984
+ drawn.longitude === item.longitude &&
11985
+ drawn.latitude === item.latitude &&
11986
+ ((_a = drawn.altitude) !== null && _a !== void 0 ? _a : 0) === ((_b = item.altitude) !== null && _b !== void 0 ? _b : 0));
11987
+ }
11988
+ /*
11989
+ * A group's members split into the Entities it labels and the ids of its places.
11990
+ */
11991
+ function splitKeys(items) {
11992
+ const entityIds = [];
11993
+ const placeIds = [];
11994
+ for (const [key, item] of items !== null && items !== void 0 ? items : []) {
11995
+ if (item.placeId) {
11996
+ placeIds.push(item.placeId);
11997
+ }
11998
+ else {
11999
+ entityIds.push(key);
12000
+ }
12001
+ }
12002
+ return { entityIds, placeIds };
12003
+ }
11810
12004
  /*
11811
12005
  * Rejects invalid geometry settings before they can create unbounded spatial-index work.
11812
12006
  */
@@ -13668,6 +13862,7 @@
13668
13862
  return this.onStyleChange;
13669
13863
  }
13670
13864
  get OnLabelGroupsChanged() { return this.labelGroupsChanged; }
13865
+ get OnLabelPlaceClick() { return this.labelPlaceClicked; }
13671
13866
  constructor(params) {
13672
13867
  var _a, _b, _c, _d, _e, _f, _g;
13673
13868
  this.id = BModels.ObjectUtils.UId();
@@ -13721,6 +13916,7 @@
13721
13916
  this.simulationRemoval = null;
13722
13917
  this.shadowsRemoval = null;
13723
13918
  this.labelGroupsChanged = new BModels.BruceEvent();
13919
+ this.labelPlaceClicked = new BModels.BruceEvent();
13724
13920
  this.hoverRingState = {};
13725
13921
  this.retiringHoverLabels = new Map();
13726
13922
  /*
@@ -14720,6 +14916,7 @@
14720
14916
  this.retiringHoverLabels.clear();
14721
14917
  (_c = this.labelGroups) === null || _c === void 0 ? void 0 : _c.Dispose();
14722
14918
  this.labelGroupsChanged.Clear();
14919
+ this.labelPlaceClicked.Clear();
14723
14920
  for (const regos of Object.values(this.rego)) {
14724
14921
  for (const rego of regos)
14725
14922
  exports.EntityLabel.Detatch({ rego, force: true });
@@ -16493,6 +16690,35 @@
16493
16690
  }
16494
16691
  return (_b = (_a = this.labelGroups) === null || _a === void 0 ? void 0 : _a.Refresh(id)) !== null && _b !== void 0 ? _b : Promise.reject(new Error(`Unknown label group: ${id}`));
16495
16692
  }
16693
+ /*
16694
+ * Whether clicks on label group places are reported through OnLabelPlaceClick. Off by default.
16695
+ */
16696
+ SetLabelPlacesInteractive(on) {
16697
+ if (this.disposed) {
16698
+ return;
16699
+ }
16700
+ if (!this.labelGroups) {
16701
+ this.labelGroups = new exports.EntityLabelGroup.Manager(this, () => this.labelGroupsChanged.Trigger(undefined));
16702
+ }
16703
+ this.labelGroups.SetPlacesInteractive(on);
16704
+ }
16705
+ /*
16706
+ * Called by a label clicked while places are interactive, with the place keys it stands for.
16707
+ */
16708
+ ClickLabelPlaces(keys, additive) {
16709
+ const places = keys.map(key => { var _a, _b, _c; return ({ groupId: (_a = this.GetLabelGroupFor(key)) === null || _a === void 0 ? void 0 : _a.groupId, placeId: (_c = (_b = this.GetLabelGroupFor(key)) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.placeId }); })
16710
+ .filter(place => place.groupId && place.placeId);
16711
+ if (places.length) {
16712
+ this.labelPlaceClicked.Trigger({ places, additive });
16713
+ }
16714
+ }
16715
+ /*
16716
+ * Replaces a group's places without reading its source again. False when no such group was set.
16717
+ */
16718
+ SetLabelGroupPlaces(id, places) {
16719
+ var _a, _b;
16720
+ return (_b = (_a = this.labelGroups) === null || _a === void 0 ? void 0 : _a.SetPlaces(id, places)) !== null && _b !== void 0 ? _b : false;
16721
+ }
16496
16722
  SetLabelGroupVisible(id, visible) {
16497
16723
  var _a, _b;
16498
16724
  return (_b = (_a = this.labelGroups) === null || _a === void 0 ? void 0 : _a.SetVisible(id, visible)) !== null && _b !== void 0 ? _b : false;
@@ -50359,6 +50585,21 @@
50359
50585
  });
50360
50586
  }
50361
50587
  EntityUtils.GetOpacity = GetOpacity;
50588
+ // How far under the surface the camera stays when the ground would hide a buried target.
50589
+ const FLY_TO_UNDERGROUND_CLEARANCE = 0.5;
50590
+ // How far a target's top must sit under the ground to count as buried, past terrain sampling error.
50591
+ const FLY_TO_BURIED_TOLERANCE = 1;
50592
+ /*
50593
+ * The camera's height for a fly-to. A buried target keeps the camera near it, not over the ground.
50594
+ */
50595
+ function GetFlyToCameraHeight(targetHeight, radius, lift, groundHeight, groundOccludes) {
50596
+ const height = targetHeight + lift;
50597
+ if (!(targetHeight + (radius || 0) < groundHeight - FLY_TO_BURIED_TOLERANCE)) {
50598
+ return height < groundHeight ? groundHeight + lift : height;
50599
+ }
50600
+ return groundOccludes ? Math.min(height, groundHeight - FLY_TO_UNDERGROUND_CLEARANCE) : height;
50601
+ }
50602
+ EntityUtils.GetFlyToCameraHeight = GetFlyToCameraHeight;
50362
50603
  async function FlyTo(params) {
50363
50604
  var _a, _b;
50364
50605
  let { entityIds, entities, tileset } = params;
@@ -50402,6 +50643,8 @@
50402
50643
  }
50403
50644
  let destination = null;
50404
50645
  let range = 10;
50646
+ // How big the target is, which tells a buried target from one that reaches the surface.
50647
+ let radius = 0;
50405
50648
  const ENTITY_ID = "FLY_TO_ENTITY";
50406
50649
  if (params.debug) {
50407
50650
  params.viewer.entities.removeById(ENTITY_ID);
@@ -50411,6 +50654,7 @@
50411
50654
  location.sphere.radius = 1;
50412
50655
  }
50413
50656
  destination = location.sphere.center;
50657
+ radius = location.sphere.radius;
50414
50658
  range = location.sphere.radius * 3;
50415
50659
  if (params.debug) {
50416
50660
  params.viewer.entities.add({
@@ -50486,13 +50730,20 @@
50486
50730
  // We'll account for range and the terrain height to give an OK starting point.
50487
50731
  let elevatedPos3d = destination.clone();
50488
50732
  const carto = Cesium.Cartographic.fromCartesian(destination);
50489
- carto.height += range;
50490
50733
  const { height: terrHeight } = await exports.DrawingUtils.GetTerrainHeight({
50491
50734
  pos3d: destination,
50492
50735
  viewer: params.viewer
50493
50736
  });
50494
- if (carto.height < terrHeight) {
50495
- carto.height = terrHeight + range;
50737
+ if (is2d) {
50738
+ carto.height += range;
50739
+ if (carto.height < terrHeight) {
50740
+ carto.height = terrHeight + range;
50741
+ }
50742
+ }
50743
+ else {
50744
+ const globe = params.viewer.scene.globe;
50745
+ const groundOccludes = Boolean((globe === null || globe === void 0 ? void 0 : globe.show) && globe.depthTestAgainstTerrain);
50746
+ carto.height = GetFlyToCameraHeight(carto.height, radius, range, terrHeight, groundOccludes);
50496
50747
  }
50497
50748
  elevatedPos3d = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height);
50498
50749
  // If we're working with a cartes3 we can adjust it so the camera is looking from the side at the position.
@@ -60609,7 +60860,7 @@ void main() {
60609
60860
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60610
60861
  })(exports.StyleUtils || (exports.StyleUtils = {}));
60611
60862
 
60612
- const VERSION = "7.8.2";
60863
+ const VERSION = "7.8.4";
60613
60864
  /**
60614
60865
  * Updates the environment instance used by bruce-cesium to one specified.
60615
60866
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.