bruce-cesium 7.0.4 → 7.0.5

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, Entity, Color, HeightReference, CallbackProperty, HorizontalOrigin, VerticalOrigin, ConstantProperty, Cartesian3, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, Model, ColorMaterialProperty, Primitive, Cesium3DTileFeature, Cartesian2, DistanceDisplayCondition, SceneTransforms, NearFarScalar, JulianDate, Quaternion, Matrix3, Rectangle, KmlDataSource, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, GeoJsonDataSource, SceneMode, Ion, IonResource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Matrix4, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, Cesium3DTileset, CesiumInspector, ClockRange, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CustomDataSource, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
3
- import { Cartes, Entity as Entity$1, ENVIRONMENT, Api, Calculator, ClientFile, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Carto, Geometry, EntityLod, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, Bounds, Color as Color$1, DataLab, DelayQueue, BruceEvent, EntityRelation, BruceApi, EntityHistoricData, ProgramKey, EntitySource, EntityCoords, Camera, ProjectViewTile, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session, AccountConcept, RecordChangeFeed, 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, HorizontalOrigin, VerticalOrigin, ClassificationType, ConstantPositionProperty, ImageMaterialProperty, PolygonHierarchy, ShadowMode, PolylineGraphics, ArcType, CornerType, ColorBlendMode, Model, SceneTransforms, NearFarScalar, Cartesian2, 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, OrthographicFrustum, EasingFunction, Cesium3DTileset, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CustomDataSource, BoundingSphere, GeometryInstance, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Api, Calculator, ClientFile, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Bounds, Color as Color$1, Geometry, EntityLod, Carto, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, AccountConcept, RecordChangeFeed, EntityRelation, BruceApi, 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.
@@ -6089,7 +6089,17 @@ function getValue$1(viewer, obj) {
6089
6089
  * Cesium's own flat ellipsoid. Deliberately not FlatTerrain, see shouldCullEntity.
6090
6090
  */
6091
6091
  const UNRECOGNISED_TERRAIN_ID = "unrecognised-terrain";
6092
+ // Keyed by entity id alone. A cached sphere is only as good as the geometry it was measured from, so anything
6093
+ // changing that geometry has to call InvalidateBounds, see it for why nothing can be inferred instead.
6092
6094
  const boundingSphereCache = new LRUCache(100000);
6095
+ /*
6096
+ * Forgets what is known about an entity's extent, so the next check measures it again.
6097
+ */
6098
+ function invalidateBounds(entityIds) {
6099
+ for (let i = 0; i < entityIds.length; i++) {
6100
+ boundingSphereCache.Delete(entityIds[i]);
6101
+ }
6102
+ }
6093
6103
  function getPositionsFromEntity(viewer, entity) {
6094
6104
  let positions = [];
6095
6105
  let heightRef;
@@ -6207,9 +6217,10 @@ function shouldCullEntity(viewer, cEntity) {
6207
6217
  const terrainId = (_c = (_b = (_a = ViewUtils.GatherTerrainTile({
6208
6218
  viewer
6209
6219
  })) === null || _a === void 0 ? void 0 : _a.terrain) === null || _b === void 0 ? void 0 : _b.tilesetId) !== null && _c !== void 0 ? _c : UNRECOGNISED_TERRAIN_ID;
6210
- const cacheKey = terrainId + cEntity.id;
6220
+ const cacheKey = cEntity.id;
6211
6221
  const cacheData = boundingSphereCache.Get(cacheKey);
6212
- if (cacheData) {
6222
+ // A sphere measured under different terrain cannot be reused, since the height treatment differs.
6223
+ if (cacheData && (cacheData == -1 || cacheData.terrainId == terrainId)) {
6213
6224
  boundingSphere = cacheData;
6214
6225
  }
6215
6226
  else {
@@ -6265,7 +6276,8 @@ function shouldCullEntity(viewer, cEntity) {
6265
6276
  }
6266
6277
  boundingSphere = {
6267
6278
  heightRef: positions.heightRef,
6268
- sphere: sphere
6279
+ sphere: sphere,
6280
+ terrainId: terrainId
6269
6281
  };
6270
6282
  if (!doNotCache) {
6271
6283
  boundingSphereCache.Set(cacheKey, boundingSphere);
@@ -6360,6 +6372,8 @@ function isCullingIgnored(viewer, rego) {
6360
6372
  rego.relation != null ||
6361
6373
  // Explicitly being either shown or hidden.
6362
6374
  rego.overrideShow != null ||
6375
+ // Being dragged around right now, so its extent is changing faster than we could measure it.
6376
+ rego.editing == true ||
6363
6377
  // Part of a collection we did not create, eg. a geojson data source, which may have its own rules for
6364
6378
  // what is in the scene. Our own per-menu-item data sources are fair game.
6365
6379
  (rego.collection && !IsCCollectionOwned(rego.collection)) ||
@@ -6648,6 +6662,38 @@ var VisualRegisterCuller;
6648
6662
  return isCullingIgnored(viewer, rego);
6649
6663
  }
6650
6664
  VisualRegisterCuller.IsCullingIgnored = IsCullingIgnored;
6665
+ /**
6666
+ * Discards what the culler knows about an entity's extent, so its next check measures the geometry again.
6667
+ * @param visuals an entity, an entity id, or an array of either.
6668
+ */
6669
+ function InvalidateBounds(visuals) {
6670
+ const list = Array.isArray(visuals) ? visuals : [visuals];
6671
+ const ids = [];
6672
+ for (let i = 0; i < list.length; i++) {
6673
+ const item = list[i];
6674
+ if (!item) {
6675
+ continue;
6676
+ }
6677
+ if (typeof item == "string") {
6678
+ ids.push(item);
6679
+ continue;
6680
+ }
6681
+ const parts = EntityUtils.GatherEntity({
6682
+ entity: item
6683
+ });
6684
+ for (let j = 0; j < parts.length; j++) {
6685
+ const part = parts[j];
6686
+ if (!(part instanceof Entity)) {
6687
+ continue;
6688
+ }
6689
+ ids.push(part.id);
6690
+ // The per-entity answer is derived from the sphere, so it goes stale with it.
6691
+ delete part[VisualRegisterCuller.VISUAL_CULL_KEY];
6692
+ }
6693
+ }
6694
+ invalidateBounds(ids);
6695
+ }
6696
+ VisualRegisterCuller.InvalidateBounds = InvalidateBounds;
6651
6697
  function IsCulled(viewer, rego, visual) {
6652
6698
  if (isCullingIgnored(viewer, rego)) {
6653
6699
  return false;
@@ -8118,6 +8164,58 @@ var VisualsRegister;
8118
8164
  CesiumEntityStyler.UpdateColorSetting("highlight", color);
8119
8165
  }
8120
8166
  }
8167
+ /**
8168
+ * Marks visuals as being actively edited, which exempts them from culling until it is turned back off.
8169
+ */
8170
+ SetEditing(params) {
8171
+ var _a, _b;
8172
+ const { entityIds, editing, menuItemId, requestRender } = params;
8173
+ if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
8174
+ return;
8175
+ }
8176
+ let changed = false;
8177
+ for (let i = 0; i < entityIds.length; i++) {
8178
+ const regos = this.rego[entityIds[i]];
8179
+ if (!regos) {
8180
+ continue;
8181
+ }
8182
+ for (let j = 0; j < regos.length; j++) {
8183
+ const rego = regos[j];
8184
+ if (menuItemId && rego.menuItemId !== menuItemId) {
8185
+ continue;
8186
+ }
8187
+ if (Boolean(rego.editing) == Boolean(editing)) {
8188
+ continue;
8189
+ }
8190
+ // Null rather than false, so the rego does not carry a key for every visual ever edited.
8191
+ rego.editing = editing ? true : null;
8192
+ changed = true;
8193
+ if (editing) {
8194
+ const parts = EntityUtils.GatherEntity({
8195
+ entity: rego.visual
8196
+ });
8197
+ for (let k = 0; k < parts.length; k++) {
8198
+ const part = parts[k];
8199
+ if (!(part instanceof Entity)) {
8200
+ continue;
8201
+ }
8202
+ const wasCulled = part[VisualRegisterCuller.VISUAL_CULL_KEY];
8203
+ delete part[VisualRegisterCuller.VISUAL_CULL_KEY];
8204
+ if (wasCulled && !IsCEntityInScene(this.viewer, part)) {
8205
+ AddCEntityToScene(this.viewer, part, rego.collection);
8206
+ }
8207
+ }
8208
+ }
8209
+ else {
8210
+ // The geometry almost certainly moved, so what was measured before is worthless.
8211
+ VisualRegisterCuller.InvalidateBounds(rego.visual);
8212
+ }
8213
+ }
8214
+ }
8215
+ if (changed && requestRender != false) {
8216
+ (_b = (_a = this.viewer) === null || _a === void 0 ? void 0 : _a.scene) === null || _b === void 0 ? void 0 : _b.requestRender();
8217
+ }
8218
+ }
8121
8219
  SetSelected(params) {
8122
8220
  var _a;
8123
8221
  let { entityIds, selected, refreshIfSelected, requestRender, menuItemId, source } = params;
@@ -39547,6 +39645,7 @@ var EntityRenderEngine;
39547
39645
  if (bandCheck) {
39548
39646
  cEntity._bandCheck = bandCheck;
39549
39647
  }
39648
+ VisualRegisterCuller.InvalidateBounds(cEntity);
39550
39649
  });
39551
39650
  return {
39552
39651
  entities: cEntities,
@@ -40316,7 +40415,7 @@ var StyleUtils;
40316
40415
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
40317
40416
  })(StyleUtils || (StyleUtils = {}));
40318
40417
 
40319
- const VERSION = "7.0.4";
40418
+ const VERSION = "7.0.5";
40320
40419
  /**
40321
40420
  * Updates the environment instance used by bruce-cesium to one specified.
40322
40421
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.