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.
@@ -1,6 +1,6 @@
1
1
  import * as Cesium from 'cesium';
2
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, BoundingSphere, GeometryInstance, CesiumInspector, ClockRange, CustomDataSource, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
3
- import { Cartes, Entity as Entity$1, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Api, Carto, Geometry, Bounds, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, AccountConcept, RecordChangeFeed, BruceApi, EntityRelation, ProgramKey, EntitySource, Camera, ProjectViewTile, ProjectViewLegacyTile, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, HeightReference, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, ShadowMode, Cartesian3, ClassificationType, Model, ArcType, CornerType, ConstantPositionProperty, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, NearFarScalar, JulianDate, Quaternion, Matrix3, KmlDataSource, Matrix4, Rectangle, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, IonResource, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, CustomDataSource, GeometryInstance, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Carto, Geometry, Api, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, Bounds, Color as Color$1, BruceEvent, EntityCoords, DelayQueue, EntityHistoricData, DataLab, EntityRelation, AccountConcept, RecordChangeFeed, BruceApi, ProgramKey, EntitySource, Camera, ProjectViewTile, ProjectViewLegacyTile, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -6026,7 +6026,7 @@ const getTerrainOffset = (viewer, pos3d) => {
6026
6026
  }
6027
6027
  if (height == null || isNaN(height)) {
6028
6028
  // Terrain tile not loaded yet. Don't record it, so a later pass can sample it properly.
6029
- return coarseCell ? coarseCell.offset : 0;
6029
+ return coarseCell ? coarseCell.offset : NaN;
6030
6030
  }
6031
6031
  // Always fold into the coarse cell as well, so its spread keeps being learned even while the finer grid is
6032
6032
  // answering lookups for this region.
@@ -6049,6 +6049,9 @@ const adjustPos3d = (viewer, heightRef, pos3d) => {
6049
6049
  return pos3d;
6050
6050
  }
6051
6051
  const offset = getTerrainOffset(viewer, pos3d);
6052
+ if (typeof offset == "number" && isNaN(offset)) {
6053
+ return null;
6054
+ }
6052
6055
  if (!offset) {
6053
6056
  return pos3d;
6054
6057
  }
@@ -6298,7 +6301,13 @@ function shouldCullEntity(viewer, cEntity) {
6298
6301
  adjustedSphere.radius += TERRAIN_SKIP_RADIUS_PAD;
6299
6302
  }
6300
6303
  else {
6301
- adjustedSphere.center = adjustPos3d(viewer, boundingSphere.heightRef, adjustedSphere.center);
6304
+ const grounded = adjustPos3d(viewer, boundingSphere.heightRef, adjustedSphere.center);
6305
+ if (!grounded) {
6306
+ // Where this sits depends on ground we have not loaded yet. Guessing means guessing wrong sometimes,
6307
+ // and a wrong cull hides something that is on screen with nothing to bring it back.
6308
+ return false;
6309
+ }
6310
+ adjustedSphere.center = grounded;
6302
6311
  }
6303
6312
  const cullingVolume = camera.frustum.computeCullingVolume(camera.position, camera.direction, camera.up);
6304
6313
  const visibility = cullingVolume.computeVisibility(adjustedSphere);
@@ -6662,6 +6671,28 @@ var VisualRegisterCuller;
6662
6671
  return isCullingIgnored(viewer, rego);
6663
6672
  }
6664
6673
  VisualRegisterCuller.IsCullingIgnored = IsCullingIgnored;
6674
+ /**
6675
+ * Drops any scene add/remove the culler has queued for these graphics.
6676
+ * Emits whether a removal was among them.
6677
+ * @param visuals an entity or an array of them.
6678
+ * @returns whether a queued removal was cancelled, ie. whether this graphic was on its way out.
6679
+ */
6680
+ function CancelQueuedSceneChange(visuals) {
6681
+ const list = Array.isArray(visuals) ? visuals : [visuals];
6682
+ let hadRemoval = false;
6683
+ for (let i = 0; i < list.length; i++) {
6684
+ const visual = list[i];
6685
+ if (!(visual instanceof Entity)) {
6686
+ continue;
6687
+ }
6688
+ if (entityRemoveAddState.get(visual.id) === false) {
6689
+ hadRemoval = true;
6690
+ }
6691
+ entityRemoveAddState.delete(visual.id);
6692
+ }
6693
+ return hadRemoval;
6694
+ }
6695
+ VisualRegisterCuller.CancelQueuedSceneChange = CancelQueuedSceneChange;
6665
6696
  /**
6666
6697
  * Discards what the culler knows about an entity's extent, so its next check measures the geometry again.
6667
6698
  * The last cull decision is deliberately kept, see the loop below.
@@ -6693,6 +6724,19 @@ var VisualRegisterCuller;
6693
6724
  invalidateBounds(ids);
6694
6725
  }
6695
6726
  VisualRegisterCuller.InvalidateBounds = InvalidateBounds;
6727
+ /**
6728
+ * Measures a graphic against the current view and says whether it is out of frame.
6729
+ */
6730
+ function ShouldCull(viewer, visual) {
6731
+ if (!(visual instanceof Entity)) {
6732
+ return false;
6733
+ }
6734
+ return shouldCullEntity(viewer, visual);
6735
+ }
6736
+ VisualRegisterCuller.ShouldCull = ShouldCull;
6737
+ /**
6738
+ * Whether the last cull pass decided this graphic was out of frame.
6739
+ */
6696
6740
  function IsCulled(viewer, rego, visual) {
6697
6741
  if (isCullingIgnored(viewer, rego)) {
6698
6742
  return false;
@@ -6701,11 +6745,7 @@ var VisualRegisterCuller;
6701
6745
  return false;
6702
6746
  }
6703
6747
  if (visual instanceof Entity) {
6704
- let status = visual[VisualRegisterCuller.VISUAL_CULL_KEY];
6705
- if (status == null) {
6706
- status = visual[VisualRegisterCuller.VISUAL_CULL_KEY] = shouldCullEntity(viewer, visual);
6707
- }
6708
- return status;
6748
+ return visual[VisualRegisterCuller.VISUAL_CULL_KEY] == true;
6709
6749
  }
6710
6750
  return false;
6711
6751
  }
@@ -8205,7 +8245,8 @@ var VisualsRegister;
8205
8245
  if (!(part instanceof Entity)) {
8206
8246
  continue;
8207
8247
  }
8208
- const wasCulled = part[VisualRegisterCuller.VISUAL_CULL_KEY];
8248
+ const removalPending = VisualRegisterCuller.CancelQueuedSceneChange(part);
8249
+ const wasCulled = part[VisualRegisterCuller.VISUAL_CULL_KEY] == true || removalPending;
8209
8250
  delete part[VisualRegisterCuller.VISUAL_CULL_KEY];
8210
8251
  if (wasCulled && !IsCEntityInScene(this.viewer, part)) {
8211
8252
  AddCEntityToScene(this.viewer, part, rego.collection);
@@ -40422,7 +40463,7 @@ var StyleUtils;
40422
40463
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
40423
40464
  })(StyleUtils || (StyleUtils = {}));
40424
40465
 
40425
- const VERSION = "7.0.7";
40466
+ const VERSION = "7.0.8";
40426
40467
  /**
40427
40468
  * Updates the environment instance used by bruce-cesium to one specified.
40428
40469
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.