bruce-cesium 6.1.3 → 6.1.5

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.
@@ -32679,6 +32679,210 @@
32679
32679
  ViewerUtils.GetEventTracker = GetEventTracker;
32680
32680
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
32681
32681
 
32682
+ const labels = {};
32683
+ const updaters = {};
32684
+ const positions = {};
32685
+ const colors = {};
32686
+ const names = {};
32687
+ const entities = {};
32688
+ const viewers = {};
32689
+ function createDOMLabel(viewer, id, name, colorCss) {
32690
+ var _a;
32691
+ const label = document.createElement("div");
32692
+ label.innerHTML = `<div style="margin-bottom:0px">${name !== null && name !== void 0 ? name : ""}</div>`;
32693
+ label.setAttribute("style", `
32694
+ position: absolute;
32695
+ z-index: 2; /* keep under app panels */
32696
+ display: none;
32697
+ pointer-events: none;
32698
+ padding: 6px 10px;
32699
+ border-radius: 8px;
32700
+ font-family: Arial, sans-serif;
32701
+ font-size: 13px;
32702
+ font-weight: 500;
32703
+ color: #ffffff;
32704
+ background-color: ${colorCss !== null && colorCss !== void 0 ? colorCss : "#3b82f6"};
32705
+ border: 1px solid rgba(255,255,255,0.2);
32706
+ box-shadow: 0 2px 8px rgba(0,0,0,0.25);
32707
+ text-shadow: 0 1px 2px rgba(0,0,0,0.5);
32708
+ white-space: nowrap;
32709
+ transform: none;
32710
+ `);
32711
+ ((_a = viewer === null || viewer === void 0 ? void 0 : viewer.container) !== null && _a !== void 0 ? _a : document.body).appendChild(label);
32712
+ labels[id] = label;
32713
+ colors[id] = colorCss;
32714
+ names[id] = name;
32715
+ return label;
32716
+ }
32717
+ function updateDOMLabel(viewer, label, pos3d) {
32718
+ if (!viewer || viewer.isDestroyed() || !label || !pos3d) {
32719
+ return;
32720
+ }
32721
+ const CESIUM = Cesium;
32722
+ const toWindow = Cesium.SceneTransforms.hasOwnProperty("wgs84ToWindowCoordinates")
32723
+ ? CESIUM.SceneTransforms.wgs84ToWindowCoordinates
32724
+ : CESIUM.SceneTransforms.worldToWindowCoordinates;
32725
+ const screenPos = toWindow(viewer.scene, pos3d);
32726
+ if (!screenPos || isNaN(screenPos.x) || isNaN(screenPos.y)) {
32727
+ label.style.display = "none";
32728
+ return;
32729
+ }
32730
+ const cameraPos = viewer.camera.position;
32731
+ const distance = Cesium.Cartesian3.distance(cameraPos, pos3d);
32732
+ const maxDistance = 25000; // Max visibility distance for labels
32733
+ const canvas = viewer.canvas;
32734
+ const withinBounds = screenPos.x >= 0 && screenPos.x <= canvas.clientWidth &&
32735
+ screenPos.y >= 0 && screenPos.y <= canvas.clientHeight;
32736
+ if (!withinBounds || distance >= maxDistance) {
32737
+ label.style.display = "none";
32738
+ return;
32739
+ }
32740
+ // Keep full opacity; no distance-based fading
32741
+ // Keep the label close to the cursor regardless of zoom
32742
+ // Use small, constant pixel offsets to bottom-right
32743
+ const offsetX = 12; // px
32744
+ const offsetY = 10; // px
32745
+ let leftPx = screenPos.x + offsetX;
32746
+ let topPx = screenPos.y + offsetY;
32747
+ const pad = 8;
32748
+ const w = label.offsetWidth || 120;
32749
+ const h = label.offsetHeight || 28;
32750
+ leftPx = Math.min(Math.max(pad, leftPx), canvas.clientWidth - w - pad);
32751
+ topPx = Math.min(Math.max(pad, topPx), canvas.clientHeight - h - pad);
32752
+ label.style.left = `${leftPx}px`;
32753
+ label.style.top = `${topPx}px`;
32754
+ label.style.display = "block";
32755
+ label.style.opacity = "1";
32756
+ }
32757
+ (function (LiveCursor) {
32758
+ function Upsert({ viewer, id, name, colorCss, pos3d, entityId, image, showBillboard = true, showEllipse = true, billboardWidth = 30, billboardHeight = 30, labelZIndex }) {
32759
+ if (!labels[id]) {
32760
+ createDOMLabel(viewer, id, name !== null && name !== void 0 ? name : "", colorCss !== null && colorCss !== void 0 ? colorCss : "#3b82f6");
32761
+ }
32762
+ else {
32763
+ // Update text/color only if changed
32764
+ if (typeof name === "string" && name !== names[id]) {
32765
+ names[id] = name;
32766
+ labels[id].innerHTML = `<div style="margin-bottom:0px">${name}</div>`;
32767
+ }
32768
+ if (typeof colorCss === "string" && colorCss !== colors[id]) {
32769
+ colors[id] = colorCss;
32770
+ labels[id].style.backgroundColor = colorCss;
32771
+ }
32772
+ }
32773
+ if (typeof labelZIndex === "number") {
32774
+ labels[id].style.zIndex = `${labelZIndex}`;
32775
+ }
32776
+ positions[id] = pos3d;
32777
+ viewers[id] = viewer;
32778
+ // Manage Cesium entity
32779
+ if ((showBillboard || showEllipse) && !entities[id]) {
32780
+ const eid = entityId !== null && entityId !== void 0 ? entityId : `live-cursor-${id}`;
32781
+ const color = colorCss ? Cesium.Color.fromCssColorString(colorCss) : Cesium.Color.WHITE;
32782
+ const entity = viewer.entities.add({
32783
+ id: eid,
32784
+ position: pos3d,
32785
+ billboard: showBillboard && image ? {
32786
+ image,
32787
+ width: billboardWidth,
32788
+ height: billboardHeight,
32789
+ heightReference: Cesium.HeightReference.NONE,
32790
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
32791
+ distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 30000),
32792
+ scaleByDistance: new Cesium.NearFarScalar(100, 1.5, 10000, 0.8),
32793
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
32794
+ horizontalOrigin: Cesium.HorizontalOrigin.CENTER
32795
+ } : undefined,
32796
+ ellipse: showEllipse ? {
32797
+ semiMajorAxis: 50.0,
32798
+ semiMinorAxis: 50.0,
32799
+ height: 0,
32800
+ outline: true,
32801
+ outlineColor: color.withAlpha(0.8),
32802
+ outlineWidth: 3,
32803
+ fill: true,
32804
+ material: color.withAlpha(0.2),
32805
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
32806
+ distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 15000)
32807
+ } : undefined
32808
+ });
32809
+ if (entity.ellipse) {
32810
+ entity.ellipse.semiMajorAxis = new Cesium.CallbackProperty(() => {
32811
+ const time = viewer.clock.currentTime;
32812
+ const pulse = Math.sin(Cesium.JulianDate.secondsDifference(time, viewer.clock.startTime) * 2) * 0.5 + 1;
32813
+ return 50 + (pulse * 20);
32814
+ }, false);
32815
+ entity.ellipse.semiMinorAxis = new Cesium.CallbackProperty(() => {
32816
+ const time = viewer.clock.currentTime;
32817
+ const pulse = Math.sin(Cesium.JulianDate.secondsDifference(time, viewer.clock.startTime) * 2) * 0.5 + 1;
32818
+ return 50 + (pulse * 20);
32819
+ }, false);
32820
+ }
32821
+ entities[id] = entity;
32822
+ }
32823
+ else if ((showBillboard || showEllipse) && entities[id]) {
32824
+ const entity = entities[id];
32825
+ const animated = new exports.CesiumAnimatedProperty.AnimatePosition({
32826
+ durationMs: 50,
32827
+ targetPos3d: pos3d,
32828
+ startPos3d: entity.position,
32829
+ viewer: viewer
32830
+ });
32831
+ entity.position = new Cesium.CallbackProperty(() => animated.GetValue(), false);
32832
+ }
32833
+ if (!updaters[id]) {
32834
+ const remover = viewer.scene.postUpdate.addEventListener(() => {
32835
+ const label = labels[id];
32836
+ let p = positions[id];
32837
+ // If we manage an entity with an animated position, follow its current value
32838
+ const ent = entities[id];
32839
+ if (ent === null || ent === void 0 ? void 0 : ent.position) {
32840
+ const posProp = ent.position;
32841
+ const date = viewer.scene.lastRenderTime || viewer.clock.currentTime;
32842
+ const val = (posProp === null || posProp === void 0 ? void 0 : posProp.getValue) ? posProp.getValue(date) : posProp;
32843
+ if (val && !isNaN(val.x)) {
32844
+ p = val;
32845
+ }
32846
+ }
32847
+ if (!label || !p) {
32848
+ return;
32849
+ }
32850
+ updateDOMLabel(viewer, label, p);
32851
+ });
32852
+ updaters[id] = remover;
32853
+ }
32854
+ // Perform an immediate update for the current frame
32855
+ updateDOMLabel(viewer, labels[id], pos3d);
32856
+ }
32857
+ LiveCursor.Upsert = Upsert;
32858
+ function Remove(id) {
32859
+ const label = labels[id];
32860
+ if (label && label.parentElement) {
32861
+ label.parentElement.removeChild(label);
32862
+ }
32863
+ delete labels[id];
32864
+ delete positions[id];
32865
+ delete names[id];
32866
+ delete colors[id];
32867
+ if (updaters[id]) {
32868
+ try {
32869
+ updaters[id]();
32870
+ }
32871
+ catch { }
32872
+ delete updaters[id];
32873
+ }
32874
+ // Remove entity if present
32875
+ const entity = entities[id];
32876
+ const viewer = viewers[id];
32877
+ if (entity && viewer && viewer.entities.contains(entity)) {
32878
+ viewer.entities.remove(entity);
32879
+ }
32880
+ delete entities[id];
32881
+ delete viewers[id];
32882
+ }
32883
+ LiveCursor.Remove = Remove;
32884
+ })(exports.LiveCursor || (exports.LiveCursor = {}));
32885
+
32682
32886
  (function (WidgetControlViewBar) {
32683
32887
  class AControl {
32684
32888
  get WidgetViewBar() {
@@ -33450,7 +33654,7 @@
33450
33654
  }
33451
33655
  }
33452
33656
 
33453
- const VERSION = "6.1.3";
33657
+ const VERSION = "6.1.5";
33454
33658
 
33455
33659
  exports.VERSION = VERSION;
33456
33660
  exports.isOutlineChanged = isOutlineChanged;