bruce-cesium 5.2.6 → 5.2.8

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.
@@ -16839,6 +16839,10 @@
16839
16839
  // This likely means poor data so we have to disable drilling otherwise lag would be too bad.
16840
16840
  // The result is no entity type IDs are known so most styles fail.
16841
16841
  this.hasHitDepthLimit = false;
16842
+ // Cache of 'something isolated' that we detect and use to calculate a default show state.
16843
+ // It's pretty expensive so we save it for a few seconds inbetween checks.
16844
+ this.somethingIsolated = null;
16845
+ this.somethingIsolatedDateTime = null;
16842
16846
  const { viewer, register: visualsManager, getters, item } = params;
16843
16847
  this.viewer = viewer;
16844
16848
  this.getters = getters;
@@ -16846,24 +16850,29 @@
16846
16850
  this.visualsManager = visualsManager;
16847
16851
  }
16848
16852
  Init() {
16849
- var _a;
16853
+ var _a, _b;
16850
16854
  const tilesetId = (_a = this.item.tileset) === null || _a === void 0 ? void 0 : _a.TilesetID;
16851
16855
  if (!tilesetId) {
16852
16856
  return;
16853
16857
  }
16858
+ let accountId = (_b = this.item.tileset) === null || _b === void 0 ? void 0 : _b.ClientAccountID;
16859
+ if (!accountId) {
16860
+ accountId = this.getters.GetAccountId();
16861
+ }
16854
16862
  this.renderPriority = this.item.renderPriority;
16855
16863
  if (this.renderPriority == null) {
16856
16864
  this.renderPriority = 0;
16857
16865
  }
16858
16866
  (async () => {
16859
- var _a, _b, _c;
16860
- let api = this.getters.GetBruceApi();
16867
+ var _a;
16868
+ const api = this.getters.GetBruceApi({
16869
+ accountId: accountId
16870
+ });
16861
16871
  let coords = null;
16862
16872
  let tileset = null;
16863
16873
  // Single shared getter to avoid multiple assemblies fighting to render.
16864
16874
  // This lets one complete, then the next start.
16865
16875
  await exports.SharedGetters.Queue.Run("Rendering assembly.", async () => {
16866
- var _a, _b;
16867
16876
  if (this.disposed) {
16868
16877
  return;
16869
16878
  }
@@ -16871,7 +16880,7 @@
16871
16880
  let canAccess = false;
16872
16881
  try {
16873
16882
  canAccess = await BModels.Tileset.Publish.IsAccessAllowed({
16874
- sourceAccountId: (_a = this.item.tileset) === null || _a === void 0 ? void 0 : _a.ClientAccountID,
16883
+ sourceAccountId: accountId,
16875
16884
  tilesetId: tilesetId,
16876
16885
  forAccountId: this.getters.GetAccountId(),
16877
16886
  getters: this.getters
@@ -16884,14 +16893,13 @@
16884
16893
  console.error(e);
16885
16894
  }
16886
16895
  if (!canAccess) {
16887
- console.warn(`Cannot access tileset: ${tilesetId}, from account: ${(_b = this.item.tileset) === null || _b === void 0 ? void 0 : _b.ClientAccountID}.`);
16896
+ console.warn(`Cannot access tileset: ${tilesetId}, from account: ${accountId}.`);
16888
16897
  return;
16889
16898
  }
16890
16899
  }
16891
16900
  else {
16892
16901
  console.warn("No tileset id found. Skipping access check.");
16893
16902
  }
16894
- api = this.getters.GetBruceApi();
16895
16903
  tileset = (await BModels.Tileset.Get({
16896
16904
  api,
16897
16905
  tilesetId
@@ -16939,7 +16947,7 @@
16939
16947
  tileset: tileset,
16940
16948
  viewer: this.viewer,
16941
16949
  coords: coords,
16942
- accountId: (_c = (_b = this.item.tileset) === null || _b === void 0 ? void 0 : _b.ClientAccountID) !== null && _c !== void 0 ? _c : this.getters.GetAccountId(),
16950
+ accountId: accountId,
16943
16951
  viaCdn: Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled),
16944
16952
  noMemoryLimit: this.item["noMaximumMemory"]
16945
16953
  });
@@ -16954,10 +16962,18 @@
16954
16962
  if (this.disposed || cTileset.isDestroyed()) {
16955
16963
  return;
16956
16964
  }
16965
+ // We style Entities to be hidden by default so that we can selectively-
16966
+ // do a default later.
16967
+ // This stops them flickering in/out as Bookmark settings get applied.
16968
+ this.cTileset.style = new Cesium.Cesium3DTileStyle({
16969
+ show: "false"
16970
+ });
16957
16971
  this.onCTilesetLoad();
16958
16972
  this.styler.Init({
16959
16973
  viewer: this.viewer,
16960
- api,
16974
+ // Default API instead of the account one.
16975
+ // Records are driven by the account loading it instead of the source account.
16976
+ api: this.getters.GetBruceApi(),
16961
16977
  cTileset: this.cTileset,
16962
16978
  fallbackStyleId: this.item.styleId,
16963
16979
  styleMapping: this.item.StyleMapping,
@@ -17014,7 +17030,12 @@
17014
17030
  for (let i = 0; i < content.featuresLength; i++) {
17015
17031
  const feature = content.getFeature(i);
17016
17032
  let rego = this.mapTilesetFeature(feature, load);
17017
- if ((rego === null || rego === void 0 ? void 0 : rego.entityId) && this.styler) {
17033
+ if (!(rego === null || rego === void 0 ? void 0 : rego.entityId)) {
17034
+ // Override the default hide state set by the style.
17035
+ feature.show = true;
17036
+ continue;
17037
+ }
17038
+ if (this.styler) {
17018
17039
  this.styler.QueueEntities([rego]);
17019
17040
  }
17020
17041
  }
@@ -17034,7 +17055,7 @@
17034
17055
  menuItemType: this.item.Type,
17035
17056
  priority: this.renderPriority,
17036
17057
  visual: feature,
17037
- accountId: (_b = (_a = this.item.tileset) === null || _a === void 0 ? void 0 : _a.ClientAccountID) !== null && _b !== void 0 ? _b : this.getters.GetAccountId(),
17058
+ accountId: (_b = ((_a = this.item.tileset) === null || _a === void 0 ? void 0 : _a.ClientAccountID)) !== null && _b !== void 0 ? _b : this.getters.GetAccountId(),
17038
17059
  tilesetId: (_c = this.item.tileset) === null || _c === void 0 ? void 0 : _c.TilesetID,
17039
17060
  tilesetType: BModels.Tileset.EType.Cad,
17040
17061
  rootId: this.rootId,
@@ -17100,6 +17121,31 @@
17100
17121
  return null;
17101
17122
  }
17102
17123
  if (add) {
17124
+ // Get the initial hide/show state.
17125
+ const state = this.visualsManager.GetState({
17126
+ entityId: rego.entityId,
17127
+ menuItemId: this.item.id,
17128
+ });
17129
+ if (this.somethingIsolated == null ||
17130
+ // 5s cache.
17131
+ (this.somethingIsolatedDateTime && this.somethingIsolatedDateTime.getTime() + 5000 < new Date().getTime())) {
17132
+ this.somethingIsolated = this.visualsManager.GetIsIsolatedAny();
17133
+ this.somethingIsolatedDateTime = new Date();
17134
+ }
17135
+ // Override the default hide state set by the style.
17136
+ let hide = false;
17137
+ if (state) {
17138
+ if (state.hidden) {
17139
+ hide = true;
17140
+ }
17141
+ else if (state.opacity === 0) {
17142
+ hide = true;
17143
+ }
17144
+ else if (!state.isolated && this.somethingIsolated) {
17145
+ hide = true;
17146
+ }
17147
+ }
17148
+ feature.show = !hide;
17103
17149
  this.visualsManager.AddRego({
17104
17150
  rego,
17105
17151
  requestRender: false
@@ -29836,7 +29882,7 @@
29836
29882
  }
29837
29883
  }
29838
29884
 
29839
- const VERSION = "5.2.6";
29885
+ const VERSION = "5.2.8";
29840
29886
 
29841
29887
  exports.VERSION = VERSION;
29842
29888
  exports.isHistoricMetadataChanged = isHistoricMetadataChanged;