bruce-cesium 7.0.8 → 7.1.0

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, 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';
2
+ import { Cartographic, Entity, DistanceDisplayCondition, HeightReference, ColorBlendMode, Color, CallbackProperty, HeadingPitchRoll, Math as Math$1, Transforms, ShadowMode, ConstantProperty, Cartesian3, ClassificationType, Model, ArcType, CornerType, ConstantPositionProperty, ColorMaterialProperty, Primitive, Cesium3DTileFeature, JulianDate, Quaternion, Matrix4, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, HorizontalOrigin, VerticalOrigin, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileset, Cesium3DTileColorBlendMode, BoundingSphere, Intersect, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, CustomDataSource, CesiumInspector, ClockRange, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Carto, Geometry, Bounds, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, Api, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, BruceApi, EntityRelation, AccountConcept, RecordChangeFeed, EntitySource, ProgramKey, ProjectViewTile, ProjectViewLegacyTile, 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.
@@ -6323,6 +6323,7 @@ const LAST_RECHECK_KEY = Symbol("LAST_RECHECK_KEY");
6323
6323
  // Attached to a cesium viewer to indicate a re-check should be done.
6324
6324
  // This is to override the cache that avoids re-checking when the camera hasn't moved.
6325
6325
  const SHOULD_RECHECK_KEY = Symbol("SHOULD_RECHECK_KEY");
6326
+ const RECHECK_KICK_KEY = Symbol("RECHECK_KICK_KEY");
6326
6327
  /**
6327
6328
  * We will recheck if the camera has turned or moved enough.
6328
6329
  * @param viewer
@@ -6469,6 +6470,8 @@ function runCullChecker(register) {
6469
6470
  }
6470
6471
  const toRemove = [];
6471
6472
  const toAdd = [];
6473
+ // Entities the register has to re-evaluate, because the culler cannot restore a `show` it did not set.
6474
+ const toRefresh = new Set();
6472
6475
  const isIsolatedAny = register.GetIsIsolatedAny();
6473
6476
  const slice = entityIds.splice(0, CHECK_BATCH);
6474
6477
  for (let i = 0; i < slice.length; i++) {
@@ -6517,6 +6520,12 @@ function runCullChecker(register) {
6517
6520
  (!isIsolatedAny || state.isolated)) {
6518
6521
  toAdd.push(part);
6519
6522
  }
6523
+ else if (part.show === false &&
6524
+ rego.overrideShow != false &&
6525
+ !state.hidden &&
6526
+ (!isIsolatedAny || state.isolated)) {
6527
+ toRefresh.add(entityId);
6528
+ }
6520
6529
  }
6521
6530
  }
6522
6531
  }
@@ -6527,6 +6536,11 @@ function runCullChecker(register) {
6527
6536
  if (toAdd.length > 0) {
6528
6537
  addEntities(viewer, toAdd);
6529
6538
  }
6539
+ if (toRefresh.size > 0) {
6540
+ register.ForceUpdate({
6541
+ entityIds: Array.from(toRefresh)
6542
+ });
6543
+ }
6530
6544
  if (entityIds.length <= 0) {
6531
6545
  clearInterval(checkInterval);
6532
6546
  checkInterval = null;
@@ -6613,6 +6627,7 @@ var VisualRegisterCuller;
6613
6627
  runCullChecker(register);
6614
6628
  lastCullCheck = new Date();
6615
6629
  }, 1000);
6630
+ 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); };
6616
6631
  let moveStartRemoval = register.Viewer.camera.moveStart.addEventListener(() => {
6617
6632
  var _a;
6618
6633
  (_a = checkQueue.Call) === null || _a === void 0 ? void 0 : _a.call(checkQueue);
@@ -6655,6 +6670,9 @@ var VisualRegisterCuller;
6655
6670
  checkWaiting = false;
6656
6671
  checkQueue === null || checkQueue === void 0 ? void 0 : checkQueue.Dispose();
6657
6672
  checkQueue = null;
6673
+ if (register.Viewer) {
6674
+ delete register.Viewer[RECHECK_KICK_KEY];
6675
+ }
6658
6676
  };
6659
6677
  }
6660
6678
  VisualRegisterCuller.Monitor = Monitor;
@@ -6745,13 +6763,25 @@ var VisualRegisterCuller;
6745
6763
  return false;
6746
6764
  }
6747
6765
  if (visual instanceof Entity) {
6748
- return visual[VisualRegisterCuller.VISUAL_CULL_KEY] == true;
6766
+ if (visual[VisualRegisterCuller.VISUAL_CULL_KEY] != true) {
6767
+ return false;
6768
+ }
6769
+ // Invalidated, so the decision above was measured from geometry that no longer describes this.
6770
+ return boundingSphereCache.Get(visual.id) != null;
6749
6771
  }
6750
6772
  return false;
6751
6773
  }
6752
6774
  VisualRegisterCuller.IsCulled = IsCulled;
6775
+ /**
6776
+ * Asks for the next cull pass to actually re-measure, and brings that pass forward.
6777
+ */
6753
6778
  function MarkShouldRecheck(viewer) {
6779
+ var _a, _b;
6780
+ if (!viewer || ((_a = viewer.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(viewer))) {
6781
+ return;
6782
+ }
6754
6783
  viewer[SHOULD_RECHECK_KEY] = true;
6784
+ (_b = viewer[RECHECK_KICK_KEY]) === null || _b === void 0 ? void 0 : _b.call(viewer);
6755
6785
  }
6756
6786
  VisualRegisterCuller.MarkShouldRecheck = MarkShouldRecheck;
6757
6787
  })(VisualRegisterCuller || (VisualRegisterCuller = {}));
