bruce-cesium 4.3.1 → 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.
- package/dist/bruce-cesium.es5.js +82 -23
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +82 -23
- 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 +81 -22
- package/dist/lib/rendering/render-managers/common/entity-label.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/render-managers/common/entity-label.d.ts +1 -0
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -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:
|
|
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(
|
|
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
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
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
|
-
|
|
8724
|
-
//
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
var
|
|
8732
|
-
|
|
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;
|
|
@@ -26364,7 +26423,7 @@
|
|
|
26364
26423
|
ViewerUtils.AssertIonToken = AssertIonToken;
|
|
26365
26424
|
})(exports.ViewerUtils || (exports.ViewerUtils = {}));
|
|
26366
26425
|
|
|
26367
|
-
var VERSION = "4.3.
|
|
26426
|
+
var VERSION = "4.3.2";
|
|
26368
26427
|
|
|
26369
26428
|
exports.VERSION = VERSION;
|
|
26370
26429
|
exports.CesiumParabola = CesiumParabola;
|