bruce-cesium 6.8.8 → 6.8.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, HeightReference, HorizontalOrigin, VerticalOrigin, Cartesian3, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, Math as Math$1, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, ColorBlendMode, Model, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Ion, IonResource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, 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, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, Intersect, CzmlDataSource, Fullscreen } 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, BruceEvent, EntityCoords, Bounds, DataLab, DelayQueue, EntityHistoricData, BruceApi, AccountConcept, RecordChangeFeed, EntityRelation, ProgramKey, EntitySource, Camera, ProjectViewTile, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session, EntityRelationType } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Cartesian3, HeightReference, ClassificationType, PolygonHierarchy, ShadowMode, ConstantPositionProperty, PolylineGraphics, ArcType, CornerType, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, Model, JulianDate, Quaternion, Matrix4, Cartesian2, HorizontalOrigin, VerticalOrigin, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, 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, CesiumInspector, ClockRange, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Bounds, Calculator, EntityTag, EntityType, Geometry, ObjectUtils, Style, Carto, ClientFile, EntityLod, LRUCache, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, Api, DataLab, DelayQueue, EntityHistoricData, BruceApi, EntityRelation, AccountConcept, RecordChangeFeed, 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.
@@ -6340,7 +6340,12 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
6340
6340
  cache.isIsolatedAny = register.GetIsIsolatedAny();
6341
6341
  }
6342
6342
  if (cache.isIsolatedAny) {
6343
- return false;
6343
+ if (cache.isolationOpacity === undefined) {
6344
+ cache.isolationOpacity = register.GetIsolationOpacity();
6345
+ }
6346
+ if (cache.isolationOpacity == null) {
6347
+ return false;
6348
+ }
6344
6349
  }
6345
6350
  }
6346
6351
  // We show all regos in the same highest priority level.
@@ -6394,10 +6399,19 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
6394
6399
  }
6395
6400
  }