@@ -8210,6 +8240,26 @@ var VisualsRegister;
8210
8240
  CesiumEntityStyler.UpdateColorSetting("highlight", color);
8211
8241
  }
8212
8242
  }
8243
+ /**
8244
+ * Whether any rego for this entity is currently held as being edited.
8245
+ */
8246
+ IsEditing(params) {
8247
+ const { entityId, menuItemId } = params;
8248
+ const regos = this.rego[entityId];
8249
+ if (!(regos === null || regos === void 0 ? void 0 : regos.length)) {
8250
+ return false;
8251
+ }
8252
+ for (let i = 0; i < regos.length; i++) {
8253
+ const rego = regos[i];
8254
+ if (menuItemId && rego.menuItemId !== menuItemId) {
8255
+ continue;
8256
+ }
8257
+ if (rego.editing) {
8258
+ return true;
8259
+ }
8260
+ }
8261
+ return false;
8262
+ }
8213
8263
  /**
8214
8264
  * Marks visuals as being actively edited, which exempts them from culling until it is turned back off.
8215
8265
  */
@@ -8230,12 +8280,15 @@ var VisualsRegister;
8230
8280
  if (menuItemId && rego.menuItemId !== menuItemId) {
8231
8281
  continue;
8232
8282
  }
8233
- if (Boolean(rego.editing) == Boolean(editing)) {
8283
+ const wasEditing = Boolean(rego.editing);
8284
+ if (wasEditing == Boolean(editing) && editing) {
8234
8285
  continue;
8235
8286
  }
8236
8287
  // Null rather than false, so the rego does not carry a key for every visual ever edited.
8237
8288
  rego.editing = editing ? true : null;
8238
- changed = true;
8289
+ if (wasEditing != Boolean(editing)) {
8290
+ changed = true;
8291
+ }
8239
8292
  if (editing) {
8240
8293
  const parts = EntityUtils.GatherEntity({
8241
8294
  entity: rego.visual
@@ -8254,7 +8307,6 @@ var VisualsRegister;
8254
8307
  }
8255
8308
  }
8256
8309
  else {
8257
- // The geometry almost certainly moved, so what was measured before is worthless.
8258
8310
  VisualRegisterCuller.InvalidateBounds(rego.visual);
8259
8311
  VisualRegisterCuller.MarkShouldRecheck(this.viewer);
8260
8312
  }
@@ -8730,6 +8782,9 @@ var VisualsRegister;
8730
8782
  // Tilesets will often add -> remove -> add because of how tiles load in and out of the scene.
8731
8783
  // To avoid flickering, we'll just replace rather than remove -> add.
8732
8784
  if (!rego.tilesetId && params.removePrior != false) {
8785
+ if (!rego.editing && this.IsEditing({ entityId: rego.entityId, menuItemId: rego.menuItemId })) {
8786
+ rego.editing = true;
8787
+ }
8733
8788
  this.RemoveRegos({
8734
8789
  entityId: rego.entityId,
8735
8790
  menuItemId: rego.menuItemId,
@@ -34757,6 +34812,54 @@ var EntityUtils;
34757
34812
  });
34758
34813
  }
34759
34814
  EntityUtils.GetPosAsync = GetPosAsync;
34815
+ // Graphics that take a heightReference, and so get a cached terrain offset from Cesium.
34816
+ const GROUND_REFERENCED_GRAPHICS = ["ellipse", "polygon", "corridor", "rectangle", "box", "cylinder", "ellipsoid"];
34817
+ const HEIGHT_REFERENCE_KEYS = ["heightReference", "extrudedHeightReference"];
34818
+ /**
34819
+ * Makes a moved graphic sample the ground again at where it now is.
34820
+ *
34821
+ * Reassigning the height references touches an observed property, so the updater discards the stale offset
34822
+ * and builds a new one against the current position.
34823
+ * @returns whether anything was refreshed.
34824
+ */
34825
+ function RefreshGroundClamping(params) {
34826
+ var _a, _b;
34827
+ const { viewer, visual } = params;
34828
+ if (!viewer || ((_a = viewer.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(viewer)) || !(visual instanceof Entity)) {
34829
+ return false;
34830
+ }
34831
+ const parts = GatherEntity({ entity: visual });
34832
+ let refreshed = false;
34833
+ for (let i = 0; i < parts.length; i++) {
34834
+ const part = parts[i];
34835
+ if (!(part instanceof Entity)) {
34836
+ continue;
34837
+ }
34838
+ for (let j = 0; j < GROUND_REFERENCED_GRAPHICS.length; j++) {
34839
+ const graphic = part[GROUND_REFERENCED_GRAPHICS[j]];
34840
+ if (!graphic) {
34841
+ continue;
34842
+ }
34843
+ for (let k = 0; k < HEIGHT_REFERENCE_KEYS.length; k++) {
34844
+ const key = HEIGHT_REFERENCE_KEYS[k];
34845
+ const current = GetValue$1(viewer, graphic[key]);
34846
+ // Nothing to resample for a graphic that does not follow the ground.
34847
+ if (current == null || current === HeightReference.NONE) {
34848
+ continue;
34849
+ }
34850
+ // A new property instance rather than the same value written back, since an equal value would
34851
+ // be dropped as a no-op and the updater would never hear about it.
34852
+ graphic[key] = new ConstantProperty(current);
34853
+ refreshed = true;
34854
+ }
34855
+ }
34856
+ }
34857
+ if (refreshed) {
34858
+ (_b = viewer.scene) === null || _b === void 0 ? void 0 : _b.requestRender();
34859
+ }
34860
+ return refreshed;
34861
+ }
34862
+ EntityUtils.RefreshGroundClamping = RefreshGroundClamping;
34760
34863
  /**
34761
34864
  * Returns entity and any associated parent/sibling entities as a flat array.
34762
34865
  * @param entity
@@ -34947,7 +35050,9 @@ var EntityUtils;
34947
35050
  viewer: params.viewer,
34948
35051
  createIfMissing: true
34949
35052
  });
34950
- const location = await EntityUtils.GetLocation({
35053
+ // A tileset-only fly-to has no entities to sample from, so there's nothing to resolve here.
35054
+ // The tileset's own bounding sphere is used further down instead.
35055
+ const location = (entityIds === null || entityIds === void 0 ? void 0 : entityIds.length) ? await EntityUtils.GetLocation({
34951
35056
  samples: entityIds.map((id) => ({
34952
35057
  entityId: id,
34953
35058
  entity: entityLookup.get(id),
@@ -34958,7 +35063,7 @@ var EntityUtils;
34958
35063
  visualRegister: manager.VisualsRegister,
34959
35064
  minimumAlt: params.minimumAlt,
34960
35065
  api: manager.Getters.GetBruceApi()
34961
- });
35066
+ }) : null;
34962
35067
  if (params.isCancelled && params.isCancelled()) {
34963
35068
  return;
34964
35069
  }
@@ -39695,6 +39800,7 @@ var EntityRenderEngine;
39695
39800
  }
39696
39801
  VisualRegisterCuller.InvalidateBounds(cEntity);
39697
39802
  });
39803
+ VisualRegisterCuller.MarkShouldRecheck(params.viewer);
39698
39804
  return {
39699
39805
  entities: cEntities,
39700
39806
  updated
@@ -40463,7 +40569,7 @@ var StyleUtils;
40463
40569
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
40464
40570
  })(StyleUtils || (StyleUtils = {}));
40465
40571
 
40466
- const VERSION = "7.0.8";
40572
+ const VERSION = "7.1.0";
40467
40573
  /**
40468
40574
  * Updates the environment instance used by bruce-cesium to one specified.
40469
40575
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -40480,5 +40586,5 @@ const getENVIRONMENT = () => {
40480
40586
  return ENVIRONMENT;
40481
40587
  };
40482
40588
 
40483
- 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 };
40589
+ 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 };
40484
40590
  //# sourceMappingURL=bruce-cesium.es5.js.map