bruce-cesium 7.7.9 → 7.8.1

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, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, 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, JulianDate, Quaternion, HeadingPitchRoll, ColorBlendMode, Model, ClassificationType, HorizontalOrigin, VerticalOrigin, ArcType, CornerType, SceneMode, IntersectionTests, Ray, SceneTransforms, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, OrthographicFrustum, EasingFunction, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ShadowMode, CustomDataSource, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, 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, Api, Geometry as Geometry$1, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, ZoomControl, ProjectView, ProjectViewBookmark, EntityRelation, BruceApi, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, Cartesian3, Model, ClassificationType, Matrix4, JulianDate, Quaternion, ArcType, CornerType, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, Cartesian2, Cartesian4, SceneMode, Ellipsoid, IntersectionTests, Ray, SceneTransforms, ShaderSource, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Intersect, WebGLConstants, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CesiumInspector, ClockRange, ShadowMode, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, Event, GeometryInstance, CustomDataSource, 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, Api, Bounds, ClientFileValueMap, Color as Color$1, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, BruceApi, EntityRelation, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, ProjectViewBookmarkGroup, EntityAttachment, EntityAttribute, MathUtils } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -7237,6 +7237,10 @@ var EntityLabel;
7237
7237
  const ICON_STACK_SCALE = 0.6;
7238
7238
  // How far an angled leader runs sideways before the label starts.
7239
7239
  const ANGLED_LEADER_RUN = 28;
7240
+ // How far a pin's white body reaches past the icon it wraps, before its tip.
7241
+ const PIN_RIM = 7;
7242
+ // A pin is drawn in one fixed look for now: a white body with a faint edge and a soft shadow.
7243
+ const PIN_COLOR = "#ffffff";
7240
7244
  // Clearance between a point or billboard glyph and the ring drawn around it.
7241
7245
  const ICON_RING_PADDING = 4;
7242
7246
  // Small points still get a ring as large as the default near ring.
@@ -7640,6 +7644,42 @@ var EntityLabel;
7640
7644
  * Prefer declared semantics; only infers from recognisable glyphs and filename tokens, never image pixels.
7641
7645
  */
7642
7646
  EntityLabel.IconPriority = GetClusterIconPriority;
7647
+ /*
7648
+ * The glyph and chip colours an icon draws with: each given one as is, a missing one inferred from the other.
7649
+ */
7650
+ function IconColors(options) {
7651
+ var _a;
7652
+ const icon = typeof options.iconColor === "string" && options.iconColor ? options.iconColor : undefined;
7653
+ const background = typeof options.iconBackground === "string" && options.iconBackground.trim() ? options.iconBackground : undefined;
7654
+ if (background) {
7655
+ return { icon: icon !== null && icon !== void 0 ? icon : contrasting(background, 1), background };
7656
+ }
7657
+ if (options.iconBackground === true) {
7658
+ return { icon, background: (_a = contrasting(icon, ICON_BACKGROUND_ALPHA)) !== null && _a !== void 0 ? _a : contrasting("white", ICON_BACKGROUND_ALPHA) };
7659
+ }
7660
+ return { icon };
7661
+ }
7662
+ EntityLabel.IconColors = IconColors;
7663
+ /*
7664
+ * A light colour darkened, or a dark one brightened, far enough to read against it.
7665
+ */
7666
+ function contrasting(css, alpha) {
7667
+ const color = css ? Color.fromCssColorString(css) : undefined;
7668
+ if (!color) {
7669
+ return undefined;
7670
+ }
7671
+ const luminance = 0.2126 * color.red + 0.7152 * color.green + 0.0722 * color.blue;
7672
+ const shade = luminance > 0.5 ?
7673
+ color.darken(ICON_BACKGROUND_BLEND, new Color()) :
7674
+ color.brighten(ICON_BACKGROUND_BLEND, new Color());
7675
+ return shade.withAlpha(alpha).toCssColorString();
7676
+ }
7677
+ /*
7678
+ * An icon's look on a pin: one with no chip of its own takes the pin's colour, which its glyph then contrasts with.
7679
+ */
7680
+ function pinLook(look) {
7681
+ return look.iconBackground ? look : { ...look, iconBackground: PIN_COLOR };
7682
+ }
7643
7683
  function iconLook(options) {
7644
7684
  return {
7645
7685
  icon: options.icon || undefined,
@@ -9431,7 +9471,9 @@ var EntityLabel;
9431
9471
  target.addEventListener(type, event => event.stopPropagation());
9432
9472
  }
9433
9473
  };
