bruce-cesium 7.6.7 → 7.6.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, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, JulianDate, Quaternion, HeadingPitchRoll, HeightReference, ConstantPositionProperty, DistanceDisplayCondition, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ArcType, CornerType, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, FeatureDetection, Matrix3, NearFarScalar, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CustomDataSource, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, UrlUtils, Api, Carto, Geometry as Geometry$1, Bounds, ClientFileValueMap, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, AccountConcept, BruceApi, EntityRelation, RecordChangeFeed, Camera, ProgramKey, ProjectViewLegacyTile, EntitySource, Account, AccountLimits, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, ProjectViewBookmarkGroup, EntityRelationType, EntityHistoricData } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, HeightReference, Matrix4, ConstantPositionProperty, DistanceDisplayCondition, ShaderSource, Ellipsoid, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, HorizontalOrigin, VerticalOrigin, ClassificationType, ColorBlendMode, ShadowMode, Model, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, FeatureDetection, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, Intersect, Cesium3DTileset, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CustomDataSource, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Api, Calculator, ClientFile, Entity as Entity$1, EntityTag, EntityType, ObjectUtils, Style, EntityLod, UrlUtils, Bounds, ClientFileValueMap, Color as Color$1, Geometry as Geometry$1, Carto, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, AccountConcept, RecordChangeFeed, EntityRelation, BruceApi, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, ProjectViewBookmarkGroup, EntityRelationType, EntityHistoricData } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -16555,18 +16555,70 @@ var MenuItemStyleOverlay;
16555
16555
  }
16556
16556
  MenuItemStyleOverlay.With = With;
