bruce-cesium 7.5.9 → 7.6.0

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.
@@ -7888,6 +7888,22 @@
7888
7888
  radius: Math.max(width, height) / 2
7889
7889
  };
7890
7890
  };
7891
+ /*
7892
+ * The on-screen centre and half-size of a model too small for its box, so the box is ringed like a glyph.
7893
+ */
7894
+ const measureModel = (anchor) => {
7895
+ const hull = layer.modelBoxes.Hull(this.id);
7896
+ if (!(hull === null || hull === void 0 ? void 0 : hull.length)) {
7897
+ return null;
7898
+ }
7899
+ const xs = hull.map(point => point.x), ys = hull.map(point => point.y);
7900
+ const left = Math.min(...xs), top = Math.min(...ys);
7901
+ const width = Math.max(...xs) - left, height = Math.max(...ys) - top;
7902
+ if (Math.max(width, height) >= MODEL_BOX_MIN_SIZE) {
7903
+ return null;
7904
+ }
7905
+ return { x: left + width / 2 - anchor.x, y: top + height / 2 - anchor.y, radius: Math.max(width, height) / 2 };
7906
+ };
7891
7907
  // Only CAD tilesets and model Entities are assembly parts with a geometry box; anything else stays a point.
7892
7908
  const boxable = Boolean(normalLeader && ((_r = this.rego) === null || _r === void 0 ? void 0 : _r.entityId) && ((visual instanceof Cesium.Cesium3DTileFeature && this.rego.tilesetType === BModels.Tileset.EType.Cad) ||
7893
7909
  (visual instanceof Cesium.Entity && Boolean(visual.model))));
@@ -7946,7 +7962,7 @@
7946
7962
  }
7947
7963
  let cursorMotion = this.cursorMotion;
7948
7964
  const project = () => {
7949
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
7965
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
7950
7966
  if (this.disposed || !this.viewer || this.viewer.isDestroyed() || ((_a = this.visible) === null || _a === void 0 ? void 0 : _a.call(this)) === false ||
7951
7967
  (presentation === "icon" && this.options.iconScale === 0)) {
7952
7968
  return null;
@@ -7989,7 +8005,8 @@
7989
8005
  const boxBlend = this.morphToBox(boxed, shownOnce ? (_f = (_e = this.options.anchorRing) === null || _e === void 0 ? void 0 : _e.transitionDuration) !== null && _f !== void 0 ? _f : 200 : 0);
7990
8006
  // Eased between the ring and where the stem meets the box, so gaining or losing a box never jumps.
7991
8007
  const boxTarget = this.boxMorph.anchor;
7992
- const ringPoint = { x: anchor.x + pixelOffset.x, y: anchor.y + pixelOffset.y };
8008
+ const model = ((_g = this.modelBox) === null || _g === void 0 ? void 0 : _g.corners) ? measureModel(anchor) : null;
8009
+ const ringPoint = { x: anchor.x + (model || pixelOffset).x, y: anchor.y + (model || pixelOffset).y };
7993
8010
  const boxAnchor = boxBlend > 0 && boxTarget ? {
7994
8011
  x: ringPoint.x + (boxTarget.x - ringPoint.x) * boxBlend,
7995
8012
  y: ringPoint.y + (boxTarget.y - ringPoint.y) * boxBlend
@@ -8000,13 +8017,13 @@
8000
8017
  return null;
8001
8018
  if (onScreen && !this.imageAsked && this.groupId && !HasIcon(this.options) && !this.options.photo) {
8002
8019
  this.imageAsked = true;
8003
- (_g = this.visualRegister) === null || _g === void 0 ? void 0 : _g.RequestLabelImage((_h = this.rego) === null || _h === void 0 ? void 0 : _h.entityId);
8020
+ (_h = this.visualRegister) === null || _h === void 0 ? void 0 : _h.RequestLabelImage((_j = this.rego) === null || _j === void 0 ? void 0 : _j.entityId);
8004
8021
  }
8005
8022
  const transientPivot = (this.Transient && !this.Persistent ?
8006
- (this.hoverFade.to === 0 ? this.retainedHoverPosition : (_j = this.visualRegister) === null || _j === void 0 ? void 0 : _j.GetLabelHoverPosition((_k = this.rego) === null || _k === void 0 ? void 0 : _k.entityId, (_l = this.rego) === null || _l === void 0 ? void 0 : _l.menuItemId)) : undefined);
8023
+ (this.hoverFade.to === 0 ? this.retainedHoverPosition : (_k = this.visualRegister) === null || _k === void 0 ? void 0 : _k.GetLabelHoverPosition((_l = this.rego) === null || _l === void 0 ? void 0 : _l.entityId, (_m = this.rego) === null || _m === void 0 ? void 0 : _m.menuItemId)) : undefined);
8007
8024
  const hover = (presentation !== "icon" ?
8008
8025
  (this.Transient && !this.Persistent && this.hoverFade.to === 0 ? this.retainedHoverPosition :
8009
- (_m = this.visualRegister) === null || _m === void 0 ? void 0 : _m.GetLabelHoverPosition((_o = this.rego) === null || _o === void 0 ? void 0 : _o.entityId, (_p = this.rego) === null || _p === void 0 ? void 0 : _p.menuItemId)) : undefined);
8026
+ (_o = this.visualRegister) === null || _o === void 0 ? void 0 : _o.GetLabelHoverPosition((_p = this.rego) === null || _p === void 0 ? void 0 : _p.entityId, (_q = this.rego) === null || _q === void 0 ? void 0 : _q.menuItemId)) : undefined);
8010
8027
  const reused = !this.Transient || this.Persistent;