9434
- const normalLeader = (_m = look.leader) !== null && _m !== void 0 ? _m : presentation === "text";
9474
+ // A pin needs an icon to wrap; a photo keeps its own shape, and plain text keeps a straight stem.
9475
+ const pin = this.options.leaderStyle === "pin" && look.leader !== false && presentation !== "text" && !look.iconPhoto;
9476
+ const normalLeader = (_m = look.leader) !== null && _m !== void 0 ? _m : (presentation === "text" || pin);
9435
9477
  const angled = this.options.leaderStyle === "angled";
9436
9478
  let leader = normalLeader;
9437
9479
  const content = document.createElement("span");
@@ -9442,6 +9484,8 @@ var EntityLabel;
9442
9484
  let iconElement;
9443
9485
  let iconContainer;
9444
9486
  let fitIconBackground;
9487
+ let pinHolder;
9488
+ let pinBody;
9445
9489
  let iconStack;
9446
9490
  let stackedFits = [];
9447
9491
  let displayedStack = "[]";
@@ -9462,7 +9506,8 @@ var EntityLabel;
9462
9506
  content.style.flexDirection = shape === "rect" ? "column-reverse" : "";
9463
9507
  };
9464
9508
  if (presentation !== "text") {
9465
- const built = this.buildIcon(look, counter, placePhoto);
9509
+ // Without a chip of its own the icon sits on the pin's white body, so its colour is inferred from that.
9510
+ const built = this.buildIcon(pin ? pinLook(look) : look, counter, placePhoto);
9466
9511
  startPhoto = built.start;
9467
9512
  const icon = iconElement = built.icon;
9468
9513
  fitIconBackground = built.fit;
@@ -9487,6 +9532,20 @@ var EntityLabel;
9487
9532
  iconStack.style.cssText = "display:none;gap:2px;align-items:center;justify-items:center;flex:none;";
9488
9533
  makeClickable(iconStack);
9489
9534
  iconContainer.append(iconStack, icon);
9535
+ if (pin) {
9536
+ // The shadow sits on an unturned holder so it falls the same way whichever way the tip points.
9537
+ pinHolder = document.createElement("span");
9538
+ pinHolder.className = "entity-label-pin";
9539
+ pinHolder.style.cssText = "position:absolute;left:50%;top:50%;z-index:-1;pointer-events:none;" +
9540
+ "filter:drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.35));";
9541
+ pinBody = document.createElement("span");
9542
+ pinBody.style.cssText = `position:absolute;inset:0;background:${PIN_COLOR};border:1px solid rgba(0, 0, 0, 0.14);` +
9543
+ "box-sizing:border-box;border-radius:50% 50% 0 50%;";
9544
+ pinHolder.appendChild(pinBody);
9545
+ iconContainer.prepend(pinHolder);
9546
+ // Text beside or above keeps its usual gap from the body rather than from the icon inside it.
9547
+ content.style.gap = `${6 + PIN_RIM}px`;
9548
+ }
9490
9549
  content.appendChild(iconContainer);
9491
9550
  }
9492
9551
  if (presentation !== "icon") {
@@ -9657,6 +9716,36 @@ var EntityLabel;
9657
9716
  run, side: (rightwards ? "right" : "left")
9658
9717
  };
9659
9718
  };
