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.
- package/dist/bruce-cesium.es5.js +184 -19
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +182 -17
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/menu-item-manager.js +89 -7
- package/dist/lib/rendering/menu-item-manager.js.map +1 -1
- package/dist/lib/rendering/menu-item-style-overlay.js +57 -5
- package/dist/lib/rendering/menu-item-style-overlay.js.map +1 -1
- package/dist/lib/rendering/menu-item-styles.js +9 -4
- package/dist/lib/rendering/menu-item-styles.js.map +1 -1
- package/dist/lib/rendering/tileset-styler.js +27 -0
- package/dist/lib/rendering/tileset-styler.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/menu-item-manager.d.ts +12 -0
- package/dist/types/rendering/menu-item-style-overlay.d.ts +28 -1
- package/dist/types/rendering/menu-item-styles.d.ts +1 -1
- package/dist/types/rendering/tileset-styler.d.ts +2 -0
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -16525,18 +16525,70 @@
|
|
|
16525
16525
|
}
|
|
16526
16526
|
MenuItemStyleOverlay.With = With;
|
|
16527
16527
|
/**
|
|
16528
|
-
* Returns
|
|
16528
|
+
* Returns the style a bookmark laid on this one item, or null when it carries none.
|
|
16529
|
+
*/
|
|
16530
|
+
function GetItemStyle(item) {
|
|
16531
|
+
var _a, _b;
|
|
16532
|
+
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;
|
|
16533
|
+
}
|
|
16534
|
+
MenuItemStyleOverlay.GetItemStyle = GetItemStyle;
|
|
16535
|
+
/**
|
|
16536
|
+
* Returns the Style record a bookmark laid on this one item, or null when it names none.
|
|
16537
|
+
*/
|
|
16538
|
+
function GetItemStyleId(item) {
|
|
16539
|
+
var _a;
|
|
16540
|
+
const styleId = (_a = item === null || item === void 0 ? void 0 : item.style) === null || _a === void 0 ? void 0 : _a.styleId;
|
|
16541
|
+
return styleId == null || styleId === "" || styleId == -1 ? null : styleId;
|
|
16542
|
+
}
|
|
16543
|
+
MenuItemStyleOverlay.GetItemStyleId = GetItemStyleId;
|
|
16544
|
+
/**
|
|
16545
|
+
* Returns a copy carrying the given bookmark style, inline or by record, or without one for null.
|
|
16546
|
+
*/
|
|
16547
|
+
function WithItemStyle(item, itemStyle) {
|
|
16548
|
+
const has = Boolean(itemStyle === null || itemStyle === void 0 ? void 0 : itemStyle.style) || (itemStyle === null || itemStyle === void 0 ? void 0 : itemStyle.styleId) != null;
|
|
16549
|
+
if (!item || (!has && !item.style)) {
|
|
16550
|
+
return item;
|
|
16551
|
+
}
|
|
16552
|
+
const next = { ...item };
|
|
16553
|
+
if (has) {
|
|
16554
|
+
next.style = { ...itemStyle };
|
|
16555
|
+
}
|
|
16556
|
+
else {
|
|
16557
|
+
delete next.style;
|
|
16558
|
+
}
|
|
16559
|
+
return next;
|
|
16560
|
+
}
|
|
16561
|
+
MenuItemStyleOverlay.WithItemStyle = WithItemStyle;
|
|
16562
|
+
/**
|
|
16563
|
+
* Returns the overlay an item renders with: its inline or loaded bookmark style, under the scene-wide one.
|
|
16564
|
+
*/
|
|
16565
|
+
function Effective(item, overlay, record) {
|
|
16566
|
+
var _a, _b;
|
|
16567
|
+
const own = (_b = (_a = GetItemStyle(item)) !== null && _a !== void 0 ? _a : record) !== null && _b !== void 0 ? _b : null;
|
|
16568
|
+
// Either alone is used as it is, so an unchanged overlay still compares equal.
|
|
16569
|
+
return own ? Merge(own, overlay) : overlay;
|
|
16570
|
+
}
|
|
16571
|
+
MenuItemStyleOverlay.Effective = Effective;
|
|
16572
|
+
/**
|
|
16573
|
+
* Returns a copy without its overlay or bookmark style, so what else two items differ by can be compared.
|
|
16574
|
+
*/
|
|
16575
|
+
function Strip(item) {
|
|
16576
|
+
return With(WithItemStyle(item, null), null);
|
|
16577
|
+
}
|
|
16578
|
+
MenuItemStyleOverlay.Strip = Strip;
|
|
16579
|
+
/**
|
|
16580
|
+
* Returns true when the two items differ by nothing but their overlay or bookmark style.
|
|
16529
16581
|
*/
|
|
16530
16582
|
function IsChangeOnly(from, to) {
|
|
16531
16583
|
if (!from || !to || from.Type !== to.Type) {
|
|
16532
16584
|
return false;
|
|
16533
16585
|
}
|
|
16534
|
-
const
|
|
16535
|
-
if (JSON.stringify(
|
|
16586
|
+
const sameOverlay = JSON.stringify(Get(from)) === JSON.stringify(Get(to));
|
|
16587
|
+
if (sameOverlay && JSON.stringify(from.style) === JSON.stringify(to.style)) {
|
|
16536
16588
|
return false;
|
|
16537
16589
|
}
|
|
16538
|
-
//
|
|
16539
|
-
return JSON.stringify(
|
|
16590
|
+
// Removing keys keeps the order of the rest, so the two compare as text.
|
|
16591
|
+
return JSON.stringify(Strip(from)) === JSON.stringify(Strip(to));
|
|
16540
16592
|
}
|
|
16541
16593
|
MenuItemStyleOverlay.IsChangeOnly = IsChangeOnly;
|
|
16542
16594
|
/*
|
|
@@ -20634,6 +20686,8 @@
|
|
|
20634
20686
|
this.fallbackStyle = null;
|
|
20635
20687
|
// Laid over whichever style each feature resolves, so it only changes the fields it sets.
|
|
20636
20688
|
this.styleOverlay = null;
|
|
20689
|
+
// The tileset's blend before an overlay's colours replaced it, put back once no overlay colours it.
|
|
20690
|
+
this.blendBeforeOverlay = null;
|
|
20637
20691
|
this.styleFallbackLoaded = false;
|
|
20638
20692
|
this.loadingCounter = 0;
|
|
20639
20693
|
// Entity IDs -> boolean to indicate if we should override the feature colour.
|
|
@@ -20692,7 +20746,12 @@
|
|
|
20692
20746
|
this.monitor = monitor;
|
|
20693
20747
|
this.viewer = viewer;
|
|
20694
20748
|
this.api = api;
|
|
20749
|
+
// A tileset handed in fresh still has its own blend, so nothing is left to put back on it.
|
|
20750
|
+
if (cTileset !== this.cTileset) {
|
|
20751
|
+
this.blendBeforeOverlay = null;
|
|
20752
|
+
}
|
|
20695
20753
|
this.cTileset = cTileset;
|
|
20754
|
+
this.applyOverlayBlend();
|
|
20696
20755
|
this.bakedAttributes = getBakedAttributes(cTileset);
|
|
20697
20756
|
this.register = register;
|
|
20698
20757
|
this.menuItemId = menuItemId;
|
|
@@ -20824,6 +20883,7 @@
|
|
|
20824
20883
|
// Left as it is when a caller omits it, so a mapping change keeps the scene-wide style.
|
|
20825
20884
|
if (params.styleOverlay !== undefined) {
|
|
20826
20885
|
this.styleOverlay = params.styleOverlay;
|
|
20886
|
+
this.applyOverlayBlend();
|
|
20827
20887
|
}
|
|
20828
20888
|
if (params.scenario != null) {
|
|
20829
20889
|
if (!this.shouldUpdateRegoStates && !!this.scenario) {
|
|
@@ -20913,6 +20973,25 @@
|
|
|
20913
20973
|
}
|
|
20914
20974
|
this.queueTilesetFeatureStyle(regos, highPriority);
|
|
20915
20975
|
}
|
|
20976
|
+
/*
|
|
20977
|
+
* Replaces the tileset's own colours while an overlay sets a model fill, so features show exactly what it maps to.
|
|
20978
|
+
*/
|
|
20979
|
+
applyOverlayBlend() {
|
|
20980
|
+
var _a, _b, _c, _d;
|
|
20981
|
+
if (!this.cTileset || ((_b = (_a = this.cTileset).isDestroyed) === null || _b === void 0 ? void 0 : _b.call(_a))) {
|
|
20982
|
+
return;
|
|
20983
|
+
}
|
|
20984
|
+
const fill = (_d = (_c = this.styleOverlay) === null || _c === void 0 ? void 0 : _c.modelStyle) === null || _d === void 0 ? void 0 : _d.fillColor;
|
|
20985
|
+
const colours = Array.isArray(fill) ? fill.length > 0 : fill != null;
|
|
20986
|
+
if (colours && this.blendBeforeOverlay == null) {
|
|
20987
|
+
this.blendBeforeOverlay = this.cTileset.colorBlendMode;
|
|
20988
|
+
this.cTileset.colorBlendMode = Cesium.Cesium3DTileColorBlendMode.REPLACE;
|
|
20989
|
+
}
|
|
20990
|
+
else if (!colours && this.blendBeforeOverlay != null) {
|
|
20991
|
+
this.cTileset.colorBlendMode = this.blendBeforeOverlay;
|
|
20992
|
+
this.blendBeforeOverlay = null;
|
|
20993
|
+
}
|
|
20994
|
+
}
|
|
20916
20995
|
/**
|
|
20917
20996
|
* Calculates the current progress % and updates the progress if there is a change.
|
|
20918
20997
|
*/
|
|
@@ -31983,17 +32062,21 @@
|
|
|
31983
32062
|
}
|
|
31984
32063
|
MenuItemStyles.Resolve = Resolve;
|
|
31985
32064
|
/**
|
|
31986
|
-
* Returns a copy on the style a bookmark alternation picked
|
|
32065
|
+
* Returns a copy on the style a bookmark alternation picked and carrying any style it laid on the item.
|
|
31987
32066
|
*/
|
|
31988
32067
|
function ApplyAlternation(item, alternation) {
|
|
31989
32068
|
var _a, _b, _c;
|
|
31990
32069
|
// Alternations are partial items and may carry no Type, so the pick is read from whichever field is present.
|
|
31991
32070
|
const alt = alternation;
|
|
31992
32071
|
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;
|
|
31993
|
-
|
|
31994
|
-
|
|
32072
|
+
const next = picked == null ? item : ((_c = WithStyleId(item, picked)) !== null && _c !== void 0 ? _c : item);
|
|
32073
|
+
// A style laid by record need not be one of the item's own, unlike the pick.
|
|
32074
|
+
const itemStyle = alternation === null || alternation === void 0 ? void 0 : alternation.style;
|
|
32075
|
+
const laid = exports.MenuItemStyleOverlay.GetItemStyle(alternation) || exports.MenuItemStyleOverlay.GetItemStyleId(alternation);
|
|
32076
|
+
if (laid == null) {
|
|
32077
|
+
return next;
|
|
31995
32078
|
}
|
|
31996
|
-
return (
|
|
32079
|
+
return exports.MenuItemStyleOverlay.WithItemStyle(next, itemStyle);
|
|
31997
32080
|
}
|
|
31998
32081
|
MenuItemStyles.ApplyAlternation = ApplyAlternation;
|
|
31999
32082
|
/**
|
|
@@ -32285,6 +32368,9 @@
|
|
|
32285
32368
|
// Laid over each item's own style where it can take one, including items rendered after it was set.
|
|
32286
32369
|
this.styleOverlay = null;
|
|
32287
32370
|
this.styleOverlayCounter = 0;
|
|
32371
|
+
// Style records bookmark styles name by ID, loaded once each; null for one that failed to load.
|
|
32372
|
+
this.itemStyleRecords = new Map();
|
|
32373
|
+
this.itemStyleRecordsLoading = new Set();
|
|
32288
32374
|
this.onUpdate = null;
|
|
32289
32375
|
// Segments discovered so far per menu item ID.
|
|
32290
32376
|
this.seriesSegments = new Map();
|
|
@@ -32367,14 +32453,15 @@
|
|
|
32367
32453
|
// An item with a style set renders its first style unless the caller already picked one of them.
|
|
32368
32454
|
params = { ...params, item: exports.MenuItemStyles.Resolve(params.item) };
|
|
32369
32455
|
// The overlay rides on the rendered copy, so the view's item never carries it.
|
|
32370
|
-
|
|
32456
|
+
const effective = this.getEffectiveOverlay(params.item, this.styleOverlay);
|
|
32457
|
+
params = { ...params, item: exports.MenuItemStyleOverlay.With(params.item, effective) };
|
|
32371
32458
|
let rItem = this.items.find(x => x.id == params.item.id);
|
|
32372
32459
|
let create = true;
|
|
32373
32460
|
// Item already exists so we'll check if we should re-create it.
|
|
32374
32461
|
if (rItem) {
|
|
32375
|
-
// Only the style pick or
|
|
32376
|
-
const
|
|
32377
|
-
const pickOnly = exports.MenuItemStyles.IsStyleChangeOnly(
|
|
32462
|
+
// Only the style pick, overlay or bookmark style changed, so the graphics are restyled, not rebuilt.
|
|
32463
|
+
const stripped = exports.MenuItemStyleOverlay.Strip(params.item);
|
|
32464
|
+
const pickOnly = exports.MenuItemStyles.IsStyleChangeOnly(exports.MenuItemStyleOverlay.Strip(rItem.item), stripped);
|
|
32378
32465
|
const restyleOnly = pickOnly || exports.MenuItemStyleOverlay.IsChangeOnly(rItem.item, params.item);
|
|
32379
32466
|
if (restyleOnly && this.isStyleSwapCapable(rItem.renderManager)) {
|
|
32380
32467
|
rItem.renderManager.SwapStyle(params.item);
|
|
@@ -32814,10 +32901,13 @@
|
|
|
32814
32901
|
if (!rItem || !this.isStyleSwapCapable(rItem.renderManager) || rItem.renderManager.Disposed) {
|
|
32815
32902
|
return false;
|
|
32816
32903
|
}
|
|
32817
|
-
const
|
|
32818
|
-
if (!
|
|
32904
|
+
const picked = exports.MenuItemStyles.WithStyleId(rItem.item, styleId);
|
|
32905
|
+
if (!picked) {
|
|
32819
32906
|
return false;
|
|
32820
32907
|
}
|
|
32908
|
+
// A Style record a bookmark laid is drawn over the pick, so picking one of the item's own takes it off.
|
|
32909
|
+
const chosen = exports.MenuItemStyleOverlay.WithItemStyle(picked, null);
|
|
32910
|
+
const next = exports.MenuItemStyleOverlay.With(chosen, this.getEffectiveOverlay(chosen, this.styleOverlay));
|
|
32821
32911
|
rItem.renderManager.SwapStyle(next);
|
|
32822
32912
|
rItem.item = next;
|
|
32823
32913
|
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
|
|
@@ -32849,7 +32939,7 @@
|
|
|
32849
32939
|
}
|
|
32850
32940
|
this.styleOverlay = overlay;
|
|
32851
32941
|
for (const rItem of this.items) {
|
|
32852
|
-
const next = exports.MenuItemStyleOverlay.With(rItem.item, overlay);
|
|
32942
|
+
const next = exports.MenuItemStyleOverlay.With(rItem.item, this.getEffectiveOverlay(rItem.item, overlay));
|
|
32853
32943
|
// Setting the same overlay again would otherwise restyle every feature for nothing.
|
|
32854
32944
|
const unchanged = JSON.stringify(exports.MenuItemStyleOverlay.Get(next)) === JSON.stringify(exports.MenuItemStyleOverlay.Get(rItem.item));
|
|
32855
32945
|
if (unchanged ||
|
|
@@ -32862,6 +32952,81 @@
|
|
|
32862
32952
|
(_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: true, itemId: rItem.id });
|
|
32863
32953
|
}
|
|
32864
32954
|
}
|
|
32955
|
+
/**
|
|
32956
|
+
* Lays an inline style or any Style record on one enabled item under the scene-wide one; neither clears it.
|
|
32957
|
+
*/
|
|
32958
|
+
SetItemStyleOverlay(params) {
|
|
32959
|
+
var _a;
|
|
32960
|
+
const rItem = this.items.find(x => x.id === params.menuItemId);
|
|
32961
|
+
let itemStyle = null;
|
|
32962
|
+
if (params.style) {
|
|
32963
|
+
itemStyle = { style: params.style };
|
|
32964
|
+
}
|
|
32965
|
+
else if (params.styleId != null) {
|
|
32966
|
+
itemStyle = { styleId: params.styleId };
|
|
32967
|
+
}
|
|
32968
|
+
if (!rItem ||
|
|
32969
|
+
!this.isStyleSwapCapable(rItem.renderManager) ||
|
|
32970
|
+
rItem.renderManager.Disposed ||
|
|
32971
|
+
(itemStyle && !exports.MenuItemStyleOverlay.Supports(rItem.item))) {
|
|
32972
|
+
return false;
|
|
32973
|
+
}
|
|
32974
|
+
const styled = exports.MenuItemStyleOverlay.WithItemStyle(rItem.item, itemStyle);
|
|
32975
|
+
const next = exports.MenuItemStyleOverlay.With(styled, this.getEffectiveOverlay(styled, this.styleOverlay));
|
|
32976
|
+
rItem.renderManager.SwapStyle(next);
|
|
32977
|
+
rItem.item = next;
|
|
32978
|
+
(_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
|
|
32979
|
+
return true;
|
|
32980
|
+
}
|
|
32981
|
+
/*
|
|
32982
|
+
* Returns the overlay the item renders with, starting the load of a record it names that is not loaded yet.
|
|
32983
|
+
*/
|
|
32984
|
+
getEffectiveOverlay(item, overlay) {
|
|
32985
|
+
const styleId = exports.MenuItemStyleOverlay.GetItemStyle(item) ? null : exports.MenuItemStyleOverlay.GetItemStyleId(item);
|
|
32986
|
+
if (styleId != null && !this.itemStyleRecords.has(String(styleId))) {
|
|
32987
|
+
this.loadItemStyleRecord(styleId);
|
|
32988
|
+
}
|
|
32989
|
+
const record = styleId != null ? this.itemStyleRecords.get(String(styleId)) : null;
|
|
32990
|
+
return exports.MenuItemStyleOverlay.Effective(item, overlay, record !== null && record !== void 0 ? record : undefined);
|
|
32991
|
+
}
|
|
32992
|
+
/*
|
|
32993
|
+
* Loads a record a bookmark style names, then restyles every enabled item that names it.
|
|
32994
|
+
*/
|
|
32995
|
+
async loadItemStyleRecord(styleId) {
|
|
32996
|
+
var _a, _b;
|
|
32997
|
+
const key = String(styleId);
|
|
32998
|
+
if (this.itemStyleRecordsLoading.has(key)) {
|
|
32999
|
+
return;
|
|
33000
|
+
}
|
|
33001
|
+
this.itemStyleRecordsLoading.add(key);
|
|
33002
|
+
let settings = null;
|
|
33003
|
+
// A record that fails to load leaves the item on its own style.
|
|
33004
|
+
try {
|
|
33005
|
+
const { style } = await BModels.Style.Get({
|
|
33006
|
+
api: this.getters.GetBruceApi(),
|
|
33007
|
+
styleId
|
|
33008
|
+
});
|
|
33009
|
+
settings = (_a = style === null || style === void 0 ? void 0 : style.Settings) !== null && _a !== void 0 ? _a : null;
|
|
33010
|
+
}
|
|
33011
|
+
catch (e) {
|
|
33012
|
+
console.error(e);
|
|
33013
|
+
}
|
|
33014
|
+
this.itemStyleRecordsLoading.delete(key);
|
|
33015
|
+
this.itemStyleRecords.set(key, settings);
|
|
33016
|
+
for (const rItem of this.items) {
|
|
33017
|
+
if (String(exports.MenuItemStyleOverlay.GetItemStyleId(rItem.item)) !== key ||
|
|
33018
|
+
exports.MenuItemStyleOverlay.GetItemStyle(rItem.item) ||
|
|
33019
|
+
!this.isStyleSwapCapable(rItem.renderManager) ||
|
|
33020
|
+
rItem.renderManager.Disposed) {
|
|
33021
|
+
continue;
|
|
33022
|
+
}
|
|
33023
|
+
const effective = this.getEffectiveOverlay(rItem.item, this.styleOverlay);
|
|
33024
|
+
const next = exports.MenuItemStyleOverlay.With(rItem.item, effective);
|
|
33025
|
+
rItem.renderManager.SwapStyle(next);
|
|
33026
|
+
rItem.item = next;
|
|
33027
|
+
(_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: true, itemId: rItem.id });
|
|
33028
|
+
}
|
|
33029
|
+
}
|
|
32865
33030
|
/*
|
|
32866
33031
|
* Picks the child the caller asked for, else the one already enabled, else the first.
|
|
32867
33032
|
*/
|
|
@@ -56371,7 +56536,7 @@ void main() {
|
|
|
56371
56536
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
56372
56537
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
56373
56538
|
|
|
56374
|
-
const VERSION = "7.6.
|
|
56539
|
+
const VERSION = "7.6.9";
|
|
56375
56540
|
/**
|
|
56376
56541
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
56377
56542
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|