8011
8028
  const now = Date.now();
8012
8029
  const animateCursor = () => {
@@ -8030,13 +8047,13 @@
8030
8047
  const cursorAmount = cursorMotion.amount;
8031
8048
  leader = normalLeader || cursorAmount > 0;
8032
8049
  // An icon keeps its callout centred on the glyph rather than following the cursor across it.
8033
- const icon = boxAnchor ? null : measureIcon();
8050
+ const icon = boxAnchor ? null : measureIcon() || model;
8034
8051
  const iconRing = icon ? Math.max(ICON_RING_MIN, icon.radius + ICON_RING_PADDING) : 0;
8035
8052
  // A boxed model is pinned the same way, with its stem leaving the top of the box outline.
8036
8053
  const pinned = Boolean(icon || boxAnchor);
8037
8054
  const pivot = pinned ? undefined : transientPivot;
8038
- let x = boxAnchor ? boxAnchor.x : ((_q = pivot === null || pivot === void 0 ? void 0 : pivot.x) !== null && _q !== void 0 ? _q : anchor.x) + (icon || pixelOffset).x;
8039
- let y = boxAnchor ? boxAnchor.y : ((_r = pivot === null || pivot === void 0 ? void 0 : pivot.y) !== null && _r !== void 0 ? _r : anchor.y) + (icon || pixelOffset).y;
8055
+ let x = boxAnchor ? boxAnchor.x : ((_r = pivot === null || pivot === void 0 ? void 0 : pivot.x) !== null && _r !== void 0 ? _r : anchor.x) + (icon || pixelOffset).x;
8056
+ let y = boxAnchor ? boxAnchor.y : ((_s = pivot === null || pivot === void 0 ? void 0 : pivot.y) !== null && _s !== void 0 ? _s : anchor.y) + (icon || pixelOffset).y;
8040
8057
  if (cursorAmount > 0 && !pinned) {
8041
8058
  // A leader-less label starts centred on its anchor; preserve that box as it lifts away.
8042
8059
  if (!normalLeader) {
@@ -8091,7 +8108,7 @@
8091
8108
  const width = ele.offsetWidth / coordinates.scaleX;
8092
8109
  const height = ele.offsetHeight / coordinates.scaleY;
8093
8110
  let clusterBounds;
8094
- if ((_s = this.options.cluster) === null || _s === void 0 ? void 0 : _s.enabled) {
8111
+ if ((_t = this.options.cluster) === null || _t === void 0 ? void 0 : _t.enabled) {
8095
8112
  const textWidth = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetWidth) || 0;
8096
8113
  const textHeight = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetHeight) || 0;
8097
8114
  // A photo is never part of the footprint, so its arrival cannot change which cluster a label joins.
@@ -8125,7 +8142,7 @@
8125
8142
  if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x > this.viewer.canvas.clientWidth || bounds.y > this.viewer.canvas.clientHeight)) {
8126
8143
  return null;
8127
8144
  }
8128
- const state = (_t = this.visualRegister) === null || _t === void 0 ? void 0 : _t.GetState({ entityId: (_u = this.rego) === null || _u === void 0 ? void 0 : _u.entityId, menuItemId: (_v = this.rego) === null || _v === void 0 ? void 0 : _v.menuItemId });
8145
+ const state = (_u = this.visualRegister) === null || _u === void 0 ? void 0 : _u.GetState({ entityId: (_v = this.rego) === null || _v === void 0 ? void 0 : _v.entityId, menuItemId: (_w = this.rego) === null || _w === void 0 ? void 0 : _w.menuItemId });
8129
8146
  const opacity = this.prePositioned || hoverOnly || MAX_DISTANCE === Infinity ? 1 : 1 - distance / MAX_DISTANCE;
8130
8147
  return {
8131
8148
  canFlip: leader && presentation !== "icon", hasLeader: leader,
@@ -8133,8 +8150,8 @@
8133
8150
  transient: this.Transient || Boolean(hover) || cursorAmount > 0,
8134
8151
  extendedGeometry: visual instanceof Cesium.Entity && Boolean(visual.polygon || visual.polyline || visual.corridor),
8135
8152
  viewportWidth: this.viewer.canvas.clientWidth,
8136
- id: this.id, entityKey: ((_w = this.rego) === null || _w === void 0 ? void 0 : _w.entityId) ? JSON.stringify([this.rego.entityId, this.rego.menuItemId || "", this.Transient && !this.Persistent ? "hover" : ""]) : undefined,
8137
- entityId: (_x = this.rego) === null || _x === void 0 ? void 0 : _x.entityId, group: this.groupId, x, y, width, height, anchorX, anchorY, depth, leaderLength, leaderRun, leaderSide, distance,
8153
+ id: this.id, entityKey: ((_x = this.rego) === null || _x === void 0 ? void 0 : _x.entityId) ? JSON.stringify([this.rego.entityId, this.rego.menuItemId || "", this.Transient && !this.Persistent ? "hover" : ""]) : undefined,
8154
+ entityId: (_y = this.rego) === null || _y === void 0 ? void 0 : _y.entityId, group: this.groupId, x, y, width, height, anchorX, anchorY, depth, leaderLength, leaderRun, leaderSide, distance,
8138
8155
  iconRadius: icon === null || icon === void 0 ? void 0 : icon.radius, modelBox: boxed || undefined, boxBlend,
8139
8156
  // Priority shows the hovered member individually without dragging its cluster along.
8140
8157
  opacity: waiting ? 0 : opacity, priority: hover || cursorAmount > 0 || (state === null || state === void 0 ? void 0 : state.highlighted) ? 1 : 0, options: this.options, text: originalText, clusterBounds
@@ -53256,7 +53273,7 @@ void main() {
53256
53273
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
53257
53274
  })(exports.StyleUtils || (exports.StyleUtils = {}));
53258
53275
 
53259
- const VERSION = "7.5.9";
53276
+ const VERSION = "7.6.0";
53260
53277
  /**
53261
53278
  * Updates the environment instance used by bruce-cesium to one specified.
53262
53279
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.