16557
16557
  /**
16558
- * Returns true when the two items differ by nothing but their overlay.
16558
+ * Returns the style a bookmark laid on this one item, or null when it carries none.
16559
+ */
16560
+ function GetItemStyle(item) {
16561
+ var _a, _b;
16562
+ return (_b = (_a = item === null || item === void 0 ? void 0 : item.style) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : null;
16563
+ }
16564
+ MenuItemStyleOverlay.GetItemStyle = GetItemStyle;
16565
+ /**
16566
+ * Returns the Style record a bookmark laid on this one item, or null when it names none.
16567
+ */
16568
+ function GetItemStyleId(item) {
16569
+ var _a;
16570
+ const styleId = (_a = item === null || item === void 0 ? void 0 : item.style) === null || _a === void 0 ? void 0 : _a.styleId;
16571
+ return styleId == null || styleId === "" || styleId == -1 ? null : styleId;
16572
+ }
16573
+ MenuItemStyleOverlay.GetItemStyleId = GetItemStyleId;
16574
+ /**
16575
+ * Returns a copy carrying the given bookmark style, inline or by record, or without one for null.
16576
+ */
16577
+ function WithItemStyle(item, itemStyle) {
16578
+ const has = Boolean(itemStyle === null || itemStyle === void 0 ? void 0 : itemStyle.style) || (itemStyle === null || itemStyle === void 0 ? void 0 : itemStyle.styleId) != null;
16579
+ if (!item || (!has && !item.style)) {
16580
+ return item;
16581
+ }
16582
+ const next = { ...item };
16583
+ if (has) {
16584
+ next.style = { ...itemStyle };
16585
+ }
16586
+ else {
16587
+ delete next.style;
16588
+ }
16589
+ return next;
16590
+ }
16591
+ MenuItemStyleOverlay.WithItemStyle = WithItemStyle;
16592
+ /**
16593
+ * Returns the overlay an item renders with: its inline or loaded bookmark style, under the scene-wide one.
16594
+ */
16595
+ function Effective(item, overlay, record) {
16596
+ var _a, _b;
16597
+ const own = (_b = (_a = GetItemStyle(item)) !== null && _a !== void 0 ? _a : record) !== null && _b !== void 0 ? _b : null;
16598
+ // Either alone is used as it is, so an unchanged overlay still compares equal.
16599
+ return own ? Merge(own, overlay) : overlay;
16600
+ }
16601
+ MenuItemStyleOverlay.Effective = Effective;
16602
+ /**
16603
+ * Returns a copy without its overlay or bookmark style, so what else two items differ by can be compared.
16604
+ */
16605
+ function Strip(item) {
16606
+ return With(WithItemStyle(item, null), null);
16607
+ }
16608
+ MenuItemStyleOverlay.Strip = Strip;
16609
+ /**
16610
+ * Returns true when the two items differ by nothing but their overlay or bookmark style.
16559
16611
  */
16560
16612
  function IsChangeOnly(from, to) {
16561
16613
  if (!from || !to || from.Type !== to.Type) {
16562
16614
  return false;
16563
16615
  }
16564
- const toOverlay = Get(to);
16565
- if (JSON.stringify(Get(from)) === JSON.stringify(toOverlay)) {
16616
+ const sameOverlay = JSON.stringify(Get(from)) === JSON.stringify(Get(to));
16617
+ if (sameOverlay && JSON.stringify(from.style) === JSON.stringify(to.style)) {
16566
16618
  return false;
16567
16619
  }
16568
- // A false mismatch only costs the in-place swap, so key order is not normalized.
16569
- return JSON.stringify(With(from, toOverlay)) === JSON.stringify(to);
16620
+ // Removing keys keeps the order of the rest, so the two compare as text.
16621
+ return JSON.stringify(Strip(from)) === JSON.stringify(Strip(to));
16570
16622
  }
16571
16623
  MenuItemStyleOverlay.IsChangeOnly = IsChangeOnly;
16572
16624
  /*
@@ -20684,6 +20736,8 @@ class TilesetStyler {
20684
20736
  this.fallbackStyle = null;
20685
20737
  // Laid over whichever style each feature resolves, so it only changes the fields it sets.
20686
20738
  this.styleOverlay = null;
20739
+ // The tileset's blend before an overlay's colours replaced it, put back once no overlay colours it.
20740
+ this.blendBeforeOverlay = null;
20687
20741
  this.styleFallbackLoaded = false;
20688
20742
  this.loadingCounter = 0;
20689
20743
  // Entity IDs -> boolean to indicate if we should override the feature colour.
@@ -20742,7 +20796,12 @@ class TilesetStyler {
20742
20796
  this.monitor = monitor;
20743
20797
  this.viewer = viewer;
20744
20798
  this.api = api;
20799
+ // A tileset handed in fresh still has its own blend, so nothing is left to put back on it.
20800
+ if (cTileset !== this.cTileset) {
20801
+ this.blendBeforeOverlay = null;
20802
+ }
20745
20803
  this.cTileset = cTileset;
20804
+ this.applyOverlayBlend();
20746
20805
  this.bakedAttributes = getBakedAttributes(cTileset);
20747
20806
  this.register = register;
20748
20807
  this.menuItemId = menuItemId;
@@ -20874,6 +20933,7 @@ class TilesetStyler {
20874
20933
  // Left as it is when a caller omits it, so a mapping change keeps the scene-wide style.
20875
20934
  if (params.styleOverlay !== undefined) {
20876
20935
  this.styleOverlay = params.styleOverlay;
20936
+ this.applyOverlayBlend();
20877
20937
  }
20878
20938
  if (params.scenario != null) {
20879
20939
  if (!this.shouldUpdateRegoStates && !!this.scenario) {
@@ -20963,6 +21023,25 @@ class TilesetStyler {
20963
21023
  }
20964
21024
  this.queueTilesetFeatureStyle(regos, highPriority);
20965
21025
  }
21026
+ /*
21027
+ * Replaces the tileset's own colours while an overlay sets a model fill, so features show exactly what it maps to.
21028
+ */
21029
+ applyOverlayBlend() {
21030
+ var _a, _b, _c, _d;
21031
+ if (!this.cTileset || ((_b = (_a = this.cTileset).isDestroyed) === null || _b === void 0 ? void 0 : _b.call(_a))) {
21032
+ return;
21033
+ }
21034
+ const fill = (_d = (_c = this.styleOverlay) === null || _c === void 0 ? void 0 : _c.modelStyle) === null || _d === void 0 ? void 0 : _d.fillColor;
21035
+ const colours = Array.isArray(fill) ? fill.length > 0 : fill != null;
21036
+ if (colours && this.blendBeforeOverlay == null) {
21037
+ this.blendBeforeOverlay = this.cTileset.colorBlendMode;
21038
+ this.cTileset.colorBlendMode = Cesium3DTileColorBlendMode.REPLACE;
21039
+ }
21040
+ else if (!colours && this.blendBeforeOverlay != null) {
21041
+ this.cTileset.colorBlendMode = this.blendBeforeOverlay;
21042
+ this.blendBeforeOverlay = null;
21043
+ }
21044
+ }
20966
21045
  /**
20967
21046
  * Calculates the current progress % and updates the progress if there is a change.
20968
21047
  */
@@ -32066,17 +32145,21 @@ var MenuItemStyles;
32066
32145
  }
32067
32146
  MenuItemStyles.Resolve = Resolve;
32068
32147
  /**
32069
- * Returns a copy on the style a bookmark alternation picked, or the item itself when that is not an option.
32148
+ * Returns a copy on the style a bookmark alternation picked and carrying any style it laid on the item.
32070
32149
  */
32071
32150
  function ApplyAlternation(item, alternation) {
32072
32151
  var _a, _b, _c;
32073
32152
  // Alternations are partial items and may carry no Type, so the pick is read from whichever field is present.
32074
32153
  const alt = alternation;
32075
32154
  const picked = (_a = alt === null || alt === void 0 ? void 0 : alt.styleId) !== null && _a !== void 0 ? _a : (_b = getVisibleRow(alt === null || alt === void 0 ? void 0 : alt.CameraZoomSettings)) === null || _b === void 0 ? void 0 : _b.StyleID;
32076
- if (picked == null) {
32077
- return item;
32155
+ const next = picked == null ? item : ((_c = WithStyleId(item, picked)) !== null && _c !== void 0 ? _c : item);
32156
+ // A style laid by record need not be one of the item's own, unlike the pick.
32157
+ const itemStyle = alternation === null || alternation === void 0 ? void 0 : alternation.style;
32158
+ const laid = MenuItemStyleOverlay.GetItemStyle(alternation) || MenuItemStyleOverlay.GetItemStyleId(alternation);
32159
+ if (laid == null) {
32160
+ return next;
32078
32161
  }
32079
- return (_c = WithStyleId(item, picked)) !== null && _c !== void 0 ? _c : item;
32162
+ return MenuItemStyleOverlay.WithItemStyle(next, itemStyle);
32080
32163
  }
32081
32164
  MenuItemStyles.ApplyAlternation = ApplyAlternation;
32082
32165
  /**
@@ -32372,6 +32455,9 @@ var MenuItemManager;
32372
32455
  // Laid over each item's own style where it can take one, including items rendered after it was set.
32373
32456
  this.styleOverlay = null;
32374
32457
  this.styleOverlayCounter = 0;
32458
+ // Style records bookmark styles name by ID, loaded once each; null for one that failed to load.
32459
+ this.itemStyleRecords = new Map();
32460
+ this.itemStyleRecordsLoading = new Set();
32375
32461
  this.onUpdate = null;
32376
32462
  // Segments discovered so far per menu item ID.
32377
32463
  this.seriesSegments = new Map();
@@ -32454,14 +32540,15 @@ var MenuItemManager;
32454
32540
  // An item with a style set renders its first style unless the caller already picked one of them.
32455
32541
  params = { ...params, item: MenuItemStyles.Resolve(params.item) };
32456
32542
  // The overlay rides on the rendered copy, so the view's item never carries it.
32457
- params = { ...params, item: MenuItemStyleOverlay.With(params.item, this.styleOverlay) };
32543
+ const effective = this.getEffectiveOverlay(params.item, this.styleOverlay);
32544
+ params = { ...params, item: MenuItemStyleOverlay.With(params.item, effective) };
32458
32545
  let rItem = this.items.find(x => x.id == params.item.id);
32459
32546
  let create = true;
32460
32547
  // Item already exists so we'll check if we should re-create it.
32461
32548
  if (rItem) {
32462
- // Only the style pick or overlay changed, so the drawn graphics are restyled, not rebuilt.
32463
- const aligned = MenuItemStyleOverlay.With(rItem.item, MenuItemStyleOverlay.Get(params.item));
32464
- const pickOnly = MenuItemStyles.IsStyleChangeOnly(aligned, params.item);
32549
+ // Only the style pick, overlay or bookmark style changed, so the graphics are restyled, not rebuilt.
32550
+ const stripped = MenuItemStyleOverlay.Strip(params.item);
32551
+ const pickOnly = MenuItemStyles.IsStyleChangeOnly(MenuItemStyleOverlay.Strip(rItem.item), stripped);
32465
32552
  const restyleOnly = pickOnly || MenuItemStyleOverlay.IsChangeOnly(rItem.item, params.item);
32466
32553
  if (restyleOnly && this.isStyleSwapCapable(rItem.renderManager)) {
32467
32554
  rItem.renderManager.SwapStyle(params.item);
@@ -32901,10 +32988,13 @@ var MenuItemManager;
32901
32988
  if (!rItem || !this.isStyleSwapCapable(rItem.renderManager) || rItem.renderManager.Disposed) {
32902
32989
  return false;
32903
32990
  }
32904
- const next = MenuItemStyles.WithStyleId(rItem.item, styleId);
32905
- if (!next) {
32991
+ const picked = MenuItemStyles.WithStyleId(rItem.item, styleId);
32992
+ if (!picked) {
32906
32993
  return false;
32907
32994
  }
32995
+ // A Style record a bookmark laid is drawn over the pick, so picking one of the item's own takes it off.
32996
+ const chosen = MenuItemStyleOverlay.WithItemStyle(picked, null);
32997
+ const next = MenuItemStyleOverlay.With(chosen, this.getEffectiveOverlay(chosen, this.styleOverlay));
32908
32998
  rItem.renderManager.SwapStyle(next);
32909
32999
  rItem.item = next;
32910
33000
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
@@ -32936,7 +33026,7 @@ var MenuItemManager;
32936
33026
  }
32937
33027
  this.styleOverlay = overlay;
32938
33028
  for (const rItem of this.items) {
32939
- const next = MenuItemStyleOverlay.With(rItem.item, overlay);
33029
+ const next = MenuItemStyleOverlay.With(rItem.item, this.getEffectiveOverlay(rItem.item, overlay));
32940
33030
  // Setting the same overlay again would otherwise restyle every feature for nothing.
32941
33031
  const unchanged = JSON.stringify(MenuItemStyleOverlay.Get(next)) === JSON.stringify(MenuItemStyleOverlay.Get(rItem.item));
32942
33032
  if (unchanged ||
@@ -32949,6 +33039,81 @@ var MenuItemManager;
32949
33039
  (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: true, itemId: rItem.id });
32950
33040
  }
32951
33041
  }
33042
+ /**
33043
+ * Lays an inline style or any Style record on one enabled item under the scene-wide one; neither clears it.
33044
+ */
33045
+ SetItemStyleOverlay(params) {
33046
+ var _a;
33047
+ const rItem = this.items.find(x => x.id === params.menuItemId);
33048
+ let itemStyle = null;
33049
+ if (params.style) {
33050
+ itemStyle = { style: params.style };
33051
+ }
33052
+ else if (params.styleId != null) {
33053
+ itemStyle = { styleId: params.styleId };
33054
+ }
33055
+ if (!rItem ||
33056
+ !this.isStyleSwapCapable(rItem.renderManager) ||
33057
+ rItem.renderManager.Disposed ||
33058
+ (itemStyle && !MenuItemStyleOverlay.Supports(rItem.item))) {
33059
+ return false;
33060
+ }
33061
+ const styled = MenuItemStyleOverlay.WithItemStyle(rItem.item, itemStyle);
33062
+ const next = MenuItemStyleOverlay.With(styled, this.getEffectiveOverlay(styled, this.styleOverlay));
33063
+ rItem.renderManager.SwapStyle(next);
33064
+ rItem.item = next;
33065
+ (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
33066
+ return true;
33067
+ }
33068
+ /*
33069
+ * Returns the overlay the item renders with, starting the load of a record it names that is not loaded yet.
33070
+ */
33071
+ getEffectiveOverlay(item, overlay) {
33072
+ const styleId = MenuItemStyleOverlay.GetItemStyle(item) ? null : MenuItemStyleOverlay.GetItemStyleId(item);
33073
+ if (styleId != null && !this.itemStyleRecords.has(String(styleId))) {
33074
+ this.loadItemStyleRecord(styleId);
33075
+ }
33076
+ const record = styleId != null ? this.itemStyleRecords.get(String(styleId)) : null;
33077
+ return MenuItemStyleOverlay.Effective(item, overlay, record !== null && record !== void 0 ? record : undefined);
33078
+ }
33079
+ /*
33080
+ * Loads a record a bookmark style names, then restyles every enabled item that names it.
33081
+ */
33082
+ async loadItemStyleRecord(styleId) {
33083
+ var _a, _b;
33084
+ const key = String(styleId);
33085
+ if (this.itemStyleRecordsLoading.has(key)) {
33086
+ return;
33087
+ }
33088
+ this.itemStyleRecordsLoading.add(key);
33089
+ let settings = null;
33090
+ // A record that fails to load leaves the item on its own style.
33091
+ try {
33092
+ const { style } = await Style.Get({
33093
+ api: this.getters.GetBruceApi(),
33094
+ styleId
33095
+ });
33096
+ settings = (_a = style === null || style === void 0 ? void 0 : style.Settings) !== null && _a !== void 0 ? _a : null;
33097
+ }
33098
+ catch (e) {
33099
+ console.error(e);
33100
+ }
33101
+ this.itemStyleRecordsLoading.delete(key);
33102
+ this.itemStyleRecords.set(key, settings);
33103
+ for (const rItem of this.items) {
33104
+ if (String(MenuItemStyleOverlay.GetItemStyleId(rItem.item)) !== key ||
33105
+ MenuItemStyleOverlay.GetItemStyle(rItem.item) ||
33106
+ !this.isStyleSwapCapable(rItem.renderManager) ||
33107
+ rItem.renderManager.Disposed) {
33108
+ continue;
33109
+ }
33110
+ const effective = this.getEffectiveOverlay(rItem.item, this.styleOverlay);
33111
+ const next = MenuItemStyleOverlay.With(rItem.item, effective);
33112
+ rItem.renderManager.SwapStyle(next);
33113
+ rItem.item = next;
33114
+ (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: true, itemId: rItem.id });
33115
+ }
33116
+ }
32952
33117
  /*
32953
33118
  * Picks the child the caller asked for, else the one already enabled, else the first.
32954
33119
  */
@@ -56523,7 +56688,7 @@ var StyleUtils;
56523
56688
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
56524
56689
  })(StyleUtils || (StyleUtils = {}));
56525
56690
 
56526
- const VERSION = "7.6.7";
56691
+ const VERSION = "7.6.9";
56527
56692
  /**
56528
56693
  * Updates the environment instance used by bruce-cesium to one specified.
56529
56694
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.