bruce-cesium 7.8.0 → 7.8.2
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 +760 -346
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +758 -344
- 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 +736 -342
- package/dist/lib/rendering/render-managers/common/entity-label.js.map +1 -1
- package/dist/lib/rendering/render-managers/common/point-clustering-core.js +24 -3
- package/dist/lib/rendering/render-managers/common/point-clustering-core.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/render-managers/common/entity-label.d.ts +28 -3
- package/dist/types/rendering/render-managers/common/point-clustering-core.d.ts +8 -3
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -6679,6 +6679,17 @@
|
|
|
6679
6679
|
* Groups eligible neighbours around stable representatives without coupling membership to its renderer.
|
|
6680
6680
|
*/
|
|
6681
6681
|
function ClusterItems(params) {
|
|
6682
|
+
const steps = ClusterItemsInSteps(params, Infinity);
|
|
6683
|
+
let next = steps.next();
|
|
6684
|
+
while (!next.done) {
|
|
6685
|
+
next = steps.next();
|
|
6686
|
+
}
|
|
6687
|
+
return next.value;
|
|
6688
|
+
}
|
|
6689
|
+
/*
|
|
6690
|
+
* ClusterItems as steps, pausing after every so many representatives tried, so a caller can spread one run over frames.
|
|
6691
|
+
*/
|
|
6692
|
+
function* ClusterItemsInSteps(params, every = 32) {
|
|
6682
6693
|
const eligible = new Map();
|
|
6683
6694
|
for (const item of params.items) {
|
|
6684
6695
|
if (!params.eligible || params.eligible(item)) {
|
|
@@ -6688,12 +6699,21 @@
|
|
|
6688
6699
|
const assigned = new Set();
|
|
6689
6700
|
const result = [];
|
|
6690
6701
|
const minimum = Math.max(2, params.minSize || 2);
|
|
6702
|
+
const free = (other) => {
|
|
6703
|
+
const key = params.id(other);
|
|
6704
|
+
return eligible.has(key) && !assigned.has(key);
|
|
6705
|
+
};
|
|
6706
|
+
let tried = 0;
|
|
6691
6707
|
for (const [id, item] of eligible) {
|
|
6692
6708
|
if (assigned.has(id)) {
|
|
6693
6709
|
continue;
|
|
6694
6710
|
}
|
|
6711
|
+
if (++tried > every) {
|
|
6712
|
+
tried = 1;
|
|
6713
|
+
yield;
|
|
6714
|
+
}
|
|
6695
6715
|
const members = new Map([[id, item]]);
|
|
6696
|
-
for (const neighbour of params.neighbours(item)) {
|
|
6716
|
+
for (const neighbour of params.neighbours(item, free)) {
|
|
6697
6717
|
const key = params.id(neighbour);
|
|
6698
6718
|
if (eligible.has(key) && !assigned.has(key)) {
|
|
6699
6719
|
members.set(key, eligible.get(key));
|
|
@@ -7218,6 +7238,14 @@
|
|
|
7218
7238
|
const ICON_STACK_SCALE = 0.6;
|
|
7219
7239
|
// How far an angled leader runs sideways before the label starts.
|
|
7220
7240
|
const ANGLED_LEADER_RUN = 28;
|
|
7241
|
+
// While labels move on screen, clusters are worked out afresh at most this often, and again once they settle.
|
|
7242
|
+
const CLUSTER_MOVING_INTERVAL = 400;
|
|
7243
|
+
// Milliseconds of each frame a fresh clustering may take; the rest of it runs on the next frames.
|
|
7244
|
+
const CLUSTER_STEP_BUDGET = 4;
|
|
7245
|
+
// How far a pin's white body reaches past the icon it wraps, before its tip.
|
|
7246
|
+
const PIN_RIM = 7;
|
|
7247
|
+
// A pin is drawn in one fixed look for now: a white body with a faint edge and a soft shadow.
|
|
7248
|
+
const PIN_COLOR = "#ffffff";
|
|
7221
7249
|
// Clearance between a point or billboard glyph and the ring drawn around it.
|
|
7222
7250
|
const ICON_RING_PADDING = 4;
|
|
7223
7251
|
// Small points still get a ring as large as the default near ring.
|
|
@@ -7536,6 +7564,8 @@
|
|
|
7536
7564
|
*/
|
|
7537
7565
|
class PlacementMemory {
|
|
7538
7566
|
constructor() {
|
|
7567
|
+
// The last clusters worked out from scratch, by label id, for frames that may reuse them.
|
|
7568
|
+
this.clusters = null;
|
|
7539
7569
|
this.previous = new Map();
|
|
7540
7570
|
this.nextOrder = 0;
|
|
7541
7571
|
}
|
|
@@ -7651,6 +7681,22 @@
|
|
|
7651
7681
|
color.brighten(ICON_BACKGROUND_BLEND, new Cesium.Color());
|
|
7652
7682
|
return shade.withAlpha(alpha).toCssColorString();
|
|
7653
7683
|
}
|
|
7684
|
+
/*
|
|
7685
|
+
* 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.
|
|
7686
|
+
*/
|
|
7687
|
+
function pinLook(look) {
|
|
7688
|
+
return look.iconBackground ? look : { ...look, iconBackground: PIN_COLOR };
|
|
7689
|
+
}
|
|
7690
|
+
/*
|
|
7691
|
+
* Whether a label draws a pin: it needs an icon to wrap, and a photo keeps its own shape.
|
|
7692
|
+
*/
|
|
7693
|
+
function HasPin(options) {
|
|
7694
|
+
return ((options === null || options === void 0 ? void 0 : options.leaderStyle) === "pin" &&
|
|
7695
|
+
options.leader !== false &&
|
|
7696
|
+
(options.presentation || "text") !== "text" &&
|
|
7697
|
+
!options.iconPhoto);
|
|
7698
|
+
}
|
|
7699
|
+
EntityLabel.HasPin = HasPin;
|
|
7654
7700
|
function iconLook(options) {
|
|
7655
7701
|
return {
|
|
7656
7702
|
icon: options.icon || undefined,
|
|
@@ -7673,20 +7719,80 @@
|
|
|
7673
7719
|
presentation === "text" ? null : iconLook(options)
|
|
7674
7720
|
]);
|
|
7675
7721
|
}
|
|
7722
|
+
function summariseCluster(cluster) {
|
|
7723
|
+
var _a, _b, _c;
|
|
7724
|
+
let chosen = cluster.representative;
|
|
7725
|
+
const iconic = (chosen.options.presentation || "text") !== "text";
|
|
7726
|
+
// Members in the order they would win representation; the seed is the nearest.
|
|
7727
|
+
let ordered = [chosen, ...cluster.members.filter(member => member !== chosen)];
|
|
7728
|
+
if (iconic && chosen.options.cluster.representative !== "nearest") {
|
|
7729
|
+
ordered = ordered.map((member, i) => ({ member, i, priority: EntityLabel.IconPriority(member.options) }))
|
|
7730
|
+
.sort((a, b) => b.priority - a.priority || a.i - b.i).map(entry => entry.member);
|
|
7731
|
+
chosen = ordered[0];
|
|
7732
|
+
}
|
|
7733
|
+
const summary = {
|
|
7734
|
+
chosen: chosen.id,
|
|
7735
|
+
members: cluster.members.map(frame => frame.id),
|
|
7736
|
+
entityIds: Array.from(new Set(cluster.members.map(frame => frame.entityId).filter(Boolean)))
|
|
7737
|
+
};
|
|
7738
|
+
if (iconic && chosen.options.iconScale !== 0) {
|
|
7739
|
+
const seen = new Set();
|
|
7740
|
+
const icons = [];
|
|
7741
|
+
for (const member of ordered) {
|
|
7742
|
+
const look = iconLook(member.options);
|
|
7743
|
+
const key = JSON.stringify(look);
|
|
7744
|
+
if (seen.has(key)) {
|
|
7745
|
+
continue;
|
|
7746
|
+
}
|
|
7747
|
+
seen.add(key);
|
|
7748
|
+
if (member !== ordered[0])
|
|
7749
|
+
icons.push(look);
|
|
7750
|
+
if (seen.size >= ICON_STACK_LIMIT) {
|
|
7751
|
+
break;
|
|
7752
|
+
}
|
|
7753
|
+
}
|
|
7754
|
+
if (icons.length)
|
|
7755
|
+
summary.icons = icons;
|
|
7756
|
+
}
|
|
7757
|
+
if (chosen.options.presentation !== "icon") {
|
|
7758
|
+
const values = new Set();
|
|
7759
|
+
const stableMembers = [...cluster.members].sort((a, b) => (a.entityKey || a.entityId || a.id).localeCompare(b.entityKey || b.entityId || b.id));
|
|
7760
|
+
for (const member of stableMembers) {
|
|
7761
|
+
const value = ((_c = (_a = member.text) !== null && _a !== void 0 ? _a : (_b = member.options) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : "").replace(/\s+/g, " ").trim();
|
|
7762
|
+
if (value) {
|
|
7763
|
+
values.add(value);
|
|
7764
|
+
}
|
|
7765
|
+
}
|
|
7766
|
+
if (values.size > 1) {
|
|
7767
|
+
// A value long enough to wrap fills the box on its own, so only one is listed.
|
|
7768
|
+
const wrapped = stableMembers.some(member => { var _a, _b; return member.textWrapped && ((_b = (member.text || ((_a = member.options) === null || _a === void 0 ? void 0 : _a.text))) === null || _b === void 0 ? void 0 : _b.trim()); });
|
|
7769
|
+
const limit = wrapped ? 1 : 2;
|
|
7770
|
+
const rows = Array.from(values).slice(0, limit);
|
|
7771
|
+
if (values.size > limit)
|
|
7772
|
+
rows.push(`+${values.size - limit} more…`);
|
|
7773
|
+
summary.text = rows.join("\n");
|
|
7774
|
+
}
|
|
7775
|
+
}
|
|
7776
|
+
return summary;
|
|
7777
|
+
}
|
|
7676
7778
|
/*
|
|
7677
|
-
*
|
|
7779
|
+
* Frames in the order they win: priority first, then nearest, with every coordinate known.
|
|
7678
7780
|
*/
|
|
7679
|
-
function
|
|
7680
|
-
|
|
7681
|
-
const frames = input.filter(frame => [frame.x, frame.y, frame.width, frame.height, frame.depth].every(Number.isFinite))
|
|
7781
|
+
function sortFrames(input) {
|
|
7782
|
+
return input.filter(frame => [frame.x, frame.y, frame.width, frame.height, frame.depth].every(Number.isFinite))
|
|
7682
7783
|
.sort((a, b) => (b.priority || 0) - (a.priority || 0) || a.depth - b.depth || a.id.localeCompare(b.id));
|
|
7683
|
-
|
|
7784
|
+
}
|
|
7785
|
+
/*
|
|
7786
|
+
* The frames clustering considers, by presentation, and the ones hidden as another label of the same entity.
|
|
7787
|
+
*/
|
|
7788
|
+
function clusterGroups(frames) {
|
|
7789
|
+
var _a, _b;
|
|
7684
7790
|
const entityKeys = new Set();
|
|
7685
7791
|
const groups = new Map();
|
|
7792
|
+
const duplicates = new Set();
|
|
7686
7793
|
for (const frame of frames) {
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
if (duplicate) {
|
|
7794
|
+
if (frame.entityKey && entityKeys.has(frame.entityKey)) {
|
|
7795
|
+
duplicates.add(frame.id);
|
|
7690
7796
|
continue;
|
|
7691
7797
|
}
|
|
7692
7798
|
if (frame.entityKey)
|
|
@@ -7701,6 +7807,13 @@
|
|
|
7701
7807
|
}
|
|
7702
7808
|
groups.get(key).push(frame);
|
|
7703
7809
|
}
|
|
7810
|
+
return { groups, duplicates };
|
|
7811
|
+
}
|
|
7812
|
+
/*
|
|
7813
|
+
* Works clusters out from scratch, as steps a caller can spread over frames or run straight through.
|
|
7814
|
+
*/
|
|
7815
|
+
function* clusterInSteps(groups, every = 32) {
|
|
7816
|
+
const clustered = [];
|
|
7704
7817
|
for (const group of groups.values()) {
|
|
7705
7818
|
// Summary and badge dimensions are output, never the next frame's membership input.
|
|
7706
7819
|
const candidates = group.map(frame => frame.extendedGeometry && frame.canFlip &&
|
|
@@ -7714,70 +7827,76 @@
|
|
|
7714
7827
|
rank.set(frame.id, i);
|
|
7715
7828
|
looks.set(frame.id, clusterLook(frame.options));
|
|
7716
7829
|
});
|
|
7717
|
-
const clusters =
|
|
7830
|
+
const clusters = yield* ClusterItemsInSteps({
|
|
7718
7831
|
items: candidates,
|
|
7719
7832
|
id: frame => frame.id,
|
|
7720
7833
|
minSize: group[0].options.cluster.minSize,
|
|
7721
|
-
neighbours: frame => {
|
|
7834
|
+
neighbours: (frame, free) => {
|
|
7722
7835
|
var _a;
|
|
7723
|
-
|
|
7724
|
-
|
|
7836
|
+
// Labels an earlier cluster took cannot join, so they are dropped before the pairwise checks.
|
|
7837
|
+
const nearby = index.Query(frame, (_a = frame.options.cluster.pixelRange) !== null && _a !== void 0 ? _a : (frame.options.presentation === "icon" ? 24 : 8))
|
|
7838
|
+
.filter(other => other === frame || free(other))
|
|
7839
|
+
.sort((a, b) => rank.get(a.id) - rank.get(b.id));
|
|
7840
|
+
// A pin stands for one thing, so it clusters only with pins that look the same.
|
|
7841
|
+
const group = (other) => HasPin(other.options) ? `look:${looks.get(other.id)}` : other.group || "";
|
|
7842
|
+
return compatibleMembers(frame, nearby, group, other => looks.get(other.id));
|
|
7725
7843
|
}
|
|
7726
|
-
});
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
if (
|
|
7760
|
-
|
|
7761
|
-
const stableMembers = [...cluster.members].sort((a, b) => (a.entityKey || a.entityId || a.id).localeCompare(b.entityKey || b.entityId || b.id));
|
|
7762
|
-
for (const member of stableMembers) {
|
|
7763
|
-
const value = ((_e = (_c = member.text) !== null && _c !== void 0 ? _c : (_d = member.options) === null || _d === void 0 ? void 0 : _d.text) !== null && _e !== void 0 ? _e : "").replace(/\s+/g, " ").trim();
|
|
7764
|
-
if (value) {
|
|
7765
|
-
values.add(value);
|
|
7766
|
-
}
|
|
7767
|
-
}
|
|
7768
|
-
if (values.size > 1) {
|
|
7769
|
-
// A value long enough to wrap fills the box on its own, so only one is listed.
|
|
7770
|
-
const wrapped = stableMembers.some(member => { var _a, _b; return member.textWrapped && ((_b = (member.text || ((_a = member.options) === null || _a === void 0 ? void 0 : _a.text))) === null || _b === void 0 ? void 0 : _b.trim()); });
|
|
7771
|
-
const limit = wrapped ? 1 : 2;
|
|
7772
|
-
const rows = Array.from(values).slice(0, limit);
|
|
7773
|
-
if (values.size > limit)
|
|
7774
|
-
rows.push(`+${values.size - limit} more…`);
|
|
7775
|
-
representative.text = rows.join("\n");
|
|
7776
|
-
}
|
|
7844
|
+
}, every);
|
|
7845
|
+
clusters.forEach(cluster => clustered.push({ representative: cluster.representative.id, members: cluster.members.map(member => member.id) }));
|
|
7846
|
+
}
|
|
7847
|
+
return clustered;
|
|
7848
|
+
}
|
|
7849
|
+
/*
|
|
7850
|
+
* Runs a clustering job to the end at once.
|
|
7851
|
+
*/
|
|
7852
|
+
function finishClustering(steps) {
|
|
7853
|
+
let next = steps.next();
|
|
7854
|
+
while (!next.done) {
|
|
7855
|
+
next = steps.next();
|
|
7856
|
+
}
|
|
7857
|
+
return next.value;
|
|
7858
|
+
}
|
|
7859
|
+
function Layout(input, memory = new PlacementMemory(), reuseClusters = false) {
|
|
7860
|
+
var _a, _b, _c;
|
|
7861
|
+
const frames = sortFrames(input);
|
|
7862
|
+
const { groups, duplicates } = clusterGroups(frames);
|
|
7863
|
+
const result = new Map();
|
|
7864
|
+
for (const frame of frames) {
|
|
7865
|
+
result.set(frame.id, { frame, visible: !duplicates.has(frame.id), opacity: frame.opacity, zIndex: 0, members: [], entityIds: frame.entityId ? [frame.entityId] : [] });
|
|
7866
|
+
}
|
|
7867
|
+
if (!reuseClusters || !memory.clusters) {
|
|
7868
|
+
memory.clusters = finishClustering(clusterInSteps(groups, Infinity));
|
|
7869
|
+
}
|
|
7870
|
+
for (const group of groups.values()) {
|
|
7871
|
+
// The kept membership, less anything gone, hovered or moved out of the group since.
|
|
7872
|
+
const byId = new Map(group.map(frame => [frame.id, frame]));
|
|
7873
|
+
const minSize = Math.max(2, (_a = group[0].options.cluster.minSize) !== null && _a !== void 0 ? _a : 2);
|
|
7874
|
+
const clusters = memory.clusters.map(entry => {
|
|
7875
|
+
var _a;
|
|
7876
|
+
const members = entry.members.map(id => byId.get(id)).filter(Boolean);
|
|
7877
|
+
if (members.length < minSize) {
|
|
7878
|
+
return null;
|
|
7777
7879
|
}
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7880
|
+
return { entry, whole: members.length === entry.members.length, representative: (_a = byId.get(entry.representative)) !== null && _a !== void 0 ? _a : members[0], members };
|
|
7881
|
+
}).filter(Boolean);
|
|
7882
|
+
for (const cluster of clusters) {
|
|
7883
|
+
// A cluster that kept every member keeps its summary, worked out once, sparing a pass over its members.
|
|
7884
|
+
let summary = cluster.whole ? cluster.entry.summary : undefined;
|
|
7885
|
+
if (!summary) {
|
|
7886
|
+
summary = summariseCluster(cluster);
|
|
7887
|
+
if (cluster.whole)
|
|
7888
|
+
cluster.entry.summary = summary;
|
|
7889
|
+
}
|
|
7890
|
+
const representative = result.get(summary.chosen);
|
|
7891
|
+
representative.members = summary.members;
|
|
7892
|
+
if (summary.icons)
|
|
7893
|
+
representative.icons = summary.icons;
|
|
7894
|
+
representative.entityIds = summary.entityIds;
|
|
7895
|
+
if (summary.text != null)
|
|
7896
|
+
representative.text = summary.text;
|
|
7897
|
+
for (const id of summary.members) {
|
|
7898
|
+
if (id !== summary.chosen)
|
|
7899
|
+
result.get(id).visible = false;
|
|
7781
7900
|
}
|
|
7782
7901
|
}
|
|
7783
7902
|
}
|
|
@@ -7796,7 +7915,7 @@
|
|
|
7796
7915
|
const box = { ...frame, x: frame.x + .01, y: frame.y + .01, width: Math.max(0, frame.width - .02), height: Math.max(0, frame.height - .02) };
|
|
7797
7916
|
const overlap = foreground.HasOverlap(box) || foregroundLeaders.HasOverlap(box) || Boolean(stem && foreground.HasOverlap(stem));
|
|
7798
7917
|
if (overlap) {
|
|
7799
|
-
placement.opacity *= Math.max(0, Math.min(1, (
|
|
7918
|
+
placement.opacity *= Math.max(0, Math.min(1, (_c = (_b = frame.options) === null || _b === void 0 ? void 0 : _b.overlapOpacity) !== null && _c !== void 0 ? _c : 0.25));
|
|
7800
7919
|
}
|
|
7801
7920
|
placement.zIndex = zIndex--;
|
|
7802
7921
|
foreground.Add(frame);
|
|
@@ -7816,21 +7935,23 @@
|
|
|
7816
7935
|
const accepted = [seed];
|
|
7817
7936
|
const byGroup = new Map([[group(seed), 1]]);
|
|
7818
7937
|
const byLook = new Map([[look(seed), 1]]);
|
|
7819
|
-
|
|
7938
|
+
// Joined with a character no group id or look holds, not serialised, since this runs per neighbour.
|
|
7939
|
+
const both = (itemGroup, itemLook) => `${itemGroup}\u0000${itemLook}`;
|
|
7940
|
+
const byBoth = new Map([[both(group(seed), look(seed)), 1]]);
|
|
7820
7941
|
for (const item of nearby) {
|
|
7821
7942
|
if (item === seed) {
|
|
7822
7943
|
continue;
|
|
7823
7944
|
}
|
|
7824
|
-
const itemGroup = group(item), itemLook = look(item),
|
|
7945
|
+
const itemGroup = group(item), itemLook = look(item), key = both(itemGroup, itemLook);
|
|
7825
7946
|
// Accepted members in another group with another look are the ones this item may not sit beside.
|
|
7826
|
-
const conflicting = accepted.length - (byGroup.get(itemGroup) || 0) - (byLook.get(itemLook) || 0) + (byBoth.get(
|
|
7947
|
+
const conflicting = accepted.length - (byGroup.get(itemGroup) || 0) - (byLook.get(itemLook) || 0) + (byBoth.get(key) || 0);
|
|
7827
7948
|
if (conflicting > 0) {
|
|
7828
7949
|
continue;
|
|
7829
7950
|
}
|
|
7830
7951
|
accepted.push(item);
|
|
7831
7952
|
byGroup.set(itemGroup, (byGroup.get(itemGroup) || 0) + 1);
|
|
7832
7953
|
byLook.set(itemLook, (byLook.get(itemLook) || 0) + 1);
|
|
7833
|
-
byBoth.set(
|
|
7954
|
+
byBoth.set(key, (byBoth.get(key) || 0) + 1);
|
|
7834
7955
|
}
|
|
7835
7956
|
return accepted;
|
|
7836
7957
|
}
|
|
@@ -7861,10 +7982,20 @@
|
|
|
7861
7982
|
this.viewer = viewer;
|
|
7862
7983
|
this.element = document.createElement("div");
|
|
7863
7984
|
this.coordinates = { x: 0, y: 0, scaleX: 1, scaleY: 1 };
|
|
7985
|
+
// The canvas size, read once a frame: reading the canvas after placing a label lays the page out again.
|
|
7986
|
+
this.viewport = { width: 0, height: 0 };
|
|
7864
7987
|
this.participants = new Set();
|
|
7865
7988
|
// Participants whose failure has been logged, so a label that throws every frame logs once.
|
|
7866
7989
|
this.failed = new WeakSet();
|
|
7867
7990
|
this.placementMemory = new PlacementMemory();
|
|
7991
|
+
// What the clusters were last worked out from: the labels taking part and where they sat, and when.
|
|
7992
|
+
this.clustered = null;
|
|
7993
|
+
// Labels added or removed, which can change any cluster's look or membership.
|
|
7994
|
+
this.clustersDirty = true;
|
|
7995
|
+
// A fresh clustering spread over frames, while the last one stays on show.
|
|
7996
|
+
this.clusterJob = null;
|
|
7997
|
+
// Labels hidden in a cluster last frame, with the frame they were laid out from, for reused clusters to skip.
|
|
7998
|
+
this.sleeping = new Map();
|
|
7868
7999
|
this.modelBoxes = new ModelBoxes();
|
|
7869
8000
|
this.forwardingWheel = false;
|
|
7870
8001
|
this.pendingDrag = null;
|
|
@@ -8041,9 +8172,12 @@
|
|
|
8041
8172
|
}
|
|
8042
8173
|
Add(participant) {
|
|
8043
8174
|
this.participants.add(participant);
|
|
8175
|
+
this.clustersDirty = true;
|
|
8044
8176
|
this.viewer.scene.requestRender();
|
|
8045
8177
|
return () => {
|
|
8046
8178
|
this.participants.delete(participant);
|
|
8179
|
+
this.sleeping.delete(participant);
|
|
8180
|
+
this.clustersDirty = true;
|
|
8047
8181
|
if (!this.participants.size) {
|
|
8048
8182
|
this.remove();
|
|
8049
8183
|
this.element.removeEventListener("wheel", this.ForwardWheel);
|
|
@@ -8094,8 +8228,9 @@
|
|
|
8094
8228
|
}
|
|
8095
8229
|
}
|
|
8096
8230
|
Update() {
|
|
8097
|
-
var _a, _b;
|
|
8231
|
+
var _a, _b, _c;
|
|
8098
8232
|
this.coordinates = this.MeasureCoordinates();
|
|
8233
|
+
this.viewport = { width: this.viewer.canvas.clientWidth, height: this.viewer.canvas.clientHeight };
|
|
8099
8234
|
this.UpdateHorizon();
|
|
8100
8235
|
const rect = (_b = (_a = this.viewer.canvas).getBoundingClientRect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
8101
8236
|
const pointer = this.pointerClient;
|
|
@@ -8111,21 +8246,77 @@
|
|
|
8111
8246
|
console.error("EntityLabel: model boxes failed to resolve.", e);
|
|
8112
8247
|
}
|
|
8113
8248
|
// This runs inside Cesium's frame, where one throwing label would stop rendering for the whole scene.
|
|
8249
|
+
const project = (participant) => {
|
|
8250
|
+
try {
|
|
8251
|
+
return participant.project();
|
|
8252
|
+
}
|
|
8253
|
+
catch (e) {
|
|
8254
|
+
this.logFailure(participant, e);
|
|
8255
|
+
return null;
|
|
8256
|
+
}
|
|
8257
|
+
};
|
|
8258
|
+
// A label hidden in a cluster needs no position while its cluster is reused, which is most frames.
|
|
8259
|
+
const mayReuse = Boolean(this.clustered) && !this.clustersDirty && Date.now() - this.clustered.at < CLUSTER_MOVING_INTERVAL;
|
|
8114
8260
|
const projected = new Map();
|
|
8115
8261
|
for (const participant of this.participants) {
|
|
8116
|
-
|
|
8262
|
+
const asleep = mayReuse && !((_c = participant.wake) === null || _c === void 0 ? void 0 : _c.call(participant)) ? this.sleeping.get(participant) : undefined;
|
|
8263
|
+
projected.set(participant, asleep !== null && asleep !== void 0 ? asleep : project(participant));
|
|
8264
|
+
}
|
|
8265
|
+
let frames = Array.from(projected.values()).filter(Boolean);
|
|
8266
|
+
const decision = this.DecideClusters(frames);
|
|
8267
|
+
if (decision !== "reuse" && mayReuse) {
|
|
8268
|
+
// Clusters are worked out from where every label is now, sleepers included.
|
|
8269
|
+
for (const participant of this.participants) {
|
|
8270
|
+
if (this.sleeping.has(participant))
|
|
8271
|
+
projected.set(participant, project(participant));
|
|
8272
|
+
}
|
|
8273
|
+
frames = Array.from(projected.values()).filter(Boolean);
|
|
8274
|
+
}
|
|
8275
|
+
if (decision === "refresh") {
|
|
8276
|
+
this.clusterJob = clusterInSteps(clusterGroups(sortFrames(frames)).groups);
|
|
8277
|
+
}
|
|
8278
|
+
this.StepClusters();
|
|
8279
|
+
const layout = Layout(frames, this.placementMemory, decision !== "now");
|
|
8280
|
+
const placements = new Map(layout.map(item => [item.frame.id, item]));
|
|
8281
|
+
const participantsById = new Map();
|
|
8282
|
+
for (const [participant, frame] of projected) {
|
|
8283
|
+
if (frame)
|
|
8284
|
+
participantsById.set(frame.id, participant);
|
|
8285
|
+
}
|
|
8286
|
+
this.sleeping = new Map();
|
|
8287
|
+
for (const placement of layout) {
|
|
8288
|
+
for (const id of placement.members) {
|
|
8289
|
+
const participant = id !== placement.frame.id ? participantsById.get(id) : undefined;
|
|
8290
|
+
if (participant)
|
|
8291
|
+
this.sleeping.set(participant, projected.get(participant));
|
|
8292
|
+
}
|
|
8293
|
+
}
|
|
8294
|
+
// Writes, then reads, then writes, each across all labels; interleaved, each read lays them out again.
|
|
8295
|
+
const measures = [];
|
|
8296
|
+
for (const [participant, frame] of projected) {
|
|
8117
8297
|
try {
|
|
8118
|
-
|
|
8298
|
+
const measure = participant.apply(frame ? placements.get(frame.id) : undefined);
|
|
8299
|
+
if (measure)
|
|
8300
|
+
measures.push([participant, measure]);
|
|
8119
8301
|
}
|
|
8120
8302
|
catch (e) {
|
|
8121
8303
|
this.logFailure(participant, e);
|
|
8122
8304
|
}
|
|
8123
|
-
projected.set(participant, frame);
|
|
8124
8305
|
}
|
|
8125
|
-
const
|
|
8126
|
-
for (const [participant,
|
|
8306
|
+
const places = [];
|
|
8307
|
+
for (const [participant, measure] of measures) {
|
|
8308
|
+
try {
|
|
8309
|
+
const place = measure();
|
|
8310
|
+
if (place)
|
|
8311
|
+
places.push([participant, place]);
|
|
8312
|
+
}
|
|
8313
|
+
catch (e) {
|
|
8314
|
+
this.logFailure(participant, e);
|
|
8315
|
+
}
|
|
8316
|
+
}
|
|
8317
|
+
for (const [participant, place] of places) {
|
|
8127
8318
|
try {
|
|
8128
|
-
|
|
8319
|
+
place();
|
|
8129
8320
|
}
|
|
8130
8321
|
catch (e) {
|
|
8131
8322
|
this.logFailure(participant, e);
|
|
@@ -8138,6 +8329,55 @@
|
|
|
8138
8329
|
console.error("EntityLabel: model boxes failed to draw.", e);
|
|
8139
8330
|
}
|
|
8140
8331
|
}
|
|
8332
|
+
/*
|
|
8333
|
+
* How this frame gets its clusters: kept from last time, refreshed by a job over frames, or worked out now.
|
|
8334
|
+
* They are kept while no clustering label has moved, and while labels move (camera or entities) until a moment
|
|
8335
|
+
* old or while a refresh is under way. Labels coming or going, or none clustered yet, work them out now.
|
|
8336
|
+
*/
|
|
8337
|
+
DecideClusters(frames) {
|
|
8338
|
+
// Where each clustering label sits, to a few pixels, so drawing alone never counts as movement.
|
|
8339
|
+
const signature = frames
|
|
8340
|
+
.filter(frame => { var _a, _b; return ((_b = (_a = frame.options) === null || _a === void 0 ? void 0 : _a.cluster) === null || _b === void 0 ? void 0 : _b.enabled) && !(frame.priority > 0); })
|
|
8341
|
+
.map(frame => `${frame.id}@${Math.round(frame.x / 4)},${Math.round(frame.y / 4)}`)
|
|
8342
|
+
.join("|");
|
|
8343
|
+
const now = Date.now();
|
|
8344
|
+
if (!this.clustered || this.clustersDirty) {
|
|
8345
|
+
this.clusterJob = null;
|
|
8346
|
+
this.clustered = { signature, at: now };
|
|
8347
|
+
this.clustersDirty = false;
|
|
8348
|
+
return "now";
|
|
8349
|
+
}
|
|
8350
|
+
if (this.clustered.signature === signature) {
|
|
8351
|
+
return "reuse";
|
|
8352
|
+
}
|
|
8353
|
+
if (this.clusterJob || now - this.clustered.at < CLUSTER_MOVING_INTERVAL) {
|
|
8354
|
+
// Another frame is due either way, so the scene gets its fresh clusters once it settles.
|
|
8355
|
+
this.viewer.scene.requestRender();
|
|
8356
|
+
return "reuse";
|
|
8357
|
+
}
|
|
8358
|
+
this.clustered = { signature, at: now };
|
|
8359
|
+
return "refresh";
|
|
8360
|
+
}
|
|
8361
|
+
/*
|
|
8362
|
+
* Advances a spread clustering for this frame's share of time, handing its result over once it finishes.
|
|
8363
|
+
*/
|
|
8364
|
+
StepClusters() {
|
|
8365
|
+
if (!this.clusterJob) {
|
|
8366
|
+
return;
|
|
8367
|
+
}
|
|
8368
|
+
const deadline = performance.now() + CLUSTER_STEP_BUDGET;
|
|
8369
|
+
let next = this.clusterJob.next();
|
|
8370
|
+
while (!next.done && performance.now() < deadline) {
|
|
8371
|
+
next = this.clusterJob.next();
|
|
8372
|
+
}
|
|
8373
|
+
if (next.done) {
|
|
8374
|
+
this.placementMemory.clusters = next.value;
|
|
8375
|
+
this.clusterJob = null;
|
|
8376
|
+
}
|
|
8377
|
+
else {
|
|
8378
|
+
this.viewer.scene.requestRender();
|
|
8379
|
+
}
|
|
8380
|
+
}
|
|
8141
8381
|
logFailure(participant, error) {
|
|
8142
8382
|
if (this.failed.has(participant)) {
|
|
8143
8383
|
return;
|
|
@@ -9442,7 +9682,8 @@
|
|
|
9442
9682
|
target.addEventListener(type, event => event.stopPropagation());
|
|
9443
9683
|
}
|
|
9444
9684
|
};
|
|
9445
|
-
const
|
|
9685
|
+
const pin = HasPin(look);
|
|
9686
|
+
const normalLeader = (_m = look.leader) !== null && _m !== void 0 ? _m : (presentation === "text" || pin);
|
|
9446
9687
|
const angled = this.options.leaderStyle === "angled";
|
|
9447
9688
|
let leader = normalLeader;
|
|
9448
9689
|
const content = document.createElement("span");
|
|
@@ -9453,6 +9694,8 @@
|
|
|
9453
9694
|
let iconElement;
|
|
9454
9695
|
let iconContainer;
|
|
9455
9696
|
let fitIconBackground;
|
|
9697
|
+
let pinHolder;
|
|
9698
|
+
let pinBody;
|
|
9456
9699
|
let iconStack;
|
|
9457
9700
|
let stackedFits = [];
|
|
9458
9701
|
let displayedStack = "[]";
|
|
@@ -9473,7 +9716,8 @@
|
|
|
9473
9716
|
content.style.flexDirection = shape === "rect" ? "column-reverse" : "";
|
|
9474
9717
|
};
|
|
9475
9718
|
if (presentation !== "text") {
|
|
9476
|
-
|
|
9719
|
+
// Without a chip of its own the icon sits on the pin's white body, so its colour is inferred from that.
|
|
9720
|
+
const built = this.buildIcon(pin ? pinLook(look) : look, counter, placePhoto);
|
|
9477
9721
|
startPhoto = built.start;
|
|
9478
9722
|
const icon = iconElement = built.icon;
|
|
9479
9723
|
fitIconBackground = built.fit;
|
|
@@ -9498,6 +9742,18 @@
|
|
|
9498
9742
|
iconStack.style.cssText = "display:none;gap:2px;align-items:center;justify-items:center;flex:none;";
|
|
9499
9743
|
makeClickable(iconStack);
|
|
9500
9744
|
iconContainer.append(iconStack, icon);
|
|
9745
|
+
if (pin) {
|
|
9746
|
+
pinHolder = document.createElement("span");
|
|
9747
|
+
pinHolder.className = "entity-label-pin";
|
|
9748
|
+
pinHolder.style.cssText = "position:absolute;left:50%;top:50%;z-index:-1;pointer-events:none;";
|
|
9749
|
+
pinBody = document.createElement("span");
|
|
9750
|
+
pinBody.style.cssText = `position:absolute;inset:0;background:${PIN_COLOR};border:1px solid rgba(0, 0, 0, 0.14);` +
|
|
9751
|
+
"box-sizing:border-box;border-radius:50% 50% 0 50%;";
|
|
9752
|
+
pinHolder.appendChild(pinBody);
|
|
9753
|
+
iconContainer.prepend(pinHolder);
|
|
9754
|
+
// Text beside or above keeps its usual gap from the body rather than from the icon inside it.
|
|
9755
|
+
content.style.gap = `${6 + PIN_RIM}px`;
|
|
9756
|
+
}
|
|
9501
9757
|
content.appendChild(iconContainer);
|
|
9502
9758
|
}
|
|
9503
9759
|
if (presentation !== "icon") {
|
|
@@ -9571,7 +9827,10 @@
|
|
|
9571
9827
|
border-radius: 9px;
|
|
9572
9828
|
color: #ffffff;
|
|
9573
9829
|
text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
|
|
9830
|
+
will-change: transform;
|
|
9574
9831
|
`);
|
|
9832
|
+
// Each label, leader and ring gets its own compositor layer: in one shared layer, moving any of them
|
|
9833
|
+
// repainted all of them, shadows included, on every camera move.
|
|
9575
9834
|
this.label = ele;
|
|
9576
9835
|
ele.style.width = "max-content";
|
|
9577
9836
|
layer.element.appendChild(ele);
|
|
@@ -9590,6 +9849,7 @@
|
|
|
9590
9849
|
width: 2px;
|
|
9591
9850
|
background: rgba(255, 255, 255, 0.8);
|
|
9592
9851
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
|
9852
|
+
will-change: transform;
|
|
9593
9853
|
`);
|
|
9594
9854
|
this.line = lineEle;
|
|
9595
9855
|
lineEle.className = "entity-label-leader";
|
|
@@ -9607,6 +9867,7 @@
|
|
|
9607
9867
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
|
9608
9868
|
top: -2px;
|
|
9609
9869
|
left: -2px;
|
|
9870
|
+
will-change: transform;
|
|
9610
9871
|
`);
|
|
9611
9872
|
lineEleNode.className = "entity-label-anchor";
|
|
9612
9873
|
// SVG preserves fractional strokes in scaled containers where CSS borders round to pixels.
|
|
@@ -9639,13 +9900,13 @@
|
|
|
9639
9900
|
}
|
|
9640
9901
|
const fitLeader = (anchorX, anchorY, desired, width, height, radius = 0) => {
|
|
9641
9902
|
const above = Math.max(0, anchorY - height);
|
|
9642
|
-
const below = Math.max(0,
|
|
9903
|
+
const below = Math.max(0, layer.viewport.height - anchorY - height);
|
|
9643
9904
|
// Keep a short visible stem before switching sides; never aim it at the cursor or a box corner.
|
|
9644
9905
|
const upwards = above >= Math.max(radius ? radius + 4 : 0, Math.min(8, desired)) || above >= below;
|
|
9645
9906
|
const length = Math.min(desired, upwards ? above : below);
|
|
9646
9907
|
const endY = anchorY + (upwards ? -length : length);
|
|
9647
9908
|
return {
|
|
9648
|
-
x: Math.max(0, Math.min(anchorX,
|
|
9909
|
+
x: Math.max(0, Math.min(anchorX, layer.viewport.width - width)),
|
|
9649
9910
|
y: upwards ? endY - height : endY, endY
|
|
9650
9911
|
};
|
|
9651
9912
|
};
|
|
@@ -9654,20 +9915,50 @@
|
|
|
9654
9915
|
* so the stem rises to the label's middle and then runs out to whichever side has the room.
|
|
9655
9916
|
*/
|
|
9656
9917
|
const fitAngledLeader = (anchorX, anchorY, desired, width, height, radius = 0) => {
|
|
9657
|
-
const canvas =
|
|
9918
|
+
const canvas = layer.viewport;
|
|
9658
9919
|
const above = Math.max(0, anchorY - height / 2);
|
|
9659
|
-
const below = Math.max(0, canvas.
|
|
9920
|
+
const below = Math.max(0, canvas.height - anchorY - height / 2);
|
|
9660
9921
|
const upwards = above >= Math.max(radius ? radius + 4 : 0, Math.min(8, desired)) || above >= below;
|
|
9661
9922
|
const length = Math.min(desired, upwards ? above : below);
|
|
9662
9923
|
const endY = anchorY + (upwards ? -length : length);
|
|
9663
9924
|
const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
|
|
9664
|
-
const rightwards = anchorX + run + width <= canvas.
|
|
9925
|
+
const rightwards = anchorX + run + width <= canvas.width || anchorX - run - width < 0;
|
|
9665
9926
|
return {
|
|
9666
|
-
x: Math.max(0, Math.min(rightwards ? anchorX + run : anchorX - run - width, canvas.
|
|
9667
|
-
y: Math.max(0, Math.min(endY - height / 2, canvas.
|
|
9927
|
+
x: Math.max(0, Math.min(rightwards ? anchorX + run : anchorX - run - width, canvas.width - width)),
|
|
9928
|
+
y: Math.max(0, Math.min(endY - height / 2, canvas.height - height)), endY,
|
|
9668
9929
|
run, side: (rightwards ? "right" : "left")
|
|
9669
9930
|
};
|
|
9670
9931
|
};
|
|
9932
|
+
/*
|
|
9933
|
+
* Where the icon sits in the label, and how far the pin's tip reaches from its centre, in layout pixels.
|
|
9934
|
+
* Measured from the icon's container, so a cluster's icon stack is wrapped the same way as a lone icon.
|
|
9935
|
+
*/
|
|
9936
|
+
const measurePin = () => {
|
|
9937
|
+
const scale = layer.coordinates.scaleX;
|
|
9938
|
+
const radius = Math.max(iconContainer.offsetWidth, iconContainer.offsetHeight) / 2 + PIN_RIM;
|
|
9939
|
+
return {
|
|
9940
|
+
x: (iconContainer.offsetLeft + iconContainer.offsetWidth / 2) / scale,
|
|
9941
|
+
y: (iconContainer.offsetTop + iconContainer.offsetHeight / 2) / layer.coordinates.scaleY,
|
|
9942
|
+
radius: radius / scale,
|
|
9943
|
+
// The body's one square corner, half a diagonal from its centre.
|
|
9944
|
+
tip: radius * Math.SQRT2 / scale
|
|
9945
|
+
};
|
|
9946
|
+
};
|
|
9947
|
+
/*
|
|
9948
|
+
* A pin stands over its anchor with the icon centred on it, and hangs below when there is no room above.
|
|
9949
|
+
* Off to the side it is only clamped back on screen, and its tip turns to keep pointing at the anchor.
|
|
9950
|
+
*/
|
|
9951
|
+
const fitPin = (anchorX, anchorY, stem, width, height, shape) => {
|
|
9952
|
+
const canvas = layer.viewport;
|
|
9953
|
+
const reach = stem + shape.tip;
|
|
9954
|
+
const above = anchorY - reach - shape.y;
|
|
9955
|
+
const below = anchorY + reach - shape.y;
|
|
9956
|
+
const upwards = above >= 0 || (below + height > canvas.height && anchorY >= canvas.height - anchorY);
|
|
9957
|
+
return {
|
|
9958
|
+
x: Math.max(0, Math.min(anchorX - shape.x, canvas.width - width)),
|
|
9959
|
+
y: upwards ? above : below
|
|
9960
|
+
};
|
|
9961
|
+
};
|
|
9671
9962
|
/*
|
|
9672
9963
|
* The on-screen centre and half-size of a point or billboard glyph, relative to its projected position.
|
|
9673
9964
|
* Read every frame, since styling and selection can rescale a billboard in place.
|
|
@@ -9782,9 +10073,46 @@
|
|
|
9782
10073
|
this.viewer.scene.requestRender();
|
|
9783
10074
|
}).finally(settle);
|
|
9784
10075
|
}
|
|
10076
|
+
/*
|
|
10077
|
+
* The label's size when last laid out. A label hidden in a cluster leaves layout altogether, so a
|
|
10078
|
+
* frame reads its size from here; a shown one refreshes it when it changes, a new one on its first frame.
|
|
10079
|
+
*/
|
|
10080
|
+
let size = null;
|
|
10081
|
+
const measureSize = () => {
|
|
10082
|
+
size = {
|
|
10083
|
+
width: ele.offsetWidth,
|
|
10084
|
+
height: ele.offsetHeight,
|
|
10085
|
+
textWidth: (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetWidth) || 0,
|
|
10086
|
+
textHeight: (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetHeight) || 0,
|
|
10087
|
+
iconWidth: (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetWidth) || 0,
|
|
10088
|
+
iconHeight: (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetHeight) || 0,
|
|
10089
|
+
naturalTextWidth: (sourceNaturalText === null || sourceNaturalText === void 0 ? void 0 : sourceNaturalText.offsetWidth) || 0,
|
|
10090
|
+
pin: pin ? measurePin() : undefined
|
|
10091
|
+
};
|
|
10092
|
+
};
|
|
10093
|
+
// Whether the label was out of layout last frame, so staying hidden writes nothing.
|
|
10094
|
+
let hiddenLast = false;
|
|
10095
|
+
// Set by this frame's writes that change the label's size, so it is measured before it is placed.
|
|
10096
|
+
let sizeStale = true;
|
|
10097
|
+
// Set when the size changed on its own; a shown label reads it at the start of the next frame, while layout
|
|
10098
|
+
// is still clean, rather than forcing a layout mid-frame.
|
|
10099
|
+
let resizedSince = false;
|
|
10100
|
+
// The cluster badge's own size beside its icon, read with the label's.
|
|
10101
|
+
let badge = null;
|
|
10102
|
+
// Images, fonts and photo transitions change the size outside any write here. Without an observer the size
|
|
10103
|
+
// is read every frame instead.
|
|
10104
|
+
const resized = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
|
|
10105
|
+
if (this.disposed || this.counter !== counter) {
|
|
10106
|
+
resized.disconnect();
|
|
10107
|
+
return;
|
|
10108
|
+
}
|
|
10109
|
+
resizedSince = true;
|
|
10110
|
+
this.viewer.scene.requestRender();
|
|
10111
|
+
});
|
|
10112
|
+
resized === null || resized === void 0 ? void 0 : resized.observe(ele);
|
|
9785
10113
|
let cursorMotion = this.cursorMotion;
|
|
9786
10114
|
const project = () => {
|
|
9787
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
10115
|
+
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;
|
|
9788
10116
|
if (this.disposed || !this.viewer || this.viewer.isDestroyed() || ((_a = this.visible) === null || _a === void 0 ? void 0 : _a.call(this)) === false ||
|
|
9789
10117
|
(presentation === "icon" && this.options.iconScale === 0)) {
|
|
9790
10118
|
return null;
|
|
@@ -9793,6 +10121,11 @@
|
|
|
9793
10121
|
(this.hoverFade.from === 0 || Date.now() - this.hoverFade.start >= 120)) {
|
|
9794
10122
|
return null;
|
|
9795
10123
|
}
|
|
10124
|
+
// A new label is still in layout, so its first frame reads its size, as does a shown one that resized.
|
|
10125
|
+
if (!size || (resizedSince && !hiddenLast)) {
|
|
10126
|
+
measureSize();
|
|
10127
|
+
resizedSince = false;
|
|
10128
|
+
}
|
|
9796
10129
|
// Moving point/model positions must be sampled at the current clock time.
|
|
9797
10130
|
if (!this.prePositioned && visual instanceof Cesium.Entity && visual.position) {
|
|
9798
10131
|
const position = getValue(this.viewer, visual.position);
|
|
@@ -9840,8 +10173,8 @@
|
|
|
9840
10173
|
y: ringPoint.y + (boxTarget.y - ringPoint.y) * boxBlend
|
|
9841
10174
|
} : undefined;
|
|
9842
10175
|
const start = boxAnchor || anchor;
|
|
9843
|
-
const onScreen = anchor.x >= 0 && anchor.y >= 0 && anchor.x <
|
|
9844
|
-
if (leader && (start.x < 0 || start.y < 0 || start.x >=
|
|
10176
|
+
const onScreen = anchor.x >= 0 && anchor.y >= 0 && anchor.x < layer.viewport.width && anchor.y < layer.viewport.height;
|
|
10177
|
+
if (leader && (start.x < 0 || start.y < 0 || start.x >= layer.viewport.width || start.y >= layer.viewport.height))
|
|
9845
10178
|
return null;
|
|
9846
10179
|
if (onScreen && !this.imageAsked && this.groupId && !HasIcon(this.options) && !this.options.photo) {
|
|
9847
10180
|
this.imageAsked = true;
|
|
@@ -9885,8 +10218,8 @@
|
|
|
9885
10218
|
if (cursorAmount > 0 && !pinned) {
|
|
9886
10219
|
// A leader-less label starts centred on its anchor; preserve that box as it lifts away.
|
|
9887
10220
|
if (!normalLeader) {
|
|
9888
|
-
x -=
|
|
9889
|
-
y +=
|
|
10221
|
+
x -= size.width / layer.coordinates.scaleX / 2;
|
|
10222
|
+
y += size.height / layer.coordinates.scaleY / 2;
|
|
9890
10223
|
}
|
|
9891
10224
|
x += (cursorMotion.position.x + pixelOffset.x - x) * cursorAmount;
|
|
9892
10225
|
y += (cursorMotion.position.y + pixelOffset.y - y) * cursorAmount;
|
|
@@ -9901,6 +10234,10 @@
|
|
|
9901
10234
|
else if (this.options.leaderLength != null) {
|
|
9902
10235
|
leaderLength = Math.max(0, this.options.leaderLength);
|
|
9903
10236
|
}
|
|
10237
|
+
else if (pin) {
|
|
10238
|
+
// The tip itself is the leader, so by default it touches what it marks.
|
|
10239
|
+
leaderLength = 0;
|
|
10240
|
+
}
|
|
9904
10241
|
else if (transientPivot) {
|
|
9905
10242
|
// Cursor callouts must not jump when the next hover target has a different extent.
|
|
9906
10243
|
leaderLength = 96;
|
|
@@ -9917,38 +10254,38 @@
|
|
|
9917
10254
|
if (visual instanceof Cesium.Entity && (visual.polygon || visual.polyline))
|
|
9918
10255
|
leaderLength /= 3;
|
|
9919
10256
|
}
|
|
9920
|
-
if (boxAnchor && this.options.leaderLength == null) {
|
|
10257
|
+
if (boxAnchor && this.options.leaderLength == null && !pin) {
|
|
9921
10258
|
leaderLength += (MODEL_BOX_STEM - leaderLength) * boxBlend;
|
|
9922
10259
|
}
|
|
9923
10260
|
if (cursorAmount > 0) {
|
|
9924
10261
|
leaderLength += (96 - leaderLength) * cursorAmount;
|
|
9925
10262
|
}
|
|
9926
10263
|
// Measured from the ring, so the visible stem is the same length whatever the glyph's size.
|
|
9927
|
-
|
|
10264
|
+
// A pin's tip rests on the glyph instead, since no ring is drawn around it.
|
|
10265
|
+
leaderLength += pin ? (_t = icon === null || icon === void 0 ? void 0 : icon.radius) !== null && _t !== void 0 ? _t : 0 : iconRing;
|
|
9928
10266
|
y = anchorY - leaderLength;
|
|
9929
10267
|
}
|
|
9930
10268
|
else if (hover && !reused && !pinned) {
|
|
9931
10269
|
x = hover.x + pixelOffset.x;
|
|
9932
10270
|
y = hover.y + pixelOffset.y - 24;
|
|
9933
10271
|
}
|
|
9934
|
-
// Hidden participants remain measurable; visibility never removes their layout boxes.
|
|
9935
10272
|
const coordinates = layer.coordinates;
|
|
9936
|
-
const width =
|
|
9937
|
-
const height =
|
|
10273
|
+
const width = size.width / coordinates.scaleX;
|
|
10274
|
+
const height = size.height / coordinates.scaleY;
|
|
9938
10275
|
let clusterBounds;
|
|
9939
|
-
if ((
|
|
9940
|
-
const textWidth =
|
|
9941
|
-
const textHeight =
|
|
10276
|
+
if ((_u = this.options.cluster) === null || _u === void 0 ? void 0 : _u.enabled) {
|
|
10277
|
+
const textWidth = size.textWidth;
|
|
10278
|
+
const textHeight = size.textHeight;
|
|
9942
10279
|
// A photo is never part of the footprint, so its arrival cannot change which cluster a label joins.
|
|
9943
|
-
const iconWidth = look.iconPhoto ? 0 :
|
|
9944
|
-
const iconHeight = look.iconPhoto ? 0 :
|
|
10280
|
+
const iconWidth = look.iconPhoto ? 0 : size.iconWidth;
|
|
10281
|
+
const iconHeight = look.iconPhoto ? 0 : size.iconHeight;
|
|
9945
10282
|
const gap = sourceText && iconWidth ? 6 : 0;
|
|
9946
10283
|
const above = presentation === "icon-text-above";
|
|
9947
10284
|
// Match the fixed content gap and label padding, excluding the count badge.
|
|
9948
10285
|
const baseWidth = ((above ? Math.max(textWidth, iconWidth) : textWidth + iconWidth + gap) + 16) / coordinates.scaleX;
|
|
9949
10286
|
const baseHeight = ((above ? textHeight + iconHeight + gap : Math.max(textHeight, iconHeight)) + 12) / coordinates.scaleY;
|
|
9950
10287
|
clusterBounds = {
|
|
9951
|
-
x: leader ? x : x - baseWidth / 2,
|
|
10288
|
+
x: leader && !pin ? x : x - baseWidth / 2,
|
|
9952
10289
|
y: leader ? y - baseHeight : y - baseHeight / 2, width: baseWidth, height: baseHeight
|
|
9953
10290
|
};
|
|
9954
10291
|
}
|
|
@@ -9959,7 +10296,9 @@
|
|
|
9959
10296
|
// Membership uses the unclamped source footprint, never the summary's changing dimensions.
|
|
9960
10297
|
let leaderRun;
|
|
9961
10298
|
let leaderSide;
|
|
9962
|
-
if (leader &&
|
|
10299
|
+
if (leader && pin)
|
|
10300
|
+
({ x, y } = fitPin(anchorX, anchorY, leaderLength, width, height, size.pin));
|
|
10301
|
+
else if (leader && angled) {
|
|
9963
10302
|
const fit = fitAngledLeader(anchorX, anchorY, leaderLength, width, height);
|
|
9964
10303
|
({ x, y } = fit);
|
|
9965
10304
|
({ run: leaderRun, side: leaderSide } = fit);
|
|
@@ -9967,19 +10306,19 @@
|
|
|
9967
10306
|
else if (leader)
|
|
9968
10307
|
({ x, y } = fitLeader(anchorX, anchorY, leaderLength, width, height));
|
|
9969
10308
|
const bounds = clusterBounds || { x, y, width, height };
|
|
9970
|
-
if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x >
|
|
10309
|
+
if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x > layer.viewport.width || bounds.y > layer.viewport.height)) {
|
|
9971
10310
|
return null;
|
|
9972
10311
|
}
|
|
9973
|
-
const state = (
|
|
10312
|
+
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 });
|
|
9974
10313
|
const opacity = this.prePositioned || hoverOnly || MAX_DISTANCE === Infinity ? 1 : 1 - distance / MAX_DISTANCE;
|
|
9975
10314
|
return {
|
|
9976
|
-
canFlip: leader && presentation !== "icon", hasLeader: leader,
|
|
9977
|
-
textWrapped:
|
|
10315
|
+
canFlip: leader && presentation !== "icon" && !pin, hasLeader: leader,
|
|
10316
|
+
textWrapped: size.naturalTextWidth > TEXT_MAX_WIDTH,
|
|
9978
10317
|
transient: this.Transient || Boolean(hover) || cursorAmount > 0,
|
|
9979
10318
|
extendedGeometry: visual instanceof Cesium.Entity && Boolean(visual.polygon || visual.polyline || visual.corridor),
|
|
9980
|
-
viewportWidth:
|
|
9981
|
-
id: this.id, entityKey: ((
|
|
9982
|
-
entityId: (
|
|
10319
|
+
viewportWidth: layer.viewport.width,
|
|
10320
|
+
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,
|
|
10321
|
+
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,
|
|
9983
10322
|
iconRadius: icon === null || icon === void 0 ? void 0 : icon.radius, modelBox: boxed || undefined, boxBlend, follows: !pinned && Boolean(transientPivot || cursorMotion.target),
|
|
9984
10323
|
// Priority shows the hovered member individually without dragging its cluster along.
|
|
9985
10324
|
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
|
|
@@ -9988,15 +10327,25 @@
|
|
|
9988
10327
|
let displacement = { x: 0, y: 0 };
|
|
9989
10328
|
let nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
|
|
9990
10329
|
const apply = (placement) => {
|
|
9991
|
-
var _a, _b, _c, _d, _e
|
|
10330
|
+
var _a, _b, _c, _d, _e;
|
|
9992
10331
|
const show = (placement === null || placement === void 0 ? void 0 : placement.visible) && placement.opacity > 0;
|
|
10332
|
+
if (!show && hiddenLast) {
|
|
10333
|
+
return;
|
|
10334
|
+
}
|
|
10335
|
+
if (show && hiddenLast) {
|
|
10336
|
+
sizeStale = true;
|
|
10337
|
+
}
|
|
10338
|
+
hiddenLast = !show;
|
|
9993
10339
|
shownOnce = shownOnce || Boolean(show);
|
|
9994
10340
|
clickEntityIds = show ? placement.entityIds : [];
|
|
10341
|
+
// Out of layout while hidden, so thousands of clustered labels cost the browser nothing to lay out.
|
|
10342
|
+
ele.style.display = show ? "flex" : "none";
|
|
9995
10343
|
ele.style.visibility = show ? "visible" : "hidden";
|
|
9996
10344
|
lineEle.style.display = show && leader ? "block" : "none";
|
|
9997
10345
|
if (runEle)
|
|
9998
10346
|
runEle.style.display = show && leader ? "block" : "none";
|
|
9999
|
-
|
|
10347
|
+
// A pin's tip marks the anchor itself, so it has no ring there.
|
|
10348
|
+
this.anchor.style.display = show && leader && !pin && !(((_a = placement.frame) === null || _a === void 0 ? void 0 : _a.boxBlend) >= 1) ? "block" : "none";
|
|
10000
10349
|
if (!show) {
|
|
10001
10350
|
displacement = { x: 0, y: 0 };
|
|
10002
10351
|
nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
|
|
@@ -10029,6 +10378,7 @@
|
|
|
10029
10378
|
const displayText = (_c = placement.text) !== null && _c !== void 0 ? _c : originalText;
|
|
10030
10379
|
if (textElement && textElement.textContent !== displayText) {
|
|
10031
10380
|
textElement.textContent = displayText;
|
|
10381
|
+
sizeStale = true;
|
|
10032
10382
|
// Measure the summary's footprint next frame without replacing each member's source text.
|
|
10033
10383
|
this.viewer.scene.requestRender();
|
|
10034
10384
|
}
|
|
@@ -10043,17 +10393,17 @@
|
|
|
10043
10393
|
const count = placement.members.length ? String(placement.members.length) : "";
|
|
10044
10394
|
if (countElement.textContent !== count) {
|
|
10045
10395
|
countElement.textContent = count;
|
|
10396
|
+
sizeStale = true;
|
|
10046
10397
|
// The badge participates in layout, so its new width needs another measurement.
|
|
10047
10398
|
this.viewer.scene.requestRender();
|
|
10048
10399
|
}
|
|
10049
|
-
fitIconBackground === null || fitIconBackground === void 0 ? void 0 : fitIconBackground();
|
|
10050
10400
|
const stack = JSON.stringify(placement.icons || []);
|
|
10051
10401
|
if (iconStack && stack !== displayedStack) {
|
|
10052
10402
|
displayedStack = stack;
|
|
10053
10403
|
const looks = ((_d = placement.icons) === null || _d === void 0 ? void 0 : _d.length) ? [iconLook(this.options), ...placement.icons] : [];
|
|
10054
10404
|
// One small size for all, so no icon in the arrangement reads as more important than another.
|
|
10055
10405
|
const size = (this.options.iconSize || 24) * ((_e = this.options.iconScale) !== null && _e !== void 0 ? _e : 1) * ICON_STACK_SCALE;
|
|
10056
|
-
const built = looks.map(look => this.buildIcon({ ...look, iconSize: size }, counter));
|
|
10406
|
+
const built = looks.map(look => this.buildIcon({ ...(pin ? pinLook(look) : look), iconSize: size }, counter));
|
|
10057
10407
|
// A stack is on show already, so its photos load straight away.
|
|
10058
10408
|
built.forEach(({ start }) => start === null || start === void 0 ? void 0 : start());
|
|
10059
10409
|
// Two sit side by side; three make a triangle with the representative on top.
|
|
@@ -10062,6 +10412,7 @@
|
|
|
10062
10412
|
built[0].icon.style.gridColumn = "1 / span 2";
|
|
10063
10413
|
}
|
|
10064
10414
|
iconStack.replaceChildren(...built.map(({ icon }) => icon));
|
|
10415
|
+
sizeStale = true;
|
|
10065
10416
|
iconStack.style.display = built.length ? "inline-grid" : "none";
|
|
10066
10417
|
// The glyph stays measurable, since cluster membership is taken from its footprint.
|
|
10067
10418
|
iconElement.style.visibility = built.length ? "hidden" : "";
|
|
@@ -10070,238 +10421,301 @@
|
|
|
10070
10421
|
// The stack widens the label, which the next frame has to measure.
|
|
10071
10422
|
this.viewer.scene.requestRender();
|
|
10072
10423
|
}
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10424
|
+
/*
|
|
10425
|
+
* Everything above writes the label's content. The layer runs what follows in two passes over all
|
|
10426
|
+
* its labels, measuring every one before placing any, so no label reads layout another just changed.
|
|
10427
|
+
*/
|
|
10428
|
+
return () => {
|
|
10429
|
+
if (sizeStale || !resized) {
|
|
10430
|
+
fitIconBackground === null || fitIconBackground === void 0 ? void 0 : fitIconBackground();
|
|
10431
|
+
for (const fit of stackedFits)
|
|
10432
|
+
fit();
|
|
10433
|
+
badge = badgeOnIcon ? {
|
|
10434
|
+
width: countElement.offsetWidth,
|
|
10435
|
+
height: countElement.offsetHeight,
|
|
10436
|
+
iconWidth: iconElement.offsetWidth,
|
|
10437
|
+
iconHeight: iconElement.offsetHeight
|
|
10438
|
+
} : null;
|
|
10439
|
+
measureSize();
|
|
10440
|
+
sizeStale = false;
|
|
10441
|
+
}
|
|
10442
|
+
const pinShape = leader && pin ? size.pin : undefined;
|
|
10443
|
+
const measuredWidth = size.width / coordinates.scaleX;
|
|
10444
|
+
const measuredHeight = size.height / coordinates.scaleY;
|
|
10445
|
+
return () => {
|
|
10446
|
+
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, _0;
|
|
10447
|
+
if (badge) {
|
|
10448
|
+
const narrow = badge.iconWidth < badge.iconHeight * 0.6;
|
|
10449
|
+
const clearance = badge.width ? (narrow ? badge.width / 2 + 2 : Math.max(0, badge.width / 2 - badge.iconWidth / 4)) : 0;
|
|
10450
|
+
// Reserve the badge overhang so adjacent text and viewport edges remain clear.
|
|
10451
|
+
const overhang = badge.height / 2;
|
|
10452
|
+
const margins = [
|
|
10453
|
+
badgeBelow ? "0px" : `${overhang}px`, badgeBelow ? `${overhang}px` : "0px", `${badge.width / 2 + clearance}px`
|
|
10454
|
+
];
|
|
10455
|
+
countElement.style.left = `calc(100% + ${clearance}px)`;
|
|
10456
|
+
if (iconContainer.style.marginTop !== margins[0] ||
|
|
10457
|
+
iconContainer.style.marginBottom !== margins[1] ||
|
|
10458
|
+
iconContainer.style.marginRight !== margins[2]) {
|
|
10459
|
+
[iconContainer.style.marginTop, iconContainer.style.marginBottom, iconContainer.style.marginRight] = margins;
|
|
10460
|
+
sizeStale = true;
|
|
10461
|
+
// The margins change the label's size, which the next frame measures.
|
|
10462
|
+
this.viewer.scene.requestRender();
|
|
10463
|
+
}
|
|
10464
|
+
}
|
|
10465
|
+
const ring = this.options.anchorRing;
|
|
10466
|
+
const pointer = (layer.pointer || (cursorMotion.target ? cursorMotion.position : undefined) || (this.Transient && !this.Persistent ?
|
|
10467
|
+
(this.hoverFade.to === 0 ? this.retainedHoverPosition : (_a = this.visualRegister) === null || _a === void 0 ? void 0 : _a.GetLabelHoverPosition((_b = this.rego) === null || _b === void 0 ? void 0 : _b.entityId, (_c = this.rego) === null || _c === void 0 ? void 0 : _c.menuItemId)) : undefined));
|
|
10468
|
+
const iconRing = frame.iconRadius ? Math.max(ICON_RING_MIN, frame.iconRadius + ICON_RING_PADDING) : 0;
|
|
10469
|
+
const boxed = leader ? frame.modelBox : undefined;
|
|
10470
|
+
const hovered = pointer && (boxed ? hullContains(boxed.hull, pointer) :
|
|
10471
|
+
Math.hypot(pointer.x - frame.anchorX, pointer.y - frame.anchorY) <= Math.max((_d = ring === null || ring === void 0 ? void 0 : ring.hoverDistance) !== null && _d !== void 0 ? _d : 24, iconRing));
|
|
10472
|
+
if (look.iconPhoto && growPhoto) {
|
|
10473
|
+
// A rectangle leans on the leader's side of the label.
|
|
10474
|
+
if (photoShape === "rect") {
|
|
10475
|
+
const align = !leader ? "center" : placement.textSide === "left" ? "flex-end" : "flex-start";
|
|
10476
|
+
if (content.style.alignItems !== align) {
|
|
10477
|
+
content.style.alignItems = align;
|
|
10478
|
+
}
|
|
10479
|
+
}
|
|
10480
|
+
// Grown in layout rather than scaled, so the border keeps its width, and the label,
|
|
10481
|
+
// whose bottom sits on the leader, grows up and sideways without changing its length.
|
|
10482
|
+
growPhoto(Boolean(hovered) && !((_e = placement.members) === null || _e === void 0 ? void 0 : _e.length));
|
|
10483
|
+
sizeStale = true;
|
|
10484
|
+
}
|
|
10485
|
+
const normalRadius = (!leader || (ring === null || ring === void 0 ? void 0 : ring.enabled) === false ? 0 : Math.max(frame.distance <= ((_f = ring === null || ring === void 0 ? void 0 : ring.nearDistance) !== null && _f !== void 0 ? _f : 100) ? ((_g = ring === null || ring === void 0 ? void 0 : ring.nearRadius) !== null && _g !== void 0 ? _g : 10) : 0, hovered ? ((_h = ring === null || ring === void 0 ? void 0 : ring.hoverRadius) !== null && _h !== void 0 ? _h : (this.Transient && !this.Persistent ? 15.4 : 22)) : 0));
|
|
10486
|
+
const targetRadius = normalRadius + (15.4 - normalRadius) * cursorMotion.amount;
|
|
10487
|
+
// Around a glyph the ring keeps its size and only fades its stroke in, never covering it.
|
|
10488
|
+
// A ring around the cursor marks nothing, so a riding label keeps only its leader.
|
|
10489
|
+
const targetOuter = frame.follows ? 0 : iconRing || targetRadius || 2.5;
|
|
10490
|
+
const targetInner = frame.follows ? 0 : iconRing ? (targetRadius > 0 ? iconRing - 2 : iconRing) : Math.max(0, targetRadius - 2);
|
|
10491
|
+
const now = Date.now();
|
|
10492
|
+
const duration = (_j = ring === null || ring === void 0 ? void 0 : ring.transitionDuration) !== null && _j !== void 0 ? _j : 200;
|
|
10493
|
+
const sharedRing = this.Transient && !this.Persistent && this.hoverFade.to === 1 ? this.hoverRingState : undefined;
|
|
10494
|
+
let ringAnimation = sharedRing ? sharedRing.animation : this.ringAnimation;
|
|
10495
|
+
if (!ringAnimation) {
|
|
10496
|
+
const outer = frame.follows ? 0 : iconRing || 2.5;
|
|
10497
|
+
const inner = frame.follows ? 0 : iconRing;
|
|
10498
|
+
ringAnimation = { target: outer, targetInner: inner, start: now, outer, inner, fromOuter: outer, fromInner: inner };
|
|
10499
|
+
}
|
|
10500
|
+
const animateRing = () => {
|
|
10501
|
+
const progress = duration > 0 ? Math.min(1, Math.max(0, (now - ringAnimation.start) / duration)) : 1;
|
|
10502
|
+
const eased = progress * progress * (3 - 2 * progress);
|
|
10503
|
+
ringAnimation.outer = ringAnimation.fromOuter + (ringAnimation.target - ringAnimation.fromOuter) * eased;
|
|
10504
|
+
ringAnimation.inner = ringAnimation.fromInner + (ringAnimation.targetInner - ringAnimation.fromInner) * eased;
|
|
10505
|
+
return progress;
|
|
10506
|
+
};
|
|
10507
|
+
animateRing();
|
|
10508
|
+
if (ringAnimation.target !== targetOuter || ringAnimation.targetInner !== targetInner) {
|
|
10509
|
+
ringAnimation = {
|
|
10510
|
+
...ringAnimation,
|
|
10511
|
+
target: targetOuter,
|
|
10512
|
+
targetInner,
|
|
10513
|
+
start: now,
|
|
10514
|
+
fromOuter: ringAnimation.outer,
|
|
10515
|
+
fromInner: ringAnimation.inner
|
|
10516
|
+
};
|
|
10517
|
+
}
|
|
10518
|
+
// Animate the hole and stem together; no CSS transition may lag behind a moving world anchor.
|
|
10519
|
+
if (animateRing() < 1 && (ringAnimation.fromOuter !== targetOuter || ringAnimation.fromInner !== targetInner)) {
|
|
10520
|
+
this.viewer.scene.requestRender();
|
|
10521
|
+
}
|
|
10522
|
+
this.ringAnimation = ringAnimation;
|
|
10523
|
+
if (sharedRing) {
|
|
10524
|
+
sharedRing.animation = ringAnimation;
|
|
10525
|
+
}
|
|
10526
|
+
const ringShare = 1 - (frame.boxBlend || 0);
|
|
10527
|
+
const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
|
|
10528
|
+
const stem = (pinShape ? fitPin(frame.anchorX, frame.anchorY, frame.leaderLength, measuredWidth, measuredHeight, pinShape) :
|
|
10529
|
+
leader ? (angled ? fitAngledLeader : fitLeader)(frame.anchorX, frame.anchorY, Math.max(frame.leaderLength, radius ? radius + 4 : 0), measuredWidth, measuredHeight, radius) : undefined);
|
|
10530
|
+
const position = { x: (stem || frame).x, y: (stem || frame).y };
|
|
10531
|
+
const width = measuredWidth;
|
|
10532
|
+
const height = measuredHeight;
|
|
10533
|
+
if (leader && angled) {
|
|
10534
|
+
// The declutter owns the side; the fit only says which one had the room to begin with.
|
|
10535
|
+
const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
|
|
10536
|
+
const side = (_l = (_k = placement.textSide) !== null && _k !== void 0 ? _k : frame.leaderSide) !== null && _l !== void 0 ? _l : "right";
|
|
10537
|
+
const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
|
|
10538
|
+
position.x = Math.max(0, Math.min(beside, layer.viewport.width - width));
|
|
10539
|
+
}
|
|
10540
|
+
else if (leader && !pin && placement.textSide === "left") {
|
|
10541
|
+
position.x = Math.max(0, Math.min(frame.anchorX - width, layer.viewport.width - width));
|
|
10542
|
+
}
|
|
10543
|
+
const gap = (_o = (_m = this.options.pointerAvoidance) === null || _m === void 0 ? void 0 : _m.gap) !== null && _o !== void 0 ? _o : 12;
|
|
10544
|
+
const containsPointer = (x, y, margin) => {
|
|
10545
|
+
return pointer && pointer.x >= x - margin && pointer.x <= x + width + margin && pointer.y >= y - margin && pointer.y <= y + height + margin;
|
|
10546
|
+
};
|
|
10547
|
+
const passive = !selectOnClick || !this.visualRegister;
|
|
10548
|
+
if (passive && ((_p = this.options.pointerAvoidance) === null || _p === void 0 ? void 0 : _p.enabled) !== false && pointer &&
|
|
10549
|
+
(containsPointer(position.x, position.y, gap) || containsPointer(position.x + displacement.x, position.y + displacement.y, gap))) {
|
|
10550
|
+
if (containsPointer(position.x + displacement.x, position.y + displacement.y, 0)) {
|
|
10551
|
+
// Choose against the original box; keep the offset until the pointer leaves both.
|
|
10552
|
+
const candidates = [
|
|
10553
|
+
{ x: 0, y: pointer.y - gap - height - position.y },
|
|
10554
|
+
{ x: 0, y: pointer.y + gap - position.y },
|
|
10555
|
+
{ x: pointer.x - gap - width - position.x, y: 0 },
|
|
10556
|
+
{ x: pointer.x + gap - position.x, y: 0 }
|
|
10557
|
+
].filter(offset => position.x + offset.x >= 0 && position.y + offset.y >= 0 &&
|
|
10558
|
+
position.x + offset.x + width <= layer.viewport.width && position.y + offset.y + height <= layer.viewport.height)
|
|
10559
|
+
.sort((a, b) => Math.hypot(a.x, a.y) - Math.hypot(b.x, b.y));
|
|
10560
|
+
displacement = candidates[0] || { x: 0, y: 0 };
|
|
10561
|
+
}
|
|
10562
|
+
}
|
|
10563
|
+
else {
|
|
10564
|
+
displacement = { x: 0, y: 0 };
|
|
10565
|
+
}
|
|
10566
|
+
const nudgeDuration = (_r = (_q = this.options.pointerAvoidance) === null || _q === void 0 ? void 0 : _q.transitionDuration) !== null && _r !== void 0 ? _r : 200;
|
|
10567
|
+
const animateNudge = () => {
|
|
10568
|
+
const progress = now < nudge.start ? 0 : nudgeDuration > 0 ? Math.min(1, (now - nudge.start) / nudgeDuration) : 1;
|
|
10569
|
+
const eased = progress * progress * (3 - 2 * progress);
|
|
10570
|
+
nudge.x = nudge.fromX + (nudge.targetX - nudge.fromX) * eased;
|
|
10571
|
+
nudge.y = nudge.fromY + (nudge.targetY - nudge.fromY) * eased;
|
|
10572
|
+
return progress;
|
|
10573
|
+
};
|
|
10574
|
+
animateNudge();
|
|
10575
|
+
if (nudge.targetX !== displacement.x || nudge.targetY !== displacement.y) {
|
|
10576
|
+
nudge = {
|
|
10577
|
+
...nudge,
|
|
10578
|
+
fromX: nudge.x,
|
|
10579
|
+
fromY: nudge.y,
|
|
10580
|
+
targetX: displacement.x,
|
|
10581
|
+
targetY: displacement.y,
|
|
10582
|
+
start: now + ((_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.delay) !== null && _t !== void 0 ? _t : 180)
|
|
10583
|
+
};
|
|
10584
|
+
}
|
|
10585
|
+
if (animateNudge() < 1 && (nudge.fromX !== nudge.targetX || nudge.fromY !== nudge.targetY)) {
|
|
10586
|
+
this.viewer.scene.requestRender();
|
|
10587
|
+
}
|
|
10588
|
+
position.x += nudge.x;
|
|
10589
|
+
position.y += nudge.y;
|
|
10590
|
+
ele.style.left = `${coordinates.x + position.x * coordinates.scaleX}px`;
|
|
10591
|
+
ele.style.top = `${coordinates.y + position.y * coordinates.scaleY}px`;
|
|
10592
|
+
for (const clickTarget of Array.from(content.querySelectorAll('[role="button"]'))) {
|
|
10593
|
+
clickTarget.setAttribute("aria-label", placement.members.length ? `Select ${placement.entityIds.length} entities` : `Select ${(_v = (_u = this.options.text) !== null && _u !== void 0 ? _u : text) !== null && _v !== void 0 ? _v : (_w = this.rego) === null || _w === void 0 ? void 0 : _w.entityId}`);
|
|
10594
|
+
}
|
|
10595
|
+
if (leader) {
|
|
10596
|
+
const nodeRadius = ringAnimation.outer * (1 - (frame.boxBlend || 0));
|
|
10597
|
+
const anchor = this.anchor;
|
|
10598
|
+
anchor.style.left = `${coordinates.x + (frame.anchorX - nodeRadius) * coordinates.scaleX}px`;
|
|
10599
|
+
anchor.style.top = `${coordinates.y + (frame.anchorY - nodeRadius) * coordinates.scaleY}px`;
|
|
10600
|
+
anchor.style.width = `${nodeRadius * 2 * coordinates.scaleX}px`;
|
|
10601
|
+
anchor.style.height = `${nodeRadius * 2 * coordinates.scaleY}px`;
|
|
10602
|
+
anchor.style.boxSizing = "border-box";
|
|
10603
|
+
anchor.style.background = "transparent";
|
|
10604
|
+
const svg = anchor.firstElementChild;
|
|
10605
|
+
svg.setAttribute("viewBox", `0 0 ${nodeRadius * 2} ${nodeRadius * 2}`);
|
|
10606
|
+
const circle = svg.firstElementChild;
|
|
10607
|
+
circle.setAttribute("cx", String(nodeRadius));
|
|
10608
|
+
circle.setAttribute("cy", String(nodeRadius));
|
|
10609
|
+
const innerRadius = ringAnimation.inner * (1 - (frame.boxBlend || 0));
|
|
10610
|
+
circle.setAttribute("r", String((nodeRadius + innerRadius) / 2));
|
|
10611
|
+
circle.setAttribute("stroke", this.options.leaderColor || "rgba(255, 255, 255, 0.8)");
|
|
10612
|
+
circle.setAttribute("stroke-width", String(nodeRadius - innerRadius));
|
|
10613
|
+
anchor.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10614
|
+
anchor.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount) * (1 - (frame.boxBlend || 0)));
|
|
10615
|
+
anchor.style.zIndex = String(placement.zIndex);
|
|
10616
|
+
// The stem starts at the rim, never across the clear centre, even after displacement.
|
|
10617
|
+
const straightX = Math.max(position.x, Math.min(frame.anchorX, position.x + width));
|
|
10618
|
+
const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
|
|
10619
|
+
const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
|
|
10620
|
+
const elbowY = position.y + height / 2;
|
|
10621
|
+
let endX = beside ? frame.anchorX : straightX;
|
|
10622
|
+
let endY = beside ? elbowY : straightY;
|
|
10623
|
+
if (pinShape) {
|
|
10624
|
+
// Aimed from wherever clamping or a nudge left it; a stem, if any, meets the tip.
|
|
10625
|
+
const centreX = position.x + pinShape.x, centreY = position.y + pinShape.y;
|
|
10626
|
+
const aim = Math.atan2(frame.anchorY - centreY, frame.anchorX - centreX);
|
|
10627
|
+
const reach = Math.min(pinShape.tip, Math.hypot(frame.anchorX - centreX, frame.anchorY - centreY));
|
|
10628
|
+
endX = centreX + Math.cos(aim) * reach;
|
|
10629
|
+
endY = centreY + Math.sin(aim) * reach;
|
|
10630
|
+
const size = `${pinShape.radius * 2 * coordinates.scaleX}px`;
|
|
10631
|
+
if (pinHolder.style.width !== size) {
|
|
10632
|
+
pinHolder.style.width = pinHolder.style.height = size;
|
|
10633
|
+
pinHolder.style.margin = `-${pinShape.radius * coordinates.scaleX}px`;
|
|
10634
|
+
}
|
|
10635
|
+
// The body's square corner starts lower right, a quarter turn short of down.
|
|
10636
|
+
const turn = Math.round((aim - Math.PI / 4) * 200) / 200;
|
|
10637
|
+
const rotation = `rotate(${turn}rad)`;
|
|
10638
|
+
if (pinBody.style.transform !== rotation) {
|
|
10639
|
+
pinBody.style.transform = rotation;
|
|
10640
|
+
// A box shadow turns with the body, so its offset is turned back to fall down
|
|
10641
|
+
// and right; a drop-shadow filter would not turn, but repaints every moving pin.
|
|
10642
|
+
const offsetX = Math.round((Math.cos(turn) + 2 * Math.sin(turn)) * 4) / 4;
|
|
10643
|
+
const offsetY = Math.round((2 * Math.cos(turn) - Math.sin(turn)) * 4) / 4;
|
|
10644
|
+
pinBody.style.boxShadow = `${offsetX}px ${offsetY}px 3px rgba(0, 0, 0, 0.35)`;
|
|
10645
|
+
}
|
|
10646
|
+
}
|
|
10647
|
+
const runToX = frame.anchorX < position.x ? position.x : position.x + width;
|
|
10648
|
+
const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
|
|
10649
|
+
const length = Math.hypot(dx, dy);
|
|
10650
|
+
const leaderAngle = Math.atan2(dy, dx);
|
|
10651
|
+
const pointerDx = pointer ? pointer.x - frame.anchorX : 0;
|
|
10652
|
+
const pointerDy = pointer ? pointer.y - frame.anchorY : 0;
|
|
10653
|
+
const desiredAngle = Math.hypot(pointerDx, pointerDy) > 0.5 ? Math.atan2(pointerDy, pointerDx) + Math.PI - leaderAngle : 0;
|
|
10654
|
+
const wrappedAngle = Math.atan2(Math.sin(desiredAngle), Math.cos(desiredAngle));
|
|
10655
|
+
// Keep the stem inside the 126-degree arc, away from antialiased endpoints.
|
|
10656
|
+
const arcFraction = 0.35;
|
|
10657
|
+
const rotationLimit = Math.PI * arcFraction - Math.PI / 30;
|
|
10658
|
+
const targetOffset = hovered ? Math.max(-rotationLimit, Math.min(rotationLimit, wrappedAngle)) : ((_x = ringAnimation.arcOffset) !== null && _x !== void 0 ? _x : 0);
|
|
10659
|
+
const targetOpen = cursorMotion.target || (hovered && (ring === null || ring === void 0 ? void 0 : ring.enabled) !== false && targetRadius > 0) ? 1 : 0;
|
|
10660
|
+
const elapsed = Math.min(32, Math.max(0, now - ((_y = ringAnimation.arcTime) !== null && _y !== void 0 ? _y : now)));
|
|
10661
|
+
const blend = duration > 0 ? 1 - Math.exp(-elapsed / (duration / 3)) : 1;
|
|
10662
|
+
const approach = (value, target) => Math.abs(value - target) < 0.001 ? target : value + (target - value) * blend;
|
|
10663
|
+
ringAnimation.arcOffset = approach((_z = ringAnimation.arcOffset) !== null && _z !== void 0 ? _z : 0, targetOffset);
|
|
10664
|
+
ringAnimation.arcOpen = approach((_0 = ringAnimation.arcOpen) !== null && _0 !== void 0 ? _0 : 0, targetOpen);
|
|
10665
|
+
ringAnimation.arcTime = now;
|
|
10666
|
+
if (ringAnimation.arcOffset !== targetOffset || ringAnimation.arcOpen !== targetOpen) {
|
|
10667
|
+
this.viewer.scene.requestRender();
|
|
10668
|
+
}
|
|
10669
|
+
const circumference = Math.PI * (nodeRadius + ringAnimation.inner);
|
|
10670
|
+
const filledFraction = 1 - ringAnimation.arcOpen * (1 - arcFraction);
|
|
10671
|
+
circle.setAttribute("stroke-dasharray", `${circumference * filledFraction} ${circumference * (1 - filledFraction)}`);
|
|
10672
|
+
circle.setAttribute("transform", `rotate(${(leaderAngle + ringAnimation.arcOffset - Math.PI * filledFraction) * 180 / Math.PI} ${nodeRadius} ${nodeRadius})`);
|
|
10673
|
+
const cut = Math.min(radius, length);
|
|
10674
|
+
const startX = frame.anchorX + (length ? dx / length * cut : 0);
|
|
10675
|
+
const startY = frame.anchorY + (length ? dy / length * cut : 0);
|
|
10676
|
+
const draw = (element, fromX, fromY, toX, toY) => {
|
|
10677
|
+
const screenDx = (toX - fromX) * coordinates.scaleX;
|
|
10678
|
+
const screenDy = (toY - fromY) * coordinates.scaleY;
|
|
10679
|
+
element.style.width = `${2 * coordinates.scaleX}px`;
|
|
10680
|
+
element.style.left = `${coordinates.x + (fromX - 1) * coordinates.scaleX}px`;
|
|
10681
|
+
element.style.top = `${coordinates.y + fromY * coordinates.scaleY}px`;
|
|
10682
|
+
element.style.height = `${Math.hypot(screenDx, screenDy)}px`;
|
|
10683
|
+
element.style.transform = `rotate(${Math.atan2(screenDy, screenDx) - Math.PI / 2}rad)`;
|
|
10684
|
+
element.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10685
|
+
element.style.transformOrigin = "top center";
|
|
10686
|
+
element.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount));
|
|
10687
|
+
element.style.zIndex = String(placement.zIndex);
|
|
10688
|
+
};
|
|
10689
|
+
draw(lineEle, startX, startY, endX, endY);
|
|
10690
|
+
if (layer.modelBoxes.Hull(this.id)) {
|
|
10691
|
+
layer.modelBoxes.Request(this.id, {
|
|
10692
|
+
whole: Boolean(cursorMotion.target), from: { x: frame.anchorX, y: frame.anchorY },
|
|
10693
|
+
opacity, zIndex: placement.zIndex, color: this.options.leaderColor || "rgba(255, 255, 255, 0.8)", duration
|
|
10694
|
+
});
|
|
10695
|
+
}
|
|
10696
|
+
if (runEle) {
|
|
10697
|
+
// Overlap the corner by the stem's own width so the elbow has no notch in it.
|
|
10698
|
+
const overlap = frame.anchorX < runToX ? -1 : 1;
|
|
10699
|
+
runEle.style.display = beside ? "block" : "none";
|
|
10700
|
+
if (beside)
|
|
10701
|
+
draw(runEle, endX + overlap, endY, runToX, endY);
|
|
10702
|
+
}
|
|
10703
|
+
}
|
|
10138
10704
|
};
|
|
10139
|
-
}
|
|
10140
|
-
// Animate the hole and stem together; no CSS transition may lag behind a moving world anchor.
|
|
10141
|
-
if (animateRing() < 1 && (ringAnimation.fromOuter !== targetOuter || ringAnimation.fromInner !== targetInner)) {
|
|
10142
|
-
this.viewer.scene.requestRender();
|
|
10143
|
-
}
|
|
10144
|
-
this.ringAnimation = ringAnimation;
|
|
10145
|
-
if (sharedRing) {
|
|
10146
|
-
sharedRing.animation = ringAnimation;
|
|
10147
|
-
}
|
|
10148
|
-
const ringShare = 1 - (frame.boxBlend || 0);
|
|
10149
|
-
const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
|
|
10150
|
-
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);
|
|
10151
|
-
const position = { x: (stem || frame).x, y: (stem || frame).y };
|
|
10152
|
-
const width = ele.offsetWidth / coordinates.scaleX;
|
|
10153
|
-
const height = ele.offsetHeight / coordinates.scaleY;
|
|
10154
|
-
if (leader && angled) {
|
|
10155
|
-
// The declutter owns the side; the fit only says which one had the room to begin with.
|
|
10156
|
-
const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
|
|
10157
|
-
const side = (_r = (_q = placement.textSide) !== null && _q !== void 0 ? _q : frame.leaderSide) !== null && _r !== void 0 ? _r : "right";
|
|
10158
|
-
const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
|
|
10159
|
-
position.x = Math.max(0, Math.min(beside, this.viewer.canvas.clientWidth - width));
|
|
10160
|
-
}
|
|
10161
|
-
else if (leader && placement.textSide === "left") {
|
|
10162
|
-
position.x = Math.max(0, Math.min(frame.anchorX - width, this.viewer.canvas.clientWidth - width));
|
|
10163
|
-
}
|
|
10164
|
-
const gap = (_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.gap) !== null && _t !== void 0 ? _t : 12;
|
|
10165
|
-
const containsPointer = (x, y, margin) => {
|
|
10166
|
-
return pointer && pointer.x >= x - margin && pointer.x <= x + width + margin && pointer.y >= y - margin && pointer.y <= y + height + margin;
|
|
10167
10705
|
};
|
|
10168
|
-
const passive = !selectOnClick || !this.visualRegister;
|
|
10169
|
-
if (passive && ((_u = this.options.pointerAvoidance) === null || _u === void 0 ? void 0 : _u.enabled) !== false && pointer &&
|
|
10170
|
-
(containsPointer(position.x, position.y, gap) || containsPointer(position.x + displacement.x, position.y + displacement.y, gap))) {
|
|
10171
|
-
if (containsPointer(position.x + displacement.x, position.y + displacement.y, 0)) {
|
|
10172
|
-
// Choose against the original box and retain the offset until the pointer leaves both boxes.
|
|
10173
|
-
const candidates = [
|
|
10174
|
-
{ x: 0, y: pointer.y - gap - height - position.y },
|
|
10175
|
-
{ x: 0, y: pointer.y + gap - position.y },
|
|
10176
|
-
{ x: pointer.x - gap - width - position.x, y: 0 },
|
|
10177
|
-
{ x: pointer.x + gap - position.x, y: 0 }
|
|
10178
|
-
].filter(offset => position.x + offset.x >= 0 && position.y + offset.y >= 0 &&
|
|
10179
|
-
position.x + offset.x + width <= this.viewer.canvas.clientWidth && position.y + offset.y + height <= this.viewer.canvas.clientHeight)
|
|
10180
|
-
.sort((a, b) => Math.hypot(a.x, a.y) - Math.hypot(b.x, b.y));
|
|
10181
|
-
displacement = candidates[0] || { x: 0, y: 0 };
|
|
10182
|
-
}
|
|
10183
|
-
}
|
|
10184
|
-
else {
|
|
10185
|
-
displacement = { x: 0, y: 0 };
|
|
10186
|
-
}
|
|
10187
|
-
const nudgeDuration = (_w = (_v = this.options.pointerAvoidance) === null || _v === void 0 ? void 0 : _v.transitionDuration) !== null && _w !== void 0 ? _w : 200;
|
|
10188
|
-
const animateNudge = () => {
|
|
10189
|
-
const progress = now < nudge.start ? 0 : nudgeDuration > 0 ? Math.min(1, (now - nudge.start) / nudgeDuration) : 1;
|
|
10190
|
-
const eased = progress * progress * (3 - 2 * progress);
|
|
10191
|
-
nudge.x = nudge.fromX + (nudge.targetX - nudge.fromX) * eased;
|
|
10192
|
-
nudge.y = nudge.fromY + (nudge.targetY - nudge.fromY) * eased;
|
|
10193
|
-
return progress;
|
|
10194
|
-
};
|
|
10195
|
-
animateNudge();
|
|
10196
|
-
if (nudge.targetX !== displacement.x || nudge.targetY !== displacement.y) {
|
|
10197
|
-
nudge = {
|
|
10198
|
-
...nudge,
|
|
10199
|
-
fromX: nudge.x,
|
|
10200
|
-
fromY: nudge.y,
|
|
10201
|
-
targetX: displacement.x,
|
|
10202
|
-
targetY: displacement.y,
|
|
10203
|
-
start: now + ((_y = (_x = this.options.pointerAvoidance) === null || _x === void 0 ? void 0 : _x.delay) !== null && _y !== void 0 ? _y : 180)
|
|
10204
|
-
};
|
|
10205
|
-
}
|
|
10206
|
-
if (animateNudge() < 1 && (nudge.fromX !== nudge.targetX || nudge.fromY !== nudge.targetY)) {
|
|
10207
|
-
this.viewer.scene.requestRender();
|
|
10208
|
-
}
|
|
10209
|
-
position.x += nudge.x;
|
|
10210
|
-
position.y += nudge.y;
|
|
10211
|
-
ele.style.left = `${coordinates.x + position.x * coordinates.scaleX}px`;
|
|
10212
|
-
ele.style.top = `${coordinates.y + position.y * coordinates.scaleY}px`;
|
|
10213
|
-
for (const clickTarget of Array.from(content.querySelectorAll('[role="button"]'))) {
|
|
10214
|
-
clickTarget.setAttribute("aria-label", placement.members.length ? `Select ${placement.entityIds.length} entities` : `Select ${(_0 = (_z = this.options.text) !== null && _z !== void 0 ? _z : text) !== null && _0 !== void 0 ? _0 : (_1 = this.rego) === null || _1 === void 0 ? void 0 : _1.entityId}`);
|
|
10215
|
-
}
|
|
10216
|
-
if (leader) {
|
|
10217
|
-
const nodeRadius = ringAnimation.outer * (1 - (frame.boxBlend || 0));
|
|
10218
|
-
const anchor = this.anchor;
|
|
10219
|
-
anchor.style.left = `${coordinates.x + (frame.anchorX - nodeRadius) * coordinates.scaleX}px`;
|
|
10220
|
-
anchor.style.top = `${coordinates.y + (frame.anchorY - nodeRadius) * coordinates.scaleY}px`;
|
|
10221
|
-
anchor.style.width = `${nodeRadius * 2 * coordinates.scaleX}px`;
|
|
10222
|
-
anchor.style.height = `${nodeRadius * 2 * coordinates.scaleY}px`;
|
|
10223
|
-
anchor.style.boxSizing = "border-box";
|
|
10224
|
-
anchor.style.background = "transparent";
|
|
10225
|
-
const svg = anchor.firstElementChild;
|
|
10226
|
-
svg.setAttribute("viewBox", `0 0 ${nodeRadius * 2} ${nodeRadius * 2}`);
|
|
10227
|
-
const circle = svg.firstElementChild;
|
|
10228
|
-
circle.setAttribute("cx", String(nodeRadius));
|
|
10229
|
-
circle.setAttribute("cy", String(nodeRadius));
|
|
10230
|
-
const innerRadius = ringAnimation.inner * (1 - (frame.boxBlend || 0));
|
|
10231
|
-
circle.setAttribute("r", String((nodeRadius + innerRadius) / 2));
|
|
10232
|
-
circle.setAttribute("stroke", this.options.leaderColor || "rgba(255, 255, 255, 0.8)");
|
|
10233
|
-
circle.setAttribute("stroke-width", String(nodeRadius - innerRadius));
|
|
10234
|
-
anchor.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10235
|
-
anchor.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount) * (1 - (frame.boxBlend || 0)));
|
|
10236
|
-
anchor.style.zIndex = String(placement.zIndex);
|
|
10237
|
-
// The stem starts at the rim, never across the transparent centre, even after passive displacement.
|
|
10238
|
-
const straightX = Math.max(position.x, Math.min(frame.anchorX, position.x + width));
|
|
10239
|
-
const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
|
|
10240
|
-
const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
|
|
10241
|
-
const elbowY = position.y + height / 2;
|
|
10242
|
-
const endX = beside ? frame.anchorX : straightX;
|
|
10243
|
-
const endY = beside ? elbowY : straightY;
|
|
10244
|
-
const runToX = frame.anchorX < position.x ? position.x : position.x + width;
|
|
10245
|
-
const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
|
|
10246
|
-
const length = Math.hypot(dx, dy);
|
|
10247
|
-
const leaderAngle = Math.atan2(dy, dx);
|
|
10248
|
-
const pointerDx = pointer ? pointer.x - frame.anchorX : 0;
|
|
10249
|
-
const pointerDy = pointer ? pointer.y - frame.anchorY : 0;
|
|
10250
|
-
const desiredAngle = Math.hypot(pointerDx, pointerDy) > 0.5 ? Math.atan2(pointerDy, pointerDx) + Math.PI - leaderAngle : 0;
|
|
10251
|
-
const wrappedAngle = Math.atan2(Math.sin(desiredAngle), Math.cos(desiredAngle));
|
|
10252
|
-
// Keep the stem inside the 126-degree arc, away from antialiased endpoints.
|
|
10253
|
-
const arcFraction = 0.35;
|
|
10254
|
-
const rotationLimit = Math.PI * arcFraction - Math.PI / 30;
|
|
10255
|
-
const targetOffset = hovered ? Math.max(-rotationLimit, Math.min(rotationLimit, wrappedAngle)) : ((_2 = ringAnimation.arcOffset) !== null && _2 !== void 0 ? _2 : 0);
|
|
10256
|
-
const targetOpen = cursorMotion.target || (hovered && (ring === null || ring === void 0 ? void 0 : ring.enabled) !== false && targetRadius > 0) ? 1 : 0;
|
|
10257
|
-
const elapsed = Math.min(32, Math.max(0, now - ((_3 = ringAnimation.arcTime) !== null && _3 !== void 0 ? _3 : now)));
|
|
10258
|
-
const blend = duration > 0 ? 1 - Math.exp(-elapsed / (duration / 3)) : 1;
|
|
10259
|
-
const approach = (value, target) => Math.abs(value - target) < 0.001 ? target : value + (target - value) * blend;
|
|
10260
|
-
ringAnimation.arcOffset = approach((_4 = ringAnimation.arcOffset) !== null && _4 !== void 0 ? _4 : 0, targetOffset);
|
|
10261
|
-
ringAnimation.arcOpen = approach((_5 = ringAnimation.arcOpen) !== null && _5 !== void 0 ? _5 : 0, targetOpen);
|
|
10262
|
-
ringAnimation.arcTime = now;
|
|
10263
|
-
if (ringAnimation.arcOffset !== targetOffset || ringAnimation.arcOpen !== targetOpen) {
|
|
10264
|
-
this.viewer.scene.requestRender();
|
|
10265
|
-
}
|
|
10266
|
-
const circumference = Math.PI * (nodeRadius + ringAnimation.inner);
|
|
10267
|
-
const filledFraction = 1 - ringAnimation.arcOpen * (1 - arcFraction);
|
|
10268
|
-
circle.setAttribute("stroke-dasharray", `${circumference * filledFraction} ${circumference * (1 - filledFraction)}`);
|
|
10269
|
-
circle.setAttribute("transform", `rotate(${(leaderAngle + ringAnimation.arcOffset - Math.PI * filledFraction) * 180 / Math.PI} ${nodeRadius} ${nodeRadius})`);
|
|
10270
|
-
const cut = Math.min(radius, length);
|
|
10271
|
-
const startX = frame.anchorX + (length ? dx / length * cut : 0);
|
|
10272
|
-
const startY = frame.anchorY + (length ? dy / length * cut : 0);
|
|
10273
|
-
const draw = (element, fromX, fromY, toX, toY) => {
|
|
10274
|
-
const screenDx = (toX - fromX) * coordinates.scaleX;
|
|
10275
|
-
const screenDy = (toY - fromY) * coordinates.scaleY;
|
|
10276
|
-
element.style.width = `${2 * coordinates.scaleX}px`;
|
|
10277
|
-
element.style.left = `${coordinates.x + (fromX - 1) * coordinates.scaleX}px`;
|
|
10278
|
-
element.style.top = `${coordinates.y + fromY * coordinates.scaleY}px`;
|
|
10279
|
-
element.style.height = `${Math.hypot(screenDx, screenDy)}px`;
|
|
10280
|
-
element.style.transform = `rotate(${Math.atan2(screenDy, screenDx) - Math.PI / 2}rad)`;
|
|
10281
|
-
element.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10282
|
-
element.style.transformOrigin = "top center";
|
|
10283
|
-
element.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount));
|
|
10284
|
-
element.style.zIndex = String(placement.zIndex);
|
|
10285
|
-
};
|
|
10286
|
-
draw(lineEle, startX, startY, endX, endY);
|
|
10287
|
-
if (layer.modelBoxes.Hull(this.id)) {
|
|
10288
|
-
layer.modelBoxes.Request(this.id, {
|
|
10289
|
-
whole: Boolean(cursorMotion.target), from: { x: frame.anchorX, y: frame.anchorY },
|
|
10290
|
-
opacity, zIndex: placement.zIndex, color: this.options.leaderColor || "rgba(255, 255, 255, 0.8)", duration
|
|
10291
|
-
});
|
|
10292
|
-
}
|
|
10293
|
-
if (runEle) {
|
|
10294
|
-
// Overlap the corner by the stem's own width so the elbow has no notch in it.
|
|
10295
|
-
const overlap = frame.anchorX < runToX ? -1 : 1;
|
|
10296
|
-
runEle.style.display = beside ? "block" : "none";
|
|
10297
|
-
if (beside)
|
|
10298
|
-
draw(runEle, endX + overlap, endY, runToX, endY);
|
|
10299
|
-
}
|
|
10300
|
-
}
|
|
10301
10706
|
};
|
|
10302
10707
|
ele.style.display = "flex";
|
|
10303
10708
|
ele.style.visibility = "hidden";
|
|
10304
|
-
|
|
10709
|
+
// Hovering, riding the cursor or a highlight lift a label out of its cluster, which a stale frame misses.
|
|
10710
|
+
const wake = () => {
|
|
10711
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10712
|
+
return Boolean(this.Transient ||
|
|
10713
|
+
((_a = this.cursorMotion) === null || _a === void 0 ? void 0 : _a.target) ||
|
|
10714
|
+
((_b = this.cursorMotion) === null || _b === void 0 ? void 0 : _b.amount) > 0 ||
|
|
10715
|
+
((_c = this.visualRegister) === null || _c === void 0 ? void 0 : _c.GetLabelHoverPosition((_d = this.rego) === null || _d === void 0 ? void 0 : _d.entityId, (_e = this.rego) === null || _e === void 0 ? void 0 : _e.menuItemId)) ||
|
|
10716
|
+
((_j = (_f = this.visualRegister) === null || _f === void 0 ? void 0 : _f.GetState({ entityId: (_g = this.rego) === null || _g === void 0 ? void 0 : _g.entityId, menuItemId: (_h = this.rego) === null || _h === void 0 ? void 0 : _h.menuItemId })) === null || _j === void 0 ? void 0 : _j.highlighted));
|
|
10717
|
+
};
|
|
10718
|
+
this.renderRemoval = layer.Add({ project, apply, wake });
|
|
10305
10719
|
leaveLayer === null || leaveLayer === void 0 ? void 0 : leaveLayer();
|
|
10306
10720
|
// If terrain changes then we'll re-call createLabel as the position may have changed.
|
|
10307
10721
|
let terrTimeout = null;
|
|
@@ -60195,7 +60609,7 @@ void main() {
|
|
|
60195
60609
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
60196
60610
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
60197
60611
|
|
|
60198
|
-
const VERSION = "7.8.
|
|
60612
|
+
const VERSION = "7.8.2";
|
|
60199
60613
|
/**
|
|
60200
60614
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
60201
60615
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|