9719
+ /*
9720
+ * Where the icon sits in the label, and how far the pin's tip reaches from its centre, in layout pixels.
9721
+ * Measured from the icon's container, so a cluster's icon stack is wrapped the same way as a lone icon.
9722
+ */
9723
+ const measurePin = () => {
9724
+ const scale = layer.coordinates.scaleX;
9725
+ const radius = Math.max(iconContainer.offsetWidth, iconContainer.offsetHeight) / 2 + PIN_RIM;
9726
+ return {
9727
+ x: (iconContainer.offsetLeft + iconContainer.offsetWidth / 2) / scale,
9728
+ y: (iconContainer.offsetTop + iconContainer.offsetHeight / 2) / layer.coordinates.scaleY,
9729
+ radius: radius / scale,
9730
+ // The body's one square corner, half a diagonal from its centre.
9731
+ tip: radius * Math.SQRT2 / scale
9732
+ };
9733
+ };
9734
+ /*
9735
+ * A pin stands over its anchor with the icon centred on it, and hangs below when there is no room above.
9736
+ * Off to the side it is only clamped back on screen, and its tip turns to keep pointing at the anchor.
9737
+ */
9738
+ const fitPin = (anchorX, anchorY, stem, width, height, shape) => {
9739
+ const canvas = this.viewer.canvas;
9740
+ const reach = stem + shape.tip;
9741
+ const above = anchorY - reach - shape.y;
9742
+ const below = anchorY + reach - shape.y;
9743
+ const upwards = above >= 0 || (below + height > canvas.clientHeight && anchorY >= canvas.clientHeight - anchorY);
9744
+ return {
9745
+ x: Math.max(0, Math.min(anchorX - shape.x, canvas.clientWidth - width)),
9746
+ y: upwards ? above : below
9747
+ };
9748
+ };
9660
9749
  /*
9661
9750
  * The on-screen centre and half-size of a point or billboard glyph, relative to its projected position.
9662
9751
  * Read every frame, since styling and selection can rescale a billboard in place.
@@ -9773,7 +9862,7 @@ var EntityLabel;
9773
9862
  }
9774
9863
  let cursorMotion = this.cursorMotion;
9775
9864
  const project = () => {
9776
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
9865
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
9777
9866
  if (this.disposed || !this.viewer || this.viewer.isDestroyed() || ((_a = this.visible) === null || _a === void 0 ? void 0 : _a.call(this)) === false ||
9778
9867
  (presentation === "icon" && this.options.iconScale === 0)) {
9779
9868
  return null;
@@ -9890,6 +9979,10 @@ var EntityLabel;
9890
9979
  else if (this.options.leaderLength != null) {
9891
9980
  leaderLength = Math.max(0, this.options.leaderLength);
9892
9981
  }
9982
+ else if (pin) {
9983
+ // The tip itself is the leader, so by default it touches what it marks.
9984
+ leaderLength = 0;
9985
+ }
9893
9986
  else if (transientPivot) {
9894
9987
  // Cursor callouts must not jump when the next hover target has a different extent.
9895
9988
  leaderLength = 96;
@@ -9906,14 +9999,15 @@ var EntityLabel;
9906
9999
  if (visual instanceof Entity && (visual.polygon || visual.polyline))
9907
10000
  leaderLength /= 3;
9908
10001
  }
9909
- if (boxAnchor && this.options.leaderLength == null) {
10002
+ if (boxAnchor && this.options.leaderLength == null && !pin) {
9910
10003
  leaderLength += (MODEL_BOX_STEM - leaderLength) * boxBlend;
9911
10004
  }
9912
10005
  if (cursorAmount > 0) {
9913
10006
  leaderLength += (96 - leaderLength) * cursorAmount;
9914
10007
  }
9915
10008
  // Measured from the ring, so the visible stem is the same length whatever the glyph's size.
9916
- leaderLength += iconRing;
10009
+ // A pin's tip rests on the glyph instead, since no ring is drawn around it.
10010
+ leaderLength += pin ? (_t = icon === null || icon === void 0 ? void 0 : icon.radius) !== null && _t !== void 0 ? _t : 0 : iconRing;
9917
10011
  y = anchorY - leaderLength;
9918
10012
  }
9919
10013
  else if (hover && !reused && !pinned) {
@@ -9925,7 +10019,7 @@ var EntityLabel;
9925
10019
  const width = ele.offsetWidth / coordinates.scaleX;
9926
10020
  const height = ele.offsetHeight / coordinates.scaleY;
9927
10021
  let clusterBounds;
9928
- if ((_t = this.options.cluster) === null || _t === void 0 ? void 0 : _t.enabled) {
10022
+ if ((_u = this.options.cluster) === null || _u === void 0 ? void 0 : _u.enabled) {
9929
10023
  const textWidth = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetWidth) || 0;
9930
10024
  const textHeight = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetHeight) || 0;
9931
10025
  // A photo is never part of the footprint, so its arrival cannot change which cluster a label joins.
@@ -9937,7 +10031,7 @@ var EntityLabel;
9937
10031
  const baseWidth = ((above ? Math.max(textWidth, iconWidth) : textWidth + iconWidth + gap) + 16) / coordinates.scaleX;
9938
10032
  const baseHeight = ((above ? textHeight + iconHeight + gap : Math.max(textHeight, iconHeight)) + 12) / coordinates.scaleY;
9939
10033
  clusterBounds = {
9940
- x: leader ? x : x - baseWidth / 2,
10034
+ x: leader && !pin ? x : x - baseWidth / 2,
9941
10035
  y: leader ? y - baseHeight : y - baseHeight / 2, width: baseWidth, height: baseHeight
9942
10036
  };
9943
10037
  }
@@ -9948,7 +10042,9 @@ var EntityLabel;
9948
10042
  // Membership uses the unclamped source footprint, never the summary's changing dimensions.
9949
10043
  let leaderRun;
9950
10044
  let leaderSide;
9951
- if (leader && angled) {
10045
+ if (leader && pin)
10046
+ ({ x, y } = fitPin(anchorX, anchorY, leaderLength, width, height, measurePin()));
10047
+ else if (leader && angled) {
9952
10048
  const fit = fitAngledLeader(anchorX, anchorY, leaderLength, width, height);
9953
10049
  ({ x, y } = fit);
9954
10050
  ({ run: leaderRun, side: leaderSide } = fit);
@@ -9959,16 +10055,16 @@ var EntityLabel;
9959
10055
  if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x > this.viewer.canvas.clientWidth || bounds.y > this.viewer.canvas.clientHeight)) {
9960
10056
  return null;
9961
10057
  }
9962
- 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 });
10058
+ const state = (_v = this.visualRegister) === null || _v === void 0 ? void 0 : _v.GetState({ entityId: (_w = this.rego) === null || _w === void 0 ? void 0 : _w.entityId, menuItemId: (_x = this.rego) === null || _x === void 0 ? void 0 : _x.menuItemId });
9963
10059
  const opacity = this.prePositioned || hoverOnly || MAX_DISTANCE === Infinity ? 1 : 1 - distance / MAX_DISTANCE;
9964
10060
  return {
9965
- canFlip: leader && presentation !== "icon", hasLeader: leader,
10061
+ canFlip: leader && presentation !== "icon" && !pin, hasLeader: leader,
9966
10062
  textWrapped: ((sourceNaturalText === null || sourceNaturalText === void 0 ? void 0 : sourceNaturalText.offsetWidth) || 0) > TEXT_MAX_WIDTH,
9967
10063
  transient: this.Transient || Boolean(hover) || cursorAmount > 0,
9968
10064
  extendedGeometry: visual instanceof Entity && Boolean(visual.polygon || visual.polyline || visual.corridor),
9969
10065
  viewportWidth: this.viewer.canvas.clientWidth,
9970
- 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,
9971
- 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,
10066
+ id: this.id, entityKey: ((_y = this.rego) === null || _y === void 0 ? void 0 : _y.entityId) ? JSON.stringify([this.rego.entityId, this.rego.menuItemId || "", this.Transient && !this.Persistent ? "hover" : ""]) : undefined,
10067
+ entityId: (_z = this.rego) === null || _z === void 0 ? void 0 : _z.entityId, group: this.groupId, x, y, width, height, anchorX, anchorY, depth, leaderLength, leaderRun, leaderSide, distance,
9972
10068
  iconRadius: icon === null || icon === void 0 ? void 0 : icon.radius, modelBox: boxed || undefined, boxBlend, follows: !pinned && Boolean(transientPivot || cursorMotion.target),
9973
10069
  // Priority shows the hovered member individually without dragging its cluster along.
9974
10070
  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
@@ -9985,7 +10081,8 @@ var EntityLabel;
9985
10081
  lineEle.style.display = show && leader ? "block" : "none";
9986
10082
  if (runEle)
9987
10083
  runEle.style.display = show && leader ? "block" : "none";
9988
- this.anchor.style.display = show && leader && !(((_a = placement.frame) === null || _a === void 0 ? void 0 : _a.boxBlend) >= 1) ? "block" : "none";
10084
+ // A pin's tip marks the anchor itself, so it has no ring there.
10085
+ this.anchor.style.display = show && leader && !pin && !(((_a = placement.frame) === null || _a === void 0 ? void 0 : _a.boxBlend) >= 1) ? "block" : "none";
9989
10086
  if (!show) {
9990
10087
  displacement = { x: 0, y: 0 };
9991
10088
  nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
@@ -10042,7 +10139,7 @@ var EntityLabel;
10042
10139
  const looks = ((_d = placement.icons) === null || _d === void 0 ? void 0 : _d.length) ? [iconLook(this.options), ...placement.icons] : [];
10043
10140
  // One small size for all, so no icon in the arrangement reads as more important than another.
10044
10141
  const size = (this.options.iconSize || 24) * ((_e = this.options.iconScale) !== null && _e !== void 0 ? _e : 1) * ICON_STACK_SCALE;
10045
- const built = looks.map(look => this.buildIcon({ ...look, iconSize: size }, counter));
10142
+ const built = looks.map(look => this.buildIcon({ ...(pin ? pinLook(look) : look), iconSize: size }, counter));
10046
10143
  // A stack is on show already, so its photos load straight away.
10047
10144
  built.forEach(({ start }) => start === null || start === void 0 ? void 0 : start());
10048
10145
  // Two sit side by side; three make a triangle with the representative on top.
@@ -10136,7 +10233,9 @@ var EntityLabel;
10136
10233
  }
10137
10234
  const ringShare = 1 - (frame.boxBlend || 0);
10138
10235
  const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
10139
- const stem = (leader ? (angled ? fitAngledLeader : fitLeader)(frame.anchorX, frame.anchorY, Math.max(frame.leaderLength, radius ? radius + 4 : 0), ele.offsetWidth / coordinates.scaleX, ele.offsetHeight / coordinates.scaleY, radius) : undefined);
10236
+ const pinShape = leader && pin ? measurePin() : undefined;
10237
+ const stem = (pinShape ? fitPin(frame.anchorX, frame.anchorY, frame.leaderLength, ele.offsetWidth / coordinates.scaleX, ele.offsetHeight / coordinates.scaleY, pinShape) :
10238
+ leader ? (angled ? fitAngledLeader : fitLeader)(frame.anchorX, frame.anchorY, Math.max(frame.leaderLength, radius ? radius + 4 : 0), ele.offsetWidth / coordinates.scaleX, ele.offsetHeight / coordinates.scaleY, radius) : undefined);
10140
10239
  const position = { x: (stem || frame).x, y: (stem || frame).y };
10141
10240
  const width = ele.offsetWidth / coordinates.scaleX;
10142
10241
  const height = ele.offsetHeight / coordinates.scaleY;
@@ -10147,7 +10246,7 @@ var EntityLabel;
10147
10246
  const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
10148
10247
  position.x = Math.max(0, Math.min(beside, this.viewer.canvas.clientWidth - width));
10149
10248
  }
10150
- else if (leader && placement.textSide === "left") {
10249
+ else if (leader && !pin && placement.textSide === "left") {
10151
10250
  position.x = Math.max(0, Math.min(frame.anchorX - width, this.viewer.canvas.clientWidth - width));
10152
10251
  }
10153
10252
  const gap = (_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.gap) !== null && _t !== void 0 ? _t : 12;
@@ -10228,8 +10327,23 @@ var EntityLabel;
10228
10327
  const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
10229
10328
  const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
10230
10329
  const elbowY = position.y + height / 2;
10231
- const endX = beside ? frame.anchorX : straightX;
10232
- const endY = beside ? elbowY : straightY;
10330
+ let endX = beside ? frame.anchorX : straightX;
10331
+ let endY = beside ? elbowY : straightY;
10332
+ if (pinShape) {
10333
+ // Aimed from wherever clamping or a nudge left it; a stem, if any, meets the tip.
10334
+ const centreX = position.x + pinShape.x, centreY = position.y + pinShape.y;
10335
+ const aim = Math.atan2(frame.anchorY - centreY, frame.anchorX - centreX);
10336
+ const reach = Math.min(pinShape.tip, Math.hypot(frame.anchorX - centreX, frame.anchorY - centreY));
10337
+ endX = centreX + Math.cos(aim) * reach;
10338
+ endY = centreY + Math.sin(aim) * reach;
10339
+ const size = `${pinShape.radius * 2 * coordinates.scaleX}px`;
10340
+ if (pinHolder.style.width !== size) {
10341
+ pinHolder.style.width = pinHolder.style.height = size;
10342
+ pinHolder.style.margin = `-${pinShape.radius * coordinates.scaleX}px`;
10343
+ }
10344
+ // The body's square corner starts at the lower right, a quarter turn short of pointing down.
10345
+ pinBody.style.transform = `rotate(${aim - Math.PI / 4}rad)`;
10346
+ }
10233
10347
  const runToX = frame.anchorX < position.x ? position.x : position.x + width;
10234
10348
  const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
10235
10349
  const length = Math.hypot(dx, dy);
@@ -10321,8 +10435,10 @@ var EntityLabel;
10321
10435
  }
10322
10436
  icon.style.cssText = `font-size:${(options.iconSize || 24) * ((_a = options.iconScale) !== null && _a !== void 0 ? _a : 1)}px;line-height:1;`;
10323
10437
  icon.style.textShadow = "0 1px 2px rgba(0, 0, 0, 0.25)";
10324
- const iconColor = typeof options.iconColor === "string" ? options.iconColor : undefined;
10325
- const iconBackground = options.iconBackground && options.iconScale !== 0;
10438
+ const colors = IconColors(options);
10439
+ // A file keeps its own colours unless one was given; only a glyph takes an inferred one.
10440
+ const iconColor = options.iconUrl ? (typeof options.iconColor === "string" ? options.iconColor : undefined) : colors.icon;
10441
+ const iconBackground = options.iconScale !== 0 ? colors.background : undefined;
10326
10442
  if (iconColor) {
10327
10443
  icon.style.color = iconColor;
10328
10444
  }
@@ -10387,12 +10503,8 @@ var EntityLabel;
10387
10503
  icon.textContent = options.icon || "●";
10388
10504
  }
10389
10505
  if (iconBackground) {
10390
- const color = Color.fromCssColorString(iconColor || "white") || Color.WHITE;
10391
- const luminance = 0.2126 * color.red + 0.7152 * color.green + 0.0722 * color.blue;
10392
- const background = (luminance > 0.5 ? color.darken(ICON_BACKGROUND_BLEND, new Color()) :
10393
- color.brighten(ICON_BACKGROUND_BLEND, new Color()));
10394
10506
  const size = (options.iconSize || 24) * ((_c = options.iconScale) !== null && _c !== void 0 ? _c : 1);
10395
- icon.style.backgroundColor = background.withAlpha(ICON_BACKGROUND_ALPHA).toCssColorString();
10507
+ icon.style.backgroundColor = iconBackground;
10396
10508
  icon.style.borderRadius = "50%";
10397
10509
  icon.style.padding = `${size / 3}px`;
10398
10510
  icon.style.display = "inline-flex";
@@ -10767,7 +10879,7 @@ var EntityLabelGroup;
10767
10879
  }
10768
10880
  return [
10769
10881
  options.text, options.icon, options.iconUrl, options.iconClass,
10770
- options.iconColor, options.iconStatus, options.iconPriority, options.iconScale
10882
+ options.iconColor, options.iconBackground, options.iconStatus, options.iconPriority, options.iconScale
10771
10883
  ].some(Array.isArray);
10772
10884
  }
10773
10885
  EntityLabelGroup.NeedsEntityData = NeedsEntityData;
@@ -10895,6 +11007,12 @@ var EntityLabelGroup;
10895
11007
  return null;
10896
11008
  }
10897
11009
  }
11010
+ /*
11011
+ * A calculated chip colour that finds nothing for an entity draws no chip, as an unset one would.
11012
+ */
11013
+ function resolveBackground(value, entity) {
11014
+ return typeof value === "boolean" ? value : resolveIcon(value, entity) || undefined;
11015
+ }
10898
11016
  // How many entities one attachment read asks for.
