bruce-cesium 7.4.6 → 7.4.8

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.
@@ -5814,6 +5814,9 @@
5814
5814
  this.placementMemory = new PlacementMemory();
5815
5815
  this.forwardingWheel = false;
5816
5816
  this.pendingDrag = null;
5817
+ // Null outside a 3D view.
5818
+ this.horizon = null;
5819
+ this.horizonScratch = new Cesium.Cartesian3();
5817
5820
  this.TrackPointer = (event) => {
5818
5821
  var _a, _b;
5819
5822
  if (event.pointerType && event.pointerType !== "mouse" && event.pointerType !== "pen")
@@ -6001,9 +6004,45 @@
6001
6004
  }
6002
6005
  };
6003
6006
  }
6007
+ /*
6008
+ * Whether the globe hides a position; labels skip the depth test, so this is their only occluder.
6009
+ */
6010
+ IsBeyondHorizon(position) {
6011
+ if (!this.horizon) {
6012
+ return false;
6013
+ }
6014
+ const { ellipsoid, camera, limbSquared } = this.horizon;
6015
+ // Scaled space makes the ellipsoid a unit sphere.
6016
+ const scaled = ellipsoid.transformPositionToScaledSpace(position, this.horizonScratch);
6017
+ const magnitudeSquared = Cesium.Cartesian3.magnitudeSquared(scaled);
6018
+ // Test sub-sea-level points from the surface.
6019
+ if (magnitudeSquared > 0 && magnitudeSquared < 1) {
6020
+ Cesium.Cartesian3.normalize(scaled, scaled);
6021
+ }
6022
+ const toPoint = Cesium.Cartesian3.subtract(scaled, camera, scaled);
6023
+ const along = -Cesium.Cartesian3.dot(toPoint, camera);
6024
+ return along > limbSquared && along * along / Cesium.Cartesian3.magnitudeSquared(toPoint) > limbSquared;
6025
+ }
6026
+ UpdateHorizon() {
6027
+ var _a, _b, _c;
6028
+ const scene = this.viewer.scene;
6029
+ const position = ((_a = scene === null || scene === void 0 ? void 0 : scene.camera) === null || _a === void 0 ? void 0 : _a.positionWC) || ((_b = scene === null || scene === void 0 ? void 0 : scene.camera) === null || _b === void 0 ? void 0 : _b.position);
6030
+ this.horizon = null;
6031
+ if ((scene === null || scene === void 0 ? void 0 : scene.mode) !== Cesium.SceneMode.SCENE3D || !Number.isFinite(position === null || position === void 0 ? void 0 : position.x)) {
6032
+ return;
6033
+ }
6034
+ const ellipsoid = ((_c = scene.globe) === null || _c === void 0 ? void 0 : _c.ellipsoid) || Cesium.Ellipsoid.WGS84;
6035
+ const camera = ellipsoid.transformPositionToScaledSpace(position, new Cesium.Cartesian3());
6036
+ const limbSquared = Cesium.Cartesian3.magnitudeSquared(camera) - 1;
6037
+ // No horizon from underground.
6038
+ if (limbSquared > 0) {
6039
+ this.horizon = { ellipsoid, camera, limbSquared };
6040
+ }
6041
+ }
6004
6042
  Update() {
6005
6043
  var _a, _b;
6006
6044
  this.coordinates = this.MeasureCoordinates();
6045
+ this.UpdateHorizon();
6007
6046
  const rect = (_b = (_a = this.viewer.canvas).getBoundingClientRect) === null || _b === void 0 ? void 0 : _b.call(_a);
6008
6047
  const pointer = this.pointerClient;
6009
6048
  this.pointer = pointer && (rect === null || rect === void 0 ? void 0 : rect.width) && (rect === null || rect === void 0 ? void 0 : rect.height) && pointer.x >= rect.left && pointer.x < rect.right && pointer.y >= rect.top && pointer.y < rect.bottom ?
@@ -6778,7 +6817,8 @@
6778
6817
  // If we're labelling from a temp label (mouse hover) don't drive opacity by cam distance.
6779
6818
  const hoverOnly = this.Transient && !this.Persistent;
6780
6819
  if (!Number.isFinite(distance) || depth <= 0 || distance < ((_c = this.options.near) !== null && _c !== void 0 ? _c : 0) ||
6781
- distance > ((_d = this.options.far) !== null && _d !== void 0 ? _d : Infinity) || (!this.prePositioned && !hoverOnly && distance >= MAX_DISTANCE)) {
6820
+ distance > ((_d = this.options.far) !== null && _d !== void 0 ? _d : Infinity) || (!this.prePositioned && !hoverOnly && distance >= MAX_DISTANCE) ||
6821
+ layer.IsBeyondHorizon(this._pos3d)) {
6782
6822
  return null;
6783
6823
  }
6784
6824
  const transforms = Cesium.SceneTransforms;
@@ -31005,6 +31045,36 @@
31005
31045
 
31006
31046
  const VIEWER_LEFT_PANEL_WIDGET_KEY = "_viewerLeftPanelWidget";
31007
31047
  const VIEWER_LEFT_PANEL_CSS_VAR_LEFT = "--nextspace-left-panel-width";
31048
+ // Size of a tab button's icon, and the drawing grid the built-in icons are authored on.
31049
+ const TAB_ICON_SIZE = 32;
31050
+ /**
31051
+ * Builds a tab's svg icon, fitted to the button whatever grid it was drawn on.
31052
+ */
31053
+ function CreateTabIconSvg(icon) {
31054
+ const SVG_NS = "http://www.w3.org/2000/svg";
31055
+ const parsed = /<svg[\s>]/i.test(icon !== null && icon !== void 0 ? icon : "") ? new DOMParser().parseFromString(icon, "image/svg+xml") : null;
31056
+ const root = parsed === null || parsed === void 0 ? void 0 : parsed.documentElement;
31057
+ let svg;
31058
+ if (root && root.localName === "svg" && !root.getElementsByTagName("parsererror").length) {
31059
+ svg = document.importNode(root, true);
31060
+ if (!svg.getAttribute("viewBox")) {
31061
+ // Without one the drawing would not scale, so its own size becomes the grid.
31062
+ const width = parseFloat(svg.getAttribute("width"));
31063
+ const height = parseFloat(svg.getAttribute("height"));
31064
+ if (width > 0 && height > 0) {
31065
+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
31066
+ }
31067
+ }
31068
+ }
31069
+ else {
31070
+ svg = document.createElementNS(SVG_NS, "svg");
31071
+ svg.setAttribute("viewBox", `0 0 ${TAB_ICON_SIZE} ${TAB_ICON_SIZE}`);
31072
+ svg.innerHTML = icon !== null && icon !== void 0 ? icon : "";
31073
+ }
31074
+ svg.setAttribute("width", String(TAB_ICON_SIZE));
31075
+ svg.setAttribute("height", String(TAB_ICON_SIZE));
31076
+ return svg;
31077
+ }
31008
31078
  class WidgetLeftPanel extends exports.Widget.AWidget {
31009
31079
  get ViewId() {
31010
31080
  return this._viewId;
@@ -31103,7 +31173,7 @@
31103
31173
  if (this._viewId !== viewId) {
31104
31174
  return;
31105
31175
  }
31106
- this.bookmarks = data.bookmarks;
31176
+ this.bookmarks = data.bookmarks.filter(exports.ViewRenderEngine.IsBookmarkSupported);
31107
31177
  this.bookmarkGroups = groups;
31108
31178
  }
31109
31179
  catch (e) {
@@ -31225,6 +31295,18 @@
31225
31295
  cursor: pointer;
31226
31296
  }
31227
31297
 
31298
+ .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >img {
31299
+ display: block;
31300
+ max-width: 100%;
31301
+ max-height: 100%;
31302
+ object-fit: contain;
31303
+ }
31304
+
31305
+ .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >i {
31306
+ color: #fff;
31307
+ font-size: 18px;
31308
+ }
31309
+
31228
31310
  .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled="true"] >.NextspaceLeftPanelButtonIcon {
31229
31311
  background-color: #fff;
31230
31312
  }
@@ -31233,6 +31315,10 @@
31233
31315
  filter: invert(1);
31234
31316
  }
