bruce-cesium 5.8.6 → 5.8.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.
@@ -4495,6 +4495,21 @@
4495
4495
  EntityUtils.GetOpacity = GetOpacity;
4496
4496
  async function FlyTo(params) {
4497
4497
  var _a, _b;
4498
+ let { entityIds, entities, tileset } = params;
4499
+ if (!entityIds && !entities && !tileset) {
4500
+ return false;
4501
+ }
4502
+ let entityLookup = new Map();
4503
+ if (!entityIds && entities) {
4504
+ entityIds = entities.map(x => x.Bruce.ID);
4505
+ }
4506
+ if (entities) {
4507
+ for (const entity of entities) {
4508
+ if (entity && entity.Bruce && entity.Bruce.ID) {
4509
+ entityLookup.set(entity.Bruce.ID, entity);
4510
+ }
4511
+ }
4512
+ }
4498
4513
  const is2d = exports.ViewUtils.Get2dStatus({
4499
4514
  viewer: params.viewer
4500
4515
  });
@@ -4503,8 +4518,9 @@
4503
4518
  createIfMissing: true
4504
4519
  });
4505
4520
  const location = await EntityUtils.GetLocation({
4506
- samples: params.entityIds.map((id) => ({
4521
+ samples: entityIds.map((id) => ({
4507
4522
  entityId: id,
4523
+ entity: entityLookup.get(id),
4508
4524
  returnHeightRef: Cesium.HeightReference.NONE,
4509
4525
  heightRef: Cesium.HeightReference.RELATIVE_TO_GROUND
4510
4526
  })),
@@ -4656,8 +4672,8 @@
4656
4672
  });
4657
4673
  return true;
4658
4674
  }
4659
- if (params.tileset && !params.tileset.isDestroyed() && params.tileset["ready"] != false && params.tileset.boundingSphere) {
4660
- params.viewer.zoomTo(params.tileset, new Cesium.HeadingPitchRange(0.0, -0.5, params.tileset.boundingSphere.radius / 4.0));
4675
+ if (tileset && !tileset.isDestroyed() && tileset["ready"] != false && tileset.boundingSphere) {
4676
+ params.viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.5, tileset.boundingSphere.radius / 4.0));
4661
4677
  return true;
4662
4678
  }
4663
4679
  return false;
@@ -14845,6 +14861,14 @@
14845
14861
  get Disposed() {
14846
14862
  return this.disposed;
14847
14863
  }
14864
+ get EntityIds() {
14865
+ var _a, _b;
14866
+ return ((_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.BruceEntity) === null || _b === void 0 ? void 0 : _b.EntityIds) || [];
14867
+ }
14868
+ get ZoomControl() {
14869
+ var _a;
14870
+ return ((_a = this.item) === null || _a === void 0 ? void 0 : _a.CameraZoomSettings) || [];
14871
+ }
14848
14872
  constructor(params) {
14849
14873
  var _a;
14850
14874
  this.getter = null;
@@ -14870,11 +14894,14 @@
14870
14894
  this.clustering = new PointClustering(visualsManager, this.item.id, (_a = this.item) === null || _a === void 0 ? void 0 : _a.clustering);
14871
14895
  }
14872
14896
  }
