bruce-cesium 7.6.3 → 7.6.4

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.
@@ -44005,37 +44005,46 @@
44005
44005
 
44006
44006
  const CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
44007
44007
  const CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
44008
- /**
44009
- * Bug related to entities not being visible after they were added then a render was requested.
44010
- * It was 4 point entities in York. They would not appear until a request render was recalled.
44011
- * Adding this slow render loop as a band-aid fix.
44012
- */
44013
44008
  const BACKGROUND_RENDERING_KEY = "_backgroundRendering";
44009
+ // How long after the scene last drew it is drawn once more.
44010
+ const FOLLOW_UP_RENDER_MS = 3000;
44011
+ /*
44012
+ * Draws once more a few seconds after the scene last drew, for graphics not ready by the render that asked for them.
44013
+ */
44014
44014
  function backgroundRendering(viewer) {
44015
44015
  if (viewer[BACKGROUND_RENDERING_KEY]) {
44016
44016
  return;
44017
44017
  }
44018
44018
  viewer[BACKGROUND_RENDERING_KEY] = true;
44019
+ // Wall time, since scene.lastRenderTime is the scene clock's and stands still while the clock is paused.
44020
+ let lastRenderAt = performance.now();
44021
+ // Whether the last render was the follow up, so a still scene is drawn once more rather than forever.
44022
+ let followedUp = false;
44023
+ let requested = false;
44024
+ const removeListener = viewer.scene.postRender.addEventListener(() => {
44025
+ lastRenderAt = performance.now();
44026
+ followedUp = requested;
44027
+ requested = false;
44028
+ });
44019
44029
  const interval = setInterval(() => {
44020
44030
  var _a;
44021
44031
  if (!(viewer === null || viewer === void 0 ? void 0 : viewer.cesiumWidget) || !(viewer === null || viewer === void 0 ? void 0 : viewer.scene) || viewer.isDestroyed()) {
44022
44032
  clearInterval(interval);
44033
+ removeListener();
44023
44034
  return;
44024
44035
  }
44025
44036
  // We'll ignore the call if the viewer container is not visible.
44026
44037
  if (!viewer.container || ((_a = viewer.container.style) === null || _a === void 0 ? void 0 : _a.display) == "none") {
44027
44038
  return;
44028
44039
  }
44040
+ if (followedUp || requested || performance.now() - lastRenderAt < FOLLOW_UP_RENDER_MS) {
44041
+ return;
44042
+ }
44029
44043
  try {
44030
- // Check if last render time is greater than 3 seconds ago.
44031
- // We check in case something else is also requesting renders.
44032
- const lastRenderTime = viewer.scene.lastRenderTime;
44033
- if (!lastRenderTime || Cesium.JulianDate.secondsDifference(Cesium.JulianDate.now(), lastRenderTime) > 3) {
44034
- // Check if window is active/in focus.
44035
- // TODO: Should render the moment it is in focus as well.
44036
- if (document.hasFocus()) {
44037
- viewer.scene.requestRender();
44038
- }
44044
+ // Only while the window has focus. TODO: should render the moment it regains focus as well.
44045
+ if (document.hasFocus()) {
44046
+ requested = true;
44047
+ viewer.scene.requestRender();
44039
44048
  }
44040
44049
  }
44041
44050
  catch (e) {
@@ -55436,7 +55445,7 @@ void main() {
55436
55445
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
55437
55446
  })(exports.StyleUtils || (exports.StyleUtils = {}));
55438
55447
 
55439
- const VERSION = "7.6.3";
55448
+ const VERSION = "7.6.4";
55440
55449
  /**
55441
55450
  * Updates the environment instance used by bruce-cesium to one specified.
55442
55451
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.