31235
31317
 
31318
+ .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled="true"] >.NextspaceLeftPanelButtonIcon >i {
31319
+ color: #000;
31320
+ }
31321
+
31236
31322
  .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-disabled="true"] {
31237
31323
  opacity: .5;
31238
31324
  pointer-events: none
@@ -31336,6 +31422,10 @@
31336
31422
  icon = params.iconImgUrl;
31337
31423
  iconSource = "file-url";
31338
31424
  }
31425
+ else if (params.iconFontClass) {
31426
+ icon = params.iconFontClass;
31427
+ iconSource = "font";
31428
+ }
31339
31429
  else if (params.svgStr) {
31340
31430
  icon = params.svgStr;
31341
31431
  iconSource = "svg";
@@ -31350,21 +31440,17 @@
31350
31440
  const buttonBookmarksIcon = document.createElement("div");
31351
31441
  buttonBookmarksIcon.className = "NextspaceLeftPanelButtonIcon";
31352
31442
  if (iconSource == "svg") {
31353
- const buttonBookmarksIconSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
31354
- buttonBookmarksIconSvg.setAttribute("viewBox", "0 0 32 32");
31355
- buttonBookmarksIconSvg.setAttribute("width", "32");
31356
- buttonBookmarksIconSvg.setAttribute("height", "32");
31357
- buttonBookmarksIconSvg.innerHTML = icon;
31358
- buttonBookmarksIcon.appendChild(buttonBookmarksIconSvg);
31443
+ buttonBookmarksIcon.appendChild(CreateTabIconSvg(icon));
31359
31444
  }
31360
31445
  else if (iconSource == "file-url") {
31361
31446
  const buttonBookmarksIconImg = document.createElement("img");
31362
31447
  buttonBookmarksIconImg.src = icon;
31363
31448
  buttonBookmarksIcon.appendChild(buttonBookmarksIconImg);
31364
- buttonBookmarksIcon.setAttribute("style", `
31365
- max-width: 32px;
31366
- max-height: 32px;
31367
- `);
31449
+ }
31450
+ else if (iconSource == "font") {
31451
+ const buttonBookmarksIconFont = document.createElement("i");
31452
+ buttonBookmarksIconFont.className = icon;
31453
+ buttonBookmarksIcon.appendChild(buttonBookmarksIconFont);
31368
31454
  }
31369
31455
  tabButton.appendChild(buttonBookmarksIcon);
31370
31456
  tabButton.onclick = () => {
@@ -34040,6 +34126,27 @@
34040
34126
  scene.globe.depthTestAgainstTerrain = Boolean(gOcclusion);
34041
34127
  }
34042
34128
  (function (ViewRenderEngine) {
34129
+ const SUPPORTED_CONTENT_TYPES = [
34130
+ BModels.ProjectViewBookmark.EContentType.WEB_3D,
34131
+ BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE,
34132
+ BModels.ProjectViewBookmark.EContentType.WEB_3D_SPLIT_PLUGIN
34133
+ ];
34134
+ /**
34135
+ * Whether a bookmark is a Cesium scene this engine can render.
34136
+ */
34137
+ function IsBookmarkSupported(bookmark) {
34138
+ var _a, _b;
34139
+ if (!bookmark) {
34140
+ return false;
34141
+ }
34142
+ const bSettings = ((_a = bookmark.Settings) !== null && _a !== void 0 ? _a : {});
34143
+ if (bSettings.contentType) {
34144
+ return SUPPORTED_CONTENT_TYPES.includes(bSettings.contentType);
34145
+ }
34146
+ // A bookmark ported from the 2D Navigator carries a zoom level rather than a 3D camera.
34147
+ return typeof ((_b = bSettings.camera) === null || _b === void 0 ? void 0 : _b.zoom) !== "number";
34148
+ }
34149
+ ViewRenderEngine.IsBookmarkSupported = IsBookmarkSupported;
34043
34150
  async function Render(params) {
34044
34151
  var _a, _b;
34045
34152
  if (!params.manager && params.viewer) {
@@ -34340,7 +34447,7 @@
34340
34447
  if (counter != this.reloadCounter) {
34341
34448
  return;
34342
34449
  }
34343
- this.bookmarks = data.bookmarks;
34450
+ this.bookmarks = data.bookmarks.filter(exports.ViewRenderEngine.IsBookmarkSupported);
34344
34451
  }
34345
34452
  catch (e) {
34346
34453
  console.error(e);
@@ -50703,7 +50810,7 @@ void main() {
50703
50810
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
50704
50811
  })(exports.StyleUtils || (exports.StyleUtils = {}));
50705
50812
 
50706
- const VERSION = "7.4.6";
50813
+ const VERSION = "7.4.8";
50707
50814
  /**
50708
50815
  * Updates the environment instance used by bruce-cesium to one specified.
50709
50816
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -50756,6 +50863,7 @@ void main() {
50756
50863
  exports.WidgetInfoView = WidgetInfoView;
50757
50864
  exports.VIEWER_LEFT_PANEL_WIDGET_KEY = VIEWER_LEFT_PANEL_WIDGET_KEY;
50758
50865
  exports.VIEWER_LEFT_PANEL_CSS_VAR_LEFT = VIEWER_LEFT_PANEL_CSS_VAR_LEFT;
50866
+ exports.CreateTabIconSvg = CreateTabIconSvg;
50759
50867
  exports.WidgetLeftPanel = WidgetLeftPanel;
50760
50868
  exports.WidgetNavCompass = WidgetNavCompass$$1;
50761
50869
  exports.VIEWER_VIEW_BAR_WIDGET_KEY = VIEWER_VIEW_BAR_WIDGET_KEY;