bruce-cesium 7.4.8 → 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();
@@ -34147,6 +34196,18 @@
34147
34196
  return typeof ((_b = bSettings.camera) === null || _b === void 0 ? void 0 : _b.zoom) !== "number";
34148
34197
  }
34149
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;
34150
34211
  async function Render(params) {
34151
34212
  var _a, _b;
34152
34213
  if (!params.manager && params.viewer) {
@@ -34184,6 +34245,7 @@
34184
34245
  viewId: params.viewId,
34185
34246
  bookmarkId: bookmarkId
34186
34247
  })).bookmark : null;
34248
+ bookmark = KeepDefaultBookmark(view, params.bookmarkId, bookmark);
34187
34249
  }
34188
34250
  if (!assertIteration$1(params.viewer, iteration)) {
34189
34251
  return;
@@ -34244,6 +34306,7 @@
34244
34306
  viewId: params.viewId,
34245
34307
  bookmarkId: bookmarkId
34246
34308
  })).bookmark : null;
34309
+ bookmark = KeepDefaultBookmark(view, params.bookmarkId, bookmark);
34247
34310
  }
34248
34311
  const viewer = params.manager.Viewer;
34249
34312
  const scene = viewer.scene;
@@ -50810,7 +50873,7 @@ void main() {
50810
50873
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
50811
50874
  })(exports.StyleUtils || (exports.StyleUtils = {}));
50812
50875
 
50813
- const VERSION = "7.4.8";
50876
+ const VERSION = "7.4.9";
50814
50877
  /**
50815
50878
  * Updates the environment instance used by bruce-cesium to one specified.
50816
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.