bruce-cesium 6.7.6 → 6.7.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.
@@ -13935,11 +13935,16 @@
13935
13935
  cacheToken: tileset.generateVersion,
13936
13936
  viaCdn: Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled)
13937
13937
  });
13938
- api.get(modelTreeUrl).then((blob) => {
13938
+ api.get(modelTreeUrl).then(async (result) => {
13939
13939
  if (this.disposed) {
13940
13940
  return;
13941
13941
  }
13942
- this.modelTree = blob || null;
13942
+ // S3 signed URLs may return application/octet-stream instead of application/json,
13943
+ // causing the API to return a Blob rather than a parsed object.
13944
+ if (result instanceof Blob) {
13945
+ result = JSON.parse(await result.text());
13946
+ }
13947
+ this.modelTree = result || null;
13943
13948
  this.modelTreeUpdate.Trigger(this.modelTree);
13944
13949
  }).catch((err) => {
13945
13950
  this.modelTreeError = err.message || "Unknown error";
@@ -13947,12 +13952,15 @@
13947
13952
  }
13948
13953
  // In v1 the model-tree is inside the tileset.json.
13949
13954
  else {
13950
- api.get(tileset.loadUrl).then((blob) => {
13955
+ api.get(tileset.loadUrl).then(async (result) => {
13951
13956
  var _a;
13952
13957
  if (this.disposed) {
13953
13958
  return;
13954
13959
  }
13955
- this.modelTree = ((_a = blob === null || blob === void 0 ? void 0 : blob.extensions) === null || _a === void 0 ? void 0 : _a.modelTree) || null;
13960
+ if (result instanceof Blob) {
13961
+ result = JSON.parse(await result.text());
13962
+ }
13963
+ this.modelTree = ((_a = result === null || result === void 0 ? void 0 : result.extensions) === null || _a === void 0 ? void 0 : _a.modelTree) || null;
13956
13964
  this.modelTreeUpdate.Trigger(this.modelTree);
13957
13965
  }).catch((err) => {
13958
13966
  this.modelTreeError = err.message || "Unknown error";
@@ -15780,10 +15788,14 @@
15780
15788
  }
15781
15789
  // API gave us a URL to use.
15782
15790
  else if (curCell.FetchURL) {
15783
- const tmpResponse = await this.api.get(curCell.FetchURL, {
15791
+ let tmpResponse = await this.api.get(curCell.FetchURL, {
15784
15792
  abortSignal: abortController.signal,
15785
15793
  noCache: true
15786
15794
  });
15795
+ // S3 signed URLs may return application/octet-stream, causing a Blob result.
15796
+ if (tmpResponse instanceof Blob) {
15797
+ tmpResponse = JSON.parse(await tmpResponse.text());
15798
+ }
15787
15799
  // Same mapping as bruce-models doing Entity.GetList.
15788
15800
  response = {
15789
15801
  entities: tmpResponse.Items ? tmpResponse.Items : [],
@@ -19115,7 +19127,7 @@
19115
19127
  this.item = params.item;
19116
19128
  }
19117
19129
  (async () => {
19118
- var _a;
19130
+ var _a, _b, _c;
19119
19131
  // If the tileset already exists then we just need to update the style.
19120
19132
  if (this.cTileset) {
19121
19133
  const colorCss = this.item.colorMask;
@@ -19142,16 +19154,44 @@
19142
19154
  console.warn("Cesium version does not support 'createGooglePhotorealistic3DTileset' so Google Photos tileset will not be rendered.");
19143
19155
  return;
19144
19156
  }
19157
+ // Proxy path: key injected server-side.
19145
19158
  if (api.IsVersionAtLeast(BModels.BruceApi.VERSION_WITH_PROXIES)) {
19146
- // Proxy path: key injected server-side.
19147
- const proxyRootUrl = api.GetBaseUrl() + "proxy/google-tiles/v1/3dtiles/root.json";
19159
+ // If we have a Google token we'll proxy through that.
19160
+ // Otherwise use Cesium Ion to load as a resource.
19161
+ const { programKeys } = await BModels.ProgramKey.GetList({
19162
+ api: this.getters.GetBruceApi()
19163
+ });
19164
+ const hasGoogleToken = Boolean((_a = programKeys.find(x => x.ProgramId === BModels.ProgramKey.EProgramId.GooglePhotogrammetry)) === null || _a === void 0 ? void 0 : _a.Available);
19165
+ // Must have own iot token, this ensures we don't use our template one for loading customer photogrammetry.
19166
+ const hasIonToken = Boolean((_b = programKeys.find(x => x.ProgramId === BModels.ProgramKey.EProgramId.CesiumIon)) === null || _b === void 0 ? void 0 : _b.Available);
19148
19167
  if (this.disposed) {
19149
19168
  this.doDispose();
19150
19169
  return;
19151
19170
  }
19152
- this.cTileset = await CESIUM.Cesium3DTileset.fromUrl(proxyRootUrl, {
19153
- showCreditsOnScreen: true
19154
- });
19171
+ // WARNING: we are routing through ion first right now as it is faster.
19172
+ // Should be a user-decision and we should improve our google proxying.
19173
+ if (hasIonToken && Cesium.Ion.defaultServer) {
19174
+ const loadUrl = await Cesium.IonResource.fromAssetId(2275207, undefined);
19175
+ if (this.disposed) {
19176
+ this.doDispose();
19177
+ return;
19178
+ }
19179
+ this.cTileset = await createTileset(loadUrl, {}, true);
19180
+ }
19181
+ else if (hasGoogleToken) {
19182
+ const proxyRootUrl = api.GetBaseUrl() + "proxy/google-tiles/v1/3dtiles/root.json";
19183
+ if (this.disposed) {
19184
+ this.doDispose();
19185
+ return;
19186
+ }
19187
+ this.cTileset = await CESIUM.Cesium3DTileset.fromUrl(proxyRootUrl, {
19188
+ showCreditsOnScreen: true
19189
+ });
19190
+ }
19191
+ else {
19192
+ console.warn("No Google or Cesium Ion token available, so Google Photos tileset will not be rendered.");
19193
+ return;
19194
+ }
19155
19195
  }
19156
19196
  // Legacy path: fetch real Google key and use createGooglePhotorealistic3DTileset().
19157
19197
  // Kill of whenever all API instances are migrated.
@@ -19179,7 +19219,7 @@
19179
19219
  this.doDispose();
19180
19220
  return;
19181
19221
  }
19182
- this.cTileset = await ((_a = CESIUM.createGooglePhotorealistic3DTileset) === null || _a === void 0 ? void 0 : _a.call(CESIUM));
19222
+ this.cTileset = await ((_c = CESIUM.createGooglePhotorealistic3DTileset) === null || _c === void 0 ? void 0 : _c.call(CESIUM));
19183
19223
  }
19184
19224
  if (this.disposed) {
19185
19225
  this.doDispose();
@@ -36354,7 +36394,7 @@
36354
36394
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
36355
36395
  })(exports.StyleUtils || (exports.StyleUtils = {}));
36356
36396
 
36357
- const VERSION = "6.7.6";
36397
+ const VERSION = "6.7.8";
36358
36398
  /**
36359
36399
  * Updates the environment instance used by bruce-cesium to one specified.
36360
36400
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -36376,6 +36416,7 @@
36376
36416
  exports.getENVIRONMENT = getENVIRONMENT;
36377
36417
  exports.isOutlineChanged = isOutlineChanged$1;
36378
36418
  exports.CesiumParabola = CesiumParabola;
36419
+ exports.createTileset = createTileset;
36379
36420
  exports.CESIUM_INSPECTOR_KEY = CESIUM_INSPECTOR_KEY;
36380
36421
  exports.CESIUM_TIMELINE_KEY = CESIUM_TIMELINE_KEY;
36381
36422
  exports.CESIUM_TIMELINE_LIVE_KEY = CESIUM_TIMELINE_LIVE_KEY;