14873
- Init() {
14897
+ Init(params) {
14874
14898
  var _a, _b, _c;
14875
14899
  if (this.disposed) {
14876
14900
  throw (new Error("This item is disposed."));
14877
14901
  }
14902
+ if (params === null || params === void 0 ? void 0 : params.item) {
14903
+ this.item = params.item;
14904
+ }
14878
14905
  if (!((_a = this.item.CameraZoomSettings) === null || _a === void 0 ? void 0 : _a.length)) {
14879
14906
  this.item.CameraZoomSettings = [
14880
14907
  {
@@ -14891,19 +14918,19 @@
14891
14918
  if (this.renderPriority == null) {
14892
14919
  this.renderPriority = 2;
14893
14920
  }
14894
- this.getter = new BatchedDataGetter.Getter(this.item.BruceEntity.EntityIds, this.monitor, BATCH_SIZE$2,
14895
- // Don't emit the same Entity multiple times.
14896
- true);
14897
- this.getterSub = this.getter.OnUpdate.Subscribe((ids) => {
14898
- this.onGetterUpdate(ids);
14899
- });
14900
- this.getter.Start();
14921
+ if (!this.getter) {
14922
+ this.getter = new BatchedDataGetter.Getter(this.item.BruceEntity.EntityIds, this.monitor, BATCH_SIZE$2,
14923
+ // Don't emit the same Entity multiple times.
14924
+ true);
14925
+ this.getterSub = this.getter.OnUpdate.Subscribe((ids) => {
14926
+ this.onGetterUpdate(ids);
14927
+ });
14928
+ this.getter.Start();
14929
+ }
14930
+ this.viewerDateTimeDispose();
14901
14931
  if (((_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b.historic) || ((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historicAttrKey)) {
14902
14932
  this.viewerDateTimeSub();
14903
14933
  }
14904
- else {
14905
- this.viewerDateTimeDispose();
14906
- }
14907
14934
  }
14908
14935
  Dispose() {
14909
14936
  if (this.disposed) {
@@ -19184,8 +19211,7 @@
19184
19211
  })(exports.DataLabRenderManager || (exports.DataLabRenderManager = {}));
19185
19212
 
19186
19213
  const MAX_BATCHES = 2;
19187
- const BATCH_SIZE_OLD_API = 30;
19188
- const BATCH_SIZE_NEW_API = 1000;
19214
+ const BATCH_SIZE$3 = 1000;
19189
19215
  const BATCH_DELAY = 200;
19190
19216
  const MAX_RANGE = 3000;
19191
19217
  (function (TilesetOsmRenderManager) {
@@ -19199,6 +19225,12 @@
19199
19225
  get count() {
19200
19226
  return ++this.counter;
19201
19227
  }
19228
+ get SourceId() {
19229
+ return this.sourceId;
19230
+ }
19231
+ get EntityTypeId() {
19232
+ return this.entityTypeId;
19233
+ }
19202
19234
  constructor(params) {
19203
19235
  this.disposed = false;
19204
19236
  this.cTileset = null;
@@ -19211,7 +19243,6 @@
19211
19243
  this.queueCheckInterval = null;
19212
19244
  this.processingQueue = 0;
19213
19245
  this._osmIdToBruceId = {};
19214
- this.batchSize = BATCH_SIZE_OLD_API;
19215
19246
  const { viewer, register: visualsManager, getters: apiGetter, monitor, item } = params;
19216
19247
  this.viewer = viewer;
19217
19248
  this.getters = apiGetter;
@@ -19243,12 +19274,22 @@
19243
19274
  });
19244
19275
  this.featureQueue = [];
19245
19276
  }
19246
- Init() {
19277
+ Init(params) {
19247
19278
  var _a, _b;
19279
+ if (params === null || params === void 0 ? void 0 : params.item) {
19280
+ this.item = params.item;
19281
+ }
19248
19282
  const menuItem = this.item;
19249
19283
  this.sourceId = EnsureNumber((_a = menuItem.BruceEntity) === null || _a === void 0 ? void 0 : _a.SourceId, 0);
19250
19284
  this.entityTypeId = (_b = menuItem.BruceEntity) === null || _b === void 0 ? void 0 : _b["EntityType.ID"];
19251
19285
  (async () => {
19286
+ if (this.disposed) {
19287
+ return;
19288
+ }
19289
+ else if (this.cTileset) {
19290
+ // Already exists, no need to re-initialize.
19291
+ return;
19292
+ }
19252
19293
  const validToken = await exports.ViewerUtils.AssertIonToken(Cesium.Ion.defaultAccessToken);
19253
19294
  if (!validToken) {
19254
19295
  console.warn("'tileset-osm-render-manager.ts' could not locate a valid Cesium Ion token.");
@@ -19268,12 +19309,13 @@
19268
19309
  console.warn("'tileset-osm-render-manager.ts' could not locate a create function for OSM buildings.");
19269
19310
  return;
19270
19311
  }
19271
- // New API versions are way better at processing this request.
19272
- const api = this.getters.GetBruceApi();
19273
- await api.Loading;
19274
- if (api.IsVersionAtLeast("1.0.5244")) {
19275
- this.batchSize = BATCH_SIZE_NEW_API;
19312
+ // See if we already have a cTileset set.
19313
+ // Happens if we re-initialized in quick succession.
19314
+ if (this.cTileset) {
19315
+ cTileset.destroy();
19316
+ return;
19276
19317
  }
19318
+ this.cTileset = cTileset;
19277
19319
  if (this.disposed) {
19278
19320
  if (this.cTileset && !this.cTileset.isDestroyed()) {
19279
19321
  this.cTileset.destroy();
@@ -19281,7 +19323,6 @@
19281
19323
  }
19282
19324
  return;
19283
19325
  }
19284
- this.cTileset = cTileset;
19285
19326
  if (this.sourceId) {
19286
19327
  if (menuItem.ghostLoading == true) {
19287
19328
  this.cTileset.style = new Cesium.Cesium3DTileStyle({
@@ -19385,7 +19426,7 @@
19385
19426
  const isClose = this.getIsVisualWithinRange(feature, MAX_RANGE);
19386
19427
  if (isClose) {
19387
19428
  batch.push(feature);
19388
- if (batch.length >= this.batchSize) {
19429
+ if (batch.length >= BATCH_SIZE$3) {
19389
19430
  return batch;
19390
19431
  }
19391
19432
  }
@@ -19535,7 +19576,7 @@
19535
19576
  delete this._loadedCesiumEntities[key];
19536
19577
  this.totalLoaded -= 1;
19537
19578
  removed += 1;
19538
- if (removed >= this.batchSize) {
19579
+ if (removed >= BATCH_SIZE$3) {
19539
19580
  return true;
19540
19581
  }
19541
19582
  }
@@ -20807,9 +20848,33 @@
20807
20848
  this.cTileset = null;
20808
20849
  }
20809
20850
  }
20810
- Init() {
20851
+ Init(params) {
20852
+ if (this.disposed) {
20853
+ return;
20854
+ }
20855
+ if (params === null || params === void 0 ? void 0 : params.item) {
20856
+ this.item = params.item;
20857
+ }
20811
20858
  (async () => {
20812
20859
  var _a;
20860
+ // If the tileset already exists then we just need to update the style.
20861
+ if (this.cTileset) {
20862
+ const colorCss = this.item.colorMask;
20863
+ if (colorCss) {
20864
+ this.cTileset.style = new Cesium.Cesium3DTileStyle({
20865
+ color: {
20866
+ conditions: [
20867
+ ["true", `color("${colorCss}")`]
20868
+ ]
20869
+ }
20870
+ });
20871
+ }
20872
+ else {
20873
+ this.cTileset.style = undefined;
20874
+ }
20875
+ this.viewer.scene.requestRender();
20876
+ return;
20877
+ }
20813
20878
  const CESIUM = Cesium;
20814
20879
  if (!CESIUM.createGooglePhotorealistic3DTileset) {
20815
20880
  console.warn("Cesium version does not support 'createGooglePhotorealistic3DTileset' so Google Photos tileset will not be rendered.");
@@ -22711,7 +22776,7 @@
22711
22776
  * @returns
22712
22777
  */
22713
22778
  RenderItem(params) {
22714
- var _a, _b, _c, _d, _e;
22779
+ var _a, _b, _c, _d, _e, _f, _g, _h;
22715
22780
  if (this.viewer.isDestroyed()) {
22716
22781
  return null;
22717
22782
  }
@@ -22733,6 +22798,7 @@
22733
22798
  }
22734
22799
  let rItem = this.items.find(x => x.id == params.item.id);
22735
22800
  let create = true;
22801
+ // Item already exists so we'll check if we should re-create it.
22736
22802
  if (rItem) {
22737
22803
  // This means we're updating a tag menu item.
22738
22804
  // Tag menu items have alternative states based on bookmark settings.
@@ -22781,18 +22847,76 @@
22781
22847
  create = false;
22782
22848
  }
22783
22849
  }
22850
+ else if (rItem.type == BModels.MenuItem.EType.PointCloud && params.item.Type == BModels.MenuItem.EType.PointCloud) {
22851
+ if (rItem.renderManager) {
22852
+ create = false;
22853
+ }
22854
+ }
22855
+ else if (rItem.type == BModels.MenuItem.EType.ArbTileset && params.item.Type == BModels.MenuItem.EType.ArbTileset) {
22856
+ if (rItem.renderManager) {
22857
+ create = false;
22858
+ }
22859
+ }
22860
+ else if (rItem.type == BModels.MenuItem.EType.I3sTileset && params.item.Type == BModels.MenuItem.EType.I3sTileset) {
22861
+ if (rItem.renderManager) {
22862
+ create = false;
22863
+ }
22864
+ }
22784
22865
  // Re-init in case model-space changed to geo-spatial or vice-versa.
22785
22866
  else if (rItem.type == BModels.MenuItem.EType.Assembly && params.item.Type == BModels.MenuItem.EType.Assembly) {
22786
22867
  if (rItem.renderManager && rItem.renderManager.ModelSpace == params.modelSpace) {
22787
22868
  create = false;
22788
22869
  }
22789
22870
  }
22871
+ // Updating an existing Google photos tileset.
22872
+ // Eg: different color mask (opacity).
22873
+ else if (rItem.type == BModels.MenuItem.EType.GooglePhotoTileset && params.item.Type == BModels.MenuItem.EType.GooglePhotoTileset) {
22874
+ if (rItem.renderManager) {
22875
+ rItem.renderManager.Init({
22876
+ item: params.item
22877
+ });
22878
+ rItem.item = params.item;
22879
+ create = false;
22880
+ }
22881
+ }
22882
+ else if (rItem.type == BModels.MenuItem.EType.Osm && params.item.Type == BModels.MenuItem.EType.Osm) {
22883
+ // If the source is the same then we can re-use the render manager.
22884
+ const oRenderManager = rItem.renderManager;
22885
+ const oItem = params.item;
22886
+ if (oRenderManager && oItem) {
22887
+ if (+oRenderManager.SourceId == +((_b = oItem.BruceEntity) === null || _b === void 0 ? void 0 : _b.SourceId) && oRenderManager.EntityTypeId == ((_c = oItem.BruceEntity) === null || _c === void 0 ? void 0 : _c["EntityType.ID"])) {
22888
+ oRenderManager.Init({
22889
+ item: oItem
22890
+ });
22891
+ rItem.item = params.item;
22892
+ create = false;
22893
+ }
22894
+ }
22895
+ }
22896
+ else if (rItem.type == BModels.MenuItem.EType.EntitiesIds && params.item.Type == BModels.MenuItem.EType.EntitiesIds) {
22897
+ // Checking for Entity IDs.
22898
+ const eIdsRenderManager = rItem.renderManager;
22899
+ const eIdsItem = params.item;
22900
+ if (eIdsRenderManager && eIdsItem) {
22901
+ const eEntityIds = eIdsRenderManager.EntityIds;
22902
+ const mEntityIds = (_d = eIdsItem.BruceEntity) === null || _d === void 0 ? void 0 : _d.EntityIds;
22903
+ const eEntityIdsStr = eEntityIds ? eEntityIds.join(",") : "";
22904
+ const mEntityIdsStr = mEntityIds ? mEntityIds.join(",") : "";
22905
+ if (eEntityIdsStr == mEntityIdsStr) {
22906
+ eIdsRenderManager.Init({
22907
+ item: eIdsItem
22908
+ });
22909
+ rItem.item = params.item;
22910
+ create = false;
22911
+ }
22912
+ }
22913
+ }
22790
22914
  else if (rItem.type != params.item.Type) {
22791
22915
  create = true;
22792
22916
  }
22793
22917
  if (create) {
22794
22918
  try {
22795
- (_b = rItem.renderManager) === null || _b === void 0 ? void 0 : _b.Dispose();
22919
+ (_e = rItem.renderManager) === null || _e === void 0 ? void 0 : _e.Dispose();
22796
22920
  }
22797
22921
  catch (e) {
22798
22922
  console.error(e);
@@ -22803,7 +22927,7 @@
22803
22927
  if (create) {
22804
22928
  if (!rItem) {
22805
22929
  rItem = {
22806
- id: (_c = params.item.id) !== null && _c !== void 0 ? _c : BModels.ObjectUtils.UId(),
22930
+ id: (_f = params.item.id) !== null && _f !== void 0 ? _f : BModels.ObjectUtils.UId(),
22807
22931
  childIds: [],
22808
22932
  item: params.item,
22809
22933
  renderManager: null,
@@ -23002,8 +23126,8 @@
23002
23126
  rItem.childIds.push(childId);
23003
23127
  }
23004
23128
  }
23005
- if (rItem.renderManager && !((_d = rItem.renderManager) === null || _d === void 0 ? void 0 : _d.Disposed)) {
23006
- (_e = this.onUpdate) === null || _e === void 0 ? void 0 : _e.Trigger({ isEnabling: true, itemId: rItem.id });
23129
+ if (rItem.renderManager && !((_g = rItem.renderManager) === null || _g === void 0 ? void 0 : _g.Disposed)) {
23130
+ (_h = this.onUpdate) === null || _h === void 0 ? void 0 : _h.Trigger({ isEnabling: true, itemId: rItem.id });
23007
23131
  }
23008
23132
  return rItem.id;
23009
23133
  }
@@ -32758,7 +32882,7 @@
32758
32882
  }
32759
32883
  }
32760
32884
 
32761
- const VERSION = "5.8.6";
32885
+ const VERSION = "5.8.8";
32762
32886
 
32763
32887
  exports.VERSION = VERSION;
32764
32888
  exports.isOutlineChanged = isOutlineChanged;