bruce-cesium 7.0.7 → 7.0.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.
@@ -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, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, DistanceDisplayCondition, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileset, OrthographicFrustum, EasingFunction, BoundingSphere, Intersect, CustomDataSource, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Api, Bounds, Color as Color$1, Geometry, Carto, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, AccountConcept, RecordChangeFeed, BruceApi, EntityRelation, ProgramKey, EntitySource, ProjectViewLegacyTile, ProjectViewTile, Camera, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session, 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);
@@ -6314,6 +6323,7 @@ const LAST_RECHECK_KEY = Symbol("LAST_RECHECK_KEY");
6314
6323
  // Attached to a cesium viewer to indicate a re-check should be done.
6315
6324
  // This is to override the cache that avoids re-checking when the camera hasn't moved.
6316
6325
  const SHOULD_RECHECK_KEY = Symbol("SHOULD_RECHECK_KEY");
6326
+ const RECHECK_KICK_KEY = Symbol("RECHECK_KICK_KEY");
6317
6327
  /**
6318
6328
  * We will recheck if the camera has turned or moved enough.
6319
6329
  * @param viewer
@@ -6604,6 +6614,7 @@ var VisualRegisterCuller;
6604
6614
  runCullChecker(register);
6605
6615
  lastCullCheck = new Date();
6606
6616
  }, 1000);
6617
+ register.Viewer[RECHECK_KICK_KEY] = () => { var _a; return (_a = checkQueue === null || checkQueue === void 0 ? void 0 : checkQueue.Call) === null || _a === void 0 ? void 0 : _a.call(checkQueue); };
6607
6618
  let moveStartRemoval = register.Viewer.camera.moveStart.addEventListener(() => {
6608
6619
  var _a;
6609
6620
  (_a = checkQueue.Call) === null || _a === void 0 ? void 0 : _a.call(checkQueue);
@@ -6646,6 +6657,9 @@ var VisualRegisterCuller;
6646
6657
  checkWaiting = false;
6647
6658
  checkQueue === null || checkQueue === void 0 ? void 0 : checkQueue.Dispose();
6648
6659
  checkQueue = null;
6660
+ if (register.Viewer) {
6661
+ delete register.Viewer[RECHECK_KICK_KEY];
6662
+ }
6649
6663
  };
6650
6664
  }
6651
6665
  VisualRegisterCuller.Monitor = Monitor;
@@ -6662,6 +6676,28 @@ var VisualRegisterCuller;
6662
6676
  return isCullingIgnored(viewer, rego);
6663
6677
  }
6664
6678
  VisualRegisterCuller.IsCullingIgnored = IsCullingIgnored;
6679
+ /**
6680
+ * Drops any scene add/remove the culler has queued for these graphics.
6681
+ * Emits whether a removal was among them.
6682
+ * @param visuals an entity or an array of them.
6683
+ * @returns whether a queued removal was cancelled, ie. whether this graphic was on its way out.
6684
+ */
6685
+ function CancelQueuedSceneChange(visuals) {
6686
+ const list = Array.isArray(visuals) ? visuals : [visuals];
6687
+ let hadRemoval = false;
6688
+ for (let i = 0; i < list.length; i++) {
6689
+ const visual = list[i];
6690
+ if (!(visual instanceof Entity)) {
6691
+ continue;
6692
+ }
6693
+ if (entityRemoveAddState.get(visual.id) === false) {
6694
+ hadRemoval = true;
6695
+ }
6696
+ entityRemoveAddState.delete(visual.id);
6697
+ }
6698
+ return hadRemoval;
6699
+ }
6700
+ VisualRegisterCuller.CancelQueuedSceneChange = CancelQueuedSceneChange;
6665
6701
  /**
6666
6702
  * Discards what the culler knows about an entity's extent, so its next check measures the geometry again.
6667
6703
  * The last cull decision is deliberately kept, see the loop below.
@@ -6693,6 +6729,19 @@ var VisualRegisterCuller;
6693
6729
  invalidateBounds(ids);
6694
6730
  }
6695
6731
  VisualRegisterCuller.InvalidateBounds = InvalidateBounds;
6732
+ /**
6733
+ * Measures a graphic against the current view and says whether it is out of frame.
6734
+ */
6735
+ function ShouldCull(viewer, visual) {
6736
+ if (!(visual instanceof Entity)) {
6737
+ return false;
6738
+ }
6739
+ return shouldCullEntity(viewer, visual);
6740
+ }
6741
+ VisualRegisterCuller.ShouldCull = ShouldCull;
6742
+ /**
6743
+ * Whether the last cull pass decided this graphic was out of frame.
6744
+ */
6696
6745
  function IsCulled(viewer, rego, visual) {
6697
6746
  if (isCullingIgnored(viewer, rego)) {
6698
6747
  return false;
@@ -6701,17 +6750,21 @@ var VisualRegisterCuller;
6701
6750
  return false;
6702
6751
  }
6703
6752
  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;
6753
+ return visual[VisualRegisterCuller.VISUAL_CULL_KEY] == true;
6709
6754
  }
6710
6755
  return false;
6711
6756
  }
6712
6757
  VisualRegisterCuller.IsCulled = IsCulled;
