bruce-cesium 4.3.1 → 4.3.3
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 +85 -23
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +85 -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 +84 -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,78 @@ 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
|
+
// If known then calculate based on size.
|
|
8761
|
+
// If we're close then we'll favour the distance over the size.
|
|
8762
|
+
var addHeight = sizeInM > 0 ? Math.max(5, Math.min(distance / 5, sizeInM * 1.2)) : null;
|
|
8763
|
+
// If unknown then calculate based on camera height or distance.
|
|
8764
|
+
// Radius is unknown for Tileset things. We could bake the radius in possibly as a feature property.
|
|
8765
|
+
// We have to make it work for both labels against tall skyscrapers, and up-close assembly models.
|
|
8766
|
+
if (addHeight == null) {
|
|
8767
|
+
addHeight = Math.max(5, Math.min(distance, _this.viewer.camera.positionCartographic.height) / 5);
|
|
8768
|
+
}
|
|
8769
|
+
lineEndPoint.height += addHeight;
|
|
8770
|
+
lineEndPos3d = Cartographic.toCartesian(lineEndPoint);
|
|
8771
|
+
var lineEndPos2d = SceneTransforms.wgs84ToWindowCoordinates(_this.viewer.scene, lineEndPos3d);
|
|
8772
|
+
// Invalid point.
|
|
8773
|
+
if (isNaN(lineEndPos2d === null || lineEndPos2d === void 0 ? void 0 : lineEndPos2d.x)) {
|
|
8774
|
+
ele.style.transform = "";
|
|
8775
|
+
ele.style.opacity = "0";
|
|
8776
|
+
lineEle.style.display = "none";
|
|
8777
|
+
return;
|
|
8778
|
+
}
|
|
8779
|
+
// If out of the screen then we can hide it.
|
|
8780
|
+
var startOutOfScreen = (lineStartPos2d.x < 0 || lineStartPos2d.x > _this.viewer.canvas.clientWidth ||
|
|
8781
|
+
lineStartPos2d.y < 0 || lineStartPos2d.y > _this.viewer.canvas.clientHeight);
|
|
8782
|
+
var endOutOfScreen = (lineEndPos2d.x < 0 || lineEndPos2d.x > _this.viewer.canvas.clientWidth ||
|
|
8783
|
+
lineEndPos2d.y < 0 || lineEndPos2d.y > _this.viewer.canvas.clientHeight);
|
|
8784
|
+
if (startOutOfScreen && endOutOfScreen) {
|
|
8785
|
+
ele.style.transform = "";
|
|
8786
|
+
ele.style.opacity = "0";
|
|
8787
|
+
lineEle.style.display = "none";
|
|
8788
|
+
return;
|
|
8789
|
+
}
|
|
8790
|
+
// Position the label above the line end point.
|
|
8791
|
+
var labelLeft = lineEndPos2d.x + pixelOffset.x;
|
|
8792
|
+
var labelTop = lineEndPos2d.y + pixelOffset.y;
|
|
8793
|
+
_this.label.style.left = "".concat(labelLeft, "px");
|
|
8794
|
+
_this.label.style.top = "".concat(labelTop, "px");
|
|
8795
|
+
// Update line position and size.
|
|
8796
|
+
var dx = lineEndPos2d.x - lineStartPos2d.x;
|
|
8797
|
+
var dy = lineEndPos2d.y - lineStartPos2d.y;
|
|
8798
|
+
var length_1 = Math.sqrt(dx * dx + dy * dy);
|
|
8799
|
+
var angle = Math.atan2(dy, dx) - Math.PI / 2;
|
|
8800
|
+
_this.line.style.left = "".concat(lineStartPos2d.x, "px");
|
|
8801
|
+
_this.line.style.top = "".concat(lineStartPos2d.y, "px");
|
|
8802
|
+
_this.line.style.height = "".concat(length_1, "px");
|
|
8803
|
+
_this.line.style.transform = "rotate(".concat(angle, "rad)");
|
|
8804
|
+
_this.line.style.transformOrigin = 'top center';
|
|
8748
8805
|
}
|
|
8749
8806
|
else {
|
|
8750
8807
|
ele.style.transform = "";
|
|
8751
8808
|
ele.style.opacity = "0";
|
|
8809
|
+
lineEle.style.display = "none";
|
|
8752
8810
|
}
|
|
8753
8811
|
};
|
|
8754
8812
|
this.renderRemoval = this.viewer.scene.postUpdate.addEventListener(updateLabel);
|
|
@@ -8780,6 +8838,10 @@ var EntityLabel;
|
|
|
8780
8838
|
this.label.parentElement.removeChild(this.label);
|
|
8781
8839
|
this.label = null;
|
|
8782
8840
|
}
|
|
8841
|
+
if (this.line && this.line.parentElement) {
|
|
8842
|
+
this.line.parentElement.removeChild(this.line);
|
|
8843
|
+
this.line = null;
|
|
8844
|
+
}
|
|
8783
8845
|
if (this.renderRemoval) {
|
|
8784
8846
|
this.renderRemoval();
|
|
8785
8847
|
this.renderRemoval = null;
|
|
@@ -26441,7 +26503,7 @@ var ViewerUtils;
|
|
|
26441
26503
|
ViewerUtils.AssertIonToken = AssertIonToken;
|
|
26442
26504
|
})(ViewerUtils || (ViewerUtils = {}));
|
|
26443
26505
|
|
|
26444
|
-
var VERSION = "4.3.
|
|
26506
|
+
var VERSION = "4.3.3";
|
|
26445
26507
|
|
|
26446
26508
|
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
26509
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|