bruce-cesium 4.3.0 → 4.3.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.
@@ -8322,6 +8322,7 @@
8322
8322
  // We wait a moment to avoid the user quickly dragging their mouse over entities and spamming requests.
8323
8323
  this.loadTimeout = null;
8324
8324
  this.loadedName = false;
8325
+ this.line = null;
8325
8326
  this.rego = params.rego;
8326
8327
  this.viewer = params.viewer;
8327
8328
  this.api = params.api;
@@ -8420,7 +8421,7 @@
8420
8421
  Label.prototype.createLabel = function (starterPos3d) {
8421
8422
  var _a, _b, _c, _d, _e, _f, _g;
8422
8423
  return __awaiter(this, void 0, void 0, function () {
8423
- var pos3d, counter, sizeInM, heightRef, pixelOffset, visual, hierarchy, posses, centerIndex, pos1, pos2, pos3, posses, isClamped, centerIndex, model, size, height, scale, posses, centerIndex, text, type, e_2, ele, _lastDistance, _lastCameraPos, getDistance, MAX_DISTANCE, updateLabel, terrTimeout;
8424
+ var pos3d, counter, sizeInM, heightRef, pixelOffset, visual, hierarchy, posses, centerIndex, pos1, pos2, pos3, posses, isClamped, centerIndex, model, size, height, scale, posses, centerIndex, text, type, e_2, ele, lineEle, lineEleNode, _lastDistance, _lastCameraPos, getDistance, MAX_DISTANCE, updateLabel, terrTimeout;
8424
8425
  var _this = this;
8425
8426
  return __generator(this, function (_h) {
8426
8427
  switch (_h.label) {
@@ -8651,16 +8652,29 @@
8651
8652
  return [2 /*return*/];
8652
8653
  }
8653
8654
  ele = null;
8655
+ lineEle = null;
8654
8656
  if (this.label) {
8655
8657
  ele = this.label;
8656
8658
  }
8657
8659
  else {
8658
8660
  ele = document.createElement("div");
8659
8661
  ele.innerHTML = text;
8660
- ele.setAttribute("style", "\n position: absolute;\n z-index: 0;\n display: none;\n pointer-events: none;\n padding: 6px 8px;\n border-radius: 6px;\n font-family: Arial;\n font-size: 12px;\n -webkit-backdrop-filter: blur(20px);\n backdrop-filter: blur(20px);\n background: rgba(33,39,42,.8);\n border-radius: 9px;\n box-shadow: 0 0 1px rgba(18,22,25,.36),0 18px 36px -4px rgba(18,22,25,.36);\n color: #ffffff;\n }");
8662
+ ele.setAttribute("style", "\n position: absolute;\n z-index: 0;\n display: none;\n pointer-events: none;\n padding: 6px 8px;\n border-radius: 6px;\n font-family: Arial;\n font-size: 13px;\n border-radius: 9px;\n color: #ffffff;\n text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);\n }");
8661
8663
  this.label = ele;
8662
8664
  this.viewer.container.appendChild(ele);
8663
8665
  }
8666
+ if (this.line) {
8667
+ lineEle = this.line;
8668
+ }
8669
+ else {
8670
+ lineEle = document.createElement("div");
8671
+ lineEle.setAttribute("style", "\n position: absolute;\n z-index: 0;\n display: none;\n pointer-events: none;\n width: 2px;\n background: rgba(255, 255, 255, 0.8);\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);\n ");
8672
+ this.line = lineEle;
8673
+ lineEleNode = document.createElement("div");
8674
+ lineEleNode.setAttribute("style", "\n position: absolute;\n pointer-events: none;\n width: 5px;\n height: 5px;\n background: rgba(255, 255, 255, 0.8);\n border-radius: 50%;\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);\n top: -2px;\n left: -2px;\n ");
8675
+ lineEle.appendChild(lineEleNode);
8676
+ this.viewer.container.appendChild(lineEle);
8677
+ }
8664
8678
  _lastDistance = null;
8665
8679
  _lastCameraPos = null;
8666
8680
  getDistance = function () {
@@ -8687,7 +8701,7 @@
8687
8701
  _lastCameraPos = cameraPos.clone();
8688
8702
  return distance;
8689
8703
  };
8690
- MAX_DISTANCE = Math.max(5000, sizeInM * 10);
8704
+ MAX_DISTANCE = Math.max(15000, sizeInM * 35);
8691
8705
  if (visual && visual instanceof Cesium.Entity) {
8692
8706
  // Consistent sized things.
8693
8707
  if (visual.polyline || visual.billboard || visual.point) {
@@ -8706,34 +8720,75 @@
8706
8720
  var distance = getDistance();
8707
8721
  if (isNaN(distance) || (!_this.prePositioned && distance >= MAX_DISTANCE)) {
8708
8722
  ele.style.display = "none";
8723
+ lineEle.style.display = "none";
8709
8724
  return;
8710
8725
  }
8711
- var pos2d = Cesium.SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, _this._pos3d);
8712
- if (isNaN(pos2d === null || pos2d === void 0 ? void 0 : pos2d.x)) {
8713
- ele.style.display = "none";
8714
- return;
8715
- }
8716
- // If out of the screen then we can hide it.
8717
- if (pos2d.x < 0 || pos2d.x > _this.viewer.canvas.clientWidth ||
8718
- pos2d.y < 0 || pos2d.y > _this.viewer.canvas.clientHeight) {
8719
- ele.style.display = "none";
8726
+ var lineStartPos2d = Cesium.SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, _this._pos3d);
8727
+ // Invalid point.
8728
+ if (isNaN(lineStartPos2d === null || lineStartPos2d === void 0 ? void 0 : lineStartPos2d.x)) {
8729
+ ele.style.transform = "";
8730
+ ele.style.opacity = "0";
8731
+ lineEle.style.display = "none";
8720
8732
  return;
8721
8733
  }
8722
8734
  ele.style.display = "block";
8723
- // Check scale to apply based on distance between camera and pos3d.
8724
- // We'll make the label smaller and less transparent when further away.
8725
- var scale = _this.prePositioned || MAX_DISTANCE == Infinity ? 1 : 1 - (distance / MAX_DISTANCE);
8726
- if (scale && scale > 0.15) {
8727
- ele.style.transform = "scale(".concat(scale, ")");
8728
- ele.style.opacity = "".concat(scale);
8729
- var left = pos2d.x - (ele.clientWidth / 2) + pixelOffset.x;
8730
- ele.style.left = "".concat(left, "px");
8731
- var top_1 = pos2d.y - ele.clientHeight + (pixelOffset.y * scale);
8732
- ele.style.top = "".concat(top_1, "px");
8735
+ lineEle.style.display = "block";
8736
+ // Calculate opacity to apply based on distance between camera and pos3d.
8737
+ // We'll make the label less transparent when further away.
8738
+ var opacity = _this.prePositioned || MAX_DISTANCE == Infinity ? 1 : 1 - (distance / MAX_DISTANCE);
8739
+ if (opacity && opacity > 0.15) {
8740
+ _this.label.style.opacity = "".concat(opacity);
8741
+ // Calc where the line should end.
8742
+ // We get the pos3d and add 'n' to it, then turn it back into 2d.
8743
+ var lineEndPos3d = _this._pos3d.clone();
8744
+ var lineEndPoint = Cesium.Cartographic.fromCartesian(lineEndPos3d);
8745
+ var addHeight = sizeInM > 0 ? Math.max(30, sizeInM * 1.2) : null;
8746
+ // Calculate based on camera height.
8747
+ // Radius is unknown for Tileset things. We could bake the radius in possibly as a feature property.
8748
+ if (addHeight == null) {
8749
+ addHeight = Math.max(30, _this.viewer.camera.positionCartographic.height / 3);
8750
+ }
8751
+ lineEndPoint.height += addHeight;
8752
+ lineEndPos3d = Cesium.Cartographic.toCartesian(lineEndPoint);
8753
+ var lineEndPos2d = Cesium.SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, lineEndPos3d);
8754
+ // Invalid point.
8755
+ if (isNaN(lineEndPos2d === null || lineEndPos2d === void 0 ? void 0 : lineEndPos2d.x)) {
8756
+ ele.style.transform = "";
8757
+ ele.style.opacity = "0";
8758
+ lineEle.style.display = "none";
8759
+ return;
8760
+ }
8761
+ // If out of the screen then we can hide it.
8762
+ var startOutOfScreen = (lineStartPos2d.x < 0 || lineStartPos2d.x > _this.viewer.canvas.clientWidth ||
8763
+ lineStartPos2d.y < 0 || lineStartPos2d.y > _this.viewer.canvas.clientHeight);
8764
+ var endOutOfScreen = (lineEndPos2d.x < 0 || lineEndPos2d.x > _this.viewer.canvas.clientWidth ||
8765
+ lineEndPos2d.y < 0 || lineEndPos2d.y > _this.viewer.canvas.clientHeight);
8766
+ if (startOutOfScreen && endOutOfScreen) {
8767
+ ele.style.transform = "";
8768
+ ele.style.opacity = "0";
8769
+ lineEle.style.display = "none";
8770
+ return;
8771
+ }
8772
+ // Position the label above the line end point.
8773
+ var labelLeft = lineEndPos2d.x + pixelOffset.x;
8774
+ var labelTop = lineEndPos2d.y + pixelOffset.y;
8775
+ _this.label.style.left = "".concat(labelLeft, "px");
8776
+ _this.label.style.top = "".concat(labelTop, "px");
8777
+ // Update line position and size.
8778
+ var dx = lineEndPos2d.x - lineStartPos2d.x;
8779
+ var dy = lineEndPos2d.y - lineStartPos2d.y;
8780
+ var length_1 = Math.sqrt(dx * dx + dy * dy);
8781
+ var angle = Math.atan2(dy, dx) - Math.PI / 2;
8782
+ _this.line.style.left = "".concat(lineStartPos2d.x, "px");
8783
+ _this.line.style.top = "".concat(lineStartPos2d.y, "px");
8784
+ _this.line.style.height = "".concat(length_1, "px");
8785
+ _this.line.style.transform = "rotate(".concat(angle, "rad)");
8786
+ _this.line.style.transformOrigin = 'top center';
8733
8787
  }
8734
8788
  else {
8735
8789
  ele.style.transform = "";
8736
8790
  ele.style.opacity = "0";
8791
+ lineEle.style.display = "none";
8737
8792
  }
8738
8793
  };
8739
8794
  this.renderRemoval = this.viewer.scene.postUpdate.addEventListener(updateLabel);
@@ -8765,6 +8820,10 @@
8765
8820
  this.label.parentElement.removeChild(this.label);
8766
8821
  this.label = null;
8767
8822
  }
8823
+ if (this.line && this.line.parentElement) {
8824
+ this.line.parentElement.removeChild(this.line);
8825
+ this.line = null;
8826
+ }
8768
8827
  if (this.renderRemoval) {
8769
8828
  this.renderRemoval();
8770
8829
  this.renderRemoval = null;
@@ -23222,9 +23281,12 @@
23222
23281
  */
23223
23282
  WidgetLeftPanel.prototype.AddPanelTab = function (params) {
23224
23283
  this.customTabs.set(params.tab, params.content);
23225
- this._addPanelTab(params.tab, params.title, params.svgStr);
23284
+ // We insert before the bottom breaker.
23285
+ var bottomBreaker = this._element.querySelector(".NextspaceLeftPanelBottomBreaker");
23286
+ var afterElement = bottomBreaker ? bottomBreaker.previousElementSibling : null;
23287
+ this._addPanelTab(params.tab, params.title, params.svgStr, afterElement);
23226
23288
  };
23227
- WidgetLeftPanel.prototype._addPanelTab = function (tab, title, svgStr) {
23289
+ WidgetLeftPanel.prototype._addPanelTab = function (tab, title, svgStr, afterElement) {
23228
23290
  var _this = this;
23229
23291
  var tabButton = document.createElement("div");
23230
23292
  tabButton.setAttribute("widget-left-panel-tab", tab);
@@ -23249,7 +23311,17 @@
23249
23311
  _this._updatePanelContent();
23250
23312
  _this._updatePanelStyles();
23251
23313
  };
23252
- this._element.appendChild(tabButton);
23314
+ if (afterElement && afterElement.parentElement) {
23315
+ if (afterElement.nextSibling) {
23316
+ afterElement.parentElement.insertBefore(tabButton, afterElement.nextSibling);
23317
+ }
23318
+ else {
23319
+ afterElement.parentElement.appendChild(tabButton);
23320
+ }
23321
+ }
23322
+ else {
23323
+ this._element.appendChild(tabButton);
23324
+ }
23253
23325
  };
23254
23326
  WidgetLeftPanel.prototype._addPlaceholderTab = function (title, svgStr) {
23255
23327
  var tabButton = document.createElement("div");
@@ -23386,10 +23458,11 @@
23386
23458
  console.error("Tab ".concat(this._enabledPanelTab, " not found."));
23387
23459
  return;
23388
23460
  }
23389
- tabContent = new (this.customTabs.get(this._enabledPanelTab)({
23461
+ var clazz = this.customTabs.get(this._enabledPanelTab);
23462
+ tabContent = new clazz({
23390
23463
  widget: this,
23391
23464
  container: container
23392
- }));
23465
+ });
23393
23466
  break;
23394
23467
  }
23395
23468
  this._enabledTabContent = tabContent;
@@ -26350,7 +26423,7 @@
26350
26423
  ViewerUtils.AssertIonToken = AssertIonToken;
26351
26424
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
26352
26425
 
26353
- var VERSION = "4.3.0";
26426
+ var VERSION = "4.3.2";
26354
26427
 
26355
26428
  exports.VERSION = VERSION;
26356
26429
  exports.CesiumParabola = CesiumParabola;