bruce-cesium 7.8.0 → 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.
- package/dist/bruce-cesium.es5.js +105 -21
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +103 -19
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/render-managers/common/entity-label.js +102 -18
- package/dist/lib/rendering/render-managers/common/entity-label.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/render-managers/common/entity-label.d.ts +1 -1
- package/package.json +1 -1
package/dist/lib/bruce-cesium.js
CHANGED
|
@@ -97,7 +97,7 @@ __exportStar(require("./widgets/widget-info-view"), exports);
|
|
|
97
97
|
__exportStar(require("./widgets/widget-left-panel"), exports);
|
|
98
98
|
__exportStar(require("./widgets/widget-nav-compass"), exports);
|
|
99
99
|
__exportStar(require("./widgets/widget-view-bar"), exports);
|
|
100
|
-
exports.VERSION = "7.8.
|
|
100
|
+
exports.VERSION = "7.8.1";
|
|
101
101
|
/**
|
|
102
102
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
103
103
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|
|
@@ -44,6 +44,10 @@ var EntityLabel;
|
|
|
44
44
|
const ICON_STACK_SCALE = 0.6;
|
|
45
45
|
// How far an angled leader runs sideways before the label starts.
|
|
46
46
|
const ANGLED_LEADER_RUN = 28;
|
|
47
|
+
// How far a pin's white body reaches past the icon it wraps, before its tip.
|
|
48
|
+
const PIN_RIM = 7;
|
|
49
|
+
// A pin is drawn in one fixed look for now: a white body with a faint edge and a soft shadow.
|
|
50
|
+
const PIN_COLOR = "#ffffff";
|
|
47
51
|
// Clearance between a point or billboard glyph and the ring drawn around it.
|
|
48
52
|
const ICON_RING_PADDING = 4;
|
|
49
53
|
// Small points still get a ring as large as the default near ring.
|
|
@@ -477,6 +481,12 @@ var EntityLabel;
|
|
|
477
481
|
color.brighten(ICON_BACKGROUND_BLEND, new Cesium.Color());
|
|
478
482
|
return shade.withAlpha(alpha).toCssColorString();
|
|
479
483
|
}
|
|
484
|
+
/*
|
|
485
|
+
* 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.
|
|
486
|
+
*/
|
|
487
|
+
function pinLook(look) {
|
|
488
|
+
return look.iconBackground ? look : { ...look, iconBackground: PIN_COLOR };
|
|
489
|
+
}
|
|
480
490
|
function iconLook(options) {
|
|
481
491
|
return {
|
|
482
492
|
icon: options.icon || undefined,
|
|
@@ -2269,7 +2279,9 @@ var EntityLabel;
|
|
|
2269
2279
|
target.addEventListener(type, event => event.stopPropagation());
|
|
2270
2280
|
}
|
|
2271
2281
|
};
|
|
2272
|
-
|
|
2282
|
+
// A pin needs an icon to wrap; a photo keeps its own shape, and plain text keeps a straight stem.
|
|
2283
|
+
const pin = this.options.leaderStyle === "pin" && look.leader !== false && presentation !== "text" && !look.iconPhoto;
|
|
2284
|
+
const normalLeader = (_m = look.leader) !== null && _m !== void 0 ? _m : (presentation === "text" || pin);
|
|
2273
2285
|
const angled = this.options.leaderStyle === "angled";
|
|
2274
2286
|
let leader = normalLeader;
|
|
2275
2287
|
const content = document.createElement("span");
|
|
@@ -2280,6 +2292,8 @@ var EntityLabel;
|
|
|
2280
2292
|
let iconElement;
|
|
2281
2293
|
let iconContainer;
|
|
2282
2294
|
let fitIconBackground;
|
|
2295
|
+
let pinHolder;
|
|
2296
|
+
let pinBody;
|
|
2283
2297
|
let iconStack;
|
|
2284
2298
|
let stackedFits = [];
|
|
2285
2299
|
let displayedStack = "[]";
|
|
@@ -2300,7 +2314,8 @@ var EntityLabel;
|
|
|
2300
2314
|
content.style.flexDirection = shape === "rect" ? "column-reverse" : "";
|
|
2301
2315
|
};
|
|
2302
2316
|
if (presentation !== "text") {
|
|
2303
|
-
|
|
2317
|
+
// Without a chip of its own the icon sits on the pin's white body, so its colour is inferred from that.
|
|
2318
|
+
const built = this.buildIcon(pin ? pinLook(look) : look, counter, placePhoto);
|
|
2304
2319
|
startPhoto = built.start;
|
|
2305
2320
|
const icon = iconElement = built.icon;
|
|
2306
2321
|
fitIconBackground = built.fit;
|
|
@@ -2325,6 +2340,20 @@ var EntityLabel;
|
|
|
2325
2340
|
iconStack.style.cssText = "display:none;gap:2px;align-items:center;justify-items:center;flex:none;";
|
|
2326
2341
|
makeClickable(iconStack);
|
|
2327
2342
|
iconContainer.append(iconStack, icon);
|
|
2343
|
+
if (pin) {
|
|
2344
|
+
// The shadow sits on an unturned holder so it falls the same way whichever way the tip points.
|
|
2345
|
+
pinHolder = document.createElement("span");
|
|
2346
|
+
pinHolder.className = "entity-label-pin";
|
|
2347
|
+
pinHolder.style.cssText = "position:absolute;left:50%;top:50%;z-index:-1;pointer-events:none;" +
|
|
2348
|
+
"filter:drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.35));";
|
|
2349
|
+
pinBody = document.createElement("span");
|
|
2350
|
+
pinBody.style.cssText = `position:absolute;inset:0;background:${PIN_COLOR};border:1px solid rgba(0, 0, 0, 0.14);` +
|
|
2351
|
+
"box-sizing:border-box;border-radius:50% 50% 0 50%;";
|
|
2352
|
+
pinHolder.appendChild(pinBody);
|
|
2353
|
+
iconContainer.prepend(pinHolder);
|
|
2354
|
+
// Text beside or above keeps its usual gap from the body rather than from the icon inside it.
|
|
2355
|
+
content.style.gap = `${6 + PIN_RIM}px`;
|
|
2356
|
+
}
|
|
2328
2357
|
content.appendChild(iconContainer);
|
|
2329
2358
|
}
|
|
2330
2359
|
if (presentation !== "icon") {
|
|
@@ -2495,6 +2524,36 @@ var EntityLabel;
|
|
|
2495
2524
|
run, side: (rightwards ? "right" : "left")
|
|
2496
2525
|
};
|
|
2497
2526
|
};
|
|
2527
|
+
/*
|
|
2528
|
+
* Where the icon sits in the label, and how far the pin's tip reaches from its centre, in layout pixels.
|
|
2529
|
+
* Measured from the icon's container, so a cluster's icon stack is wrapped the same way as a lone icon.
|
|
2530
|
+
*/
|
|
2531
|
+
const measurePin = () => {
|
|
2532
|
+
const scale = layer.coordinates.scaleX;
|
|
2533
|
+
const radius = Math.max(iconContainer.offsetWidth, iconContainer.offsetHeight) / 2 + PIN_RIM;
|
|
2534
|
+
return {
|
|
2535
|
+
x: (iconContainer.offsetLeft + iconContainer.offsetWidth / 2) / scale,
|
|
2536
|
+
y: (iconContainer.offsetTop + iconContainer.offsetHeight / 2) / layer.coordinates.scaleY,
|
|
2537
|
+
radius: radius / scale,
|
|
2538
|
+
// The body's one square corner, half a diagonal from its centre.
|
|
2539
|
+
tip: radius * Math.SQRT2 / scale
|
|
2540
|
+
};
|
|
2541
|
+
};
|
|
2542
|
+
/*
|
|
2543
|
+
* A pin stands over its anchor with the icon centred on it, and hangs below when there is no room above.
|
|
2544
|
+
* Off to the side it is only clamped back on screen, and its tip turns to keep pointing at the anchor.
|
|
2545
|
+
*/
|
|
2546
|
+
const fitPin = (anchorX, anchorY, stem, width, height, shape) => {
|
|
2547
|
+
const canvas = this.viewer.canvas;
|
|
2548
|
+
const reach = stem + shape.tip;
|
|
2549
|
+
const above = anchorY - reach - shape.y;
|
|
2550
|
+
const below = anchorY + reach - shape.y;
|
|
2551
|
+
const upwards = above >= 0 || (below + height > canvas.clientHeight && anchorY >= canvas.clientHeight - anchorY);
|
|
2552
|
+
return {
|
|
2553
|
+
x: Math.max(0, Math.min(anchorX - shape.x, canvas.clientWidth - width)),
|
|
2554
|
+
y: upwards ? above : below
|
|
2555
|
+
};
|
|
2556
|
+
};
|
|
2498
2557
|
/*
|
|
2499
2558
|
* The on-screen centre and half-size of a point or billboard glyph, relative to its projected position.
|
|
2500
2559
|
* Read every frame, since styling and selection can rescale a billboard in place.
|
|
@@ -2611,7 +2670,7 @@ var EntityLabel;
|
|
|
2611
2670
|
}
|
|
2612
2671
|
let cursorMotion = this.cursorMotion;
|
|
2613
2672
|
const project = () => {
|
|
2614
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
2673
|
+
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;
|
|
2615
2674
|
if (this.disposed || !this.viewer || this.viewer.isDestroyed() || ((_a = this.visible) === null || _a === void 0 ? void 0 : _a.call(this)) === false ||
|
|
2616
2675
|
(presentation === "icon" && this.options.iconScale === 0)) {
|
|
2617
2676
|
return null;
|
|
@@ -2731,6 +2790,10 @@ var EntityLabel;
|
|
|
2731
2790
|
else if (this.options.leaderLength != null) {
|
|
2732
2791
|
leaderLength = Math.max(0, this.options.leaderLength);
|
|
2733
2792
|
}
|
|
2793
|
+
else if (pin) {
|
|
2794
|
+
// The tip itself is the leader, so by default it touches what it marks.
|
|
2795
|
+
leaderLength = 0;
|
|
2796
|
+
}
|
|
2734
2797
|
else if (transientPivot) {
|
|
2735
2798
|
// Cursor callouts must not jump when the next hover target has a different extent.
|
|
2736
2799
|
leaderLength = 96;
|
|
@@ -2747,7 +2810,7 @@ var EntityLabel;
|
|
|
2747
2810
|
if (visual instanceof Cesium.Entity && (visual.polygon || visual.polyline))
|
|
2748
2811
|
leaderLength /= 3;
|
|
2749
2812
|
}
|
|
2750
|
-
if (boxAnchor && this.options.leaderLength == null) {
|
|
2813
|
+
if (boxAnchor && this.options.leaderLength == null && !pin) {
|
|
2751
2814
|
leaderLength += (MODEL_BOX_STEM - leaderLength) * boxBlend;
|
|
2752
2815
|
}
|
|
2753
2816
|
if (cursorAmount > 0) {
|
|
@@ -2755,7 +2818,8 @@ var EntityLabel;
|
|
|
2755
2818
|
}
|
|
2756
2819
|
;
|
|
2757
2820
|
// Measured from the ring, so the visible stem is the same length whatever the glyph's size.
|
|
2758
|
-
|
|
2821
|
+
// A pin's tip rests on the glyph instead, since no ring is drawn around it.
|
|
2822
|
+
leaderLength += pin ? (_t = icon === null || icon === void 0 ? void 0 : icon.radius) !== null && _t !== void 0 ? _t : 0 : iconRing;
|
|
2759
2823
|
y = anchorY - leaderLength;
|
|
2760
2824
|
}
|
|
2761
2825
|
else if (hover && !reused && !pinned) {
|
|
@@ -2767,7 +2831,7 @@ var EntityLabel;
|
|
|
2767
2831
|
const width = ele.offsetWidth / coordinates.scaleX;
|
|
2768
2832
|
const height = ele.offsetHeight / coordinates.scaleY;
|
|
2769
2833
|
let clusterBounds;
|
|
2770
|
-
if ((
|
|
2834
|
+
if ((_u = this.options.cluster) === null || _u === void 0 ? void 0 : _u.enabled) {
|
|
2771
2835
|
const textWidth = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetWidth) || 0;
|
|
2772
2836
|
const textHeight = (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetHeight) || 0;
|
|
2773
2837
|
// A photo is never part of the footprint, so its arrival cannot change which cluster a label joins.
|
|
@@ -2779,7 +2843,7 @@ var EntityLabel;
|
|
|
2779
2843
|
const baseWidth = ((above ? Math.max(textWidth, iconWidth) : textWidth + iconWidth + gap) + 16) / coordinates.scaleX;
|
|
2780
2844
|
const baseHeight = ((above ? textHeight + iconHeight + gap : Math.max(textHeight, iconHeight)) + 12) / coordinates.scaleY;
|
|
2781
2845
|
clusterBounds = {
|
|
2782
|
-
x: leader ? x : x - baseWidth / 2,
|
|
2846
|
+
x: leader && !pin ? x : x - baseWidth / 2,
|
|
2783
2847
|
y: leader ? y - baseHeight : y - baseHeight / 2, width: baseWidth, height: baseHeight
|
|
2784
2848
|
};
|
|
2785
2849
|
}
|
|
@@ -2790,7 +2854,9 @@ var EntityLabel;
|
|
|
2790
2854
|
// Membership uses the unclamped source footprint, never the summary's changing dimensions.
|
|
2791
2855
|
let leaderRun;
|
|
2792
2856
|
let leaderSide;
|
|
2793
|
-
if (leader &&
|
|
2857
|
+
if (leader && pin)
|
|
2858
|
+
({ x, y } = fitPin(anchorX, anchorY, leaderLength, width, height, measurePin()));
|
|
2859
|
+
else if (leader && angled) {
|
|
2794
2860
|
const fit = fitAngledLeader(anchorX, anchorY, leaderLength, width, height);
|
|
2795
2861
|
({ x, y } = fit);
|
|
2796
2862
|
({ run: leaderRun, side: leaderSide } = fit);
|
|
@@ -2801,16 +2867,16 @@ var EntityLabel;
|
|
|
2801
2867
|
if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x > this.viewer.canvas.clientWidth || bounds.y > this.viewer.canvas.clientHeight)) {
|
|
2802
2868
|
return null;
|
|
2803
2869
|
}
|
|
2804
|
-
const state = (
|
|
2870
|
+
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 });
|
|
2805
2871
|
const opacity = this.prePositioned || hoverOnly || MAX_DISTANCE === Infinity ? 1 : 1 - distance / MAX_DISTANCE;
|
|
2806
2872
|
return {
|
|
2807
|
-
canFlip: leader && presentation !== "icon", hasLeader: leader,
|
|
2873
|
+
canFlip: leader && presentation !== "icon" && !pin, hasLeader: leader,
|
|
2808
2874
|
textWrapped: ((sourceNaturalText === null || sourceNaturalText === void 0 ? void 0 : sourceNaturalText.offsetWidth) || 0) > TEXT_MAX_WIDTH,
|
|
2809
2875
|
transient: this.Transient || Boolean(hover) || cursorAmount > 0,
|
|
2810
2876
|
extendedGeometry: visual instanceof Cesium.Entity && Boolean(visual.polygon || visual.polyline || visual.corridor),
|
|
2811
2877
|
viewportWidth: this.viewer.canvas.clientWidth,
|
|
2812
|
-
id: this.id, entityKey: ((
|
|
2813
|
-
entityId: (
|
|
2878
|
+
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,
|
|
2879
|
+
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,
|
|
2814
2880
|
iconRadius: icon === null || icon === void 0 ? void 0 : icon.radius, modelBox: boxed || undefined, boxBlend, follows: !pinned && Boolean(transientPivot || cursorMotion.target),
|
|
2815
2881
|
// Priority shows the hovered member individually without dragging its cluster along.
|
|
2816
2882
|
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
|
|
@@ -2827,7 +2893,8 @@ var EntityLabel;
|
|
|
2827
2893
|
lineEle.style.display = show && leader ? "block" : "none";
|
|
2828
2894
|
if (runEle)
|
|
2829
2895
|
runEle.style.display = show && leader ? "block" : "none";
|
|
2830
|
-
|
|
2896
|
+
// A pin's tip marks the anchor itself, so it has no ring there.
|
|
2897
|
+
this.anchor.style.display = show && leader && !pin && !(((_a = placement.frame) === null || _a === void 0 ? void 0 : _a.boxBlend) >= 1) ? "block" : "none";
|
|
2831
2898
|
if (!show) {
|
|
2832
2899
|
displacement = { x: 0, y: 0 };
|
|
2833
2900
|
nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
|
|
@@ -2884,7 +2951,7 @@ var EntityLabel;
|
|
|
2884
2951
|
const looks = ((_d = placement.icons) === null || _d === void 0 ? void 0 : _d.length) ? [iconLook(this.options), ...placement.icons] : [];
|
|
2885
2952
|
// One small size for all, so no icon in the arrangement reads as more important than another.
|
|
2886
2953
|
const size = (this.options.iconSize || 24) * ((_e = this.options.iconScale) !== null && _e !== void 0 ? _e : 1) * ICON_STACK_SCALE;
|
|
2887
|
-
const built = looks.map(look => this.buildIcon({ ...look, iconSize: size }, counter));
|
|
2954
|
+
const built = looks.map(look => this.buildIcon({ ...(pin ? pinLook(look) : look), iconSize: size }, counter));
|
|
2888
2955
|
// A stack is on show already, so its photos load straight away.
|
|
2889
2956
|
built.forEach(({ start }) => start === null || start === void 0 ? void 0 : start());
|
|
2890
2957
|
// Two sit side by side; three make a triangle with the representative on top.
|
|
@@ -2979,7 +3046,9 @@ var EntityLabel;
|
|
|
2979
3046
|
}
|
|
2980
3047
|
const ringShare = 1 - (frame.boxBlend || 0);
|
|
2981
3048
|
const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
|
|
2982
|
-
const
|
|
3049
|
+
const pinShape = leader && pin ? measurePin() : undefined;
|
|
3050
|
+
const stem = (pinShape ? fitPin(frame.anchorX, frame.anchorY, frame.leaderLength, ele.offsetWidth / coordinates.scaleX, ele.offsetHeight / coordinates.scaleY, pinShape) :
|
|
3051
|
+
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);
|
|
2983
3052
|
const position = { x: (stem || frame).x, y: (stem || frame).y };
|
|
2984
3053
|
const width = ele.offsetWidth / coordinates.scaleX;
|
|
2985
3054
|
const height = ele.offsetHeight / coordinates.scaleY;
|
|
@@ -2990,7 +3059,7 @@ var EntityLabel;
|
|
|
2990
3059
|
const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
|
|
2991
3060
|
position.x = Math.max(0, Math.min(beside, this.viewer.canvas.clientWidth - width));
|
|
2992
3061
|
}
|
|
2993
|
-
else if (leader && placement.textSide === "left") {
|
|
3062
|
+
else if (leader && !pin && placement.textSide === "left") {
|
|
2994
3063
|
position.x = Math.max(0, Math.min(frame.anchorX - width, this.viewer.canvas.clientWidth - width));
|
|
2995
3064
|
}
|
|
2996
3065
|
const gap = (_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.gap) !== null && _t !== void 0 ? _t : 12;
|
|
@@ -3071,8 +3140,23 @@ var EntityLabel;
|
|
|
3071
3140
|
const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
|
|
3072
3141
|
const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
|
|
3073
3142
|
const elbowY = position.y + height / 2;
|
|
3074
|
-
|
|
3075
|
-
|
|
3143
|
+
let endX = beside ? frame.anchorX : straightX;
|
|
3144
|
+
let endY = beside ? elbowY : straightY;
|
|
3145
|
+
if (pinShape) {
|
|
3146
|
+
// Aimed from wherever clamping or a nudge left it; a stem, if any, meets the tip.
|
|
3147
|
+
const centreX = position.x + pinShape.x, centreY = position.y + pinShape.y;
|
|
3148
|
+
const aim = Math.atan2(frame.anchorY - centreY, frame.anchorX - centreX);
|
|
3149
|
+
const reach = Math.min(pinShape.tip, Math.hypot(frame.anchorX - centreX, frame.anchorY - centreY));
|
|
3150
|
+
endX = centreX + Math.cos(aim) * reach;
|
|
3151
|
+
endY = centreY + Math.sin(aim) * reach;
|
|
3152
|
+
const size = `${pinShape.radius * 2 * coordinates.scaleX}px`;
|
|
3153
|
+
if (pinHolder.style.width !== size) {
|
|
3154
|
+
pinHolder.style.width = pinHolder.style.height = size;
|
|
3155
|
+
pinHolder.style.margin = `-${pinShape.radius * coordinates.scaleX}px`;
|
|
3156
|
+
}
|
|
3157
|
+
// The body's square corner starts at the lower right, a quarter turn short of pointing down.
|
|
3158
|
+
pinBody.style.transform = `rotate(${aim - Math.PI / 4}rad)`;
|
|
3159
|
+
}
|
|
3076
3160
|
const runToX = frame.anchorX < position.x ? position.x : position.x + width;
|
|
3077
3161
|
const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
|
|
3078
3162
|
const length = Math.hypot(dx, dy);
|