6396
6401
  if (refresh === true || (refresh !== false && (refresh === null || refresh === void 0 ? void 0 : refresh.opacity))) {
6397
- if (state.opacity != null && state.opacity != 1) {
6402
+ let effectiveOpacity = state.opacity;
6403
+ if ((effectiveOpacity == null || effectiveOpacity == 1) && !state.isolated && visible) {
6404
+ if (cache.isolationOpacity === undefined) {
6405
+ cache.isolationOpacity = register.GetIsolationOpacity();
6406
+ }
6407
+ if (cache.isolationOpacity != null) {
6408
+ effectiveOpacity = cache.isolationOpacity;
6409
+ }
6410
+ }
6411
+ if (effectiveOpacity != null && effectiveOpacity != 1) {
6398
6412
  EntityUtils.SetOpacity({
6399
6413
  entity: rego.visual,
6400
- opacity: state.opacity,
6414
+ opacity: effectiveOpacity,
6401
6415
  viewer: viewer,
6402
6416
  requestRender: false
6403
6417
  });
@@ -6541,6 +6555,10 @@ var VisualsRegister;
6541
6555
  // Caches GetIsIsolatedAny(). `null` means "unknown, recompute".
6542
6556
  // Invalidated on any write that could affect isolation.
6543
6557
  this.isolatedAnyCache = null;
6558
+ // Caches GetIsolationOpacity(). `undefined` means "unknown, recompute", `null` means
6559
+ // "isolation (if any) is the legacy boolean/full-hide kind, not a numeric dim".
6560
+ // Invalidated alongside isolatedAnyCache.
6561
+ this.isolationOpacityCache = undefined;
6544
6562
  // Lazy OverrideStates() bookkeeping. See cancelLazyOverride()/startLazyOverride().
6545
6563
  this.lazyOverrideToken = 0;
6546
6564
  this.lazyOverrideActive = false;
@@ -6722,12 +6740,12 @@ var VisualsRegister;
6722
6740
  if (!state || isBlankState(state)) {
6723
6741
  return;
6724
6742
  }
6743
+ const updateAll = state.hasOwnProperty("isolated");
6725
6744
  const refresh = {
6726
6745
  highlighted: state.hasOwnProperty("highlighted"),
6727
6746
  selected: state.hasOwnProperty("selected"),
6728
- opacity: state.hasOwnProperty("opacity")
6747
+ opacity: state.hasOwnProperty("opacity") || updateAll
6729
6748
  };
6730
- const updateAll = state.hasOwnProperty("isolated");
6731
6749
  let changed = this.setStateValues(state);
6732
6750
  // Update the related Entity.
6733
6751
  if (changed && update) {
@@ -6785,6 +6803,7 @@ var VisualsRegister;
6785
6803
  const updateRefreshMarkers = (state) => {
6786
6804
  if (state.hasOwnProperty("isolated")) {
6787
6805
  updateAll = true;
6806
+ refreshAccumulated.opacity = true;
6788
6807
  }
6789
6808
  let values = refresh[state.entityId];
6790
6809
  if (!values) {
@@ -6883,6 +6902,7 @@ var VisualsRegister;
6883
6902
  }
6884
6903
  if (keys.includes("isolated")) {
6885
6904
  this.isolatedAnyCache = null;
6905
+ this.isolationOpacityCache = undefined;
6886
6906
  }
6887
6907
  let changed = false;
6888
6908
  const eStates = this.states[entityId] || {};
@@ -7720,18 +7740,28 @@ var VisualsRegister;
7720
7740
  SetIsolated(params) {
7721
7741
  var _a;
7722
7742
  const { entityIds, isolated: isolate, requestRender, menuItemId, source, doUpdate } = params;
7743
+ let isolatedValue;
7744
+ if (isolate === true) {
7745
+ isolatedValue = true;
7746
+ }
7747
+ else if (typeof isolate === "number" && !isNaN(isolate)) {
7748
+ isolatedValue = Math.max(0, Math.min(1, isolate));
7749
+ }
7750
+ else {
7751
+ isolatedValue = null;
7752
+ }
7723
7753
  for (let i = 0; i < entityIds.length; i++) {
7724
7754
  const entityId = entityIds[i];
7725
7755
  this.setStateValues({
7726
7756
  entityId: entityId,
7727
7757
  menuItemId: menuItemId,
7728
7758
  // Null means it will be deleted from the object.
7729
- isolated: isolate ? true : null
7759
+ isolated: isolatedValue
7730
7760
  });
7731
7761
  const update = {
7732
7762
  entityId: entityId,
7733
7763
  type: EVisualUpdateType.Update,
7734
- isolated: isolate
7764
+ isolated: isolatedValue
7735
7765
  };
7736
7766
  if (source) {
7737
7767
  update.source = source;
@@ -7741,9 +7771,12 @@ var VisualsRegister;
7741
7771
  }
7742
7772
  }
7743
7773
  if (doUpdate !== false) {
7774
+ // Always a full refresh (not just when isolating): un-isolating these entities can
7775
+ // change opacity for every other entity too, eg: if this was the last isolated
7776
+ // entity, everyone else needs to revert from a numeric dim back to full opacity.
7744
7777
  this.updateAllEntities({
7745
7778
  requestRender: false,
7746
- refresh: isolate
7779
+ refresh: true
7747
7780
  });
7748
7781
  if (requestRender != false) {
7749
7782
  this.viewer.scene.requestRender();
@@ -7756,7 +7789,9 @@ var VisualsRegister;
7756
7789
  entityId: id,
7757
7790
  menuItemId: menuItemId
7758
7791
  });
7759
- return state.isolated === true;
7792
+ // Truthy check (not strict `=== true`) so a numeric isolate value (see
7793
+ // GetIsolationOpacity()) still counts as "this entity is isolated".
7794
+ return Boolean(state.isolated);
7760
7795
  }
7761
7796
  GetIsIsolatedAny() {
7762
7797
  if (this.isolatedAnyCache == null) {
@@ -7764,6 +7799,36 @@ var VisualsRegister;
7764
7799
  }
7765
7800
  return this.isolatedAnyCache;
7766
7801
  }
7802
+ /**
7803
+ * Returns the opacity that should be applied to non-isolated entities while isolation is
7804
+ * active, or null if isolation (if any) is the legacy boolean kind.
7805
+ */
7806
+ GetIsolationOpacity() {
7807
+ if (this.isolationOpacityCache !== undefined) {
7808
+ return this.isolationOpacityCache;
7809
+ }
7810
+ let sawBooleanIsolate = false;
7811
+ let minOpacity = null;
7812
+ for (const entityStates of Object.values(this.states)) {
7813
+ if (!entityStates) {
7814
+ continue;
7815
+ }
7816
+ for (const item of Object.values(entityStates)) {
7817
+ const isolated = item === null || item === void 0 ? void 0 : item.isolated;
7818
+ if (isolated === true) {
7819
+ sawBooleanIsolate = true;
7820
+ }
7821
+ else if (typeof isolated === "number" && !isNaN(isolated)) {
7822
+ const clamped = Math.max(0, Math.min(1, isolated));
7823
+ if (minOpacity == null || clamped < minOpacity) {
7824
+ minOpacity = clamped;
7825
+ }
7826
+ }
7827
+ }
7828
+ }
7829
+ this.isolationOpacityCache = sawBooleanIsolate ? null : minOpacity;
7830
+ return this.isolationOpacityCache;
7831
+ }
7767
7832
  /**
7768
7833
  * Returns all isolated entity ids, without regard to menu item id.
7769
7834
  * @returns
@@ -7790,6 +7855,7 @@ var VisualsRegister;
7790
7855
  if (changed) {
7791
7856
  // Mutated `isolated` directly rather than through setStateValues().
7792
7857
  this.isolatedAnyCache = false;
7858
+ this.isolationOpacityCache = null;
7793
7859
  }
7794
7860
  if (changed && (params === null || params === void 0 ? void 0 : params.doUpdate) !== false) {
7795
7861
  this.updateAllEntities({
@@ -37568,7 +37634,7 @@ var StyleUtils;
37568
37634
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
37569
37635
  })(StyleUtils || (StyleUtils = {}));
37570
37636
 
37571
- const VERSION = "6.8.8";
37637
+ const VERSION = "6.8.9";
37572
37638
  /**
37573
37639
  * Updates the environment instance used by bruce-cesium to one specified.
37574
37640
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.