bruce-cesium 7.0.7 → 7.0.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.
@@ -6010,7 +6010,7 @@
6010
6010
  }
6011
6011
  if (height == null || isNaN(height)) {
6012
6012
  // Terrain tile not loaded yet. Don't record it, so a later pass can sample it properly.
6013
- return coarseCell ? coarseCell.offset : 0;
6013
+ return coarseCell ? coarseCell.offset : NaN;
6014
6014
  }
6015
6015
  // Always fold into the coarse cell as well, so its spread keeps being learned even while the finer grid is
6016
6016
  // answering lookups for this region.
@@ -6033,6 +6033,9 @@
6033
6033
  return pos3d;
6034
6034
  }
6035
6035
  const offset = getTerrainOffset(viewer, pos3d);
6036
+ if (typeof offset == "number" && isNaN(offset)) {
6037
+ return null;
6038
+ }
6036
6039
  if (!offset) {
6037
6040
  return pos3d;
6038
6041
  }
@@ -6282,7 +6285,13 @@
6282
6285
  adjustedSphere.radius += TERRAIN_SKIP_RADIUS_PAD;
6283
6286
  }
6284
6287
  else {
6285
- adjustedSphere.center = adjustPos3d(viewer, boundingSphere.heightRef, adjustedSphere.center);
6288
+ const grounded = adjustPos3d(viewer, boundingSphere.heightRef, adjustedSphere.center);
6289
+ if (!grounded) {
6290
+ // Where this sits depends on ground we have not loaded yet. Guessing means guessing wrong sometimes,
6291
+ // and a wrong cull hides something that is on screen with nothing to bring it back.
6292
+ return false;
6293
+ }
6294
+ adjustedSphere.center = grounded;
6286
6295
  }
6287
6296
  const cullingVolume = camera.frustum.computeCullingVolume(camera.position, camera.direction, camera.up);
6288
6297
  const visibility = cullingVolume.computeVisibility(adjustedSphere);
@@ -6646,6 +6655,28 @@
6646
6655
  return isCullingIgnored(viewer, rego);
6647
6656
  }
6648
6657
  VisualRegisterCuller.IsCullingIgnored = IsCullingIgnored;
6658
+ /**
6659
+ * Drops any scene add/remove the culler has queued for these graphics.
6660
+ * Emits whether a removal was among them.
6661
+ * @param visuals an entity or an array of them.
6662
+ * @returns whether a queued removal was cancelled, ie. whether this graphic was on its way out.
6663
+ */
6664
+ function CancelQueuedSceneChange(visuals) {
6665
+ const list = Array.isArray(visuals) ? visuals : [visuals];
6666
+ let hadRemoval = false;
6667
+ for (let i = 0; i < list.length; i++) {
6668
+ const visual = list[i];
6669
+ if (!(visual instanceof Cesium.Entity)) {
6670
+ continue;
6671
+ }
6672
+ if (entityRemoveAddState.get(visual.id) === false) {
6673
+ hadRemoval = true;
6674
+ }
6675
+ entityRemoveAddState.delete(visual.id);
6676
+ }
6677
+ return hadRemoval;
6678
+ }
6679
+ VisualRegisterCuller.CancelQueuedSceneChange = CancelQueuedSceneChange;
6649
6680
  /**
6650
6681
  * Discards what the culler knows about an entity's extent, so its next check measures the geometry again.
6651
6682
  * The last cull decision is deliberately kept, see the loop below.
@@ -6677,6 +6708,19 @@
6677
6708
  invalidateBounds(ids);
6678
6709
  }
6679
6710
  VisualRegisterCuller.InvalidateBounds = InvalidateBounds;
6711
+ /**
6712
+ * Measures a graphic against the current view and says whether it is out of frame.
6713
+ */
6714
+ function ShouldCull(viewer, visual) {
6715
+ if (!(visual instanceof Cesium.Entity)) {
6716
+ return false;
6717
+ }
6718
+ return shouldCullEntity(viewer, visual);
6719
+ }
6720
+ VisualRegisterCuller.ShouldCull = ShouldCull;
6721
+ /**
6722
+ * Whether the last cull pass decided this graphic was out of frame.
6723
+ */
6680
6724
  function IsCulled(viewer, rego, visual) {
6681
6725
  if (isCullingIgnored(viewer, rego)) {
6682
6726
  return false;
@@ -6685,11 +6729,7 @@
6685
6729
  return false;
6686
6730
  }
6687
6731
  if (visual instanceof Cesium.Entity) {
6688
- let status = visual[VisualRegisterCuller.VISUAL_CULL_KEY];
6689
- if (status == null) {
6690
- status = visual[VisualRegisterCuller.VISUAL_CULL_KEY] = shouldCullEntity(viewer, visual);
6691
- }
6692
- return status;
6732
+ return visual[VisualRegisterCuller.VISUAL_CULL_KEY] == true;
6693
6733
  }
6694
6734
  return false;
6695
6735
  }
@@ -8185,7 +8225,8 @@
8185
8225
  if (!(part instanceof Cesium.Entity)) {
8186
8226
  continue;
8187
8227
  }
8188
- const wasCulled = part[VisualRegisterCuller.VISUAL_CULL_KEY];
8228
+ const removalPending = VisualRegisterCuller.CancelQueuedSceneChange(part);
8229
+ const wasCulled = part[VisualRegisterCuller.VISUAL_CULL_KEY] == true || removalPending;
8189
8230
  delete part[VisualRegisterCuller.VISUAL_CULL_KEY];
8190
8231
  if (wasCulled && !IsCEntityInScene(this.viewer, part)) {
8191
8232
  AddCEntityToScene(this.viewer, part, rego.collection);
@@ -40300,7 +40341,7 @@
40300
40341
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
40301
40342
  })(exports.StyleUtils || (exports.StyleUtils = {}));
40302
40343
 
40303
- const VERSION = "7.0.7";
40344
+ const VERSION = "7.0.8";
40304
40345
  /**
40305
40346
  * Updates the environment instance used by bruce-cesium to one specified.
40306
40347
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.