bruce-cesium 7.9.2 → 7.9.3

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.
Files changed (36) hide show
  1. package/dist/bruce-cesium.es5.js +198 -65
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +196 -63
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +1 -1
  6. package/dist/lib/rendering/displaced-surface-primitive.js +17 -0
  7. package/dist/lib/rendering/displaced-surface-primitive.js.map +1 -1
  8. package/dist/lib/rendering/entity-render-engine-model3d.js +10 -10
  9. package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -1
  10. package/dist/lib/rendering/entity-render-engine-point.js +6 -6
  11. package/dist/lib/rendering/entity-render-engine-point.js.map +1 -1
  12. package/dist/lib/rendering/entity-render-engine-polygon.js +30 -12
  13. package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
  14. package/dist/lib/rendering/entity-render-engine-polyline.js +4 -4
  15. package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -1
  16. package/dist/lib/rendering/menu-item-manager.js +16 -2
  17. package/dist/lib/rendering/menu-item-manager.js.map +1 -1
  18. package/dist/lib/rendering/menu-item-style-overlay.js +51 -11
  19. package/dist/lib/rendering/menu-item-style-overlay.js.map +1 -1
  20. package/dist/lib/rendering/menu-item-styles.js +9 -1
  21. package/dist/lib/rendering/menu-item-styles.js.map +1 -1
  22. package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js +1 -1
  23. package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js.map +1 -1
  24. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +1 -1
  25. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
  26. package/dist/lib/rendering/tileset-styler.js +14 -9
  27. package/dist/lib/rendering/tileset-styler.js.map +1 -1
  28. package/dist/lib/rendering/visuals-register.js +36 -5
  29. package/dist/lib/rendering/visuals-register.js.map +1 -1
  30. package/dist/types/bruce-cesium.d.ts +1 -1
  31. package/dist/types/rendering/displaced-surface-primitive.d.ts +6 -2
  32. package/dist/types/rendering/menu-item-manager.d.ts +1 -0
  33. package/dist/types/rendering/menu-item-style-overlay.d.ts +22 -4
  34. package/dist/types/rendering/tileset-styler.d.ts +1 -0
  35. package/dist/types/rendering/visuals-register.d.ts +11 -0
  36. package/package.json +1 -1
@@ -14288,7 +14288,7 @@ void main()
14288
14288
  }
14289
14289
  }
14290
14290
  function updateEntity(viewer, entityId, register, refresh, cache = {}) {
14291
- var _a, _b, _c;
14291
+ var _a, _b, _c, _d;
14292
14292
  if (!entityId) {
14293
14293
  // What are we doing?
14294
14294
  return;
@@ -14375,7 +14375,8 @@ void main()
14375
14375
  }
14376
14376
  }
