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.es5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Cesium from 'cesium';
|
|
2
|
-
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition,
|
|
3
|
-
import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed,
|
|
2
|
+
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, Cartesian3, ClassificationType, ShaderSource, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, ArcType, CornerType, ColorBlendMode, HeadingPitchRoll, Model, JulianDate, Quaternion, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ShadowMode, CustomDataSource, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, GeometryInstance, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, Event, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
|
|
3
|
+
import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, Api, Geometry as Geometry$1, EntityLod, UrlUtils, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, ZoomControl, ProjectView, ProjectViewBookmark, EntityRelation, BruceApi, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Ensures a number is returned from a given value.
|
|
@@ -6690,6 +6690,17 @@ function GetClusterIconPriority(options) {
|
|
|
6690
6690
|
* Groups eligible neighbours around stable representatives without coupling membership to its renderer.
|
|
6691
6691
|
*/
|
|
6692
6692
|
function ClusterItems(params) {
|
|
6693
|
+
const steps = ClusterItemsInSteps(params, Infinity);
|
|
6694
|
+
let next = steps.next();
|
|
6695
|
+
while (!next.done) {
|
|
6696
|
+
next = steps.next();
|
|
6697
|
+
}
|
|
6698
|
+
return next.value;
|
|
6699
|
+
}
|
|
6700
|
+
/*
|
|
6701
|
+
* ClusterItems as steps, pausing after every so many representatives tried, so a caller can spread one run over frames.
|
|
6702
|
+
*/
|
|
6703
|
+
function* ClusterItemsInSteps(params, every = 32) {
|
|
6693
6704
|
const eligible = new Map();
|
|
6694
6705
|
for (const item of params.items) {
|
|
6695
6706
|
if (!params.eligible || params.eligible(item)) {
|
|
@@ -6699,12 +6710,21 @@ function ClusterItems(params) {
|
|
|
6699
6710
|
const assigned = new Set();
|
|
6700
6711
|
const result = [];
|
|
6701
6712
|
const minimum = Math.max(2, params.minSize || 2);
|
|
6713
|
+
const free = (other) => {
|
|
6714
|
+
const key = params.id(other);
|
|
6715
|
+
return eligible.has(key) && !assigned.has(key);
|
|
6716
|
+
};
|
|
6717
|
+
let tried = 0;
|
|
6702
6718
|
for (const [id, item] of eligible) {
|
|
6703
6719
|
if (assigned.has(id)) {
|
|
6704
6720
|
continue;
|
|
6705
6721
|
}
|
|
6722
|
+
if (++tried > every) {
|
|
6723
|
+
tried = 1;
|
|
6724
|
+
yield;
|
|
6725
|
+
}
|
|
6706
6726
|
const members = new Map([[id, item]]);
|
|
6707
|
-
for (const neighbour of params.neighbours(item)) {
|
|
6727
|
+
for (const neighbour of params.neighbours(item, free)) {
|
|
6708
6728
|
const key = params.id(neighbour);
|
|
6709
6729
|
if (eligible.has(key) && !assigned.has(key)) {
|
|
6710
6730
|
members.set(key, eligible.get(key));
|
|
@@ -7237,6 +7257,14 @@ var EntityLabel;
|
|
|
7237
7257
|
const ICON_STACK_SCALE = 0.6;
|
|
7238
7258
|
// How far an angled leader runs sideways before the label starts.
|
|
7239
7259
|
const ANGLED_LEADER_RUN = 28;
|
|
7260
|
+
// While labels move on screen, clusters are worked out afresh at most this often, and again once they settle.
|
|
7261
|
+
const CLUSTER_MOVING_INTERVAL = 400;
|
|
7262
|
+
// Milliseconds of each frame a fresh clustering may take; the rest of it runs on the next frames.
|
|
7263
|
+
const CLUSTER_STEP_BUDGET = 4;
|
|
7264
|
+
// How far a pin's white body reaches past the icon it wraps, before its tip.
|
|
7265
|
+
const PIN_RIM = 7;
|
|
7266
|
+
// A pin is drawn in one fixed look for now: a white body with a faint edge and a soft shadow.
|
|
7267
|
+
const PIN_COLOR = "#ffffff";
|
|
7240
7268
|
// Clearance between a point or billboard glyph and the ring drawn around it.
|
|
7241
7269
|
const ICON_RING_PADDING = 4;
|
|
7242
7270
|
// Small points still get a ring as large as the default near ring.
|
|
@@ -7555,6 +7583,8 @@ var EntityLabel;
|
|
|
7555
7583
|
*/
|
|
7556
7584
|
class PlacementMemory {
|
|
7557
7585
|
constructor() {
|
|
7586
|
+
// The last clusters worked out from scratch, by label id, for frames that may reuse them.
|
|
7587
|
+
this.clusters = null;
|
|
7558
7588
|
this.previous = new Map();
|
|
7559
7589
|
this.nextOrder = 0;
|
|
7560
7590
|
}
|
|
@@ -7670,6 +7700,22 @@ var EntityLabel;
|
|
|
7670
7700
|
color.brighten(ICON_BACKGROUND_BLEND, new Color());
|
|
7671
7701
|
return shade.withAlpha(alpha).toCssColorString();
|
|
7672
7702
|
}
|
|
7703
|
+
/*
|
|
7704
|
+
* 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.
|
|
7705
|
+
*/
|
|
7706
|
+
function pinLook(look) {
|
|
7707
|
+
return look.iconBackground ? look : { ...look, iconBackground: PIN_COLOR };
|
|
7708
|
+
}
|
|
7709
|
+
/*
|
|
7710
|
+
* Whether a label draws a pin: it needs an icon to wrap, and a photo keeps its own shape.
|
|
7711
|
+
*/
|
|
7712
|
+
function HasPin(options) {
|
|
7713
|
+
return ((options === null || options === void 0 ? void 0 : options.leaderStyle) === "pin" &&
|
|
7714
|
+
options.leader !== false &&
|
|
7715
|
+
(options.presentation || "text") !== "text" &&
|
|
7716
|
+
!options.iconPhoto);
|
|
7717
|
+
}
|
|
7718
|
+
EntityLabel.HasPin = HasPin;
|
|
7673
7719
|
function iconLook(options) {
|
|
7674
7720
|
return {
|
|
7675
7721
|
icon: options.icon || undefined,
|
|
@@ -7692,20 +7738,80 @@ var EntityLabel;
|
|
|
7692
7738
|
presentation === "text" ? null : iconLook(options)
|
|
7693
7739
|
]);
|
|
7694
7740
|
}
|
|
7741
|
+
function summariseCluster(cluster) {
|
|
7742
|
+
var _a, _b, _c;
|
|
7743
|
+
let chosen = cluster.representative;
|
|
7744
|
+
const iconic = (chosen.options.presentation || "text") !== "text";
|
|
7745
|
+
// Members in the order they would win representation; the seed is the nearest.
|
|
7746
|
+
let ordered = [chosen, ...cluster.members.filter(member => member !== chosen)];
|
|
7747
|
+
if (iconic && chosen.options.cluster.representative !== "nearest") {
|
|
7748
|
+
ordered = ordered.map((member, i) => ({ member, i, priority: EntityLabel.IconPriority(member.options) }))
|
|
7749
|
+
.sort((a, b) => b.priority - a.priority || a.i - b.i).map(entry => entry.member);
|
|
7750
|
+
chosen = ordered[0];
|
|
7751
|
+
}
|
|
7752
|
+
const summary = {
|
|
7753
|
+
chosen: chosen.id,
|
|
7754
|
+
members: cluster.members.map(frame => frame.id),
|
|
7755
|
+
entityIds: Array.from(new Set(cluster.members.map(frame => frame.entityId).filter(Boolean)))
|
|
7756
|
+
};
|
|
7757
|
+
if (iconic && chosen.options.iconScale !== 0) {
|
|
7758
|
+
const seen = new Set();
|
|
7759
|
+
const icons = [];
|
|
7760
|
+
for (const member of ordered) {
|
|
7761
|
+
const look = iconLook(member.options);
|
|
7762
|
+
const key = JSON.stringify(look);
|
|
7763
|
+
if (seen.has(key)) {
|
|
7764
|
+
continue;
|
|
7765
|
+
}
|
|
7766
|
+
seen.add(key);
|
|
7767
|
+
if (member !== ordered[0])
|
|
7768
|
+
icons.push(look);
|
|
7769
|
+
if (seen.size >= ICON_STACK_LIMIT) {
|
|
7770
|
+
break;
|
|
7771
|
+
}
|
|
7772
|
+
}
|
|
7773
|
+
if (icons.length)
|
|
7774
|
+
summary.icons = icons;
|
|
7775
|
+
}
|
|
7776
|
+
if (chosen.options.presentation !== "icon") {
|
|
7777
|
+
const values = new Set();
|
|
7778
|
+
const stableMembers = [...cluster.members].sort((a, b) => (a.entityKey || a.entityId || a.id).localeCompare(b.entityKey || b.entityId || b.id));
|
|
7779
|
+
for (const member of stableMembers) {
|
|
7780
|
+
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();
|
|
7781
|
+
if (value) {
|
|
7782
|
+
values.add(value);
|
|
7783
|
+
}
|
|
7784
|
+
}
|
|
7785
|
+
if (values.size > 1) {
|
|
7786
|
+
// A value long enough to wrap fills the box on its own, so only one is listed.
|
|
7787
|
+
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()); });
|
|
7788
|
+
const limit = wrapped ? 1 : 2;
|
|
7789
|
+
const rows = Array.from(values).slice(0, limit);
|
|
7790
|
+
if (values.size > limit)
|
|
7791
|
+
rows.push(`+${values.size - limit} more…`);
|
|
7792
|
+
summary.text = rows.join("\n");
|
|
7793
|
+
}
|
|
7794
|
+
}
|
|
7795
|
+
return summary;
|
|
7796
|
+
}
|
|
7695
7797
|
/*
|
|
7696
|
-
*
|
|
7798
|
+
* Frames in the order they win: priority first, then nearest, with every coordinate known.
|
|
7697
7799
|
*/
|
|
7698
|
-
function
|
|
7699
|
-
|
|
7700
|
-
const frames = input.filter(frame => [frame.x, frame.y, frame.width, frame.height, frame.depth].every(Number.isFinite))
|
|
7800
|
+
function sortFrames(input) {
|
|
7801
|
+
return input.filter(frame => [frame.x, frame.y, frame.width, frame.height, frame.depth].every(Number.isFinite))
|
|
7701
7802
|
.sort((a, b) => (b.priority || 0) - (a.priority || 0) || a.depth - b.depth || a.id.localeCompare(b.id));
|
|
7702
|
-
|
|
7803
|
+
}
|
|
7804
|
+
/*
|
|
7805
|
+
* The frames clustering considers, by presentation, and the ones hidden as another label of the same entity.
|
|
7806
|
+
*/
|
|
7807
|
+
function clusterGroups(frames) {
|
|
7808
|
+
var _a, _b;
|
|
7703
7809
|
const entityKeys = new Set();
|
|
7704
7810
|
const groups = new Map();
|
|
7811
|
+
const duplicates = new Set();
|
|
7705
7812
|
for (const frame of frames) {
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
if (duplicate) {
|
|
7813
|
+
if (frame.entityKey && entityKeys.has(frame.entityKey)) {
|
|
7814
|
+
duplicates.add(frame.id);
|
|
7709
7815
|
continue;
|
|
7710
7816
|
}
|
|
7711
7817
|
if (frame.entityKey)
|
|
@@ -7720,6 +7826,13 @@ var EntityLabel;
|
|
|
7720
7826
|
}
|
|
7721
7827
|
groups.get(key).push(frame);
|
|
7722
7828
|
}
|
|
7829
|
+
return { groups, duplicates };
|
|
7830
|
+
}
|
|
7831
|
+
/*
|
|
7832
|
+
* Works clusters out from scratch, as steps a caller can spread over frames or run straight through.
|
|
7833
|
+
*/
|
|
7834
|
+
function* clusterInSteps(groups, every = 32) {
|
|
7835
|
+
const clustered = [];
|
|
7723
7836
|
for (const group of groups.values()) {
|
|
7724
7837
|
// Summary and badge dimensions are output, never the next frame's membership input.
|
|
7725
7838
|
const candidates = group.map(frame => frame.extendedGeometry && frame.canFlip &&
|
|
@@ -7733,70 +7846,76 @@ var EntityLabel;
|
|
|
7733
7846
|
rank.set(frame.id, i);
|
|
7734
7847
|
looks.set(frame.id, clusterLook(frame.options));
|
|
7735
7848
|
});
|
|
7736
|
-
const clusters =
|
|
7849
|
+
const clusters = yield* ClusterItemsInSteps({
|
|
7737
7850
|
items: candidates,
|
|
7738
7851
|
id: frame => frame.id,
|
|
7739
7852
|
minSize: group[0].options.cluster.minSize,
|
|
7740
|
-
neighbours: frame => {
|
|
7853
|
+
neighbours: (frame, free) => {
|
|
7741
7854
|
var _a;
|
|
7742
|
-
|
|
7743
|
-
|
|
7855
|
+
// Labels an earlier cluster took cannot join, so they are dropped before the pairwise checks.
|
|
7856
|
+
const nearby = index.Query(frame, (_a = frame.options.cluster.pixelRange) !== null && _a !== void 0 ? _a : (frame.options.presentation === "icon" ? 24 : 8))
|
|
7857
|
+
.filter(other => other === frame || free(other))
|
|
7858
|
+
.sort((a, b) => rank.get(a.id) - rank.get(b.id));
|
|
7859
|
+
// A pin stands for one thing, so it clusters only with pins that look the same.
|
|
7860
|
+
const group = (other) => HasPin(other.options) ? `look:${looks.get(other.id)}` : other.group || "";
|
|
7861
|
+
return compatibleMembers(frame, nearby, group, other => looks.get(other.id));
|
|
7744
7862
|
}
|
|
7745
|
-
});
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
if (
|
|
7779
|
-
|
|
7780
|
-
const stableMembers = [...cluster.members].sort((a, b) => (a.entityKey || a.entityId || a.id).localeCompare(b.entityKey || b.entityId || b.id));
|
|
7781
|
-
for (const member of stableMembers) {
|
|
7782
|
-
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();
|
|
7783
|
-
if (value) {
|
|
7784
|
-
values.add(value);
|
|
7785
|
-
}
|
|
7786
|
-
}
|
|
7787
|
-
if (values.size > 1) {
|
|
7788
|
-
// A value long enough to wrap fills the box on its own, so only one is listed.
|
|
7789
|
-
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()); });
|
|
7790
|
-
const limit = wrapped ? 1 : 2;
|
|
7791
|
-
const rows = Array.from(values).slice(0, limit);
|
|
7792
|
-
if (values.size > limit)
|
|
7793
|
-
rows.push(`+${values.size - limit} more…`);
|
|
7794
|
-
representative.text = rows.join("\n");
|
|
7795
|
-
}
|
|
7863
|
+
}, every);
|
|
7864
|
+
clusters.forEach(cluster => clustered.push({ representative: cluster.representative.id, members: cluster.members.map(member => member.id) }));
|
|
7865
|
+
}
|
|
7866
|
+
return clustered;
|
|
7867
|
+
}
|
|
7868
|
+
/*
|
|
7869
|
+
* Runs a clustering job to the end at once.
|
|
7870
|
+
*/
|
|
7871
|
+
function finishClustering(steps) {
|
|
7872
|
+
let next = steps.next();
|
|
7873
|
+
while (!next.done) {
|
|
7874
|
+
next = steps.next();
|
|
7875
|
+
}
|
|
7876
|
+
return next.value;
|
|
7877
|
+
}
|
|
7878
|
+
function Layout(input, memory = new PlacementMemory(), reuseClusters = false) {
|
|
7879
|
+
var _a, _b, _c;
|
|
7880
|
+
const frames = sortFrames(input);
|
|
7881
|
+
const { groups, duplicates } = clusterGroups(frames);
|
|
7882
|
+
const result = new Map();
|
|
7883
|
+
for (const frame of frames) {
|
|
7884
|
+
result.set(frame.id, { frame, visible: !duplicates.has(frame.id), opacity: frame.opacity, zIndex: 0, members: [], entityIds: frame.entityId ? [frame.entityId] : [] });
|
|
7885
|
+
}
|
|
7886
|
+
if (!reuseClusters || !memory.clusters) {
|
|
7887
|
+
memory.clusters = finishClustering(clusterInSteps(groups, Infinity));
|
|
7888
|
+
}
|
|
7889
|
+
for (const group of groups.values()) {
|
|
7890
|
+
// The kept membership, less anything gone, hovered or moved out of the group since.
|
|
7891
|
+
const byId = new Map(group.map(frame => [frame.id, frame]));
|
|
7892
|
+
const minSize = Math.max(2, (_a = group[0].options.cluster.minSize) !== null && _a !== void 0 ? _a : 2);
|
|
7893
|
+
const clusters = memory.clusters.map(entry => {
|
|
7894
|
+
var _a;
|
|
7895
|
+
const members = entry.members.map(id => byId.get(id)).filter(Boolean);
|
|
7896
|
+
if (members.length < minSize) {
|
|
7897
|
+
return null;
|
|
7796
7898
|
}
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7899
|
+
return { entry, whole: members.length === entry.members.length, representative: (_a = byId.get(entry.representative)) !== null && _a !== void 0 ? _a : members[0], members };
|
|
7900
|
+
}).filter(Boolean);
|
|
7901
|
+
for (const cluster of clusters) {
|
|
7902
|
+
// A cluster that kept every member keeps its summary, worked out once, sparing a pass over its members.
|
|
7903
|
+
let summary = cluster.whole ? cluster.entry.summary : undefined;
|
|
7904
|
+
if (!summary) {
|
|
7905
|
+
summary = summariseCluster(cluster);
|
|
7906
|
+
if (cluster.whole)
|
|
7907
|
+
cluster.entry.summary = summary;
|
|
7908
|
+
}
|
|
7909
|
+
const representative = result.get(summary.chosen);
|
|
7910
|
+
representative.members = summary.members;
|
|
7911
|
+
if (summary.icons)
|
|
7912
|
+
representative.icons = summary.icons;
|
|
7913
|
+
representative.entityIds = summary.entityIds;
|
|
7914
|
+
if (summary.text != null)
|
|
7915
|
+
representative.text = summary.text;
|
|
7916
|
+
for (const id of summary.members) {
|
|
7917
|
+
if (id !== summary.chosen)
|
|
7918
|
+
result.get(id).visible = false;
|
|
7800
7919
|
}
|
|
7801
7920
|
}
|
|
7802
7921
|
}
|
|
@@ -7815,7 +7934,7 @@ var EntityLabel;
|
|
|
7815
7934
|
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) };
|
|
7816
7935
|
const overlap = foreground.HasOverlap(box) || foregroundLeaders.HasOverlap(box) || Boolean(stem && foreground.HasOverlap(stem));
|
|
7817
7936
|
if (overlap) {
|
|
7818
|
-
placement.opacity *= Math.max(0, Math.min(1, (
|
|
7937
|
+
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));
|
|
7819
7938
|
}
|
|
7820
7939
|
placement.zIndex = zIndex--;
|
|
7821
7940
|
foreground.Add(frame);
|
|
@@ -7835,21 +7954,23 @@ var EntityLabel;
|
|
|
7835
7954
|
const accepted = [seed];
|
|
7836
7955
|
const byGroup = new Map([[group(seed), 1]]);
|
|
7837
7956
|
const byLook = new Map([[look(seed), 1]]);
|
|
7838
|
-
|
|
7957
|
+
// Joined with a character no group id or look holds, not serialised, since this runs per neighbour.
|
|
7958
|
+
const both = (itemGroup, itemLook) => `${itemGroup}\u0000${itemLook}`;
|
|
7959
|
+
const byBoth = new Map([[both(group(seed), look(seed)), 1]]);
|
|
7839
7960
|
for (const item of nearby) {
|
|
7840
7961
|
if (item === seed) {
|
|
7841
7962
|
continue;
|
|
7842
7963
|
}
|
|
7843
|
-
const itemGroup = group(item), itemLook = look(item),
|
|
7964
|
+
const itemGroup = group(item), itemLook = look(item), key = both(itemGroup, itemLook);
|
|
7844
7965
|
// Accepted members in another group with another look are the ones this item may not sit beside.
|
|
7845
|
-
const conflicting = accepted.length - (byGroup.get(itemGroup) || 0) - (byLook.get(itemLook) || 0) + (byBoth.get(
|
|
7966
|
+
const conflicting = accepted.length - (byGroup.get(itemGroup) || 0) - (byLook.get(itemLook) || 0) + (byBoth.get(key) || 0);
|
|
7846
7967
|
if (conflicting > 0) {
|
|
7847
7968
|
continue;
|
|
7848
7969
|
}
|
|
7849
7970
|
accepted.push(item);
|
|
7850
7971
|
byGroup.set(itemGroup, (byGroup.get(itemGroup) || 0) + 1);
|
|
7851
7972
|
byLook.set(itemLook, (byLook.get(itemLook) || 0) + 1);
|
|
7852
|
-
byBoth.set(
|
|
7973
|
+
byBoth.set(key, (byBoth.get(key) || 0) + 1);
|
|
7853
7974
|
}
|
|
7854
7975
|
return accepted;
|
|
7855
7976
|
}
|
|
@@ -7880,10 +8001,20 @@ var EntityLabel;
|
|
|
7880
8001
|
this.viewer = viewer;
|
|
7881
8002
|
this.element = document.createElement("div");
|
|
7882
8003
|
this.coordinates = { x: 0, y: 0, scaleX: 1, scaleY: 1 };
|
|
8004
|
+
// The canvas size, read once a frame: reading the canvas after placing a label lays the page out again.
|
|
8005
|
+
this.viewport = { width: 0, height: 0 };
|
|
7883
8006
|
this.participants = new Set();
|
|
7884
8007
|
// Participants whose failure has been logged, so a label that throws every frame logs once.
|
|
7885
8008
|
this.failed = new WeakSet();
|
|
7886
8009
|
this.placementMemory = new PlacementMemory();
|
|
8010
|
+
// What the clusters were last worked out from: the labels taking part and where they sat, and when.
|
|
8011
|
+
this.clustered = null;
|
|
8012
|
+
// Labels added or removed, which can change any cluster's look or membership.
|
|
8013
|
+
this.clustersDirty = true;
|
|
8014
|
+
// A fresh clustering spread over frames, while the last one stays on show.
|
|
8015
|
+
this.clusterJob = null;
|
|
8016
|
+
// Labels hidden in a cluster last frame, with the frame they were laid out from, for reused clusters to skip.
|
|
8017
|
+
this.sleeping = new Map();
|
|
7887
8018
|
this.modelBoxes = new ModelBoxes();
|
|
7888
8019
|
this.forwardingWheel = false;
|
|
7889
8020
|
this.pendingDrag = null;
|
|
@@ -8060,9 +8191,12 @@ var EntityLabel;
|
|
|
8060
8191
|
}
|
|
8061
8192
|
Add(participant) {
|
|
8062
8193
|
this.participants.add(participant);
|
|
8194
|
+
this.clustersDirty = true;
|
|
8063
8195
|
this.viewer.scene.requestRender();
|
|
8064
8196
|
return () => {
|
|
8065
8197
|
this.participants.delete(participant);
|
|
8198
|
+
this.sleeping.delete(participant);
|
|
8199
|
+
this.clustersDirty = true;
|
|
8066
8200
|
if (!this.participants.size) {
|
|
8067
8201
|
this.remove();
|
|
8068
8202
|
this.element.removeEventListener("wheel", this.ForwardWheel);
|
|
@@ -8113,8 +8247,9 @@ var EntityLabel;
|
|
|
8113
8247
|
}
|
|
8114
8248
|
}
|
|
8115
8249
|
Update() {
|
|
8116
|
-
var _a, _b;
|
|
8250
|
+
var _a, _b, _c;
|
|
8117
8251
|
this.coordinates = this.MeasureCoordinates();
|
|
8252
|
+
this.viewport = { width: this.viewer.canvas.clientWidth, height: this.viewer.canvas.clientHeight };
|
|
8118
8253
|
this.UpdateHorizon();
|
|
8119
8254
|
const rect = (_b = (_a = this.viewer.canvas).getBoundingClientRect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
8120
8255
|
const pointer = this.pointerClient;
|
|
@@ -8130,21 +8265,77 @@ var EntityLabel;
|
|
|
8130
8265
|
console.error("EntityLabel: model boxes failed to resolve.", e);
|
|
8131
8266
|
}
|
|
8132
8267
|
// This runs inside Cesium's frame, where one throwing label would stop rendering for the whole scene.
|
|
8268
|
+
const project = (participant) => {
|
|
8269
|
+
try {
|
|
8270
|
+
return participant.project();
|
|
8271
|
+
}
|
|
8272
|
+
catch (e) {
|
|
8273
|
+
this.logFailure(participant, e);
|
|
8274
|
+
return null;
|
|
8275
|
+
}
|
|
8276
|
+
};
|
|
8277
|
+
// A label hidden in a cluster needs no position while its cluster is reused, which is most frames.
|
|
8278
|
+
const mayReuse = Boolean(this.clustered) && !this.clustersDirty && Date.now() - this.clustered.at < CLUSTER_MOVING_INTERVAL;
|
|
8133
8279
|
const projected = new Map();
|
|
8134
8280
|
for (const participant of this.participants) {
|
|
8135
|
-
|
|
8281
|
+
const asleep = mayReuse && !((_c = participant.wake) === null || _c === void 0 ? void 0 : _c.call(participant)) ? this.sleeping.get(participant) : undefined;
|
|
8282
|
+
projected.set(participant, asleep !== null && asleep !== void 0 ? asleep : project(participant));
|
|
8283
|
+
}
|
|
8284
|
+
let frames = Array.from(projected.values()).filter(Boolean);
|
|
8285
|
+
const decision = this.DecideClusters(frames);
|
|
8286
|
+
if (decision !== "reuse" && mayReuse) {
|
|
8287
|
+
// Clusters are worked out from where every label is now, sleepers included.
|
|
8288
|
+
for (const participant of this.participants) {
|
|
8289
|
+
if (this.sleeping.has(participant))
|
|
8290
|
+
projected.set(participant, project(participant));
|
|
8291
|
+
}
|
|
8292
|
+
frames = Array.from(projected.values()).filter(Boolean);
|
|
8293
|
+
}
|
|
8294
|
+
if (decision === "refresh") {
|
|
8295
|
+
this.clusterJob = clusterInSteps(clusterGroups(sortFrames(frames)).groups);
|
|
8296
|
+
}
|
|
8297
|
+
this.StepClusters();
|
|
8298
|
+
const layout = Layout(frames, this.placementMemory, decision !== "now");
|
|
8299
|
+
const placements = new Map(layout.map(item => [item.frame.id, item]));
|
|
8300
|
+
const participantsById = new Map();
|
|
8301
|
+
for (const [participant, frame] of projected) {
|
|
8302
|
+
if (frame)
|
|
8303
|
+
participantsById.set(frame.id, participant);
|
|
8304
|
+
}
|
|
8305
|
+
this.sleeping = new Map();
|
|
8306
|
+
for (const placement of layout) {
|
|
8307
|
+
for (const id of placement.members) {
|
|
8308
|
+
const participant = id !== placement.frame.id ? participantsById.get(id) : undefined;
|
|
8309
|
+
if (participant)
|
|
8310
|
+
this.sleeping.set(participant, projected.get(participant));
|
|
8311
|
+
}
|
|
8312
|
+
}
|
|
8313
|
+
// Writes, then reads, then writes, each across all labels; interleaved, each read lays them out again.
|
|
8314
|
+
const measures = [];
|
|
8315
|
+
for (const [participant, frame] of projected) {
|
|
8136
8316
|
try {
|
|
8137
|
-
|
|
8317
|
+
const measure = participant.apply(frame ? placements.get(frame.id) : undefined);
|
|
8318
|
+
if (measure)
|
|
8319
|
+
measures.push([participant, measure]);
|
|
8138
8320
|
}
|
|
8139
8321
|
catch (e) {
|
|
8140
8322
|
this.logFailure(participant, e);
|
|
8141
8323
|
}
|
|
8142
|
-
projected.set(participant, frame);
|
|
8143
8324
|
}
|
|
8144
|
-
const
|
|
8145
|
-
for (const [participant,
|
|
8325
|
+
const places = [];
|
|
8326
|
+
for (const [participant, measure] of measures) {
|
|
8327
|
+
try {
|
|
8328
|
+
const place = measure();
|
|
8329
|
+
if (place)
|
|
8330
|
+
places.push([participant, place]);
|
|
8331
|
+
}
|
|
8332
|
+
catch (e) {
|
|
8333
|
+
this.logFailure(participant, e);
|
|
8334
|
+
}
|
|
8335
|
+
}
|
|
8336
|
+
for (const [participant, place] of places) {
|
|
8146
8337
|
try {
|
|
8147
|
-
|
|
8338
|
+
place();
|
|
8148
8339
|
}
|
|
8149
8340
|
catch (e) {
|
|
8150
8341
|
this.logFailure(participant, e);
|
|
@@ -8157,6 +8348,55 @@ var EntityLabel;
|
|
|
8157
8348
|
console.error("EntityLabel: model boxes failed to draw.", e);
|
|
8158
8349
|
}
|
|
8159
8350
|
}
|
|
8351
|
+
/*
|
|
8352
|
+
* How this frame gets its clusters: kept from last time, refreshed by a job over frames, or worked out now.
|
|
8353
|
+
* They are kept while no clustering label has moved, and while labels move (camera or entities) until a moment
|
|
8354
|
+
* old or while a refresh is under way. Labels coming or going, or none clustered yet, work them out now.
|
|
8355
|
+
*/
|
|
8356
|
+
DecideClusters(frames) {
|
|
8357
|
+
// Where each clustering label sits, to a few pixels, so drawing alone never counts as movement.
|
|
8358
|
+
const signature = frames
|
|
8359
|
+
.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); })
|
|
8360
|
+
.map(frame => `${frame.id}@${Math.round(frame.x / 4)},${Math.round(frame.y / 4)}`)
|
|
8361
|
+
.join("|");
|
|
8362
|
+
const now = Date.now();
|
|
8363
|
+
if (!this.clustered || this.clustersDirty) {
|
|
8364
|
+
this.clusterJob = null;
|
|
8365
|
+
this.clustered = { signature, at: now };
|
|
8366
|
+
this.clustersDirty = false;
|
|
8367
|
+
return "now";
|
|
8368
|
+
}
|
|
8369
|
+
if (this.clustered.signature === signature) {
|
|
8370
|
+
return "reuse";
|
|
8371
|
+
}
|
|
8372
|
+
if (this.clusterJob || now - this.clustered.at < CLUSTER_MOVING_INTERVAL) {
|
|
8373
|
+
// Another frame is due either way, so the scene gets its fresh clusters once it settles.
|
|
8374
|
+
this.viewer.scene.requestRender();
|
|
8375
|
+
return "reuse";
|
|
8376
|
+
}
|
|
8377
|
+
this.clustered = { signature, at: now };
|
|
8378
|
+
return "refresh";
|
|
8379
|
+
}
|
|
8380
|
+
/*
|
|
8381
|
+
* Advances a spread clustering for this frame's share of time, handing its result over once it finishes.
|
|
8382
|
+
*/
|
|
8383
|
+
StepClusters() {
|
|
8384
|
+
if (!this.clusterJob) {
|
|
8385
|
+
return;
|
|
8386
|
+
}
|
|
8387
|
+
const deadline = performance.now() + CLUSTER_STEP_BUDGET;
|
|
8388
|
+
let next = this.clusterJob.next();
|
|
8389
|
+
while (!next.done && performance.now() < deadline) {
|
|
8390
|
+
next = this.clusterJob.next();
|
|
8391
|
+
}
|
|
8392
|
+
if (next.done) {
|
|
8393
|
+
this.placementMemory.clusters = next.value;
|
|
8394
|
+
this.clusterJob = null;
|
|
8395
|
+
}
|
|
8396
|
+
else {
|
|
8397
|
+
this.viewer.scene.requestRender();
|
|
8398
|
+
}
|
|
8399
|
+
}
|
|
8160
8400
|
logFailure(participant, error) {
|
|
8161
8401
|
if (this.failed.has(participant)) {
|
|
8162
8402
|
return;
|
|
@@ -9461,7 +9701,8 @@ var EntityLabel;
|
|
|
9461
9701
|
target.addEventListener(type, event => event.stopPropagation());
|
|
9462
9702
|
}
|
|
9463
9703
|
};
|
|
9464
|
-
const
|
|
9704
|
+
const pin = HasPin(look);
|
|
9705
|
+
const normalLeader = (_m = look.leader) !== null && _m !== void 0 ? _m : (presentation === "text" || pin);
|
|
9465
9706
|
const angled = this.options.leaderStyle === "angled";
|
|
9466
9707
|
let leader = normalLeader;
|
|
9467
9708
|
const content = document.createElement("span");
|
|
@@ -9472,6 +9713,8 @@ var EntityLabel;
|
|
|
9472
9713
|
let iconElement;
|
|
9473
9714
|
let iconContainer;
|
|
9474
9715
|
let fitIconBackground;
|
|
9716
|
+
let pinHolder;
|
|
9717
|
+
let pinBody;
|
|
9475
9718
|
let iconStack;
|
|
9476
9719
|
let stackedFits = [];
|
|
9477
9720
|
let displayedStack = "[]";
|
|
@@ -9492,7 +9735,8 @@ var EntityLabel;
|
|
|
9492
9735
|
content.style.flexDirection = shape === "rect" ? "column-reverse" : "";
|
|
9493
9736
|
};
|
|
9494
9737
|
if (presentation !== "text") {
|
|
9495
|
-
|
|
9738
|
+
// Without a chip of its own the icon sits on the pin's white body, so its colour is inferred from that.
|
|
9739
|
+
const built = this.buildIcon(pin ? pinLook(look) : look, counter, placePhoto);
|
|
9496
9740
|
startPhoto = built.start;
|
|
9497
9741
|
const icon = iconElement = built.icon;
|
|
9498
9742
|
fitIconBackground = built.fit;
|
|
@@ -9517,6 +9761,18 @@ var EntityLabel;
|
|
|
9517
9761
|
iconStack.style.cssText = "display:none;gap:2px;align-items:center;justify-items:center;flex:none;";
|
|
9518
9762
|
makeClickable(iconStack);
|
|
9519
9763
|
iconContainer.append(iconStack, icon);
|
|
9764
|
+
if (pin) {
|
|
9765
|
+
pinHolder = document.createElement("span");
|
|
9766
|
+
pinHolder.className = "entity-label-pin";
|
|
9767
|
+
pinHolder.style.cssText = "position:absolute;left:50%;top:50%;z-index:-1;pointer-events:none;";
|
|
9768
|
+
pinBody = document.createElement("span");
|
|
9769
|
+
pinBody.style.cssText = `position:absolute;inset:0;background:${PIN_COLOR};border:1px solid rgba(0, 0, 0, 0.14);` +
|
|
9770
|
+
"box-sizing:border-box;border-radius:50% 50% 0 50%;";
|
|
9771
|
+
pinHolder.appendChild(pinBody);
|
|
9772
|
+
iconContainer.prepend(pinHolder);
|
|
9773
|
+
// Text beside or above keeps its usual gap from the body rather than from the icon inside it.
|
|
9774
|
+
content.style.gap = `${6 + PIN_RIM}px`;
|
|
9775
|
+
}
|
|
9520
9776
|
content.appendChild(iconContainer);
|
|
9521
9777
|
}
|
|
9522
9778
|
if (presentation !== "icon") {
|
|
@@ -9590,7 +9846,10 @@ var EntityLabel;
|
|
|
9590
9846
|
border-radius: 9px;
|
|
9591
9847
|
color: #ffffff;
|
|
9592
9848
|
text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
|
|
9849
|
+
will-change: transform;
|
|
9593
9850
|
`);
|
|
9851
|
+
// Each label, leader and ring gets its own compositor layer: in one shared layer, moving any of them
|
|
9852
|
+
// repainted all of them, shadows included, on every camera move.
|
|
9594
9853
|
this.label = ele;
|
|
9595
9854
|
ele.style.width = "max-content";
|
|
9596
9855
|
layer.element.appendChild(ele);
|
|
@@ -9609,6 +9868,7 @@ var EntityLabel;
|
|
|
9609
9868
|
width: 2px;
|
|
9610
9869
|
background: rgba(255, 255, 255, 0.8);
|
|
9611
9870
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
|
9871
|
+
will-change: transform;
|
|
9612
9872
|
`);
|
|
9613
9873
|
this.line = lineEle;
|
|
9614
9874
|
lineEle.className = "entity-label-leader";
|
|
@@ -9626,6 +9886,7 @@ var EntityLabel;
|
|
|
9626
9886
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
|
9627
9887
|
top: -2px;
|
|
9628
9888
|
left: -2px;
|
|
9889
|
+
will-change: transform;
|
|
9629
9890
|
`);
|
|
9630
9891
|
lineEleNode.className = "entity-label-anchor";
|
|
9631
9892
|
// SVG preserves fractional strokes in scaled containers where CSS borders round to pixels.
|
|
@@ -9658,13 +9919,13 @@ var EntityLabel;
|
|
|
9658
9919
|
}
|
|
9659
9920
|
const fitLeader = (anchorX, anchorY, desired, width, height, radius = 0) => {
|
|
9660
9921
|
const above = Math.max(0, anchorY - height);
|
|
9661
|
-
const below = Math.max(0,
|
|
9922
|
+
const below = Math.max(0, layer.viewport.height - anchorY - height);
|
|
9662
9923
|
// Keep a short visible stem before switching sides; never aim it at the cursor or a box corner.
|
|
9663
9924
|
const upwards = above >= Math.max(radius ? radius + 4 : 0, Math.min(8, desired)) || above >= below;
|
|
9664
9925
|
const length = Math.min(desired, upwards ? above : below);
|
|
9665
9926
|
const endY = anchorY + (upwards ? -length : length);
|
|
9666
9927
|
return {
|
|
9667
|
-
x: Math.max(0, Math.min(anchorX,
|
|
9928
|
+
x: Math.max(0, Math.min(anchorX, layer.viewport.width - width)),
|
|
9668
9929
|
y: upwards ? endY - height : endY, endY
|
|
9669
9930
|
};
|
|
9670
9931
|
};
|
|
@@ -9673,20 +9934,50 @@ var EntityLabel;
|
|
|
9673
9934
|
* so the stem rises to the label's middle and then runs out to whichever side has the room.
|
|
9674
9935
|
*/
|
|
9675
9936
|
const fitAngledLeader = (anchorX, anchorY, desired, width, height, radius = 0) => {
|
|
9676
|
-
const canvas =
|
|
9937
|
+
const canvas = layer.viewport;
|
|
9677
9938
|
const above = Math.max(0, anchorY - height / 2);
|
|
9678
|
-
const below = Math.max(0, canvas.
|
|
9939
|
+
const below = Math.max(0, canvas.height - anchorY - height / 2);
|
|
9679
9940
|
const upwards = above >= Math.max(radius ? radius + 4 : 0, Math.min(8, desired)) || above >= below;
|
|
9680
9941
|
const length = Math.min(desired, upwards ? above : below);
|
|
9681
9942
|
const endY = anchorY + (upwards ? -length : length);
|
|
9682
9943
|
const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
|
|
9683
|
-
const rightwards = anchorX + run + width <= canvas.
|
|
9944
|
+
const rightwards = anchorX + run + width <= canvas.width || anchorX - run - width < 0;
|
|
9684
9945
|
return {
|
|
9685
|
-
x: Math.max(0, Math.min(rightwards ? anchorX + run : anchorX - run - width, canvas.
|
|
9686
|
-
y: Math.max(0, Math.min(endY - height / 2, canvas.
|
|
9946
|
+
x: Math.max(0, Math.min(rightwards ? anchorX + run : anchorX - run - width, canvas.width - width)),
|
|
9947
|
+
y: Math.max(0, Math.min(endY - height / 2, canvas.height - height)), endY,
|
|
9687
9948
|
run, side: (rightwards ? "right" : "left")
|
|
9688
9949
|
};
|
|
9689
9950
|
};
|
|
9951
|
+
/*
|
|
9952
|
+
* Where the icon sits in the label, and how far the pin's tip reaches from its centre, in layout pixels.
|
|
9953
|
+
* Measured from the icon's container, so a cluster's icon stack is wrapped the same way as a lone icon.
|
|
9954
|
+
*/
|
|
9955
|
+
const measurePin = () => {
|
|
9956
|
+
const scale = layer.coordinates.scaleX;
|
|
9957
|
+
const radius = Math.max(iconContainer.offsetWidth, iconContainer.offsetHeight) / 2 + PIN_RIM;
|
|
9958
|
+
return {
|
|
9959
|
+
x: (iconContainer.offsetLeft + iconContainer.offsetWidth / 2) / scale,
|
|
9960
|
+
y: (iconContainer.offsetTop + iconContainer.offsetHeight / 2) / layer.coordinates.scaleY,
|
|
9961
|
+
radius: radius / scale,
|
|
9962
|
+
// The body's one square corner, half a diagonal from its centre.
|
|
9963
|
+
tip: radius * Math.SQRT2 / scale
|
|
9964
|
+
};
|
|
9965
|
+
};
|
|
9966
|
+
/*
|
|
9967
|
+
* A pin stands over its anchor with the icon centred on it, and hangs below when there is no room above.
|
|
9968
|
+
* Off to the side it is only clamped back on screen, and its tip turns to keep pointing at the anchor.
|
|
9969
|
+
*/
|
|
9970
|
+
const fitPin = (anchorX, anchorY, stem, width, height, shape) => {
|
|
9971
|
+
const canvas = layer.viewport;
|
|
9972
|
+
const reach = stem + shape.tip;
|
|
9973
|
+
const above = anchorY - reach - shape.y;
|
|
9974
|
+
const below = anchorY + reach - shape.y;
|
|
9975
|
+
const upwards = above >= 0 || (below + height > canvas.height && anchorY >= canvas.height - anchorY);
|
|
9976
|
+
return {
|
|
9977
|
+
x: Math.max(0, Math.min(anchorX - shape.x, canvas.width - width)),
|
|
9978
|
+
y: upwards ? above : below
|
|
9979
|
+
};
|
|
9980
|
+
};
|
|
9690
9981
|
/*
|
|
9691
9982
|
* The on-screen centre and half-size of a point or billboard glyph, relative to its projected position.
|
|
9692
9983
|
* Read every frame, since styling and selection can rescale a billboard in place.
|
|
@@ -9801,9 +10092,46 @@ var EntityLabel;
|
|
|
9801
10092
|
this.viewer.scene.requestRender();
|
|
9802
10093
|
}).finally(settle);
|
|
9803
10094
|
}
|
|
10095
|
+
/*
|
|
10096
|
+
* The label's size when last laid out. A label hidden in a cluster leaves layout altogether, so a
|
|
10097
|
+
* frame reads its size from here; a shown one refreshes it when it changes, a new one on its first frame.
|
|
10098
|
+
*/
|
|
10099
|
+
let size = null;
|
|
10100
|
+
const measureSize = () => {
|
|
10101
|
+
size = {
|
|
10102
|
+
width: ele.offsetWidth,
|
|
10103
|
+
height: ele.offsetHeight,
|
|
10104
|
+
textWidth: (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetWidth) || 0,
|
|
10105
|
+
textHeight: (sourceText === null || sourceText === void 0 ? void 0 : sourceText.offsetHeight) || 0,
|
|
10106
|
+
iconWidth: (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetWidth) || 0,
|
|
10107
|
+
iconHeight: (iconElement === null || iconElement === void 0 ? void 0 : iconElement.offsetHeight) || 0,
|
|
10108
|
+
naturalTextWidth: (sourceNaturalText === null || sourceNaturalText === void 0 ? void 0 : sourceNaturalText.offsetWidth) || 0,
|
|
10109
|
+
pin: pin ? measurePin() : undefined
|
|
10110
|
+
};
|
|
10111
|
+
};
|
|
10112
|
+
// Whether the label was out of layout last frame, so staying hidden writes nothing.
|
|
10113
|
+
let hiddenLast = false;
|
|
10114
|
+
// Set by this frame's writes that change the label's size, so it is measured before it is placed.
|
|
10115
|
+
let sizeStale = true;
|
|
10116
|
+
// Set when the size changed on its own; a shown label reads it at the start of the next frame, while layout
|
|
10117
|
+
// is still clean, rather than forcing a layout mid-frame.
|
|
10118
|
+
let resizedSince = false;
|
|
10119
|
+
// The cluster badge's own size beside its icon, read with the label's.
|
|
10120
|
+
let badge = null;
|
|
10121
|
+
// Images, fonts and photo transitions change the size outside any write here. Without an observer the size
|
|
10122
|
+
// is read every frame instead.
|
|
10123
|
+
const resized = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => {
|
|
10124
|
+
if (this.disposed || this.counter !== counter) {
|
|
10125
|
+
resized.disconnect();
|
|
10126
|
+
return;
|
|
10127
|
+
}
|
|
10128
|
+
resizedSince = true;
|
|
10129
|
+
this.viewer.scene.requestRender();
|
|
10130
|
+
});
|
|
10131
|
+
resized === null || resized === void 0 ? void 0 : resized.observe(ele);
|
|
9804
10132
|
let cursorMotion = this.cursorMotion;
|
|
9805
10133
|
const project = () => {
|
|
9806
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
10134
|
+
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;
|
|
9807
10135
|
if (this.disposed || !this.viewer || this.viewer.isDestroyed() || ((_a = this.visible) === null || _a === void 0 ? void 0 : _a.call(this)) === false ||
|
|
9808
10136
|
(presentation === "icon" && this.options.iconScale === 0)) {
|
|
9809
10137
|
return null;
|
|
@@ -9812,6 +10140,11 @@ var EntityLabel;
|
|
|
9812
10140
|
(this.hoverFade.from === 0 || Date.now() - this.hoverFade.start >= 120)) {
|
|
9813
10141
|
return null;
|
|
9814
10142
|
}
|
|
10143
|
+
// A new label is still in layout, so its first frame reads its size, as does a shown one that resized.
|
|
10144
|
+
if (!size || (resizedSince && !hiddenLast)) {
|
|
10145
|
+
measureSize();
|
|
10146
|
+
resizedSince = false;
|
|
10147
|
+
}
|
|
9815
10148
|
// Moving point/model positions must be sampled at the current clock time.
|
|
9816
10149
|
if (!this.prePositioned && visual instanceof Entity && visual.position) {
|
|
9817
10150
|
const position = getValue(this.viewer, visual.position);
|
|
@@ -9859,8 +10192,8 @@ var EntityLabel;
|
|
|
9859
10192
|
y: ringPoint.y + (boxTarget.y - ringPoint.y) * boxBlend
|
|
9860
10193
|
} : undefined;
|
|
9861
10194
|
const start = boxAnchor || anchor;
|
|
9862
|
-
const onScreen = anchor.x >= 0 && anchor.y >= 0 && anchor.x <
|
|
9863
|
-
if (leader && (start.x < 0 || start.y < 0 || start.x >=
|
|
10195
|
+
const onScreen = anchor.x >= 0 && anchor.y >= 0 && anchor.x < layer.viewport.width && anchor.y < layer.viewport.height;
|
|
10196
|
+
if (leader && (start.x < 0 || start.y < 0 || start.x >= layer.viewport.width || start.y >= layer.viewport.height))
|
|
9864
10197
|
return null;
|
|
9865
10198
|
if (onScreen && !this.imageAsked && this.groupId && !HasIcon(this.options) && !this.options.photo) {
|
|
9866
10199
|
this.imageAsked = true;
|
|
@@ -9904,8 +10237,8 @@ var EntityLabel;
|
|
|
9904
10237
|
if (cursorAmount > 0 && !pinned) {
|
|
9905
10238
|
// A leader-less label starts centred on its anchor; preserve that box as it lifts away.
|
|
9906
10239
|
if (!normalLeader) {
|
|
9907
|
-
x -=
|
|
9908
|
-
y +=
|
|
10240
|
+
x -= size.width / layer.coordinates.scaleX / 2;
|
|
10241
|
+
y += size.height / layer.coordinates.scaleY / 2;
|
|
9909
10242
|
}
|
|
9910
10243
|
x += (cursorMotion.position.x + pixelOffset.x - x) * cursorAmount;
|
|
9911
10244
|
y += (cursorMotion.position.y + pixelOffset.y - y) * cursorAmount;
|
|
@@ -9920,6 +10253,10 @@ var EntityLabel;
|
|
|
9920
10253
|
else if (this.options.leaderLength != null) {
|
|
9921
10254
|
leaderLength = Math.max(0, this.options.leaderLength);
|
|
9922
10255
|
}
|
|
10256
|
+
else if (pin) {
|
|
10257
|
+
// The tip itself is the leader, so by default it touches what it marks.
|
|
10258
|
+
leaderLength = 0;
|
|
10259
|
+
}
|
|
9923
10260
|
else if (transientPivot) {
|
|
9924
10261
|
// Cursor callouts must not jump when the next hover target has a different extent.
|
|
9925
10262
|
leaderLength = 96;
|
|
@@ -9936,38 +10273,38 @@ var EntityLabel;
|
|
|
9936
10273
|
if (visual instanceof Entity && (visual.polygon || visual.polyline))
|
|
9937
10274
|
leaderLength /= 3;
|
|
9938
10275
|
}
|
|
9939
|
-
if (boxAnchor && this.options.leaderLength == null) {
|
|
10276
|
+
if (boxAnchor && this.options.leaderLength == null && !pin) {
|
|
9940
10277
|
leaderLength += (MODEL_BOX_STEM - leaderLength) * boxBlend;
|
|
9941
10278
|
}
|
|
9942
10279
|
if (cursorAmount > 0) {
|
|
9943
10280
|
leaderLength += (96 - leaderLength) * cursorAmount;
|
|
9944
10281
|
}
|
|
9945
10282
|
// Measured from the ring, so the visible stem is the same length whatever the glyph's size.
|
|
9946
|
-
|
|
10283
|
+
// A pin's tip rests on the glyph instead, since no ring is drawn around it.
|
|
10284
|
+
leaderLength += pin ? (_t = icon === null || icon === void 0 ? void 0 : icon.radius) !== null && _t !== void 0 ? _t : 0 : iconRing;
|
|
9947
10285
|
y = anchorY - leaderLength;
|
|
9948
10286
|
}
|
|
9949
10287
|
else if (hover && !reused && !pinned) {
|
|
9950
10288
|
x = hover.x + pixelOffset.x;
|
|
9951
10289
|
y = hover.y + pixelOffset.y - 24;
|
|
9952
10290
|
}
|
|
9953
|
-
// Hidden participants remain measurable; visibility never removes their layout boxes.
|
|
9954
10291
|
const coordinates = layer.coordinates;
|
|
9955
|
-
const width =
|
|
9956
|
-
const height =
|
|
10292
|
+
const width = size.width / coordinates.scaleX;
|
|
10293
|
+
const height = size.height / coordinates.scaleY;
|
|
9957
10294
|
let clusterBounds;
|
|
9958
|
-
if ((
|
|
9959
|
-
const textWidth =
|
|
9960
|
-
const textHeight =
|
|
10295
|
+
if ((_u = this.options.cluster) === null || _u === void 0 ? void 0 : _u.enabled) {
|
|
10296
|
+
const textWidth = size.textWidth;
|
|
10297
|
+
const textHeight = size.textHeight;
|
|
9961
10298
|
// A photo is never part of the footprint, so its arrival cannot change which cluster a label joins.
|
|
9962
|
-
const iconWidth = look.iconPhoto ? 0 :
|
|
9963
|
-
const iconHeight = look.iconPhoto ? 0 :
|
|
10299
|
+
const iconWidth = look.iconPhoto ? 0 : size.iconWidth;
|
|
10300
|
+
const iconHeight = look.iconPhoto ? 0 : size.iconHeight;
|
|
9964
10301
|
const gap = sourceText && iconWidth ? 6 : 0;
|
|
9965
10302
|
const above = presentation === "icon-text-above";
|
|
9966
10303
|
// Match the fixed content gap and label padding, excluding the count badge.
|
|
9967
10304
|
const baseWidth = ((above ? Math.max(textWidth, iconWidth) : textWidth + iconWidth + gap) + 16) / coordinates.scaleX;
|
|
9968
10305
|
const baseHeight = ((above ? textHeight + iconHeight + gap : Math.max(textHeight, iconHeight)) + 12) / coordinates.scaleY;
|
|
9969
10306
|
clusterBounds = {
|
|
9970
|
-
x: leader ? x : x - baseWidth / 2,
|
|
10307
|
+
x: leader && !pin ? x : x - baseWidth / 2,
|
|
9971
10308
|
y: leader ? y - baseHeight : y - baseHeight / 2, width: baseWidth, height: baseHeight
|
|
9972
10309
|
};
|
|
9973
10310
|
}
|
|
@@ -9978,7 +10315,9 @@ var EntityLabel;
|
|
|
9978
10315
|
// Membership uses the unclamped source footprint, never the summary's changing dimensions.
|
|
9979
10316
|
let leaderRun;
|
|
9980
10317
|
let leaderSide;
|
|
9981
|
-
if (leader &&
|
|
10318
|
+
if (leader && pin)
|
|
10319
|
+
({ x, y } = fitPin(anchorX, anchorY, leaderLength, width, height, size.pin));
|
|
10320
|
+
else if (leader && angled) {
|
|
9982
10321
|
const fit = fitAngledLeader(anchorX, anchorY, leaderLength, width, height);
|
|
9983
10322
|
({ x, y } = fit);
|
|
9984
10323
|
({ run: leaderRun, side: leaderSide } = fit);
|
|
@@ -9986,19 +10325,19 @@ var EntityLabel;
|
|
|
9986
10325
|
else if (leader)
|
|
9987
10326
|
({ x, y } = fitLeader(anchorX, anchorY, leaderLength, width, height));
|
|
9988
10327
|
const bounds = clusterBounds || { x, y, width, height };
|
|
9989
|
-
if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x >
|
|
10328
|
+
if (!leader && (bounds.x + bounds.width < 0 || bounds.y + bounds.height < 0 || bounds.x > layer.viewport.width || bounds.y > layer.viewport.height)) {
|
|
9990
10329
|
return null;
|
|
9991
10330
|
}
|
|
9992
|
-
const state = (
|
|
10331
|
+
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 });
|
|
9993
10332
|
const opacity = this.prePositioned || hoverOnly || MAX_DISTANCE === Infinity ? 1 : 1 - distance / MAX_DISTANCE;
|
|
9994
10333
|
return {
|
|
9995
|
-
canFlip: leader && presentation !== "icon", hasLeader: leader,
|
|
9996
|
-
textWrapped:
|
|
10334
|
+
canFlip: leader && presentation !== "icon" && !pin, hasLeader: leader,
|
|
10335
|
+
textWrapped: size.naturalTextWidth > TEXT_MAX_WIDTH,
|
|
9997
10336
|
transient: this.Transient || Boolean(hover) || cursorAmount > 0,
|
|
9998
10337
|
extendedGeometry: visual instanceof Entity && Boolean(visual.polygon || visual.polyline || visual.corridor),
|
|
9999
|
-
viewportWidth:
|
|
10000
|
-
id: this.id, entityKey: ((
|
|
10001
|
-
entityId: (
|
|
10338
|
+
viewportWidth: layer.viewport.width,
|
|
10339
|
+
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,
|
|
10340
|
+
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,
|
|
10002
10341
|
iconRadius: icon === null || icon === void 0 ? void 0 : icon.radius, modelBox: boxed || undefined, boxBlend, follows: !pinned && Boolean(transientPivot || cursorMotion.target),
|
|
10003
10342
|
// Priority shows the hovered member individually without dragging its cluster along.
|
|
10004
10343
|
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
|
|
@@ -10007,15 +10346,25 @@ var EntityLabel;
|
|
|
10007
10346
|
let displacement = { x: 0, y: 0 };
|
|
10008
10347
|
let nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
|
|
10009
10348
|
const apply = (placement) => {
|
|
10010
|
-
var _a, _b, _c, _d, _e
|
|
10349
|
+
var _a, _b, _c, _d, _e;
|
|
10011
10350
|
const show = (placement === null || placement === void 0 ? void 0 : placement.visible) && placement.opacity > 0;
|
|
10351
|
+
if (!show && hiddenLast) {
|
|
10352
|
+
return;
|
|
10353
|
+
}
|
|
10354
|
+
if (show && hiddenLast) {
|
|
10355
|
+
sizeStale = true;
|
|
10356
|
+
}
|
|
10357
|
+
hiddenLast = !show;
|
|
10012
10358
|
shownOnce = shownOnce || Boolean(show);
|
|
10013
10359
|
clickEntityIds = show ? placement.entityIds : [];
|
|
10360
|
+
// Out of layout while hidden, so thousands of clustered labels cost the browser nothing to lay out.
|
|
10361
|
+
ele.style.display = show ? "flex" : "none";
|
|
10014
10362
|
ele.style.visibility = show ? "visible" : "hidden";
|
|
10015
10363
|
lineEle.style.display = show && leader ? "block" : "none";
|
|
10016
10364
|
if (runEle)
|
|
10017
10365
|
runEle.style.display = show && leader ? "block" : "none";
|
|
10018
|
-
|
|
10366
|
+
// A pin's tip marks the anchor itself, so it has no ring there.
|
|
10367
|
+
this.anchor.style.display = show && leader && !pin && !(((_a = placement.frame) === null || _a === void 0 ? void 0 : _a.boxBlend) >= 1) ? "block" : "none";
|
|
10019
10368
|
if (!show) {
|
|
10020
10369
|
displacement = { x: 0, y: 0 };
|
|
10021
10370
|
nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
|
|
@@ -10048,6 +10397,7 @@ var EntityLabel;
|
|
|
10048
10397
|
const displayText = (_c = placement.text) !== null && _c !== void 0 ? _c : originalText;
|
|
10049
10398
|
if (textElement && textElement.textContent !== displayText) {
|
|
10050
10399
|
textElement.textContent = displayText;
|
|
10400
|
+
sizeStale = true;
|
|
10051
10401
|
// Measure the summary's footprint next frame without replacing each member's source text.
|
|
10052
10402
|
this.viewer.scene.requestRender();
|
|
10053
10403
|
}
|
|
@@ -10062,17 +10412,17 @@ var EntityLabel;
|
|
|
10062
10412
|
const count = placement.members.length ? String(placement.members.length) : "";
|
|
10063
10413
|
if (countElement.textContent !== count) {
|
|
10064
10414
|
countElement.textContent = count;
|
|
10415
|
+
sizeStale = true;
|
|
10065
10416
|
// The badge participates in layout, so its new width needs another measurement.
|
|
10066
10417
|
this.viewer.scene.requestRender();
|
|
10067
10418
|
}
|
|
10068
|
-
fitIconBackground === null || fitIconBackground === void 0 ? void 0 : fitIconBackground();
|
|
10069
10419
|
const stack = JSON.stringify(placement.icons || []);
|
|
10070
10420
|
if (iconStack && stack !== displayedStack) {
|
|
10071
10421
|
displayedStack = stack;
|
|
10072
10422
|
const looks = ((_d = placement.icons) === null || _d === void 0 ? void 0 : _d.length) ? [iconLook(this.options), ...placement.icons] : [];
|
|
10073
10423
|
// One small size for all, so no icon in the arrangement reads as more important than another.
|
|
10074
10424
|
const size = (this.options.iconSize || 24) * ((_e = this.options.iconScale) !== null && _e !== void 0 ? _e : 1) * ICON_STACK_SCALE;
|
|
10075
|
-
const built = looks.map(look => this.buildIcon({ ...look, iconSize: size }, counter));
|
|
10425
|
+
const built = looks.map(look => this.buildIcon({ ...(pin ? pinLook(look) : look), iconSize: size }, counter));
|
|
10076
10426
|
// A stack is on show already, so its photos load straight away.
|
|
10077
10427
|
built.forEach(({ start }) => start === null || start === void 0 ? void 0 : start());
|
|
10078
10428
|
// Two sit side by side; three make a triangle with the representative on top.
|
|
@@ -10081,6 +10431,7 @@ var EntityLabel;
|
|
|
10081
10431
|
built[0].icon.style.gridColumn = "1 / span 2";
|
|
10082
10432
|
}
|
|
10083
10433
|
iconStack.replaceChildren(...built.map(({ icon }) => icon));
|
|
10434
|
+
sizeStale = true;
|
|
10084
10435
|
iconStack.style.display = built.length ? "inline-grid" : "none";
|
|
10085
10436
|
// The glyph stays measurable, since cluster membership is taken from its footprint.
|
|
10086
10437
|
iconElement.style.visibility = built.length ? "hidden" : "";
|
|
@@ -10089,238 +10440,301 @@ var EntityLabel;
|
|
|
10089
10440
|
// The stack widens the label, which the next frame has to measure.
|
|
10090
10441
|
this.viewer.scene.requestRender();
|
|
10091
10442
|
}
|
|
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
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10443
|
+
/*
|
|
10444
|
+
* Everything above writes the label's content. The layer runs what follows in two passes over all
|
|
10445
|
+
* its labels, measuring every one before placing any, so no label reads layout another just changed.
|
|
10446
|
+
*/
|
|
10447
|
+
return () => {
|
|
10448
|
+
if (sizeStale || !resized) {
|
|
10449
|
+
fitIconBackground === null || fitIconBackground === void 0 ? void 0 : fitIconBackground();
|
|
10450
|
+
for (const fit of stackedFits)
|
|
10451
|
+
fit();
|
|
10452
|
+
badge = badgeOnIcon ? {
|
|
10453
|
+
width: countElement.offsetWidth,
|
|
10454
|
+
height: countElement.offsetHeight,
|
|
10455
|
+
iconWidth: iconElement.offsetWidth,
|
|
10456
|
+
iconHeight: iconElement.offsetHeight
|
|
10457
|
+
} : null;
|
|
10458
|
+
measureSize();
|
|
10459
|
+
sizeStale = false;
|
|
10460
|
+
}
|
|
10461
|
+
const pinShape = leader && pin ? size.pin : undefined;
|
|
10462
|
+
const measuredWidth = size.width / coordinates.scaleX;
|
|
10463
|
+
const measuredHeight = size.height / coordinates.scaleY;
|
|
10464
|
+
return () => {
|
|
10465
|
+
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;
|
|
10466
|
+
if (badge) {
|
|
10467
|
+
const narrow = badge.iconWidth < badge.iconHeight * 0.6;
|
|
10468
|
+
const clearance = badge.width ? (narrow ? badge.width / 2 + 2 : Math.max(0, badge.width / 2 - badge.iconWidth / 4)) : 0;
|
|
10469
|
+
// Reserve the badge overhang so adjacent text and viewport edges remain clear.
|
|
10470
|
+
const overhang = badge.height / 2;
|
|
10471
|
+
const margins = [
|
|
10472
|
+
badgeBelow ? "0px" : `${overhang}px`, badgeBelow ? `${overhang}px` : "0px", `${badge.width / 2 + clearance}px`
|
|
10473
|
+
];
|
|
10474
|
+
countElement.style.left = `calc(100% + ${clearance}px)`;
|
|
10475
|
+
if (iconContainer.style.marginTop !== margins[0] ||
|
|
10476
|
+
iconContainer.style.marginBottom !== margins[1] ||
|
|
10477
|
+
iconContainer.style.marginRight !== margins[2]) {
|
|
10478
|
+
[iconContainer.style.marginTop, iconContainer.style.marginBottom, iconContainer.style.marginRight] = margins;
|
|
10479
|
+
sizeStale = true;
|
|
10480
|
+
// The margins change the label's size, which the next frame measures.
|
|
10481
|
+
this.viewer.scene.requestRender();
|
|
10482
|
+
}
|
|
10483
|
+
}
|
|
10484
|
+
const ring = this.options.anchorRing;
|
|
10485
|
+
const pointer = (layer.pointer || (cursorMotion.target ? cursorMotion.position : undefined) || (this.Transient && !this.Persistent ?
|
|
10486
|
+
(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));
|
|
10487
|
+
const iconRing = frame.iconRadius ? Math.max(ICON_RING_MIN, frame.iconRadius + ICON_RING_PADDING) : 0;
|
|
10488
|
+
const boxed = leader ? frame.modelBox : undefined;
|
|
10489
|
+
const hovered = pointer && (boxed ? hullContains(boxed.hull, pointer) :
|
|
10490
|
+
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));
|
|
10491
|
+
if (look.iconPhoto && growPhoto) {
|
|
10492
|
+
// A rectangle leans on the leader's side of the label.
|
|
10493
|
+
if (photoShape === "rect") {
|
|
10494
|
+
const align = !leader ? "center" : placement.textSide === "left" ? "flex-end" : "flex-start";
|
|
10495
|
+
if (content.style.alignItems !== align) {
|
|
10496
|
+
content.style.alignItems = align;
|
|
10497
|
+
}
|
|
10498
|
+
}
|
|
10499
|
+
// Grown in layout rather than scaled, so the border keeps its width, and the label,
|
|
10500
|
+
// whose bottom sits on the leader, grows up and sideways without changing its length.
|
|
10501
|
+
growPhoto(Boolean(hovered) && !((_e = placement.members) === null || _e === void 0 ? void 0 : _e.length));
|
|
10502
|
+
sizeStale = true;
|
|
10503
|
+
}
|
|
10504
|
+
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));
|
|
10505
|
+
const targetRadius = normalRadius + (15.4 - normalRadius) * cursorMotion.amount;
|
|
10506
|
+
// Around a glyph the ring keeps its size and only fades its stroke in, never covering it.
|
|
10507
|
+
// A ring around the cursor marks nothing, so a riding label keeps only its leader.
|
|
10508
|
+
const targetOuter = frame.follows ? 0 : iconRing || targetRadius || 2.5;
|
|
10509
|
+
const targetInner = frame.follows ? 0 : iconRing ? (targetRadius > 0 ? iconRing - 2 : iconRing) : Math.max(0, targetRadius - 2);
|
|
10510
|
+
const now = Date.now();
|
|
10511
|
+
const duration = (_j = ring === null || ring === void 0 ? void 0 : ring.transitionDuration) !== null && _j !== void 0 ? _j : 200;
|
|
10512
|
+
const sharedRing = this.Transient && !this.Persistent && this.hoverFade.to === 1 ? this.hoverRingState : undefined;
|
|
10513
|
+
let ringAnimation = sharedRing ? sharedRing.animation : this.ringAnimation;
|
|
10514
|
+
if (!ringAnimation) {
|
|
10515
|
+
const outer = frame.follows ? 0 : iconRing || 2.5;
|
|
10516
|
+
const inner = frame.follows ? 0 : iconRing;
|
|
10517
|
+
ringAnimation = { target: outer, targetInner: inner, start: now, outer, inner, fromOuter: outer, fromInner: inner };
|
|
10518
|
+
}
|
|
10519
|
+
const animateRing = () => {
|
|
10520
|
+
const progress = duration > 0 ? Math.min(1, Math.max(0, (now - ringAnimation.start) / duration)) : 1;
|
|
10521
|
+
const eased = progress * progress * (3 - 2 * progress);
|
|
10522
|
+
ringAnimation.outer = ringAnimation.fromOuter + (ringAnimation.target - ringAnimation.fromOuter) * eased;
|
|
10523
|
+
ringAnimation.inner = ringAnimation.fromInner + (ringAnimation.targetInner - ringAnimation.fromInner) * eased;
|
|
10524
|
+
return progress;
|
|
10525
|
+
};
|
|
10526
|
+
animateRing();
|
|
10527
|
+
if (ringAnimation.target !== targetOuter || ringAnimation.targetInner !== targetInner) {
|
|
10528
|
+
ringAnimation = {
|
|
10529
|
+
...ringAnimation,
|
|
10530
|
+
target: targetOuter,
|
|
10531
|
+
targetInner,
|
|
10532
|
+
start: now,
|
|
10533
|
+
fromOuter: ringAnimation.outer,
|
|
10534
|
+
fromInner: ringAnimation.inner
|
|
10535
|
+
};
|
|
10536
|
+
}
|
|
10537
|
+
// Animate the hole and stem together; no CSS transition may lag behind a moving world anchor.
|
|
10538
|
+
if (animateRing() < 1 && (ringAnimation.fromOuter !== targetOuter || ringAnimation.fromInner !== targetInner)) {
|
|
10539
|
+
this.viewer.scene.requestRender();
|
|
10540
|
+
}
|
|
10541
|
+
this.ringAnimation = ringAnimation;
|
|
10542
|
+
if (sharedRing) {
|
|
10543
|
+
sharedRing.animation = ringAnimation;
|
|
10544
|
+
}
|
|
10545
|
+
const ringShare = 1 - (frame.boxBlend || 0);
|
|
10546
|
+
const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
|
|
10547
|
+
const stem = (pinShape ? fitPin(frame.anchorX, frame.anchorY, frame.leaderLength, measuredWidth, measuredHeight, pinShape) :
|
|
10548
|
+
leader ? (angled ? fitAngledLeader : fitLeader)(frame.anchorX, frame.anchorY, Math.max(frame.leaderLength, radius ? radius + 4 : 0), measuredWidth, measuredHeight, radius) : undefined);
|
|
10549
|
+
const position = { x: (stem || frame).x, y: (stem || frame).y };
|
|
10550
|
+
const width = measuredWidth;
|
|
10551
|
+
const height = measuredHeight;
|
|
10552
|
+
if (leader && angled) {
|
|
10553
|
+
// The declutter owns the side; the fit only says which one had the room to begin with.
|
|
10554
|
+
const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
|
|
10555
|
+
const side = (_l = (_k = placement.textSide) !== null && _k !== void 0 ? _k : frame.leaderSide) !== null && _l !== void 0 ? _l : "right";
|
|
10556
|
+
const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
|
|
10557
|
+
position.x = Math.max(0, Math.min(beside, layer.viewport.width - width));
|
|
10558
|
+
}
|
|
10559
|
+
else if (leader && !pin && placement.textSide === "left") {
|
|
10560
|
+
position.x = Math.max(0, Math.min(frame.anchorX - width, layer.viewport.width - width));
|
|
10561
|
+
}
|
|
10562
|
+
const gap = (_o = (_m = this.options.pointerAvoidance) === null || _m === void 0 ? void 0 : _m.gap) !== null && _o !== void 0 ? _o : 12;
|
|
10563
|
+
const containsPointer = (x, y, margin) => {
|
|
10564
|
+
return pointer && pointer.x >= x - margin && pointer.x <= x + width + margin && pointer.y >= y - margin && pointer.y <= y + height + margin;
|
|
10565
|
+
};
|
|
10566
|
+
const passive = !selectOnClick || !this.visualRegister;
|
|
10567
|
+
if (passive && ((_p = this.options.pointerAvoidance) === null || _p === void 0 ? void 0 : _p.enabled) !== false && pointer &&
|
|
10568
|
+
(containsPointer(position.x, position.y, gap) || containsPointer(position.x + displacement.x, position.y + displacement.y, gap))) {
|
|
10569
|
+
if (containsPointer(position.x + displacement.x, position.y + displacement.y, 0)) {
|
|
10570
|
+
// Choose against the original box; keep the offset until the pointer leaves both.
|
|
10571
|
+
const candidates = [
|
|
10572
|
+
{ x: 0, y: pointer.y - gap - height - position.y },
|
|
10573
|
+
{ x: 0, y: pointer.y + gap - position.y },
|
|
10574
|
+
{ x: pointer.x - gap - width - position.x, y: 0 },
|
|
10575
|
+
{ x: pointer.x + gap - position.x, y: 0 }
|
|
10576
|
+
].filter(offset => position.x + offset.x >= 0 && position.y + offset.y >= 0 &&
|
|
10577
|
+
position.x + offset.x + width <= layer.viewport.width && position.y + offset.y + height <= layer.viewport.height)
|
|
10578
|
+
.sort((a, b) => Math.hypot(a.x, a.y) - Math.hypot(b.x, b.y));
|
|
10579
|
+
displacement = candidates[0] || { x: 0, y: 0 };
|
|
10580
|
+
}
|
|
10581
|
+
}
|
|
10582
|
+
else {
|
|
10583
|
+
displacement = { x: 0, y: 0 };
|
|
10584
|
+
}
|
|
10585
|
+
const nudgeDuration = (_r = (_q = this.options.pointerAvoidance) === null || _q === void 0 ? void 0 : _q.transitionDuration) !== null && _r !== void 0 ? _r : 200;
|
|
10586
|
+
const animateNudge = () => {
|
|
10587
|
+
const progress = now < nudge.start ? 0 : nudgeDuration > 0 ? Math.min(1, (now - nudge.start) / nudgeDuration) : 1;
|
|
10588
|
+
const eased = progress * progress * (3 - 2 * progress);
|
|
10589
|
+
nudge.x = nudge.fromX + (nudge.targetX - nudge.fromX) * eased;
|
|
10590
|
+
nudge.y = nudge.fromY + (nudge.targetY - nudge.fromY) * eased;
|
|
10591
|
+
return progress;
|
|
10592
|
+
};
|
|
10593
|
+
animateNudge();
|
|
10594
|
+
if (nudge.targetX !== displacement.x || nudge.targetY !== displacement.y) {
|
|
10595
|
+
nudge = {
|
|
10596
|
+
...nudge,
|
|
10597
|
+
fromX: nudge.x,
|
|
10598
|
+
fromY: nudge.y,
|
|
10599
|
+
targetX: displacement.x,
|
|
10600
|
+
targetY: displacement.y,
|
|
10601
|
+
start: now + ((_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.delay) !== null && _t !== void 0 ? _t : 180)
|
|
10602
|
+
};
|
|
10603
|
+
}
|
|
10604
|
+
if (animateNudge() < 1 && (nudge.fromX !== nudge.targetX || nudge.fromY !== nudge.targetY)) {
|
|
10605
|
+
this.viewer.scene.requestRender();
|
|
10606
|
+
}
|
|
10607
|
+
position.x += nudge.x;
|
|
10608
|
+
position.y += nudge.y;
|
|
10609
|
+
ele.style.left = `${coordinates.x + position.x * coordinates.scaleX}px`;
|
|
10610
|
+
ele.style.top = `${coordinates.y + position.y * coordinates.scaleY}px`;
|
|
10611
|
+
for (const clickTarget of Array.from(content.querySelectorAll('[role="button"]'))) {
|
|
10612
|
+
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}`);
|
|
10613
|
+
}
|
|
10614
|
+
if (leader) {
|
|
10615
|
+
const nodeRadius = ringAnimation.outer * (1 - (frame.boxBlend || 0));
|
|
10616
|
+
const anchor = this.anchor;
|
|
10617
|
+
anchor.style.left = `${coordinates.x + (frame.anchorX - nodeRadius) * coordinates.scaleX}px`;
|
|
10618
|
+
anchor.style.top = `${coordinates.y + (frame.anchorY - nodeRadius) * coordinates.scaleY}px`;
|
|
10619
|
+
anchor.style.width = `${nodeRadius * 2 * coordinates.scaleX}px`;
|
|
10620
|
+
anchor.style.height = `${nodeRadius * 2 * coordinates.scaleY}px`;
|
|
10621
|
+
anchor.style.boxSizing = "border-box";
|
|
10622
|
+
anchor.style.background = "transparent";
|
|
10623
|
+
const svg = anchor.firstElementChild;
|
|
10624
|
+
svg.setAttribute("viewBox", `0 0 ${nodeRadius * 2} ${nodeRadius * 2}`);
|
|
10625
|
+
const circle = svg.firstElementChild;
|
|
10626
|
+
circle.setAttribute("cx", String(nodeRadius));
|
|
10627
|
+
circle.setAttribute("cy", String(nodeRadius));
|
|
10628
|
+
const innerRadius = ringAnimation.inner * (1 - (frame.boxBlend || 0));
|
|
10629
|
+
circle.setAttribute("r", String((nodeRadius + innerRadius) / 2));
|
|
10630
|
+
circle.setAttribute("stroke", this.options.leaderColor || "rgba(255, 255, 255, 0.8)");
|
|
10631
|
+
circle.setAttribute("stroke-width", String(nodeRadius - innerRadius));
|
|
10632
|
+
anchor.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10633
|
+
anchor.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount) * (1 - (frame.boxBlend || 0)));
|
|
10634
|
+
anchor.style.zIndex = String(placement.zIndex);
|
|
10635
|
+
// The stem starts at the rim, never across the clear centre, even after displacement.
|
|
10636
|
+
const straightX = Math.max(position.x, Math.min(frame.anchorX, position.x + width));
|
|
10637
|
+
const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
|
|
10638
|
+
const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
|
|
10639
|
+
const elbowY = position.y + height / 2;
|
|
10640
|
+
let endX = beside ? frame.anchorX : straightX;
|
|
10641
|
+
let endY = beside ? elbowY : straightY;
|
|
10642
|
+
if (pinShape) {
|
|
10643
|
+
// Aimed from wherever clamping or a nudge left it; a stem, if any, meets the tip.
|
|
10644
|
+
const centreX = position.x + pinShape.x, centreY = position.y + pinShape.y;
|
|
10645
|
+
const aim = Math.atan2(frame.anchorY - centreY, frame.anchorX - centreX);
|
|
10646
|
+
const reach = Math.min(pinShape.tip, Math.hypot(frame.anchorX - centreX, frame.anchorY - centreY));
|
|
10647
|
+
endX = centreX + Math.cos(aim) * reach;
|
|
10648
|
+
endY = centreY + Math.sin(aim) * reach;
|
|
10649
|
+
const size = `${pinShape.radius * 2 * coordinates.scaleX}px`;
|
|
10650
|
+
if (pinHolder.style.width !== size) {
|
|
10651
|
+
pinHolder.style.width = pinHolder.style.height = size;
|
|
10652
|
+
pinHolder.style.margin = `-${pinShape.radius * coordinates.scaleX}px`;
|
|
10653
|
+
}
|
|
10654
|
+
// The body's square corner starts lower right, a quarter turn short of down.
|
|
10655
|
+
const turn = Math.round((aim - Math.PI / 4) * 200) / 200;
|
|
10656
|
+
const rotation = `rotate(${turn}rad)`;
|
|
10657
|
+
if (pinBody.style.transform !== rotation) {
|
|
10658
|
+
pinBody.style.transform = rotation;
|
|
10659
|
+
// A box shadow turns with the body, so its offset is turned back to fall down
|
|
10660
|
+
// and right; a drop-shadow filter would not turn, but repaints every moving pin.
|
|
10661
|
+
const offsetX = Math.round((Math.cos(turn) + 2 * Math.sin(turn)) * 4) / 4;
|
|
10662
|
+
const offsetY = Math.round((2 * Math.cos(turn) - Math.sin(turn)) * 4) / 4;
|
|
10663
|
+
pinBody.style.boxShadow = `${offsetX}px ${offsetY}px 3px rgba(0, 0, 0, 0.35)`;
|
|
10664
|
+
}
|
|
10665
|
+
}
|
|
10666
|
+
const runToX = frame.anchorX < position.x ? position.x : position.x + width;
|
|
10667
|
+
const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
|
|
10668
|
+
const length = Math.hypot(dx, dy);
|
|
10669
|
+
const leaderAngle = Math.atan2(dy, dx);
|
|
10670
|
+
const pointerDx = pointer ? pointer.x - frame.anchorX : 0;
|
|
10671
|
+
const pointerDy = pointer ? pointer.y - frame.anchorY : 0;
|
|
10672
|
+
const desiredAngle = Math.hypot(pointerDx, pointerDy) > 0.5 ? Math.atan2(pointerDy, pointerDx) + Math.PI - leaderAngle : 0;
|
|
10673
|
+
const wrappedAngle = Math.atan2(Math.sin(desiredAngle), Math.cos(desiredAngle));
|
|
10674
|
+
// Keep the stem inside the 126-degree arc, away from antialiased endpoints.
|
|
10675
|
+
const arcFraction = 0.35;
|
|
10676
|
+
const rotationLimit = Math.PI * arcFraction - Math.PI / 30;
|
|
10677
|
+
const targetOffset = hovered ? Math.max(-rotationLimit, Math.min(rotationLimit, wrappedAngle)) : ((_x = ringAnimation.arcOffset) !== null && _x !== void 0 ? _x : 0);
|
|
10678
|
+
const targetOpen = cursorMotion.target || (hovered && (ring === null || ring === void 0 ? void 0 : ring.enabled) !== false && targetRadius > 0) ? 1 : 0;
|
|
10679
|
+
const elapsed = Math.min(32, Math.max(0, now - ((_y = ringAnimation.arcTime) !== null && _y !== void 0 ? _y : now)));
|
|
10680
|
+
const blend = duration > 0 ? 1 - Math.exp(-elapsed / (duration / 3)) : 1;
|
|
10681
|
+
const approach = (value, target) => Math.abs(value - target) < 0.001 ? target : value + (target - value) * blend;
|
|
10682
|
+
ringAnimation.arcOffset = approach((_z = ringAnimation.arcOffset) !== null && _z !== void 0 ? _z : 0, targetOffset);
|
|
10683
|
+
ringAnimation.arcOpen = approach((_0 = ringAnimation.arcOpen) !== null && _0 !== void 0 ? _0 : 0, targetOpen);
|
|
10684
|
+
ringAnimation.arcTime = now;
|
|
10685
|
+
if (ringAnimation.arcOffset !== targetOffset || ringAnimation.arcOpen !== targetOpen) {
|
|
10686
|
+
this.viewer.scene.requestRender();
|
|
10687
|
+
}
|
|
10688
|
+
const circumference = Math.PI * (nodeRadius + ringAnimation.inner);
|
|
10689
|
+
const filledFraction = 1 - ringAnimation.arcOpen * (1 - arcFraction);
|
|
10690
|
+
circle.setAttribute("stroke-dasharray", `${circumference * filledFraction} ${circumference * (1 - filledFraction)}`);
|
|
10691
|
+
circle.setAttribute("transform", `rotate(${(leaderAngle + ringAnimation.arcOffset - Math.PI * filledFraction) * 180 / Math.PI} ${nodeRadius} ${nodeRadius})`);
|
|
10692
|
+
const cut = Math.min(radius, length);
|
|
10693
|
+
const startX = frame.anchorX + (length ? dx / length * cut : 0);
|
|
10694
|
+
const startY = frame.anchorY + (length ? dy / length * cut : 0);
|
|
10695
|
+
const draw = (element, fromX, fromY, toX, toY) => {
|
|
10696
|
+
const screenDx = (toX - fromX) * coordinates.scaleX;
|
|
10697
|
+
const screenDy = (toY - fromY) * coordinates.scaleY;
|
|
10698
|
+
element.style.width = `${2 * coordinates.scaleX}px`;
|
|
10699
|
+
element.style.left = `${coordinates.x + (fromX - 1) * coordinates.scaleX}px`;
|
|
10700
|
+
element.style.top = `${coordinates.y + fromY * coordinates.scaleY}px`;
|
|
10701
|
+
element.style.height = `${Math.hypot(screenDx, screenDy)}px`;
|
|
10702
|
+
element.style.transform = `rotate(${Math.atan2(screenDy, screenDx) - Math.PI / 2}rad)`;
|
|
10703
|
+
element.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10704
|
+
element.style.transformOrigin = "top center";
|
|
10705
|
+
element.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount));
|
|
10706
|
+
element.style.zIndex = String(placement.zIndex);
|
|
10707
|
+
};
|
|
10708
|
+
draw(lineEle, startX, startY, endX, endY);
|
|
10709
|
+
if (layer.modelBoxes.Hull(this.id)) {
|
|
10710
|
+
layer.modelBoxes.Request(this.id, {
|
|
10711
|
+
whole: Boolean(cursorMotion.target), from: { x: frame.anchorX, y: frame.anchorY },
|
|
10712
|
+
opacity, zIndex: placement.zIndex, color: this.options.leaderColor || "rgba(255, 255, 255, 0.8)", duration
|
|
10713
|
+
});
|
|
10714
|
+
}
|
|
10715
|
+
if (runEle) {
|
|
10716
|
+
// Overlap the corner by the stem's own width so the elbow has no notch in it.
|
|
10717
|
+
const overlap = frame.anchorX < runToX ? -1 : 1;
|
|
10718
|
+
runEle.style.display = beside ? "block" : "none";
|
|
10719
|
+
if (beside)
|
|
10720
|
+
draw(runEle, endX + overlap, endY, runToX, endY);
|
|
10721
|
+
}
|
|
10722
|
+
}
|
|
10157
10723
|
};
|
|
10158
|
-
}
|
|
10159
|
-
// Animate the hole and stem together; no CSS transition may lag behind a moving world anchor.
|
|
10160
|
-
if (animateRing() < 1 && (ringAnimation.fromOuter !== targetOuter || ringAnimation.fromInner !== targetInner)) {
|
|
10161
|
-
this.viewer.scene.requestRender();
|
|
10162
|
-
}
|
|
10163
|
-
this.ringAnimation = ringAnimation;
|
|
10164
|
-
if (sharedRing) {
|
|
10165
|
-
sharedRing.animation = ringAnimation;
|
|
10166
|
-
}
|
|
10167
|
-
const ringShare = 1 - (frame.boxBlend || 0);
|
|
10168
|
-
const radius = ringShare > 0 && ringAnimation.inner > 0 ? ringAnimation.outer * ringShare : 0;
|
|
10169
|
-
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);
|
|
10170
|
-
const position = { x: (stem || frame).x, y: (stem || frame).y };
|
|
10171
|
-
const width = ele.offsetWidth / coordinates.scaleX;
|
|
10172
|
-
const height = ele.offsetHeight / coordinates.scaleY;
|
|
10173
|
-
if (leader && angled) {
|
|
10174
|
-
// The declutter owns the side; the fit only says which one had the room to begin with.
|
|
10175
|
-
const run = Math.max(ANGLED_LEADER_RUN, radius + 4);
|
|
10176
|
-
const side = (_r = (_q = placement.textSide) !== null && _q !== void 0 ? _q : frame.leaderSide) !== null && _r !== void 0 ? _r : "right";
|
|
10177
|
-
const beside = side === "left" ? frame.anchorX - run - width : frame.anchorX + run;
|
|
10178
|
-
position.x = Math.max(0, Math.min(beside, this.viewer.canvas.clientWidth - width));
|
|
10179
|
-
}
|
|
10180
|
-
else if (leader && placement.textSide === "left") {
|
|
10181
|
-
position.x = Math.max(0, Math.min(frame.anchorX - width, this.viewer.canvas.clientWidth - width));
|
|
10182
|
-
}
|
|
10183
|
-
const gap = (_t = (_s = this.options.pointerAvoidance) === null || _s === void 0 ? void 0 : _s.gap) !== null && _t !== void 0 ? _t : 12;
|
|
10184
|
-
const containsPointer = (x, y, margin) => {
|
|
10185
|
-
return pointer && pointer.x >= x - margin && pointer.x <= x + width + margin && pointer.y >= y - margin && pointer.y <= y + height + margin;
|
|
10186
10724
|
};
|
|
10187
|
-
const passive = !selectOnClick || !this.visualRegister;
|
|
10188
|
-
if (passive && ((_u = this.options.pointerAvoidance) === null || _u === void 0 ? void 0 : _u.enabled) !== false && pointer &&
|
|
10189
|
-
(containsPointer(position.x, position.y, gap) || containsPointer(position.x + displacement.x, position.y + displacement.y, gap))) {
|
|
10190
|
-
if (containsPointer(position.x + displacement.x, position.y + displacement.y, 0)) {
|
|
10191
|
-
// Choose against the original box and retain the offset until the pointer leaves both boxes.
|
|
10192
|
-
const candidates = [
|
|
10193
|
-
{ x: 0, y: pointer.y - gap - height - position.y },
|
|
10194
|
-
{ x: 0, y: pointer.y + gap - position.y },
|
|
10195
|
-
{ x: pointer.x - gap - width - position.x, y: 0 },
|
|
10196
|
-
{ x: pointer.x + gap - position.x, y: 0 }
|
|
10197
|
-
].filter(offset => position.x + offset.x >= 0 && position.y + offset.y >= 0 &&
|
|
10198
|
-
position.x + offset.x + width <= this.viewer.canvas.clientWidth && position.y + offset.y + height <= this.viewer.canvas.clientHeight)
|
|
10199
|
-
.sort((a, b) => Math.hypot(a.x, a.y) - Math.hypot(b.x, b.y));
|
|
10200
|
-
displacement = candidates[0] || { x: 0, y: 0 };
|
|
10201
|
-
}
|
|
10202
|
-
}
|
|
10203
|
-
else {
|
|
10204
|
-
displacement = { x: 0, y: 0 };
|
|
10205
|
-
}
|
|
10206
|
-
const nudgeDuration = (_w = (_v = this.options.pointerAvoidance) === null || _v === void 0 ? void 0 : _v.transitionDuration) !== null && _w !== void 0 ? _w : 200;
|
|
10207
|
-
const animateNudge = () => {
|
|
10208
|
-
const progress = now < nudge.start ? 0 : nudgeDuration > 0 ? Math.min(1, (now - nudge.start) / nudgeDuration) : 1;
|
|
10209
|
-
const eased = progress * progress * (3 - 2 * progress);
|
|
10210
|
-
nudge.x = nudge.fromX + (nudge.targetX - nudge.fromX) * eased;
|
|
10211
|
-
nudge.y = nudge.fromY + (nudge.targetY - nudge.fromY) * eased;
|
|
10212
|
-
return progress;
|
|
10213
|
-
};
|
|
10214
|
-
animateNudge();
|
|
10215
|
-
if (nudge.targetX !== displacement.x || nudge.targetY !== displacement.y) {
|
|
10216
|
-
nudge = {
|
|
10217
|
-
...nudge,
|
|
10218
|
-
fromX: nudge.x,
|
|
10219
|
-
fromY: nudge.y,
|
|
10220
|
-
targetX: displacement.x,
|
|
10221
|
-
targetY: displacement.y,
|
|
10222
|
-
start: now + ((_y = (_x = this.options.pointerAvoidance) === null || _x === void 0 ? void 0 : _x.delay) !== null && _y !== void 0 ? _y : 180)
|
|
10223
|
-
};
|
|
10224
|
-
}
|
|
10225
|
-
if (animateNudge() < 1 && (nudge.fromX !== nudge.targetX || nudge.fromY !== nudge.targetY)) {
|
|
10226
|
-
this.viewer.scene.requestRender();
|
|
10227
|
-
}
|
|
10228
|
-
position.x += nudge.x;
|
|
10229
|
-
position.y += nudge.y;
|
|
10230
|
-
ele.style.left = `${coordinates.x + position.x * coordinates.scaleX}px`;
|
|
10231
|
-
ele.style.top = `${coordinates.y + position.y * coordinates.scaleY}px`;
|
|
10232
|
-
for (const clickTarget of Array.from(content.querySelectorAll('[role="button"]'))) {
|
|
10233
|
-
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}`);
|
|
10234
|
-
}
|
|
10235
|
-
if (leader) {
|
|
10236
|
-
const nodeRadius = ringAnimation.outer * (1 - (frame.boxBlend || 0));
|
|
10237
|
-
const anchor = this.anchor;
|
|
10238
|
-
anchor.style.left = `${coordinates.x + (frame.anchorX - nodeRadius) * coordinates.scaleX}px`;
|
|
10239
|
-
anchor.style.top = `${coordinates.y + (frame.anchorY - nodeRadius) * coordinates.scaleY}px`;
|
|
10240
|
-
anchor.style.width = `${nodeRadius * 2 * coordinates.scaleX}px`;
|
|
10241
|
-
anchor.style.height = `${nodeRadius * 2 * coordinates.scaleY}px`;
|
|
10242
|
-
anchor.style.boxSizing = "border-box";
|
|
10243
|
-
anchor.style.background = "transparent";
|
|
10244
|
-
const svg = anchor.firstElementChild;
|
|
10245
|
-
svg.setAttribute("viewBox", `0 0 ${nodeRadius * 2} ${nodeRadius * 2}`);
|
|
10246
|
-
const circle = svg.firstElementChild;
|
|
10247
|
-
circle.setAttribute("cx", String(nodeRadius));
|
|
10248
|
-
circle.setAttribute("cy", String(nodeRadius));
|
|
10249
|
-
const innerRadius = ringAnimation.inner * (1 - (frame.boxBlend || 0));
|
|
10250
|
-
circle.setAttribute("r", String((nodeRadius + innerRadius) / 2));
|
|
10251
|
-
circle.setAttribute("stroke", this.options.leaderColor || "rgba(255, 255, 255, 0.8)");
|
|
10252
|
-
circle.setAttribute("stroke-width", String(nodeRadius - innerRadius));
|
|
10253
|
-
anchor.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10254
|
-
anchor.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount) * (1 - (frame.boxBlend || 0)));
|
|
10255
|
-
anchor.style.zIndex = String(placement.zIndex);
|
|
10256
|
-
// The stem starts at the rim, never across the transparent centre, even after passive displacement.
|
|
10257
|
-
const straightX = Math.max(position.x, Math.min(frame.anchorX, position.x + width));
|
|
10258
|
-
const straightY = frame.anchorY < position.y ? position.y : frame.anchorY > position.y + height ? position.y + height : frame.anchorY;
|
|
10259
|
-
const beside = angled && (frame.anchorX < position.x || frame.anchorX > position.x + width);
|
|
10260
|
-
const elbowY = position.y + height / 2;
|
|
10261
|
-
const endX = beside ? frame.anchorX : straightX;
|
|
10262
|
-
const endY = beside ? elbowY : straightY;
|
|
10263
|
-
const runToX = frame.anchorX < position.x ? position.x : position.x + width;
|
|
10264
|
-
const dx = endX - frame.anchorX, dy = endY - frame.anchorY;
|
|
10265
|
-
const length = Math.hypot(dx, dy);
|
|
10266
|
-
const leaderAngle = Math.atan2(dy, dx);
|
|
10267
|
-
const pointerDx = pointer ? pointer.x - frame.anchorX : 0;
|
|
10268
|
-
const pointerDy = pointer ? pointer.y - frame.anchorY : 0;
|
|
10269
|
-
const desiredAngle = Math.hypot(pointerDx, pointerDy) > 0.5 ? Math.atan2(pointerDy, pointerDx) + Math.PI - leaderAngle : 0;
|
|
10270
|
-
const wrappedAngle = Math.atan2(Math.sin(desiredAngle), Math.cos(desiredAngle));
|
|
10271
|
-
// Keep the stem inside the 126-degree arc, away from antialiased endpoints.
|
|
10272
|
-
const arcFraction = 0.35;
|
|
10273
|
-
const rotationLimit = Math.PI * arcFraction - Math.PI / 30;
|
|
10274
|
-
const targetOffset = hovered ? Math.max(-rotationLimit, Math.min(rotationLimit, wrappedAngle)) : ((_2 = ringAnimation.arcOffset) !== null && _2 !== void 0 ? _2 : 0);
|
|
10275
|
-
const targetOpen = cursorMotion.target || (hovered && (ring === null || ring === void 0 ? void 0 : ring.enabled) !== false && targetRadius > 0) ? 1 : 0;
|
|
10276
|
-
const elapsed = Math.min(32, Math.max(0, now - ((_3 = ringAnimation.arcTime) !== null && _3 !== void 0 ? _3 : now)));
|
|
10277
|
-
const blend = duration > 0 ? 1 - Math.exp(-elapsed / (duration / 3)) : 1;
|
|
10278
|
-
const approach = (value, target) => Math.abs(value - target) < 0.001 ? target : value + (target - value) * blend;
|
|
10279
|
-
ringAnimation.arcOffset = approach((_4 = ringAnimation.arcOffset) !== null && _4 !== void 0 ? _4 : 0, targetOffset);
|
|
10280
|
-
ringAnimation.arcOpen = approach((_5 = ringAnimation.arcOpen) !== null && _5 !== void 0 ? _5 : 0, targetOpen);
|
|
10281
|
-
ringAnimation.arcTime = now;
|
|
10282
|
-
if (ringAnimation.arcOffset !== targetOffset || ringAnimation.arcOpen !== targetOpen) {
|
|
10283
|
-
this.viewer.scene.requestRender();
|
|
10284
|
-
}
|
|
10285
|
-
const circumference = Math.PI * (nodeRadius + ringAnimation.inner);
|
|
10286
|
-
const filledFraction = 1 - ringAnimation.arcOpen * (1 - arcFraction);
|
|
10287
|
-
circle.setAttribute("stroke-dasharray", `${circumference * filledFraction} ${circumference * (1 - filledFraction)}`);
|
|
10288
|
-
circle.setAttribute("transform", `rotate(${(leaderAngle + ringAnimation.arcOffset - Math.PI * filledFraction) * 180 / Math.PI} ${nodeRadius} ${nodeRadius})`);
|
|
10289
|
-
const cut = Math.min(radius, length);
|
|
10290
|
-
const startX = frame.anchorX + (length ? dx / length * cut : 0);
|
|
10291
|
-
const startY = frame.anchorY + (length ? dy / length * cut : 0);
|
|
10292
|
-
const draw = (element, fromX, fromY, toX, toY) => {
|
|
10293
|
-
const screenDx = (toX - fromX) * coordinates.scaleX;
|
|
10294
|
-
const screenDy = (toY - fromY) * coordinates.scaleY;
|
|
10295
|
-
element.style.width = `${2 * coordinates.scaleX}px`;
|
|
10296
|
-
element.style.left = `${coordinates.x + (fromX - 1) * coordinates.scaleX}px`;
|
|
10297
|
-
element.style.top = `${coordinates.y + fromY * coordinates.scaleY}px`;
|
|
10298
|
-
element.style.height = `${Math.hypot(screenDx, screenDy)}px`;
|
|
10299
|
-
element.style.transform = `rotate(${Math.atan2(screenDy, screenDx) - Math.PI / 2}rad)`;
|
|
10300
|
-
element.style.boxShadow = radius ? "none" : "0 0 5px rgba(0, 0, 0, 0.3)";
|
|
10301
|
-
element.style.transformOrigin = "top center";
|
|
10302
|
-
element.style.opacity = String(opacity * (normalLeader ? 1 : cursorMotion.amount));
|
|
10303
|
-
element.style.zIndex = String(placement.zIndex);
|
|
10304
|
-
};
|
|
10305
|
-
draw(lineEle, startX, startY, endX, endY);
|
|
10306
|
-
if (layer.modelBoxes.Hull(this.id)) {
|
|
10307
|
-
layer.modelBoxes.Request(this.id, {
|
|
10308
|
-
whole: Boolean(cursorMotion.target), from: { x: frame.anchorX, y: frame.anchorY },
|
|
10309
|
-
opacity, zIndex: placement.zIndex, color: this.options.leaderColor || "rgba(255, 255, 255, 0.8)", duration
|
|
10310
|
-
});
|
|
10311
|
-
}
|
|
10312
|
-
if (runEle) {
|
|
10313
|
-
// Overlap the corner by the stem's own width so the elbow has no notch in it.
|
|
10314
|
-
const overlap = frame.anchorX < runToX ? -1 : 1;
|
|
10315
|
-
runEle.style.display = beside ? "block" : "none";
|
|
10316
|
-
if (beside)
|
|
10317
|
-
draw(runEle, endX + overlap, endY, runToX, endY);
|
|
10318
|
-
}
|
|
10319
|
-
}
|
|
10320
10725
|
};
|
|
10321
10726
|
ele.style.display = "flex";
|
|
10322
10727
|
ele.style.visibility = "hidden";
|
|
10323
|
-
|
|
10728
|
+
// Hovering, riding the cursor or a highlight lift a label out of its cluster, which a stale frame misses.
|
|
10729
|
+
const wake = () => {
|
|
10730
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10731
|
+
return Boolean(this.Transient ||
|
|
10732
|
+
((_a = this.cursorMotion) === null || _a === void 0 ? void 0 : _a.target) ||
|
|
10733
|
+
((_b = this.cursorMotion) === null || _b === void 0 ? void 0 : _b.amount) > 0 ||
|
|
10734
|
+
((_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)) ||
|
|
10735
|
+
((_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));
|
|
10736
|
+
};
|
|
10737
|
+
this.renderRemoval = layer.Add({ project, apply, wake });
|
|
10324
10738
|
leaveLayer === null || leaveLayer === void 0 ? void 0 : leaveLayer();
|
|
10325
10739
|
// If terrain changes then we'll re-call createLabel as the position may have changed.
|
|
10326
10740
|
let terrTimeout = null;
|
|
@@ -60365,7 +60779,7 @@ var StyleUtils;
|
|
|
60365
60779
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
60366
60780
|
})(StyleUtils || (StyleUtils = {}));
|
|
60367
60781
|
|
|
60368
|
-
const VERSION = "7.8.
|
|
60782
|
+
const VERSION = "7.8.2";
|
|
60369
60783
|
/**
|
|
60370
60784
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
60371
60785
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|