bruce-cesium 7.4.7 → 7.4.9

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.
@@ -1464,6 +1464,48 @@
1464
1464
  ViewUtils.GetModelSpace = GetModelSpace;
1465
1465
  })(exports.ViewUtils || (exports.ViewUtils = {}));
1466
1466
 
1467
+ // End time of the frames already being requested for a viewer, so overlapping animations share one loop.
1468
+ const renderDriverEnds = new WeakMap();
1469
+ // A browser frame where there is one, so the requests keep pace with Cesium's own loop.
1470
+ function nextFrame(callback) {
1471
+ if (typeof requestAnimationFrame === "function") {
1472
+ requestAnimationFrame(callback);
1473
+ }
1474
+ else {
1475
+ setTimeout(callback, 16);
1476
+ }
1477
+ }
1478
+ /**
1479
+ * Keeps frames coming until a time based animation has ended, then draws one more for its final value.
1480
+ */
1481
+ function requestRendersFor(viewer, durationMs) {
1482
+ var _a;
1483
+ const scene = viewer === null || viewer === void 0 ? void 0 : viewer.scene;
1484
+ if (typeof (scene === null || scene === void 0 ? void 0 : scene.requestRender) !== "function" || ((_a = viewer.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(viewer))) {
1485
+ return;
1486
+ }
1487
+ scene.requestRender();
1488
+ const endAt = Date.now() + Math.max(durationMs || 0, 0);
1489
+ if (renderDriverEnds.has(viewer)) {
1490
+ renderDriverEnds.set(viewer, Math.max(renderDriverEnds.get(viewer), endAt));
1491
+ return;
1492
+ }
1493
+ renderDriverEnds.set(viewer, endAt);
1494
+ const tick = () => {
1495
+ var _a;
1496
+ if ((_a = viewer.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(viewer)) {
1497
+ renderDriverEnds.delete(viewer);
1498
+ return;
1499
+ }
1500
+ scene.requestRender();
1501
+ if (Date.now() >= renderDriverEnds.get(viewer)) {
1502
+ renderDriverEnds.delete(viewer);
1503
+ return;
1504
+ }
1505
+ nextFrame(tick);
1506
+ };
1507
+ nextFrame(tick);
1508
+ }
1467
1509
  function getColor(viewer, obj) {
1468
1510
  let value = null;
1469
1511
  if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
@@ -1580,6 +1622,7 @@
1580
1622
  this.durationMs = 0;
1581
1623
  }
1582
1624
  this.startTime = new Date();
1625
+ requestRendersFor(this.viewer, this.durationMs);
1583
1626
  }
1584
1627
  IsDone() {
1585
1628
  const now = new Date();
@@ -1631,12 +1674,14 @@
1631
1674
  }
1632
1675
  if (!this.paused) {
1633
1676
  this.startTime = new Date();
1677
+ requestRendersFor(this.viewer, this.durationMs);
1634
1678
  }
1635
1679
  }
1636
1680
  Play() {
1637
1681
  if (this.paused) {
1638
1682
  this.paused = false;
1639
1683
  this.startTime = new Date();
1684
+ requestRendersFor(this.viewer, this.durationMs);
1640
1685
  }
1641
1686
  }