6758
+ /**
6759
+ * Asks for the next cull pass to actually re-measure, and brings that pass forward.
6760
+ */
6713
6761
  function MarkShouldRecheck(viewer) {
6762
+ var _a, _b;
6763
+ if (!viewer || ((_a = viewer.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(viewer))) {
6764
+ return;
6765
+ }
6714
6766
  viewer[SHOULD_RECHECK_KEY] = true;
6767
+ (_b = viewer[RECHECK_KICK_KEY]) === null || _b === void 0 ? void 0 : _b.call(viewer);
6715
6768
  }
6716
6769
  VisualRegisterCuller.MarkShouldRecheck = MarkShouldRecheck;
6717
6770
  })(VisualRegisterCuller || (VisualRegisterCuller = {}));
@@ -8170,6 +8223,26 @@ var VisualsRegister;
8170
8223
  CesiumEntityStyler.UpdateColorSetting("highlight", color);
8171
8224
  }
8172
8225
  }
8226
+ /**
8227
+ * Whether any rego for this entity is currently held as being edited.
8228
+ */
8229
+ IsEditing(params) {
8230
+ const { entityId, menuItemId } = params;
8231
+ const regos = this.rego[entityId];
8232
+ if (!(regos === null || regos === void 0 ? void 0 : regos.length)) {
8233
+ return false;
8234
+ }
8235
+ for (let i = 0; i < regos.length; i++) {
8236
+ const rego = regos[i];
8237
+ if (menuItemId && rego.menuItemId !== menuItemId) {
8238
+ continue;
8239
+ }
8240
+ if (rego.editing) {
8241
+ return true;
8242
+ }
8243
+ }
8244
+ return false;
8245
+ }
8173
8246
  /**
8174
8247
  * Marks visuals as being actively edited, which exempts them from culling until it is turned back off.
8175
8248
  */
@@ -8190,12 +8263,15 @@ var VisualsRegister;
8190
8263
  if (menuItemId && rego.menuItemId !== menuItemId) {
8191
8264
  continue;
8192
8265
  }
8193
- if (Boolean(rego.editing) == Boolean(editing)) {
8266
+ const wasEditing = Boolean(rego.editing);
8267
+ if (wasEditing == Boolean(editing) && editing) {
8194
8268
  continue;
8195
8269
  }
8196
8270
  // Null rather than false, so the rego does not carry a key for every visual ever edited.
8197
8271
  rego.editing = editing ? true : null;
8198
- changed = true;
8272
+ if (wasEditing != Boolean(editing)) {
8273
+ changed = true;
8274
+ }
8199
8275
  if (editing) {
8200
8276
  const parts = EntityUtils.GatherEntity({
8201
8277
  entity: rego.visual
@@ -8205,7 +8281,8 @@ var VisualsRegister;
8205
8281
  if (!(part instanceof Entity)) {
8206
8282
  continue;
8207
8283
  }
8208
- const wasCulled = part[VisualRegisterCuller.VISUAL_CULL_KEY];
8284
+ const removalPending = VisualRegisterCuller.CancelQueuedSceneChange(part);
8285
+ const wasCulled = part[VisualRegisterCuller.VISUAL_CULL_KEY] == true || removalPending;
8209
8286
  delete part[VisualRegisterCuller.VISUAL_CULL_KEY];
8210
8287
  if (wasCulled && !IsCEntityInScene(this.viewer, part)) {
8211
8288
  AddCEntityToScene(this.viewer, part, rego.collection);
@@ -8213,7 +8290,6 @@ var VisualsRegister;
8213
8290
  }
8214
8291
  }
8215
8292
  else {
8216
- // The geometry almost certainly moved, so what was measured before is worthless.
8217
8293
  VisualRegisterCuller.InvalidateBounds(rego.visual);
8218
8294
  VisualRegisterCuller.MarkShouldRecheck(this.viewer);
8219
8295
  }
@@ -8689,6 +8765,9 @@ var VisualsRegister;
8689
8765
  // Tilesets will often add -> remove -> add because of how tiles load in and out of the scene.
8690
8766
  // To avoid flickering, we'll just replace rather than remove -> add.
8691
8767
  if (!rego.tilesetId && params.removePrior != false) {
8768
+ if (!rego.editing && this.IsEditing({ entityId: rego.entityId, menuItemId: rego.menuItemId })) {
8769
+ rego.editing = true;
8770
+ }
8692
8771
  this.RemoveRegos({
8693
8772
  entityId: rego.entityId,
8694
8773
  menuItemId: rego.menuItemId,
@@ -39654,6 +39733,7 @@ var EntityRenderEngine;
39654
39733
  }
39655
39734
  VisualRegisterCuller.InvalidateBounds(cEntity);
39656
39735
  });
39736
+ VisualRegisterCuller.MarkShouldRecheck(params.viewer);
39657
39737
  return {
39658
39738
  entities: cEntities,
39659
39739
  updated
@@ -40422,7 +40502,7 @@ var StyleUtils;
40422
40502
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
40423
40503
  })(StyleUtils || (StyleUtils = {}));
40424
40504
 
40425
- const VERSION = "7.0.7";
40505
+ const VERSION = "7.0.9";
40426
40506
  /**
40427
40507
  * Updates the environment instance used by bruce-cesium to one specified.
40428
40508
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -40439,5 +40519,5 @@ const getENVIRONMENT = () => {
40439
40519
  return ENVIRONMENT;
40440
40520
  };
40441
40521
 
40442
- export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, createTileset, TilesetRenderEngine, ViewRenderEngine, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, CesiumViewMonitor, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
40522
+ export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, createTileset, TilesetRenderEngine, ViewRenderEngine, VisualRegisterCuller, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, CesiumViewMonitor, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
40443
40523
  //# sourceMappingURL=bruce-cesium.es5.js.map