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.es5.js
CHANGED
|
@@ -8337,6 +8337,7 @@ var EntityLabel;
|
|
|
8337
8337
|
// We wait a moment to avoid the user quickly dragging their mouse over entities and spamming requests.
|
|
8338
8338
|
this.loadTimeout = null;
|
|
8339
8339
|
this.loadedName = false;
|
|
8340
|
+
this.line = null;
|
|
8340
8341
|
this.rego = params.rego;
|
|
8341
8342
|
this.viewer = params.viewer;
|
|
8342
8343
|
this.api = params.api;
|
|
@@ -8435,7 +8436,7 @@ var EntityLabel;
|
|
|
8435
8436
|
Label.prototype.createLabel = function (starterPos3d) {
|
|
8436
8437
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
8437
8438
|
return __awaiter(this, void 0, void 0, function () {
|
|
8438
|
-
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;
|
|
8439
|
+
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;
|
|
8439
8440
|
var _this = this;
|
|
8440
8441
|
return __generator(this, function (_h) {
|
|
8441
8442
|
switch (_h.label) {
|
|
@@ -8666,16 +8667,29 @@ var EntityLabel;
|
|
|
8666
8667
|
return [2 /*return*/];
|
|
8667
8668
|
}
|
|
8668
8669
|
ele = null;
|
|
8670
|
+
lineEle = null;
|
|
8669
8671
|
if (this.label) {
|
|
8670
8672
|
ele = this.label;
|
|
8671
8673
|
}
|
|
8672
8674
|
else {
|
|
8673
8675
|
ele = document.createElement("div");
|
|
8674
8676
|
ele.innerHTML = text;
|
|
8675
|
-
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:
|
|
8677
|
+
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 }");
|
|
8676
8678
|
this.label = ele;
|
|
8677
8679
|
this.viewer.container.appendChild(ele);
|
|
8678
8680
|
}
|
|
8681
|
+
if (this.line) {
|
|
8682
|
+
lineEle = this.line;
|
|
8683
|
+
}
|
|
8684
|
+
else {
|
|
8685
|
+
lineEle = document.createElement("div");
|
|
8686
|
+
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 ");
|
|
8687
|
+
this.line = lineEle;
|
|
8688
|
+
lineEleNode = document.createElement("div");
|
|
8689
|
+
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 ");
|
|
8690
|
+
lineEle.appendChild(lineEleNode);
|
|
8691
|
+
this.viewer.container.appendChild(lineEle);
|
|
8692
|
+
}
|
|
8679
8693
|
_lastDistance = null;
|
|
8680
8694
|
_lastCameraPos = null;
|
|
8681
8695
|
getDistance = function () {
|
|
@@ -8702,7 +8716,7 @@ var EntityLabel;
|
|
|
8702
8716
|
_lastCameraPos = cameraPos.clone();
|
|
8703
8717
|
return distance;
|
|
8704
8718
|
};
|
|
8705
|
-
MAX_DISTANCE = Math.max(
|
|
8719
|
+
MAX_DISTANCE = Math.max(15000, sizeInM * 35);
|
|
8706
8720
|
if (visual && visual instanceof Entity) {
|
|
8707
8721
|
// Consistent sized things.
|
|
8708
8722
|
if (visual.polyline || visual.billboard || visual.point) {
|
|
@@ -8721,34 +8735,75 @@ var EntityLabel;
|
|
|
8721
8735
|
var distance = getDistance();
|
|
8722
8736
|
if (isNaN(distance) || (!_this.prePositioned && distance >= MAX_DISTANCE)) {
|
|
8723
8737
|
ele.style.display = "none";
|
|
8738
|
+
lineEle.style.display = "none";
|
|
8724
8739
|
return;
|
|
8725
8740
|
}
|
|
8726
|
-
var
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
if (pos2d.x < 0 || pos2d.x > _this.viewer.canvas.clientWidth ||
|
|
8733
|
-
pos2d.y < 0 || pos2d.y > _this.viewer.canvas.clientHeight) {
|
|
8734
|
-
ele.style.display = "none";
|
|
8741
|
+
var lineStartPos2d = SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, _this._pos3d);
|
|
8742
|
+
// Invalid point.
|
|
8743
|
+
if (isNaN(lineStartPos2d === null || lineStartPos2d === void 0 ? void 0 : lineStartPos2d.x)) {
|
|
8744
|
+
ele.style.transform = "";
|
|
8745
|
+
ele.style.opacity = "0";
|
|
8746
|
+
lineEle.style.display = "none";
|
|
8735
8747
|
return;
|
|
8736
8748
|
}
|
|
8737
8749
|
ele.style.display = "block";
|
|
8738
|
-
|
|
8739
|
-
//
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
var
|
|
8747
|
-
|
|
8750
|
+
lineEle.style.display = "block";
|
|
8751
|
+
// Calculate opacity to apply based on distance between camera and pos3d.
|
|
8752
|
+
// We'll make the label less transparent when further away.
|
|
8753
|
+
var opacity = _this.prePositioned || MAX_DISTANCE == Infinity ? 1 : 1 - (distance / MAX_DISTANCE);
|
|
8754
|
+
if (opacity && opacity > 0.15) {
|
|
8755
|
+
_this.label.style.opacity = "".concat(opacity);
|
|
8756
|
+
// Calc where the line should end.
|
|
8757
|
+
// We get the pos3d and add 'n' to it, then turn it back into 2d.
|
|
8758
|
+
var lineEndPos3d = _this._pos3d.clone();
|
|
8759
|
+
var lineEndPoint = Cartographic.fromCartesian(lineEndPos3d);
|
|
8760
|
+
var addHeight = sizeInM > 0 ? Math.max(30, sizeInM * 1.2) : null;
|
|
8761
|
+
// Calculate based on camera height.
|
|
8762
|
+
// Radius is unknown for Tileset things. We could bake the radius in possibly as a feature property.
|
|
8763
|
+
if (addHeight == null) {
|
|
8764
|
+
addHeight = Math.max(30, _this.viewer.camera.positionCartographic.height / 3);
|
|
8765
|
+
}
|
|
8766
|
+
lineEndPoint.height += addHeight;
|
|
8767
|
+
lineEndPos3d = Cartographic.toCartesian(lineEndPoint);
|
|
8768
|
+
var lineEndPos2d = SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, lineEndPos3d);
|
|
8769
|
+
// Invalid point.
|
|
8770
|
+
if (isNaN(lineEndPos2d === null || lineEndPos2d === void 0 ? void 0 : lineEndPos2d.x)) {
|
|
8771
|
+
ele.style.transform = "";
|
|
8772
|
+
ele.style.opacity = "0";
|
|
8773
|
+
lineEle.style.display = "none";
|
|
8774
|
+
return;
|
|
8775
|
+
}
|
|
8776
|
+
// If out of the screen then we can hide it.
|
|
8777
|
+
var startOutOfScreen = (lineStartPos2d.x < 0 || lineStartPos2d.x > _this.viewer.canvas.clientWidth ||
|
|
8778
|
+
lineStartPos2d.y < 0 || lineStartPos2d.y > _this.viewer.canvas.clientHeight);
|
|
8779
|
+
var endOutOfScreen = (lineEndPos2d.x < 0 || lineEndPos2d.x > _this.viewer.canvas.clientWidth ||
|
|
8780
|
+
lineEndPos2d.y < 0 || lineEndPos2d.y > _this.viewer.canvas.clientHeight);
|
|
8781
|
+
if (startOutOfScreen && endOutOfScreen) {
|
|
8782
|
+
ele.style.transform = "";
|
|
8783
|
+
ele.style.opacity = "0";
|
|
8784
|
+
lineEle.style.display = "none";
|
|
8785
|
+
return;
|
|
8786
|
+
}
|
|
8787
|
+
// Position the label above the line end point.
|
|
8788
|
+
var labelLeft = lineEndPos2d.x + pixelOffset.x;
|
|
8789
|
+
var labelTop = lineEndPos2d.y + pixelOffset.y;
|
|
8790
|
+
_this.label.style.left = "".concat(labelLeft, "px");
|
|
8791
|
+
_this.label.style.top = "".concat(labelTop, "px");
|
|
8792
|
+
// Update line position and size.
|
|
8793
|
+
var dx = lineEndPos2d.x - lineStartPos2d.x;
|
|
8794
|
+
var dy = lineEndPos2d.y - lineStartPos2d.y;
|
|
8795
|
+
var length_1 = Math.sqrt(dx * dx + dy * dy);
|
|
8796
|
+
var angle = Math.atan2(dy, dx) - Math.PI / 2;
|
|
8797
|
+
_this.line.style.left = "".concat(lineStartPos2d.x, "px");
|
|
8798
|
+
_this.line.style.top = "".concat(lineStartPos2d.y, "px");
|
|
8799
|
+
_this.line.style.height = "".concat(length_1, "px");
|
|
8800
|
+
_this.line.style.transform = "rotate(".concat(angle, "rad)");
|
|
8801
|
+
_this.line.style.transformOrigin = 'top center';
|
|
8748
8802
|
}
|
|
8749
8803
|
else {
|
|
8750
8804
|
ele.style.transform = "";
|
|
8751
8805
|
ele.style.opacity = "0";
|
|
8806
|
+
lineEle.style.display = "none";
|
|
8752
8807
|
}
|
|
8753
8808
|
};
|
|
8754
8809
|
this.renderRemoval = this.viewer.scene.postUpdate.addEventListener(updateLabel);
|
|
@@ -8780,6 +8835,10 @@ var EntityLabel;
|
|
|
8780
8835
|
this.label.parentElement.removeChild(this.label);
|
|
8781
8836
|
this.label = null;
|
|
8782
8837
|
}
|
|
8838
|
+
if (this.line && this.line.parentElement) {
|
|
8839
|
+
this.line.parentElement.removeChild(this.line);
|
|
8840
|
+
this.line = null;
|
|
8841
|
+
}
|
|
8783
8842
|
if (this.renderRemoval) {
|
|
8784
8843
|
this.renderRemoval();
|
|
8785
8844
|
this.renderRemoval = null;
|
|
@@ -26441,7 +26500,7 @@ var ViewerUtils;
|
|
|
26441
26500
|
ViewerUtils.AssertIonToken = AssertIonToken;
|
|
26442
26501
|
})(ViewerUtils || (ViewerUtils = {}));
|
|
26443
26502
|
|
|
26444
|
-
var VERSION = "4.3.
|
|
26503
|
+
var VERSION = "4.3.2";
|
|
26445
26504
|
|
|
26446
26505
|
export { VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, WidgetSearchBar, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
|
|
26447
26506
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|