1642
1687
  GetValue() {
@@ -1714,6 +1759,8 @@
1714
1759
  setMark(startColor, mark);
1715
1760
  setMark(color, mark);
1716
1761
  let startTime = new Date();
1762
+ // A feature's colour change does not ask for a frame, the final one included.
1763
+ requestRendersFor(viewer, durationMs);
1717
1764
  let removal = viewer.scene.postUpdate.addEventListener(() => {
1718
1765
  if (!isFeatureAlive(viewer, feature)) {
1719
1766
  removal === null || removal === void 0 ? void 0 : removal();
@@ -1785,6 +1832,7 @@
1785
1832
  this.startPos3d = Cesium.Cartesian3.clone(this.targetPos3d);
1786
1833
  }
1787
1834
  this.startTime = new Date();
1835
+ requestRendersFor(this.viewer, this.durationMs);
1788
1836
  }
1789
1837
  GetValue() {
1790
1838
  const now = new Date();
@@ -1816,6 +1864,7 @@
1816
1864
  this.startHeadingDeg = 0;
1817
1865
  }
1818
1866
  this.startTime = new Date();
1867
+ requestRendersFor(this.viewer, this.durationMs);
1819
1868
  }
1820
1869
  IsDone() {
1821
1870
  const now = new Date();
@@ -31045,6 +31094,36 @@
31045
31094
 
31046
31095
  const VIEWER_LEFT_PANEL_WIDGET_KEY = "_viewerLeftPanelWidget";
31047
31096
  const VIEWER_LEFT_PANEL_CSS_VAR_LEFT = "--nextspace-left-panel-width";
31097
+ // Size of a tab button's icon, and the drawing grid the built-in icons are authored on.
31098
+ const TAB_ICON_SIZE = 32;
31099
+ /**
31100
+ * Builds a tab's svg icon, fitted to the button whatever grid it was drawn on.
31101
+ */
31102
+ function CreateTabIconSvg(icon) {
31103
+ const SVG_NS = "http://www.w3.org/2000/svg";
31104
+ const parsed = /<svg[\s>]/i.test(icon !== null && icon !== void 0 ? icon : "") ? new DOMParser().parseFromString(icon, "image/svg+xml") : null;
31105
+ const root = parsed === null || parsed === void 0 ? void 0 : parsed.documentElement;
31106
+ let svg;
31107
+ if (root && root.localName === "svg" && !root.getElementsByTagName("parsererror").length) {
31108
+ svg = document.importNode(root, true);
31109
+ if (!svg.getAttribute("viewBox")) {
31110
+ // Without one the drawing would not scale, so its own size becomes the grid.
31111
+ const width = parseFloat(svg.getAttribute("width"));
31112
+ const height = parseFloat(svg.getAttribute("height"));
31113
+ if (width > 0 && height > 0) {
31114
+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
31115
+ }
31116
+ }
31117
+ }
31118
+ else {
31119
+ svg = document.createElementNS(SVG_NS, "svg");
31120
+ svg.setAttribute("viewBox", `0 0 ${TAB_ICON_SIZE} ${TAB_ICON_SIZE}`);
31121
+ svg.innerHTML = icon !== null && icon !== void 0 ? icon : "";
31122
+ }
31123
+ svg.setAttribute("width", String(TAB_ICON_SIZE));
31124
+ svg.setAttribute("height", String(TAB_ICON_SIZE));
31125
+ return svg;
31126
+ }
31048
31127
  class WidgetLeftPanel extends exports.Widget.AWidget {
31049
31128
  get ViewId() {
31050
31129
  return this._viewId;
@@ -31143,7 +31222,7 @@
31143
31222
  if (this._viewId !== viewId) {
31144
31223
  return;
31145
31224
  }
31146
- this.bookmarks = data.bookmarks;
31225
+ this.bookmarks = data.bookmarks.filter(exports.ViewRenderEngine.IsBookmarkSupported);
31147
31226
  this.bookmarkGroups = groups;
31148
31227
  }
31149
31228
  catch (e) {
@@ -31265,6 +31344,18 @@
31265
31344
  cursor: pointer;
31266
31345
  }
31267
31346
 
31347
+ .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >img {
31348
+ display: block;
31349
+ max-width: 100%;
31350
+ max-height: 100%;
31351
+ object-fit: contain;
31352
+ }
31353
+
31354
+ .NextspaceLeftPanel >.NextspaceLeftPanelButton >.NextspaceLeftPanelButtonIcon >i {
31355
+ color: #fff;
31356
+ font-size: 18px;
31357
+ }
31358
+
31268
31359
  .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled="true"] >.NextspaceLeftPanelButtonIcon {
31269
31360
  background-color: #fff;
31270
31361
  }
@@ -31273,6 +31364,10 @@
31273
31364
  filter: invert(1);
31274
31365
  }
31275
31366
 
31367
+ .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-enabled="true"] >.NextspaceLeftPanelButtonIcon >i {
31368
+ color: #000;
31369
+ }
31370
+
31276
31371
  .NextspaceLeftPanel >.NextspaceLeftPanelButton[is-disabled="true"] {
31277
31372
  opacity: .5;
31278
31373
  pointer-events: none
@@ -31376,6 +31471,10 @@
31376
31471
  icon = params.iconImgUrl;
31377
31472
  iconSource = "file-url";
31378
31473
  }
