bruce-cesium 5.9.2 → 5.9.4

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.
@@ -16695,32 +16695,33 @@
16695
16695
  const api = params.apiGetter.getApi(params.accountId);
16696
16696
  // Ensure regional url is loaded.
16697
16697
  await api.Loading;
16698
- let loadUrl = params.tileset.loadUrl;
16699
- // CDN enabled and tileset url template is available.
16700
- if (params.viaCdn && api.GetCdnBaseUrl()) {
16701
- /*
16702
- loadUrl = api.TilesetCdnUrl.replace("<TILESETID>", params.tileset.id).replace("<FILEPATH>", "files/tileset.json");
16703
- // First url param reserved for accountId. This is set within the API instance.
16704
- loadUrl += "&generation=" + params.tileset.generateVersion;
16705
- */
16706
- loadUrl = BModels.Tileset.GetFileUrl({
16707
- file: "tileset.json",
16708
- tilesetId: params.tileset.id,
16709
- viaCdn: true,
16710
- legacy: false,
16711
- cacheToken: params.tileset.generateVersion,
16712
- api: api
16713
- });
16698
+ let loadUrl = params.loadUrl;
16699
+ if (!loadUrl) {
16700
+ loadUrl = params.tileset.loadUrl;
16701
+ // CDN enabled and tileset url template is available.
16702
+ if (params.viaCdn && api.GetCdnBaseUrl()) {
16703
+ loadUrl = BModels.Tileset.GetFileUrl({
16704
+ file: "tileset.json",
16705
+ tilesetId: params.tileset.id,
16706
+ viaCdn: true,
16707
+ legacy: false,
16708
+ cacheToken: params.tileset.generateVersion,
16709
+ api: api
16710
+ });
16711
+ }
16714
16712
  }
16715
16713
  if (params.tileset.type == BModels.Tileset.EType.Cad) {
16716
- const cTileset = await createTileset(loadUrl ? loadUrl : BModels.Tileset.GetFileUrl({
16717
- api,
16718
- tilesetId: params.tileset.id,
16719
- file: "tileset.json",
16720
- cacheToken: params.tileset.generateVersion,
16721
- legacy: false,
16722
- viaCdn: false
16723
- }) + "?generation=" + params.tileset.generateVersion, null, params.noMemoryLimit);
16714
+ if (!loadUrl) {
16715
+ BModels.Tileset.GetFileUrl({
16716
+ api,
16717
+ tilesetId: params.tileset.id,
16718
+ file: "tileset.json",
16719
+ cacheToken: params.tileset.generateVersion,
16720
+ legacy: false,
16721
+ viaCdn: false
16722
+ }) + "?generation=" + params.tileset.generateVersion;
16723
+ }
16724
+ const cTileset = await createTileset(loadUrl, null, params.noMemoryLimit);
16724
16725
  params.viewer.scene.primitives.add(cTileset);
16725
16726
  OnTilesetReady(cTileset).then(() => {
16726
16727
  var _a, _b, _c, _d;
@@ -16756,26 +16757,32 @@
16756
16757
  return cTileset;
16757
16758
  }
16758
16759
  else if (params.tileset.type === BModels.Tileset.EType.EntitiesSet) {
16759
- const cTileset = await createTileset(loadUrl ? loadUrl : BModels.Tileset.GetFileUrl({
16760
- api,
16761
- tilesetId: params.tileset.id,
16762
- file: "tileset.json",
16763
- cacheToken: params.tileset.generateVersion,
16764
- legacy: false,
16765
- viaCdn: false
16766
- }) + "?generation=" + params.tileset.generateVersion, null, params.noMemoryLimit);
16760
+ if (!loadUrl) {
16761
+ loadUrl = BModels.Tileset.GetFileUrl({
16762
+ api,
16763
+ tilesetId: params.tileset.id,
16764
+ file: "tileset.json",
16765
+ cacheToken: params.tileset.generateVersion,
16766
+ legacy: false,
16767
+ viaCdn: false
16768
+ }) + "?generation=" + params.tileset.generateVersion;
16769
+ }
16770
+ const cTileset = await createTileset(loadUrl, null, params.noMemoryLimit);
16767
16771
  params.viewer.scene.primitives.add(cTileset);
16768
16772
  return cTileset;
16769
16773
  }
16770
16774
  else if (params.tileset.type == BModels.Tileset.EType.PointCloud) {
16771
- const cTileset = await createTileset(loadUrl ? loadUrl : BModels.Tileset.GetFileUrl({
16772
- api,
16773
- tilesetId: params.tileset.id,
16774
- file: "tileset.json",
16775
- cacheToken: params.tileset.generateVersion,
16776
- legacy: false,
16777
- viaCdn: false
16778
- }) + "?generation=" + params.tileset.generateVersion, null, params.noMemoryLimit);
16775
+ if (!loadUrl) {
16776
+ loadUrl = BModels.Tileset.GetFileUrl({
16777
+ api,
16778
+ tilesetId: params.tileset.id,
16779
+ file: "tileset.json",
16780
+ cacheToken: params.tileset.generateVersion,
16781
+ legacy: false,
16782
+ viaCdn: false
16783
+ }) + "?generation=" + params.tileset.generateVersion;
16784
+ }
16785
+ const cTileset = await createTileset(loadUrl, null, params.noMemoryLimit);
16779
16786
  params.viewer.scene.primitives.add(cTileset);
16780
16787
  OnTilesetReady(cTileset).then(() => {
16781
16788
  var _a;
@@ -18066,11 +18073,18 @@
18066
18073
  get Styler() {
18067
18074
  return this.styler;
18068
18075
  }
18076
+ get ModelTree() {
18077
+ return this.modelTree;
18078
+ }
18079
+ get ModelTreeUpdate() {
18080
+ return this.modelTreeUpdate;
18081
+ }
18069
18082
  constructor(params) {
18070
18083
  this.disposed = false;
18071
18084
  this.modelSpace = false;
18072
18085
  this.cTileset = null;
18073
18086
  this.styler = new exports.TilesetRenderEngine.Styler();
18087
+ this.modelTreeUpdate = new BModels.BruceEvent();
18074
18088
  // Quick look-up of the model tree nodes by entity/geomId.
18075
18089
  // Saves us from recursing the model tree for every feature.
18076
18090
  this.treeNodeByGeomId = null;
@@ -18110,8 +18124,11 @@
18110
18124
  if (this.renderPriority == null) {
18111
18125
  this.renderPriority = 0;
18112
18126
  }
18127
+ const viaCdn = Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled);
18128
+ // URL to load for loading the Tileset.
18129
+ // We calculate it here instead of relying on the render engine as we need to extract the model-tree from it.
18130
+ let loadUrl = null;
18113
18131
  (async () => {
18114
- var _a;
18115
18132
  const api = this.getters.GetBruceApi({
18116
18133
  accountId: accountId
18117
18134
  });
@@ -18120,7 +18137,7 @@
18120
18137
  // Single shared getter to avoid multiple assemblies fighting to render.
18121
18138
  // This lets one complete, then the next start.
18122
18139
  await exports.SharedGetters.Queue.Run("Rendering assembly.", async () => {
18123
- var _a;
18140
+ var _a, _b, _c;
18124
18141
  if (this.disposed) {
18125
18142
  return;
18126
18143
  }
@@ -18155,11 +18172,62 @@
18155
18172
  if (!tileset || this.disposed) {
18156
18173
  return;
18157
18174
  }
18175
+ loadUrl = tileset.loadUrl;
18176
+ // CDN enabled and available.
18177
+ if (viaCdn && api.GetCdnBaseUrl()) {
18178
+ loadUrl = BModels.Tileset.GetFileUrl({
18179
+ file: "tileset.json",
18180
+ tilesetId: tileset.id,
18181
+ viaCdn: true,
18182
+ legacy: false,
18183
+ cacheToken: tileset.generateVersion,
18184
+ api: api
18185
+ });
18186
+ }
18187
+ // Backup. Should not be needed.
18188
+ if (!loadUrl) {
18189
+ loadUrl = BModels.Tileset.GetFileUrl({
18190
+ api,
18191
+ tilesetId: tileset.id,
18192
+ file: "tileset.json",
18193
+ cacheToken: tileset.generateVersion,
18194
+ legacy: false,
18195
+ viaCdn: false
18196
+ });
18197
+ }
18198
+ // ModelTree is needed to map incoming graphics to Entities.
18199
+ // So we load it first, then start rendering.
18200
+ try {
18201
+ // In >v1 the model-tree sits in its own file.
18202
+ if (((_a = tileset.settings) === null || _a === void 0 ? void 0 : _a["tilesetVersion"]) > 1) {
18203
+ const modelTreeUrl = BModels.Tileset.GetFileUrl({
18204
+ api: api,
18205
+ file: "model_tree.json",
18206
+ tilesetId: tileset.id,
18207
+ cacheToken: tileset.generateVersion,
18208
+ viaCdn: Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled)
18209
+ });
18210
+ this.modelTree = await api.get(modelTreeUrl);
18211
+ this.modelTreeUpdate.Trigger(this.modelTree);
18212
+ }
18213
+ // In v1 the model-tree is inside the tileset.json.
18214
+ else {
18215
+ const tilesetJson = await api.get(tileset.loadUrl);
18216
+ this.modelTree = ((_b = tilesetJson === null || tilesetJson === void 0 ? void 0 : tilesetJson.extensions) === null || _b === void 0 ? void 0 : _b.modelTree) || null;
18217
+ this.modelTreeUpdate.Trigger(this.modelTree);
18218
+ }
18219
+ }
18220
+ catch (e) {
18221
+ console.error(e);
18222
+ }
18223
+ if (this.disposed) {
18224
+ return;
18225
+ }
18158
18226
  const settings = tileset.settings;
18159
18227
  const rootId = settings.rootEntityId;
18160
18228
  this.rootId = rootId;
18161
18229
  // If historic, we'll see if the root Entity has a historic position to use.
18162
- if (((_a = this.item.BruceEntity) === null || _a === void 0 ? void 0 : _a.historic) && rootId) {
18230
+ if (((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historic) && rootId) {
18163
18231
  try {
18164
18232
  const { entity: root } = await BModels.Entity.Get({
18165
18233
  entityId: rootId,
@@ -18189,34 +18257,15 @@
18189
18257
  if (!tileset || this.disposed) {
18190
18258
  return;
18191
18259
  }
18192
- // Get the model tree if it's in a separate file.
18193
- // There is a setting that is more explicit but it's lying on the file name so can't trust it yet.
18194
- if (((_a = tileset.settings) === null || _a === void 0 ? void 0 : _a["tilesetVersion"]) > 1) {
18195
- try {
18196
- const modelTreeUrl = BModels.Tileset.GetFileUrl({
18197
- api: api,
18198
- file: "model_tree.json",
18199
- tilesetId: tileset.id,
18200
- cacheToken: tileset.generateVersion,
18201
- viaCdn: Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled)
18202
- });
18203
- this.modelTree = await api.get(modelTreeUrl);
18204
- }
18205
- catch (e) {
18206
- console.error(e);
18207
- }
18208
- }
18209
- if (this.disposed) {
18210
- return;
18211
- }
18212
18260
  // Render outside the shared process because we can't control file requests from Cesium.
18213
18261
  const cTileset = this.cTileset = await exports.TilesetRenderEngine.Render({
18262
+ loadUrl: loadUrl,
18214
18263
  apiGetter: this.getters.GetBruceGetter(),
18215
18264
  tileset: tileset,
18216
18265
  viewer: this.viewer,
18217
18266
  coords: coords,
18218
18267
  accountId: accountId,
18219
- viaCdn: Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled),
18268
+ viaCdn: viaCdn,
18220
18269
  noMemoryLimit: this.item["noMaximumMemory"],
18221
18270
  modelSpace: this.modelSpace
18222
18271
  });
@@ -18466,17 +18515,11 @@
18466
18515
  }
18467
18516
  }
18468
18517
  getMetaByGeomId(geomId, tileset) {
18469
- var _a;
18470
18518
  if (this.treeNodeByGeomId == null) {
18471
- let modelTree = (_a = tileset === null || tileset === void 0 ? void 0 : tileset.extensions) === null || _a === void 0 ? void 0 : _a.modelTree;
18472
- // Wasn't inside tileset.json and instead in a separate file.
18473
- if (!modelTree) {
18474
- modelTree = this.modelTree;
18475
- }
18476
- if (!modelTree) {
18519
+ if (!this.modelTree) {
18477
18520
  return null;
18478
18521
  }
18479
- this.buildModelTreeNodes(modelTree);
18522
+ this.buildModelTreeNodes(this.modelTree);
18480
18523
  }
18481
18524
  return this.treeNodeByGeomId[geomId] || null;
18482
18525
  }
@@ -18510,7 +18553,7 @@
18510
18553
  if (!firstFoundCollapsedBranch && node.collapsed) {
18511
18554
  newFirstFoundCollapsedBranch = cache;
18512
18555
  }
18513
- // Push children to stack in reverse order to maintain correct traversal
18556
+ // Push children to stack in reverse order to maintain correct traversal.
18514
18557
  if (node.children) {
18515
18558
  for (let i = node.children.length - 1; i >= 0; i--) {
18516
18559
  stack.push({
@@ -18524,18 +18567,12 @@
18524
18567
  }
18525
18568
  }
18526
18569
  getEntityTypeByPath(path) {
18527
- var _a, _b;
18528
18570
  const entityId = path[path.length - 1];
18529
18571
  if (this.treeNodeByEntityId == null) {
18530
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18531
- // Wasn't inside tileset.json and instead in a separate file.
18532
- if (!modelTree) {
18533
- modelTree = this.modelTree;
18534
- }
18535
- if (!modelTree) {
18572
+ if (!this.modelTree) {
18536
18573
  return null;
18537
18574
  }
18538
- this.buildModelTreeNodes(modelTree);
18575
+ this.buildModelTreeNodes(this.modelTree);
18539
18576
  }
18540
18577
  const node = this.treeNodeByEntityId[entityId] || null;
18541
18578
  return node ? node.typeId : null;
@@ -18546,16 +18583,11 @@
18546
18583
  * @returns The parent node or null if no parent exists
18547
18584
  */
18548
18585
  getParentNode(entityId) {
18549
- var _a, _b;
18550
18586
  if (this.treeNodeByEntityId == null) {
18551
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18552
- if (!modelTree) {
18553
- modelTree = this.modelTree;
18554
- }
18555
- if (!modelTree) {
18587
+ if (!this.modelTree) {
18556
18588
  return null;
18557
18589
  }
18558
- this.buildModelTreeNodes(modelTree);
18590
+ this.buildModelTreeNodes(this.modelTree);
18559
18591
  }
18560
18592
  const node = this.treeNodeByEntityId[entityId];
18561
18593
  if (node === null || node === void 0 ? void 0 : node.parentId) {
@@ -18569,16 +18601,11 @@
18569
18601
  * @returns Array of child nodes
18570
18602
  */
18571
18603
  getChildNodes(entityId) {
18572
- var _a, _b;
18573
18604
  if (this.treeNodeByEntityId == null) {
18574
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18575
- if (!modelTree) {
18576
- modelTree = this.modelTree;
18577
- }
18578
- if (!modelTree) {
18605
+ if (!this.modelTree) {
18579
18606
  return [];
18580
18607
  }
18581
- this.buildModelTreeNodes(modelTree);
18608
+ this.buildModelTreeNodes(this.modelTree);
18582
18609
  }
18583
18610
  const children = [];
18584
18611
  for (const nodeId in this.treeNodeByEntityId) {
@@ -18595,16 +18622,11 @@
18595
18622
  * @returns Array of descendant nodes
18596
18623
  */
18597
18624
  getDescendantNodes(entityId) {
18598
- var _a, _b;
18599
18625
  if (this.treeNodeByEntityId == null) {
18600
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18601
- if (!modelTree) {
18602
- modelTree = this.modelTree;
18603
- }
18604
- if (!modelTree) {
18626
+ if (!this.modelTree) {
18605
18627
  return [];
18606
18628
  }
18607
- this.buildModelTreeNodes(modelTree);
18629
+ this.buildModelTreeNodes(this.modelTree);
18608
18630
  }
18609
18631
  const descendants = [];
18610
18632
  const stack = [entityId];
@@ -18628,16 +18650,11 @@
18628
18650
  * @returns The root node or null if no tree exists
18629
18651
  */
18630
18652
  getRootNode() {
18631
- var _a, _b;
18632
18653
  if (this.treeNodeByEntityId == null) {
18633
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18634
- if (!modelTree) {
18635
- modelTree = this.modelTree;
18636
- }
18637
- if (!modelTree) {
18654
+ if (!this.modelTree) {
18638
18655
  return null;
18639
18656
  }
18640
- this.buildModelTreeNodes(modelTree);
18657
+ this.buildModelTreeNodes(this.modelTree);
18641
18658
  }
18642
18659
  // Find the node with no parent (root node)
18643
18660
  for (const nodeId in this.treeNodeByEntityId) {
@@ -18654,16 +18671,11 @@
18654
18671
  * @returns Array of node IDs representing the path from root to the entity
18655
18672
  */
18656
18673
  getNodePath(entityId) {
18657
- var _a, _b;
18658
18674
  if (this.treeNodeByEntityId == null) {
18659
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18660
- if (!modelTree) {
18661
- modelTree = this.modelTree;
18662
- }
18663
- if (!modelTree) {
18675
+ if (!this.modelTree) {
18664
18676
  return [];
18665
18677
  }
18666
- this.buildModelTreeNodes(modelTree);
18678
+ this.buildModelTreeNodes(this.modelTree);
18667
18679
  }
18668
18680
  const path = [];
18669
18681
  let currentId = entityId;
@@ -18683,16 +18695,11 @@
18683
18695
  * @returns Map of entityId to path array
18684
18696
  */
18685
18697
  getNodePathsBatch(entityIds) {
18686
- var _a, _b;
18687
18698
  if (this.treeNodeByEntityId == null) {
18688
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18689
- if (!modelTree) {
18690
- modelTree = this.modelTree;
18691
- }
18692
- if (!modelTree) {
18699
+ if (!this.modelTree) {
18693
18700
  return new Map();
18694
18701
  }
18695
- this.buildModelTreeNodes(modelTree);
18702
+ this.buildModelTreeNodes(this.modelTree);
18696
18703
  }
18697
18704
  const paths = new Map();
18698
18705
  for (const entityId of entityIds) {
@@ -18716,16 +18723,11 @@
18716
18723
  * @returns Map of entityId to parent node
18717
18724
  */
18718
18725
  getParentNodesBatch(entityIds) {
18719
- var _a, _b;
18720
18726
  if (this.treeNodeByEntityId == null) {
18721
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18722
- if (!modelTree) {
18723
- modelTree = this.modelTree;
18724
- }
18725
- if (!modelTree) {
18727
+ if (!this.modelTree) {
18726
18728
  return new Map();
18727
18729
  }
18728
- this.buildModelTreeNodes(modelTree);
18730
+ this.buildModelTreeNodes(this.modelTree);
18729
18731
  }
18730
18732
  const parents = new Map();
18731
18733
  for (const entityId of entityIds) {
@@ -18745,16 +18747,11 @@
18745
18747
  * @returns Map of entityId to array of child nodes
18746
18748
  */
18747
18749
  getChildNodesBatch(entityIds) {
18748
- var _a, _b;
18749
18750
  if (this.treeNodeByEntityId == null) {
18750
- let modelTree = (_b = (_a = this.cTileset) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b.modelTree;
18751
- if (!modelTree) {
18752
- modelTree = this.modelTree;
18753
- }
18754
- if (!modelTree) {
18751
+ if (!this.modelTree) {
18755
18752
  return new Map();
18756
18753
  }
18757
- this.buildModelTreeNodes(modelTree);
18754
+ this.buildModelTreeNodes(this.modelTree);
18758
18755
  }
18759
18756
  const children = new Map();
18760
18757
  // Initialize all entityIds with empty arrays
@@ -22326,6 +22323,12 @@
22326
22323
  get Disposed() {
22327
22324
  return this.disposed;
22328
22325
  }
22326
+ get Hierarchy() {
22327
+ return this.hierarchy;
22328
+ }
22329
+ get HierarchyUpdate() {
22330
+ return this.hierarchyUpdate;
22331
+ }
22329
22332
  get ModelSpace() {
22330
22333
  return this.modelSpace;
22331
22334
  }
@@ -22333,6 +22336,7 @@
22333
22336
  this.disposed = false;
22334
22337
  // Cache of the hierarchy so that our scene-tree can reference it.
22335
22338
  this.hierarchy = null;
22339
+ this.hierarchyUpdate = new BModels.BruceEvent();
22336
22340
  // Quick look-up of the hierarchy nodes by entity ID.
22337
22341
  this.hierarchyNodeByEntityId = null;
22338
22342
  this.modelSpace = false;
@@ -22362,6 +22366,7 @@
22362
22366
  if (this.disposed) {
22363
22367
  return;
22364
22368
  }
22369
+ this.hierarchyUpdate.Trigger(hierarchy);
22365
22370
  // Build hierarchy node cache for quick lookups
22366
22371
  this.buildHierarchyNodes(hierarchy);
22367
22372
  const traverseHierarchy = (node, leavesOnly) => {
@@ -31471,6 +31476,7 @@
31471
31476
  width: 100%;
31472
31477
  background-color: rgba(33, 39, 42, 0.8);
31473
31478
  margin-bottom: 20px;
31479
+ margin-top: 20px;
31474
31480
 
31475
31481
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='%23343a3f' d='M0 0h5v5H0zm5 5h5v5H5z'/></svg>");
31476
31482
  background-size: 20px 20px;
@@ -33023,7 +33029,7 @@
33023
33029
  }
33024
33030
  }
33025
33031
 
33026
- const VERSION = "5.9.2";
33032
+ const VERSION = "5.9.4";
33027
33033
 
33028
33034
  exports.VERSION = VERSION;
33029
33035
  exports.isOutlineChanged = isOutlineChanged;