10899
11017
  const IMAGES_AT_ONCE = 100;
10900
11018
  // How long on-screen requests gather before they are read together.
@@ -11132,7 +11250,7 @@ var EntityLabelGroup;
11132
11250
  iconUrl: resolveIcon((_h = group.definition.options) === null || _h === void 0 ? void 0 : _h.iconUrl, entity),
11133
11251
  iconClass: resolveIcon((_j = group.definition.options) === null || _j === void 0 ? void 0 : _j.iconClass, entity),
11134
11252
  iconColor: resolveIcon((_k = group.definition.options) === null || _k === void 0 ? void 0 : _k.iconColor, entity),
11135
- iconBackground: (_l = group.definition.options) === null || _l === void 0 ? void 0 : _l.iconBackground,
11253
+ iconBackground: resolveBackground((_l = group.definition.options) === null || _l === void 0 ? void 0 : _l.iconBackground, entity),
11136
11254
  iconPriority: Number.isFinite(iconPriority) ? iconPriority : item.iconPriority,
11137
11255
  iconStatus: (_o = resolveIcon((_m = group.definition.options) === null || _m === void 0 ? void 0 : _m.iconStatus, entity)) !== null && _o !== void 0 ? _o : item.iconStatus
11138
11256
  };
@@ -11387,8 +11505,11 @@ var EntityLabelGroup;
11387
11505
  if (!options) {
11388
11506
  return;
11389
11507
  }
11390
- if (options.iconBackground != null && typeof options.iconBackground !== "boolean") {
11391
- throw new Error("Label iconBackground must be a boolean");
11508
+ if (options.iconBackground != null &&
11509
+ typeof options.iconBackground !== "boolean" &&
11510
+ typeof options.iconBackground !== "string" &&
11511
+ !Array.isArray(options.iconBackground)) {
11512
+ throw new Error("Label iconBackground must be a boolean, a colour or a Calculator field array");
11392
11513
  }
11393
11514
  for (const value of [options.icon, options.iconUrl, options.iconClass, options.iconColor, options.text]) {
11394
11515
  if (value != null && typeof value !== "string" && !Array.isArray(value)) {
@@ -60328,7 +60449,7 @@ var StyleUtils;
60328
60449
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60329
60450
  })(StyleUtils || (StyleUtils = {}));
60330
60451
 
60331
- const VERSION = "7.7.9";
60452
+ const VERSION = "7.8.1";
60332
60453
  /**
60333
60454
  * Updates the environment instance used by bruce-cesium to one specified.
60334
60455
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.