31474
+ else if (params.iconFontClass) {
31475
+ icon = params.iconFontClass;
31476
+ iconSource = "font";
31477
+ }
31379
31478
  else if (params.svgStr) {
31380
31479
  icon = params.svgStr;
31381
31480
  iconSource = "svg";
@@ -31390,21 +31489,17 @@
31390
31489
  const buttonBookmarksIcon = document.createElement("div");
31391
31490
  buttonBookmarksIcon.className = "NextspaceLeftPanelButtonIcon";
31392
31491
  if (iconSource == "svg") {
31393
- const buttonBookmarksIconSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
31394
- buttonBookmarksIconSvg.setAttribute("viewBox", "0 0 32 32");
31395
- buttonBookmarksIconSvg.setAttribute("width", "32");
31396
- buttonBookmarksIconSvg.setAttribute("height", "32");
31397
- buttonBookmarksIconSvg.innerHTML = icon;
31398
- buttonBookmarksIcon.appendChild(buttonBookmarksIconSvg);
31492
+ buttonBookmarksIcon.appendChild(CreateTabIconSvg(icon));
31399
31493
  }
31400
31494
  else if (iconSource == "file-url") {
31401
31495
  const buttonBookmarksIconImg = document.createElement("img");
31402
31496
  buttonBookmarksIconImg.src = icon;
31403
31497
  buttonBookmarksIcon.appendChild(buttonBookmarksIconImg);
31404
- buttonBookmarksIcon.setAttribute("style", `
31405
- max-width: 32px;
31406
- max-height: 32px;
31407
- `);
31498
+ }
31499
+ else if (iconSource == "font") {
31500
+ const buttonBookmarksIconFont = document.createElement("i");
31501
+ buttonBookmarksIconFont.className = icon;
31502
+ buttonBookmarksIcon.appendChild(buttonBookmarksIconFont);
31408
31503
  }
31409
31504
  tabButton.appendChild(buttonBookmarksIcon);
31410
31505
  tabButton.onclick = () => {
@@ -34080,6 +34175,39 @@
34080
34175
  scene.globe.depthTestAgainstTerrain = Boolean(gOcclusion);
34081
34176
  }
34082
34177
  (function (ViewRenderEngine) {
34178
+ const SUPPORTED_CONTENT_TYPES = [
34179
+ BModels.ProjectViewBookmark.EContentType.WEB_3D,
34180
+ BModels.ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE,
34181
+ BModels.ProjectViewBookmark.EContentType.WEB_3D_SPLIT_PLUGIN
34182
+ ];
34183
+ /**
34184
+ * Whether a bookmark is a Cesium scene this engine can render.
34185
+ */
34186
+ function IsBookmarkSupported(bookmark) {
34187
+ var _a, _b;
34188
+ if (!bookmark) {
34189
+ return false;
34190
+ }
34191
+ const bSettings = ((_a = bookmark.Settings) !== null && _a !== void 0 ? _a : {});
34192
+ if (bSettings.contentType) {
34193
+ return SUPPORTED_CONTENT_TYPES.includes(bSettings.contentType);
34194
+ }
34195
+ // A bookmark ported from the 2D Navigator carries a zoom level rather than a 3D camera.
34196
+ return typeof ((_b = bSettings.camera) === null || _b === void 0 ? void 0 : _b.zoom) !== "number";
34197
+ }
34198
+ ViewRenderEngine.IsBookmarkSupported = IsBookmarkSupported;
34199
+ /**
34200
+ * Drops the view's default bookmark when it is not a Cesium scene, so the view renders without it.
34201
+ * A bookmark the caller asked for by ID is kept.
34202
+ */
34203
+ function KeepDefaultBookmark(view, requestedId, bookmark) {
34204
+ // Legacy views store a different bookmark shape.
34205
+ if (requestedId || !bookmark || (view === null || view === void 0 ? void 0 : view.DataVersion) == 1) {
34206
+ return bookmark;
34207
+ }
34208
+ return IsBookmarkSupported(bookmark) ? bookmark : null;
34209
+ }
34210
+ ViewRenderEngine.KeepDefaultBookmark = KeepDefaultBookmark;
34083
34211
  async function Render(params) {
34084
34212
  var _a, _b;
34085
34213
  if (!params.manager && params.viewer) {
@@ -34117,6 +34245,7 @@
34117
34245
  viewId: params.viewId,
34118
34246
  bookmarkId: bookmarkId
34119
34247
  })).bookmark : null;
34248
+ bookmark = KeepDefaultBookmark(view, params.bookmarkId, bookmark);
34120
34249
  }
34121
34250
  if (!assertIteration$1(params.viewer, iteration)) {
34122
34251
  return;
@@ -34177,6 +34306,7 @@
34177
34306
  viewId: params.viewId,
34178
34307
  bookmarkId: bookmarkId
34179
34308
  })).bookmark : null;
34309
+ bookmark = KeepDefaultBookmark(view, params.bookmarkId, bookmark);
34180
34310
  }
34181
34311
  const viewer = params.manager.Viewer;
34182
34312
  const scene = viewer.scene;
@@ -34380,7 +34510,7 @@
34380
34510
  if (counter != this.reloadCounter) {
34381
34511
  return;
34382
34512
  }
34383
- this.bookmarks = data.bookmarks;
34513
+ this.bookmarks = data.bookmarks.filter(exports.ViewRenderEngine.IsBookmarkSupported);
34384
34514
  }
34385
34515
  catch (e) {
34386
34516
  console.error(e);
@@ -50743,7 +50873,7 @@ void main() {
50743
50873
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
50744
50874
  })(exports.StyleUtils || (exports.StyleUtils = {}));
50745
50875
 
50746
- const VERSION = "7.4.7";
50876
+ const VERSION = "7.4.9";
50747
50877
  /**
50748
50878
  * Updates the environment instance used by bruce-cesium to one specified.
50749
50879
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -50796,6 +50926,7 @@ void main() {
50796
50926
  exports.WidgetInfoView = WidgetInfoView;
50797
50927
  exports.VIEWER_LEFT_PANEL_WIDGET_KEY = VIEWER_LEFT_PANEL_WIDGET_KEY;
50798
50928
  exports.VIEWER_LEFT_PANEL_CSS_VAR_LEFT = VIEWER_LEFT_PANEL_CSS_VAR_LEFT;
50929
+ exports.CreateTabIconSvg = CreateTabIconSvg;
50799
50930
  exports.WidgetLeftPanel = WidgetLeftPanel;
50800
50931
  exports.WidgetNavCompass = WidgetNavCompass$$1;
50801
50932
  exports.VIEWER_VIEW_BAR_WIDGET_KEY = VIEWER_VIEW_BAR_WIDGET_KEY;