14377
14377
  if (refresh === true || (refresh !== false && (refresh === null || refresh === void 0 ? void 0 : refresh.opacity))) {
14378
- let effectiveOpacity = state.opacity;
14378
+ // An Entity's own opacity wins over the one its menu item's bookmark style asks for.
14379
+ let effectiveOpacity = (_b = state.opacity) !== null && _b !== void 0 ? _b : register.GetMenuItemOpacity(rego.menuItemId);
14379
14380
  if ((effectiveOpacity == null || effectiveOpacity == 1) && !state.isolated && visible) {
14380
14381
  if (cache.isolationOpacity === undefined) {
14381
14382
  cache.isolationOpacity = register.GetIsolationOpacity();
@@ -14406,14 +14407,14 @@ void main()
14406
14407
  exports.EntityLabel.Attach({
14407
14408
  rego,
14408
14409
  viewer,
14409
- api: (_b = register.ApiGetters) === null || _b === void 0 ? void 0 : _b.GetBruceApi(),
14410
+ api: (_c = register.ApiGetters) === null || _c === void 0 ? void 0 : _c.GetBruceApi(),
14410
14411
  visualRegister: register,
14411
14412
  options: labelGroup ? labelGroup.options : register.GetLabelDefaults(),
14412
14413
  groupId: labelGroup === null || labelGroup === void 0 ? void 0 : labelGroup.groupId,
14413
14414
  persistent: true
14414
14415
  });
14415
14416
  }
14416
- else if (!visible || ((_c = exports.EntityLabel.GetLabel({ rego })) === null || _c === void 0 ? void 0 : _c.Persistent)) {
14417
+ else if (!visible || ((_d = exports.EntityLabel.GetLabel({ rego })) === null || _d === void 0 ? void 0 : _d.Persistent)) {
14417
14418
  exports.EntityLabel.Detatch({
14418
14419
  rego, force: true
14419
14420
  });
@@ -14579,6 +14580,8 @@ void main()
14579
14580
  // When no Menu Item ID is set, then the second key is a blank string.
14580
14581
  // If an Entity ID state is set without a Menu Item ID, then it acts as a default for all Menu Items.
14581
14582
  this.states = {};
14583
+ // Opacity a whole menu item is drawn at, from its bookmark style; never a saved state.
14584
+ this.menuItemOpacities = new Map();
14582
14585
  // Queue of Entity updates to process in batches to avoid overloading the render loop.
14583
14586
  this.updateQueue = [];
14584
14587
  // Mirrors updateQueue for O(1) "already queued" checks.
@@ -15563,7 +15566,7 @@ void main()
15563
15566
  return;
15564
15567
  }
15565
15568
  this.dimmingDirty = false;
15566
- const dimming = Object.values(this.states).some(states => Object.values(states).some(state => state.isolated || (state.opacity != null && state.opacity < 1)));
15569
+ const dimming = Object.values(this.states).some(states => Object.values(states).some(state => state.isolated || (state.opacity != null && state.opacity < 1))) || this.menuItemOpacities.size > 0;
15567
15570
  if (!exports.CesiumEntityStyler.SetDimming(this.viewer, this.id, dimming)) {
15568
15571
  return;
15569
15572
  }
@@ -17149,6 +17152,34 @@ void main()
17149
17152
  }
17150
17153
  return (totalOpacity && totalTicks) ? (totalOpacity / totalTicks) : totalOpacity != null && typeof totalOpacity == "number" ? totalOpacity : 1;
17151
17154
  }
17155
+ /**
17156
+ * Draws every Entity of a menu item at this opacity unless it has its own; null puts them back.
17157
+ * It is not a visual state, so a Bookmark save does not store it per Entity.
17158
+ */
17159
+ SetMenuItemOpacity(params) {
17160
+ var _a, _b, _c;
17161
+ const { menuItemId, opacity } = params;
17162
+ const wanted = typeof opacity === "number" && opacity >= 0 && opacity < 1 ? opacity : null;
17163
+ if (((_a = this.menuItemOpacities.get(menuItemId)) !== null && _a !== void 0 ? _a : null) === wanted) {
17164
+ return;
17165
+ }
17166
+ if (wanted == null) {
17167
+ this.menuItemOpacities.delete(menuItemId);
17168
+ }
17169
+ else {
17170
+ this.menuItemOpacities.set(menuItemId, wanted);
17171
+ }
17172
+ this.dimmingDirty = true;
17173
+ const entityIds = new Set(this.GetRegos({ menuItemId }).map(rego => rego.entityId).filter(Boolean));
17174
+ entityIds.forEach(entityId => this.queueUpdate({ entityId, refresh: { opacity: true } }));
17175
+ if (params.requestRender !== false) {
17176
+ (_c = (_b = this.viewer) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.requestRender();
17177
+ }
17178
+ }
17179
+ GetMenuItemOpacity(menuItemId) {
17180
+ var _a;
17181
+ return menuItemId ? ((_a = this.menuItemOpacities.get(menuItemId)) !== null && _a !== void 0 ? _a : null) : null;
17182
+ }
17152
17183
  ClearOpacity(params) {
17153
17184
  const clearedIds = new Set();
17154
17185
  this.ForEachState((state) => {
@@ -17516,18 +17547,57 @@ void main()
17516
17547
  BModels.MenuItem.EType.EntitiesLoaded,
17517
17548
  BModels.MenuItem.EType.DataLab
17518
17549
  ];
17550
+ // The row every Entities render manager draws an item with when it names none.
17551
+ const DEFAULT_ZOOM_ROW = {
17552
+ MinZoom: 0,
17553
+ MaxZoom: 200000,
17554
+ DisplayType: BModels.ZoomControl.EDisplayType.Model3D,
17555
+ LODCategoryID: "glb",
17556
+ LODLevel: 0,
17557
+ StyleID: 0
17558
+ };
17559
+ // Instructions an overlay carries that are not style fields, so a merge never copies them onto a style.
17560
+ const INSTRUCTION_KEYS = ["types", "expandSources", "opacity"];
17519
17561
  /**
17520
- * Returns the base style with each field the overlay sets laid over it.
17562
+ * Returns the base style with each field the overlay sets laid over it, then its style for the Entity Type when given.
17521
17563
  */
17522
- function Merge(base, overlay) {
17523
- var _a, _b;
17564
+ function Merge(base, overlay, entityTypeId) {
17565
+ var _a;
17524
17566
  if (!overlay) {
17525
17567
  return base;
17526
17568
  }
17527
- const merged = { ...(base !== null && base !== void 0 ? base : {}) };
17569
+ const merged = layFields({ ...(base !== null && base !== void 0 ? base : {}) }, overlay);
17570
+ const typed = entityTypeId ? (_a = overlay.types) === null || _a === void 0 ? void 0 : _a[entityTypeId] : null;
17571
+ return typed ? layFields(merged, typed) : merged;
17572
+ }
17573
+ MenuItemStyleOverlay.Merge = Merge;
17574
+ /**
17575
+ * Returns whether an overlay paints a model fill, for the layer or for any Entity Type in it.
17576
+ */
17577
+ function SetsModelFill(overlay) {
17578
+ var _a;
17579
+ if (!overlay) {
17580
+ return false;
17581
+ }
17582
+ const types = Object.values((_a = overlay.types) !== null && _a !== void 0 ? _a : {});
17583
+ return [overlay, ...types].some(style => { var _a; return isSet((_a = style === null || style === void 0 ? void 0 : style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor); });
17584
+ }
17585
+ MenuItemStyleOverlay.SetsModelFill = SetsModelFill;
17586
+ /**
17587
+ * Returns whether an overlay asks for attributes read from the Entities' sources.
17588
+ */
17589
+ function ExpandsSources(overlay) {
17590
+ return Boolean(overlay === null || overlay === void 0 ? void 0 : overlay.expandSources);
17591
+ }
17592
+ MenuItemStyleOverlay.ExpandsSources = ExpandsSources;
17593
+ /*
17594
+ * Lays each style field an overlay sets onto a copy already taken, leaving its instructions behind.
17595
+ */
17596
+ function layFields(merged, overlay) {
17597
+ var _a, _b;
17528
17598
  for (const key of Object.keys(overlay)) {
17529
17599
  const value = overlay[key];
17530
- if (!isSet(value)) {
17600
+ if (INSTRUCTION_KEYS.includes(key) || !isSet(value)) {
17531
17601
  continue;
17532
17602
  }
17533
17603
  if (isPlainObject(value)) {
@@ -17543,12 +17613,11 @@ void main()
17543
17613
  }
17544
17614
  return merged;
17545
17615
  }
17546
- MenuItemStyleOverlay.Merge = Merge;
17547
17616
  /**
17548
- * Returns the overlay a zoom control row carries laid over the style it resolved.
17617
+ * Returns the overlay a zoom control row carries laid over the style it resolved, for an Entity of the given type.
17549
17618
  */
17550
- function ApplyRow(style, row) {
17551
- return Merge(style, row === null || row === void 0 ? void 0 : row.StyleOverlay);
17619
+ function ApplyRow(style, row, entityTypeId) {
17620
+ return Merge(style, row === null || row === void 0 ? void 0 : row.StyleOverlay, entityTypeId);
17552
17621
  }
17553
17622
  MenuItemStyleOverlay.ApplyRow = ApplyRow;
17554
17623
  /**
@@ -17587,7 +17656,7 @@ void main()
17587
17656
  * Returns a copy carrying the overlay, or the item itself when it cannot take one and carries none.
17588
17657
  */
17589
17658
  function With(item, overlay) {
17590
- var _a;
17659
+ var _a, _b;
17591
17660
  const target = Supports(item) ? overlay : null;
17592
17661
  if (!target && !Get(item)) {
17593
17662
  return item;
@@ -17603,9 +17672,11 @@ void main()
17603
17672
  return next;
17604
17673
  }
17605
17674
  const zItem = item;
17675
+ // An item with no rows is drawn on the render managers' own default row, which has to carry the overlay too.
17676
+ const rows = ((_a = zItem.CameraZoomSettings) === null || _a === void 0 ? void 0 : _a.length) || !target ? ((_b = zItem.CameraZoomSettings) !== null && _b !== void 0 ? _b : []) : [{ ...DEFAULT_ZOOM_ROW }];
17606
17677
  return {
17607
17678
  ...zItem,
17608
- CameraZoomSettings: ((_a = zItem.CameraZoomSettings) !== null && _a !== void 0 ? _a : []).map(row => {
17679
+ CameraZoomSettings: rows.map(row => {
17609
17680
  const next = { ...row };
17610
17681
  if (target) {
17611
17682
  next.StyleOverlay = target;
@@ -17807,6 +17878,8 @@ void main()
17807
17878
  this.scenario = 0;
17808
17879
  // Indicates that we should expand the sources of the Entity.
17809
17880
  this.expandSources = false;
17881
+ // What the item itself asks for, which an overlay reading sourced attributes can only add to.
17882
+ this.ownExpandSources = false;
17810
17883
  // Indicates that we are retrieving historic records.
17811
17884
  // This means that the current scene's time is included in the request.
17812
17885
  this.historic = false;
@@ -17872,8 +17945,9 @@ void main()
17872
17945
  this.applyStyles = Boolean(applyStyles);
17873
17946
  }
17874
17947
  if (expandSources != null) {
17875
- this.expandSources = expandSources;
17948
+ this.ownExpandSources = expandSources;
17876
17949
  }
17950
+ this.expandSources = this.ownExpandSources || exports.MenuItemStyleOverlay.ExpandsSources(this.styleOverlay);
17877
17951
  if (fallbackStyleId != null) {
17878
17952
  this.fallbackStyleId = fallbackStyleId;
17879
17953
  }
@@ -18010,11 +18084,13 @@ void main()
18010
18084
  this.historic = params.historic;
18011
18085
  }
18012
18086
  if (params.expandSources != null) {
18013
- if (this.expandSources != params.expandSources) {
18014
- this.shouldUpdateRegoStates = true;
18015
- }
18016
- this.expandSources = params.expandSources;
18087
+ this.ownExpandSources = params.expandSources;
18088
+ }
18089
+ const expandSources = this.ownExpandSources || exports.MenuItemStyleOverlay.ExpandsSources(this.styleOverlay);
18090
+ if (this.expandSources != expandSources) {
18091
+ this.shouldUpdateRegoStates = true;
18017
18092
  }
18093
+ this.expandSources = expandSources;
18018
18094
  // Reload styles.
18019
18095
  if (this.loaded) {
18020
18096
  this.styledEntityIds.clear();
@@ -18089,12 +18165,12 @@ void main()
18089
18165
  * Replaces the tileset's own colours while an overlay sets a model fill, so features show exactly what it maps to.
18090
18166
  */
18091
18167
  applyOverlayBlend() {
18092
- var _a, _b, _c, _d;
18168
+ var _a, _b;
18093
18169
  if (!this.cTileset || ((_b = (_a = this.cTileset).isDestroyed) === null || _b === void 0 ? void 0 : _b.call(_a))) {
18094
18170
  return;
18095
18171
  }
18096
- const fill = (_d = (_c = this.styleOverlay) === null || _c === void 0 ? void 0 : _c.modelStyle) === null || _d === void 0 ? void 0 : _d.fillColor;
18097
- const colours = Array.isArray(fill) ? fill.length > 0 : fill != null;
18172
+ // A fill for one Entity Type replaces too, as does a hide, which is a fully transparent fill.
18173
+ const colours = exports.MenuItemStyleOverlay.SetsModelFill(this.styleOverlay);
18098
18174
  if (colours && this.blendBeforeOverlay == null) {
18099
18175
  this.blendBeforeOverlay = this.cTileset.colorBlendMode;
18100
18176
  this.cTileset.colorBlendMode = Cesium.Cesium3DTileColorBlendMode.REPLACE;
@@ -18570,7 +18646,7 @@ void main()
18570
18646
  style = (_b = this.fallbackStyle) === null || _b === void 0 ? void 0 : _b.Settings;
18571
18647
  styleId = this.fallbackStyleId != null ? Number(this.fallbackStyleId) : null;
18572
18648
  }
18573
- style = exports.MenuItemStyleOverlay.Merge(style, this.styleOverlay);
18649
+ style = exports.MenuItemStyleOverlay.Merge(style, this.styleOverlay, entityTypeId);
18574
18650
  if (!style || !((_c = style === null || style === void 0 ? void 0 : style.modelStyle) === null || _c === void 0 ? void 0 : _c.customize)) {
18575
18651
  return { settings: null, styleId: null };
18576
18652
  }
@@ -22977,7 +23053,7 @@ void main()
22977
23053
  console.error(e);
22978
23054
  }
22979
23055
  }
22980
- style = exports.MenuItemStyleOverlay.ApplyRow(style, zoomItem);
23056
+ style = exports.MenuItemStyleOverlay.ApplyRow(style, zoomItem, entityTypeId);
22981
23057
  const pStyle = (_g = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _g !== void 0 ? _g : {};
22982
23058
  const lStyle = (_h = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _h !== void 0 ? _h : {};
22983
23059
  const polygonsClamped = ((_j = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _j === void 0 ? void 0 : _j.id) == null ? true : ((_k = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _k === void 0 ? void 0 : _k.id) == 0;
@@ -24078,7 +24154,7 @@ void main()
24078
24154
  if (!style) {
24079
24155
  style = zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.Style;
24080
24156
  }
24081
- style = exports.MenuItemStyleOverlay.ApplyRow(style, zoomItem);
24157
+ style = exports.MenuItemStyleOverlay.ApplyRow(style, zoomItem, entityTypeId);
24082
24158
  const pStyle = (_h = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _h !== void 0 ? _h : {};
24083
24159
  const lStyle = (_j = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _j !== void 0 ? _j : {};
24084
24160
  const polygonsClamped = ((_k = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _k === void 0 ? void 0 : _k.id) == null ? true : ((_l = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _l === void 0 ? void 0 : _l.id) == 0;
@@ -35551,7 +35627,15 @@ void main()
35551
35627
  if (laid == null) {
35552
35628
  return next;
35553
35629
  }
35554
- return exports.MenuItemStyleOverlay.WithItemStyle(next, itemStyle);
35630
+ // These two only run a Styler with Apply Styles on, and a bookmark that lays colours on one needs them drawn; opacity alone does not.
35631
+ const inline = exports.MenuItemStyleOverlay.GetItemStyle(alternation);
35632
+ const drawsStyle = inline
35633
+ ? Object.keys(inline).some(key => key !== "opacity" && key !== "expandSources")
35634
+ : exports.MenuItemStyleOverlay.GetItemStyleId(alternation) != null;
35635
+ const styled = drawsStyle && (next.Type === BModels.MenuItem.EType.ArbTileset || next.Type === BModels.MenuItem.EType.EntityTileset) && !next.ApplyStyles
35636
+ ? { ...next, ApplyStyles: true }
35637
+ : next;
35638
+ return exports.MenuItemStyleOverlay.WithItemStyle(styled, itemStyle);
35555
35639
  }
35556
35640
  MenuItemStyles.ApplyAlternation = ApplyAlternation;
35557
35641
  /**
@@ -36302,6 +36386,7 @@ void main()
36302
36386
  }
36303
36387
  }
36304
36388
  if (rItem.renderManager && !((_g = rItem.renderManager) === null || _g === void 0 ? void 0 : _g.Disposed)) {
36389
+ this.syncItemOpacity(rItem);
36305
36390
  (_h = this.onUpdate) === null || _h === void 0 ? void 0 : _h.Trigger({ isEnabling: true, itemId: rItem.id });
36306
36391
  }
36307
36392
  return rItem.id;
@@ -36312,7 +36397,7 @@ void main()
36312
36397
  * @param params
36313
36398
  */
36314
36399
  RemoveItemById(params) {
36315
- var _a, _b;
36400
+ var _a, _b, _c;
36316
36401
  let { menuItemId: id, recursive, allowHandoff } = params;
36317
36402
  if (this.viewer.isDestroyed()) {
36318
36403
  return;
@@ -36347,8 +36432,9 @@ void main()
36347
36432
  }
36348
36433
  this.ClearSeriesSegments(item.id);
36349
36434
  }
36435
+ (_b = this.visualsRegister) === null || _b === void 0 ? void 0 : _b.SetMenuItemOpacity({ menuItemId: item.id, opacity: null, requestRender: false });
36350
36436
  this.items = this.items.filter(x => x.id !== id);
36351
- (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: false, itemId: item.id });
36437
+ (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: false, itemId: item.id });
36352
36438
  }
36353
36439
  }
36354
36440
  /**
@@ -36387,6 +36473,7 @@ void main()
36387
36473
  const next = exports.MenuItemStyleOverlay.With(chosen, this.getEffectiveOverlay(chosen, this.styleOverlay));
36388
36474
  rItem.renderManager.SwapStyle(next);
36389
36475
  rItem.item = next;
36476
+ this.syncItemOpacity(rItem);
36390
36477
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
36391
36478
  return true;
36392
36479
  }
@@ -36426,9 +36513,18 @@ void main()
36426
36513
  }
36427
36514
  rItem.renderManager.SwapStyle(next);
36428
36515
  rItem.item = next;
36516
+ this.syncItemOpacity(rItem);
36429
36517
  (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: true, itemId: rItem.id });
36430
36518
  }
36431
36519
  }
36520
+ /*
36521
+ * Draws an item at the opacity its bookmark style asks for, or opaque again once none is asked.
36522
+ */
36523
+ syncItemOpacity(rItem) {
36524
+ var _a, _b;
36525
+ const wanted = (_a = exports.MenuItemStyleOverlay.GetItemStyle(rItem.item)) === null || _a === void 0 ? void 0 : _a.opacity;
36526
+ (_b = this.visualsRegister) === null || _b === void 0 ? void 0 : _b.SetMenuItemOpacity({ menuItemId: rItem.id, opacity: typeof wanted === "number" ? wanted : null });
36527
+ }
36432
36528
  /**
36433
36529
  * Lays an inline style or any Style record on one enabled item under the scene-wide one; neither clears it.
36434
36530
  */
@@ -36452,6 +36548,7 @@ void main()
36452
36548
  const next = exports.MenuItemStyleOverlay.With(styled, this.getEffectiveOverlay(styled, this.styleOverlay));
36453
36549
  rItem.renderManager.SwapStyle(next);
36454
36550
  rItem.item = next;
36551
+ this.syncItemOpacity(rItem);
36455
36552
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
36456
36553
  return true;
36457
36554
  }
@@ -36501,6 +36598,7 @@ void main()
36501
36598
  const next = exports.MenuItemStyleOverlay.With(rItem.item, effective);
36502
36599
  rItem.renderManager.SwapStyle(next);
36503
36600
  rItem.item = next;
36601
+ this.syncItemOpacity(rItem);
36504
36602
  (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: true, itemId: rItem.id });
36505
36603
  }
36506
36604
  }
@@ -53310,7 +53408,7 @@ void main()
53310
53408
  * @returns
53311
53409
  */
53312
53410
  async function RenderGroup(params) {
53313
- var _a, _b, _c, _d, _e;
53411
+ var _a, _b, _c, _d, _e, _f;
53314
53412
  const api = params.apiGetter.getApi();
53315
53413
  const cEntities = new Map();
53316
53414
  // Gathering tags in case styling needs it.
@@ -53342,7 +53440,7 @@ void main()
53342
53440
  const entity = params.entities[i];
53343
53441
  const zoomItem = params.zoomItems[entity.Bruce.ID];
53344
53442
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$1(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
53345
- const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
53443
+ const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
53346
53444
  // Pass through tags that may be needed for styling.
53347
53445
  const tagIds = entity.Bruce["Layer.ID"];
53348
53446
  const tags = [];
@@ -53354,11 +53452,11 @@ void main()
53354
53452
  }
53355
53453
  }
53356
53454
  }
53357
- const pStyle = (_b = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _b !== void 0 ? _b : {};
53455
+ const pStyle = (_c = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _c !== void 0 ? _c : {};
53358
53456
  let rego = null;
53359
53457
  // Only used for historic tracks right now.
53360
53458
  // So won't bother getting it if we don't have historic data.
53361
- if ((_c = params.entitiesHistoric) === null || _c === void 0 ? void 0 : _c[entity.Bruce.ID]) {
53459
+ if ((_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID]) {
53362
53460
  rego = params.visualRegister.GetRego({
53363
53461
  entityId: entity.Bruce.ID,
53364
53462
  menuItemId: params.menuItemId
@@ -53373,8 +53471,8 @@ void main()
53373
53471
  apiGetter: params.apiGetter,
53374
53472
  maxDistance: zoomItem.MaxZoom,
53375
53473
  minDistance: zoomItem.MinZoom,
53376
- rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID),
53377
- entityHistoric: (_e = params.entitiesHistoric) === null || _e === void 0 ? void 0 : _e[entity.Bruce.ID],
53474
+ rendered: (_e = params.rendered) === null || _e === void 0 ? void 0 : _e.get(entity.Bruce.ID),
53475
+ entityHistoric: (_f = params.entitiesHistoric) === null || _f === void 0 ? void 0 : _f[entity.Bruce.ID],
53378
53476
  entityHistoricDrawTrack: params.entityHistoricDrawTrack,
53379
53477
  fullStyle: style,
53380
53478
  rego: rego
@@ -54200,7 +54298,7 @@ void main()
54200
54298
  * @returns
54201
54299
  */
54202
54300
  async function RenderGroup(params) {
54203
- var _a, _b, _c, _d, _e, _f, _g, _h;
54301
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
54204
54302
  const api = params.apiGetter.getApi();
54205
54303
  await api.Loading;
54206
54304
  const cEntities = new Map();
@@ -54238,7 +54336,7 @@ void main()
54238
54336
  const entity = params.entities[i];
54239
54337
  const zoomItem = params.zoomItems[entity.Bruce.ID];
54240
54338
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$2(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
54241
- const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
54339
+ const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
54242
54340
  // Pass through tags that may be needed for styling.
54243
54341
  const tagIds = entity.Bruce["Layer.ID"];
54244
54342
  const tags = [];
@@ -54250,7 +54348,7 @@ void main()
54250
54348
  }
54251
54349
  }
54252
54350
  }
54253
- const mStyle = (_b = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _b !== void 0 ? _b : {};
54351
+ const mStyle = (_c = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _c !== void 0 ? _c : {};
54254
54352
  let group = mStyle.lodGroup ? BModels.Calculator.GetString(mStyle.lodGroup, entity, tags) : null;
54255
54353
  if (!group) {
54256
54354
  group = "DEFAULT";
@@ -54277,8 +54375,8 @@ void main()
54277
54375
  for (let i = 0; i < params.entities.length; i++) {
54278
54376
  const entity = params.entities[i];
54279
54377
  const zoomItem = params.zoomItems[entity.Bruce.ID];
54280
- const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_c = (await getStyle$2(api, entity, zoomItem.StyleID))) === null || _c === void 0 ? void 0 : _c.Settings : zoomItem.Style;
54281
- const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
54378
+ const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_d = (await getStyle$2(api, entity, zoomItem.StyleID))) === null || _d === void 0 ? void 0 : _d.Settings : zoomItem.Style;
54379
+ const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e["EntityType.ID"]);
54282
54380
  const lod = lodData.find(x => x.entityId == entity.Bruce.ID);
54283
54381
  if (!(lod === null || lod === void 0 ? void 0 : lod.clientFileId)) {
54284
54382
  continue;
@@ -54297,21 +54395,21 @@ void main()
54297
54395
  let rego = null;
54298
54396
  // Only used for historic tracks right now.
54299
54397
  // So won't bother getting it if we don't have historic data.
54300
- if ((_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID]) {
54398
+ if ((_f = params.entitiesHistoric) === null || _f === void 0 ? void 0 : _f[entity.Bruce.ID]) {
54301
54399
  rego = params.visualRegister.GetRego({
54302
54400
  entityId: entity.Bruce.ID,
54303
54401
  menuItemId: params.menuItemId
54304
54402
  });
54305
54403
  }
54306
- const mStyle = (_e = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _e !== void 0 ? _e : {};
54404
+ const mStyle = (_g = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _g !== void 0 ? _g : {};
54307
54405
  const cEntity = Render({
54308
- rendered: (_f = params.rendered) === null || _f === void 0 ? void 0 : _f.get(entity.Bruce.ID),
54406
+ rendered: (_h = params.rendered) === null || _h === void 0 ? void 0 : _h.get(entity.Bruce.ID),
54309
54407
  entity: entity,
54310
- entityHistoric: (_g = params.entitiesHistoric) === null || _g === void 0 ? void 0 : _g[entity.Bruce.ID],
54408
+ entityHistoric: (_j = params.entitiesHistoric) === null || _j === void 0 ? void 0 : _j[entity.Bruce.ID],
54311
54409
  style: mStyle,
54312
54410
  tags: tags,
54313
54411
  viewer: params.viewer,
54314
- lodUrl: (_h = lod.url) !== null && _h !== void 0 ? _h : BModels.ClientFile.GetUrl({
54412
+ lodUrl: (_k = lod.url) !== null && _k !== void 0 ? _k : BModels.ClientFile.GetUrl({
54315
54413
  api,
54316
54414
  fileId: lod.clientFileId,
54317
54415
  viaCdn: true
@@ -54814,7 +54912,7 @@ void main()
54814
54912
  * @returns
54815
54913
  */
54816
54914
  async function RenderGroup(params) {
54817
- var _a, _b, _c;
54915
+ var _a, _b, _c, _d;
54818
54916
  const api = params.apiGetter.getApi();
54819
54917
  const cEntities = new Map();
54820
54918
  // Gathering tags in case styling needs it.
@@ -54846,7 +54944,7 @@ void main()
54846
54944
  const entity = params.entities[i];
54847
54945
  const zoomItem = params.zoomItems[entity.Bruce.ID];
54848
54946
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$3(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
54849
- const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
54947
+ const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
54850
54948
  // Pass through tags that may be needed for styling.
54851
54949
  const tagIds = entity.Bruce["Layer.ID"];
54852
54950
  const tags = [];
@@ -54858,7 +54956,7 @@ void main()
54858
54956
  }
54859
54957
  }
54860
54958
  }
54861
- const lStyle = (_b = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _b !== void 0 ? _b : {};
54959
+ const lStyle = (_c = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _c !== void 0 ? _c : {};
54862
54960
  const cEntity = Render({
54863
54961
  entity: entity,
54864
54962
  style: lStyle,
@@ -54866,7 +54964,7 @@ void main()
54866
54964
  viewer: params.viewer,
54867
54965
  maxDistance: zoomItem.MaxZoom,
54868
54966
  minDistance: zoomItem.MinZoom,
54869
- rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID)
54967
+ rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID)
54870
54968
  });
54871
54969
  if (cEntity) {
54872
54970
  const name = await getName$2(api, entity, params.offline);
@@ -58185,6 +58283,23 @@ void main() {
58185
58283
  GetPlacementKey() {
58186
58284
  return [this.groundPixels ? 1 : 0, this.baseHeight, this.exaggeration, this.followGround ? 1 : 0].join("|");
58187
58285
  }
58286
+ /**
58287
+ * Repaints the sheet with new colours, keeping its geometry and the frames it is reading.
58288
+ */
58289
+ SetRamp(rampStops, lowColor, highColor) {
58290
+ const pixels = RampLookup(rampStops || null, lowColor || DEFAULT_LOW_COLOR, highColor || DEFAULT_HIGH_COLOR);
58291
+ // A re-render with the same colours keeps the texture it already has.
58292
+ if (this.rampPixels && pixels.length === this.rampPixels.length && pixels.every((value, i) => value === this.rampPixels[i])) {
58293
+ return;
58294
+ }
58295
+ this.rampPixels = pixels;
58296
+ this.maskFillValue = firstOpaqueStop(this.rampPixels);
58297
+ // Rebuilt from the new pixels on the next frame.
58298
+ if (this.rampTexture) {
58299
+ this.rampTexture.destroy();
58300
+ this.rampTexture = null;
58301
+ }
58302
+ }
58188
58303
  /**
58189
58304
  * The ramp the sheet is painted with, as 256 RGBA steps across the value range.
58190
58305
  */
@@ -58937,6 +59052,8 @@ void main() {
58937
59052
  const EXTRUSION_ANIMATOR_KEY = "TextureFrameSeriesAnimator.ExtrusionAnimator";
58938
59053
  const TEXTURE_VALUE_LABELS_KEY = "TextureValueLabels.Overlay";
58939
59054
  const DISPLACED_SURFACE_KEY = "DisplacedSurfacePrimitive.Surface";
59055
+ // Whether the surface's animator was built hiding the baseline, which it cannot change afterwards.
59056
+ const EXTRUSION_BASELINE_KEY = "TextureFrameSeriesAnimator.ExtrusionBaseline";
58940
59057
  (function (EntityRenderEnginePolygon) {
58941
59058
  /**
58942
59059
  * The height reference a polygon is actually drawn with.
@@ -59491,7 +59608,7 @@ void main() {
59491
59608
  }
59492
59609
  EntityRenderEnginePolygon.Render = Render;
59493
59610
  async function RenderGroup(params) {
59494
- var _a, _b, _c, _d;
59611
+ var _a, _b, _c, _d, _e;
59495
59612
  const api = params.apiGetter.getApi();
59496
59613
  const cEntities = new Map();
59497
59614
  // Gathering tags in case styling needs it.
@@ -59523,7 +59640,7 @@ void main() {
59523
59640
  const entity = params.entities[i];
59524
59641
  const zoomItem = params.zoomItems[entity.Bruce.ID];
59525
59642
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$4(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
59526
- const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
59643
+ const style = exports.MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
59527
59644
  // Pass through tags that may be needed for styling.
59528
59645
  const tagIds = entity.Bruce["Layer.ID"];
59529
59646
  const tags = [];
@@ -59535,7 +59652,7 @@ void main() {
59535
59652
  }
59536
59653
  }
59537
59654
  }
59538
- const pStyle = (_b = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _b !== void 0 ? _b : {};
59655
+ const pStyle = (_c = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _c !== void 0 ? _c : {};
59539
59656
  let cEntity = null;
59540
59657
  try {
59541
59658
  cEntity = await Render({
@@ -59549,14 +59666,14 @@ void main() {
59549
59666
  // Temporarily disabling re-using graphics for polygons as they have some bugs, and
59550
59667
  // they don't support any animation yet.
59551
59668
  // rendered: null
59552
- rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID),
59669
+ rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID),
59553
59670
  menuItemId: params.menuItemId,
59554
59671
  visualRegister: params.visualRegister,
59555
59672
  onSeriesDiscovered: params.onSeriesDiscovered
59556
59673
  });
59557
59674
  }
59558
59675
  catch (e) {
59559
- console.error(`Polygon.RenderGroup: failed to render entity ${((_d = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _d === void 0 ? void 0 : _d.ID) || "<NONE>"}:`, e);
59676
+ console.error(`Polygon.RenderGroup: failed to render entity ${((_e = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _e === void 0 ? void 0 : _e.ID) || "<NONE>"}:`, e);
59560
59677
  }
59561
59678
  if (cEntity) {
59562
59679
  const name = await getName$3(api, entity, params.offline);
@@ -59768,10 +59885,15 @@ void main() {
59768
59885
  const placement = surfacePlacement(entity, heightRef, extrusionArchive && exports.TextureFrameSeriesAnimator.IsDatumHeight(extrusionArchive.metadata));
59769
59886
  // Whether the surface follows terrain is baked into its ground sampling, so a change there has
59770
59887
  // to rebuild rather than update in place.
59771
- if (reusable && existingSurface.GetFollowsGround() === placement.followGround) {
59888
+ // The baseline mask is read by the animator as it is built, so a change there rebuilds too.
59889
+ const baselineKept = cEntity[EXTRUSION_BASELINE_KEY] === Boolean(style.maskTextureBaseline);
59890
+ if (reusable && baselineKept && existingSurface.GetFollowsGround() === placement.followGround) {
59772
59891
  existingSurface.SetBaseHeight(placement.baseHeight);
59773
59892
  existingSurface.SetExaggeration(exaggerationFor(style));
59774
59893
  existingSurface.SetWater(waterFor(style));
59894
+ // A restyle that only recolours, such as a bookmark's own ramp, repaints in place.
59895
+ const ramp = surfaceRamp(style.textureColorMask, extrusionArchive.metadata);
59896
+ existingSurface.SetRamp(ramp.rampStops, ramp.lowColor, ramp.highColor);
59775
59897
  return;
59776
59898
  }
59777
59899
  disposeDisplacedSurface(cEntity, viewer);
@@ -59798,7 +59920,8 @@ void main() {
59798
59920
  maskBaseline: style.maskTextureBaseline
59799
59921
  });
59800
59922
  cEntity[EXTRUSION_ANIMATOR_KEY] = animator;
59801
- const mask = style.textureColorMask;
59923
+ cEntity[EXTRUSION_BASELINE_KEY] = Boolean(style.maskTextureBaseline);
59924
+ const ramp = surfaceRamp(style.textureColorMask, extrusionArchive.metadata);
59802
59925
  const surface = new exports.DisplacedSurfacePrimitive.Surface({
59803
59926
  extent,
59804
59927
  // The grid has to be walked the way the raster was sampled, or the surface skews across the extent.
@@ -59812,18 +59935,28 @@ void main() {
59812
59935
  packedValue: exports.TextureFrameSeriesAnimator.IsPackedValue(extrusionArchive.metadata),
59813
59936
  exaggeration: exaggerationFor(style),
59814
59937
  water: waterFor(style),
59938
+ lowColor: ramp.lowColor,
59939
+ highColor: ramp.highColor,
59940
+ rampStops: ramp.rampStops
59941
+ });
59942
+ surface.BindAnimator(animator);
59943
+ viewer.scene.primitives.add(surface);
59944
+ cEntity[DISPLACED_SURFACE_KEY] = surface;
59945
+ }
59946
+ /*
59947
+ * The colours a displaced surface paints with, from the style's mask.
59948
+ */
59949
+ function surfaceRamp(mask, metadata) {
59950
+ return {
59815
59951
  lowColor: mask ? BModels.Color.ColorFromStr(mask.minColor) : null,
59816
59952
  highColor: mask ? BModels.Color.ColorFromStr(mask.maxColor) : null,
59817
59953
  // Normalised the same way the animator normalises them, so the surface and the flat drape
59818
59954
  // agree about which values the style hides.
59819
59955
  rampStops: ((mask && mask.points) || []).map((stop) => ({
59820
- position: exports.TextureFrameSeriesAnimator.NormalisePosition(extrusionArchive.metadata, stop.position),
59956
+ position: exports.TextureFrameSeriesAnimator.NormalisePosition(metadata, stop.position),
59821
59957
  color: BModels.Color.ColorFromStr(stop.color)
59822
59958
  })).filter((stop) => Boolean(stop.color))
59823
- });
59824
- surface.BindAnimator(animator);
59825
- viewer.scene.primitives.add(surface);
59826
- cEntity[DISPLACED_SURFACE_KEY] = surface;
59959
+ };
59827
59960
  }
59828
59961
  /**
59829
59962
  * Turns the polygon's altitude option into the two things the displaced surface needs:
@@ -61791,7 +61924,7 @@ void main() {
61791
61924
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
61792
61925
  })(exports.StyleUtils || (exports.StyleUtils = {}));
61793
61926
 
61794
- const VERSION = "7.9.2";
61927
+ const VERSION = "7.9.3";
61795
61928
  /**
61796
61929
  * Updates the environment instance used by bruce-cesium to one specified.
61797
61930
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.