bruce-cesium 6.0.4 → 6.0.6

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.
@@ -1,6 +1,6 @@
1
1
  import { BruceEvent, Cartes, Entity as Entity$1, ProjectViewTile, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, DataLab, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, AbstractApi, Session } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, SceneMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, KmlDataSource, Quaternion, Matrix3, Matrix4, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, ClassificationType, ArcType, CornerType, ShadowMode, ConstantProperty, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, HorizontalOrigin, VerticalOrigin, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Ion, Cesium3DTileColorBlendMode, KmlDataSource, Quaternion, Matrix3, Matrix4, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, Cesium3DTileset, IonResource, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  const TIME_LAG = 300;
6
6
  const POSITION_CHECK_TIMER = 950;
@@ -2989,6 +2989,7 @@ const CESIUM_TIMELINE_KEY = "_nextspace_timeline";
2989
2989
  const CESIUM_TIMELINE_LIVE_KEY = "_nextspace_timeline_live";
2990
2990
  const CESIUM_TIMELINE_LIVE_PADDING_KEY = "_nextspace_timeline_live_padding";
2991
2991
  const CESIUM_TIMELINE_INTERVAL_KEY = "_nextspace_timeline_interval";
2992
+ const CESIUM_MODEL_SPACE_KEY = "_nextspace_model_space";
2992
2993
  const DEFAULT_LIVE_PADDING_SECONDS = 30 * 60;
2993
2994
  var ViewUtils;
2994
2995
  (function (ViewUtils) {
@@ -3351,7 +3352,7 @@ var ViewUtils;
3351
3352
  }
3352
3353
  // When globe is off, we'll also hide the stars/moon.
3353
3354
  // We also grab the globe color and apply it to the sky.
3354
- if (hidden) {
3355
+ if (hidden && GetModelSpace(viewer)) {
3355
3356
  scene.skyBox.show = false;
3356
3357
  scene.skyAtmosphere.show = false;
3357
3358
  scene.sun.show = false;
@@ -3368,6 +3369,25 @@ var ViewUtils;
3368
3369
  scene.globe.baseColor = baseColor;
3369
3370
  }
3370
3371
  ViewUtils.SetGlobeDetails = SetGlobeDetails;
3372
+ function SetModelSpace(viewer, modelSpace) {
3373
+ if (!viewer) {
3374
+ return;
3375
+ }
3376
+ if (viewer[CESIUM_MODEL_SPACE_KEY] === modelSpace) {
3377
+ return;
3378
+ }
3379
+ viewer[CESIUM_MODEL_SPACE_KEY] = modelSpace;
3380
+ // Reload globe since we display it differently between the two modes.
3381
+ SetGlobeDetails({ viewer });
3382
+ }
3383
+ ViewUtils.SetModelSpace = SetModelSpace;
3384
+ function GetModelSpace(viewer) {
3385
+ if (!viewer) {
3386
+ return false;
3387
+ }
3388
+ return Boolean(viewer[CESIUM_MODEL_SPACE_KEY]);
3389
+ }
3390
+ ViewUtils.GetModelSpace = GetModelSpace;
3371
3391
  })(ViewUtils || (ViewUtils = {}));
3372
3392
 
3373
3393
  function traverseEntity(cEntity, arr, ignoreParent, onlyEditable, onlySelectable) {
@@ -3550,7 +3570,7 @@ var EntityUtils;
3550
3570
  let validSamples = 0;
3551
3571
  // When in model-space, Assembly Entities are all relative to 0,0 lat/lon.
3552
3572
  // Which means we have to ignore the location and calculate based on relative position to 0,0.
3553
- const modelSpace = viewer["nextspace-model-space"] === true;
3573
+ const modelSpace = ViewUtils.GetModelSpace(viewer);
3554
3574
  // Quick lookup on what historic Entities we have and what dates they map to.
3555
3575
  let latestDate = null;
3556
3576
  const entityIdDates = new Map();
@@ -4228,7 +4248,7 @@ var EntityUtils;
4228
4248
  if (allowRendered == null) {
4229
4249
  allowRendered = true;
4230
4250
  }
4231
- const isModelSpace = viewer["nextspace-model-space"] === true;
4251
+ const isModelSpace = ViewUtils.GetModelSpace(viewer);
4232
4252
  const isAssemblyEntity = ((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.AssemblyRootLocation) != null;
4233
4253
  function evaluateRendered() {
4234
4254
  const rego = visualRegister ? visualRegister.GetRego({
@@ -10765,7 +10785,10 @@ function isAlive$1(viewer, visual) {
10765
10785
  if (!cTileset) {
10766
10786
  return false;
10767
10787
  }
10768
- if (cTileset.isDestroyed() || !viewer.scene.primitives.contains(cTileset)) {
10788
+ else if (cTileset.isDestroyed() || !viewer.scene.primitives.contains(cTileset)) {
10789
+ return false;
10790
+ }
10791
+ else if (visual.primitive && visual.primitive.isDestroyed()) {
10769
10792
  return false;
10770
10793
  }
10771
10794
  return true;
@@ -10860,11 +10883,15 @@ function updateEntityShow(viewer, rego, show) {
10860
10883
  }
10861
10884
  function updateEntity(viewer, entityId, register, refresh, cache = {}) {
10862
10885
  var _a;
10886
+ if (!entityId) {
10887
+ // What are we doing?
10888
+ return;
10889
+ }
10863
10890
  // Unavailable for unoptimized single-Entity updates.
10864
10891
  if (!cache) {
10865
10892
  cache = {};
10866
10893
  }
10867
- let regos = register.GetRegos({
10894
+ const regos = register.GetRegos({
10868
10895
  entityId
10869
10896
  });
10870
10897
  regos.sort((a, b) => {
@@ -11149,7 +11176,7 @@ var VisualsRegister;
11149
11176
  for (let i = 0; i < batch.length; i++) {
11150
11177
  const entityId = batch[i];
11151
11178
  // Check if still registered.
11152
- if (!this.rego[entityId] || !this.rego[entityId].length) {
11179
+ if (entityId && (!this.rego[entityId] || !this.rego[entityId].length)) {
11153
11180
  continue;
11154
11181
  }
11155
11182
  updateEntity(this.viewer, entityId, this, this.updateQueueSettings[entityId] == null ? false : this.updateQueueSettings[entityId], cache);
@@ -12190,6 +12217,7 @@ var VisualsRegister;
12190
12217
  }
12191
12218
  return visuals;
12192
12219
  }
12220
+ return [];
12193
12221
  }
12194
12222
  /**
12195
12223
  * Removes regos matching given criteria.
@@ -12327,6 +12355,77 @@ var VisualsRegister;
12327
12355
  }
12328
12356
  }
12329
12357
  }
12358
+ /**
12359
+ * Removes regos matching given visuals.
12360
+ * This is used when we cannot unpack properties from the visual any longer to determine its ID.
12361
+ * Usually for Tileset features.
12362
+ * @param params
12363
+ */
12364
+ RemoveRegosByVisuals(params) {
12365
+ var _a, _b, _c;
12366
+ const { doRemove = true, requestRender = true, source, doUpdate, menuItemId } = params;
12367
+ const entityIds = Object.keys(this.rego);
12368
+ const removedEntityIds = [];
12369
+ for (const entityId of entityIds) {
12370
+ const regos = this.rego[entityId];
12371
+ if (regos && regos.length) {
12372
+ for (const rego of regos) {
12373
+ if (params.visuals.includes(rego.visual)) {
12374
+ EntityLabel.Detatch({
12375
+ rego
12376
+ });
12377
+ if (doRemove != false) {
12378
+ removeEntity(this.viewer, rego.visual);
12379
+ }
12380
+ rego.visual = null;
12381
+ this.rego[entityId] = regos.filter(r => r.visual !== rego.visual);
12382
+ const update = {
12383
+ type: EVisualUpdateType.Remove,
12384
+ entityId: rego.entityId,
12385
+ rego: rego
12386
+ };
12387
+ if (source) {
12388
+ update.source = source;
12389
+ }
12390
+ if (source !== EUpdateSource.TREE_CASCADE) {
12391
+ (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger(update);
12392
+ }
12393
+ if (doUpdate && menuItemId) {
12394
+ this.queueUpdate({
12395
+ entityId: entityId,
12396
+ refresh: false
12397
+ });
12398
+ }
12399
+ if (!removedEntityIds.includes(rego.entityId)) {
12400
+ removedEntityIds.push(rego.entityId);
12401
+ }
12402
+ }
12403
+ // Check siblings.
12404
+ else if ((_b = rego.visual) === null || _b === void 0 ? void 0 : _b["_siblingGraphics"]) {
12405
+ let siblings = rego.visual["_siblingGraphics"];
12406
+ if (doRemove != false) {
12407
+ for (const sibling of siblings) {
12408
+ if (params.visuals.includes(sibling)) {
12409
+ removeEntity(this.viewer, sibling);
12410
+ }
12411
+ }
12412
+ }
12413
+ siblings = siblings.filter(s => !params.visuals.includes(s));
12414
+ rego.visual["_siblingGraphics"] = siblings;
12415
+ }
12416
+ }
12417
+ }
12418
+ if (!((_c = this.rego[entityId]) === null || _c === void 0 ? void 0 : _c.length)) {
12419
+ delete this.rego[entityId];
12420
+ }
12421
+ }
12422
+ if (requestRender) {
12423
+ this.viewer.scene.requestRender();
12424
+ }
12425
+ return {
12426
+ removedEntityIds
12427
+ };
12428
+ }
12330
12429
  /**
12331
12430
  * Returns an array of drilled visuals associated with this register.
12332
12431
  * The top array item is the first found.
@@ -18351,6 +18450,17 @@ var TilesetCadRenderManager;
18351
18450
  this.historicPossesInitialLoaded = false;
18352
18451
  this.historicAnimation = null;
18353
18452
  this.historicPossesLoadingProm = null;
18453
+ // Queue of loaded in features that we haven't processed yet.
18454
+ this.featureQueue = [];
18455
+ // State is true for 'add' or 'false' for 'remove'.
18456
+ this.featureQueueStates = new Map();
18457
+ this.featureQueueInterval = null;
18458
+ // Cache of feature properties we wanted to find vs what we found.
18459
+ // Eg: "entityId" -> "entityId" | "bruceId" | "id" | null.
18460
+ // Eg: "geomId" -> null | "geomId";
18461
+ // Saves having to do a case-insensitive lookup every time.
18462
+ this.featurePropCache = new Map();
18463
+ this.featurePropsChecked = 0;
18354
18464
  const { viewer, register: visualsManager, getters, item, modelSpace } = params;
18355
18465
  this.viewer = viewer;
18356
18466
  this.getters = getters;
@@ -18385,7 +18495,7 @@ var TilesetCadRenderManager;
18385
18495
  // Single shared getter to avoid multiple assemblies fighting to render.
18386
18496
  // This lets one complete, then the next start.
18387
18497
  await SharedGetters.Queue.Run("Rendering assembly.", async () => {
18388
- var _a, _b, _c;
18498
+ var _a, _b;
18389
18499
  if (this.disposed) {
18390
18500
  return;
18391
18501
  }
@@ -18443,30 +18553,39 @@ var TilesetCadRenderManager;
18443
18553
  viaCdn: false
18444
18554
  });
18445
18555
  }
18446
- // ModelTree is needed to map incoming graphics to Entities.
18447
- // So we load it first, then start rendering.
18448
- try {
18449
- // In >v1 the model-tree sits in its own file.
18450
- if (((_a = tileset.settings) === null || _a === void 0 ? void 0 : _a["tilesetVersion"]) > 1) {
18451
- const modelTreeUrl = Tileset.GetFileUrl({
18452
- api: api,
18453
- file: "model_tree.json",
18454
- tilesetId: tileset.id,
18455
- cacheToken: tileset.generateVersion,
18456
- viaCdn: Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled)
18457
- });
18458
- this.modelTree = await api.get(modelTreeUrl);
18459
- this.modelTreeUpdate.Trigger(this.modelTree);
18460
- }
18461
- // In v1 the model-tree is inside the tileset.json.
18462
- else {
18463
- const tilesetJson = await api.get(tileset.loadUrl);
18464
- this.modelTree = ((_b = tilesetJson === null || tilesetJson === void 0 ? void 0 : tilesetJson.extensions) === null || _b === void 0 ? void 0 : _b.modelTree) || null;
18556
+ // TODO: we shouldn't just assume we'll need it, huge assemblies are 100+ MB.
18557
+ // TODO: this is a problem as we need to know what nodes are collapsed...
18558
+ // In >v1 the model-tree sits in its own file.
18559
+ if (((_a = tileset.settings) === null || _a === void 0 ? void 0 : _a["tilesetVersion"]) > 1) {
18560
+ const modelTreeUrl = Tileset.GetFileUrl({
18561
+ api: api,
18562
+ file: "model_tree.json",
18563
+ tilesetId: tileset.id,
18564
+ cacheToken: tileset.generateVersion,
18565
+ viaCdn: Boolean(this.item.cdnEnabled == null ? true : this.item.cdnEnabled)
18566
+ });
18567
+ api.get(modelTreeUrl).then((blob) => {
18568
+ if (this.disposed) {
18569
+ return;
18570
+ }
18571
+ this.modelTree = blob || null;
18465
18572
  this.modelTreeUpdate.Trigger(this.modelTree);
18466
- }
18573
+ }).catch((err) => {
18574
+ this.modelTreeError = err.message || "Unknown error";
18575
+ });
18467
18576
  }
18468
- catch (e) {
18469
- console.error(e);
18577
+ // In v1 the model-tree is inside the tileset.json.
18578
+ else {
18579
+ api.get(tileset.loadUrl).then((blob) => {
18580
+ var _a;
18581
+ if (this.disposed) {
18582
+ return;
18583
+ }
18584
+ this.modelTree = ((_a = blob === null || blob === void 0 ? void 0 : blob.extensions) === null || _a === void 0 ? void 0 : _a.modelTree) || null;
18585
+ this.modelTreeUpdate.Trigger(this.modelTree);
18586
+ }).catch((err) => {
18587
+ this.modelTreeError = err.message || "Unknown error";
18588
+ });
18470
18589
  }
18471
18590
  if (this.disposed) {
18472
18591
  return;
@@ -18475,7 +18594,7 @@ var TilesetCadRenderManager;
18475
18594
  const rootId = settings.rootEntityId;
18476
18595
  this.rootId = rootId;
18477
18596
  // If historic, we'll see if the root Entity has a historic position to use.
18478
- if (((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historic) && rootId) {
18597
+ if (((_b = this.item.BruceEntity) === null || _b === void 0 ? void 0 : _b.historic) && rootId) {
18479
18598
  try {
18480
18599
  const { entity: root } = await Entity$1.Get({
18481
18600
  entityId: rootId,
@@ -18563,7 +18682,7 @@ var TilesetCadRenderManager;
18563
18682
  });
18564
18683
  cTileset.tileLoad.addEventListener((tile) => {
18565
18684
  try {
18566
- this.mapCTile(tile, true);
18685
+ this.queueTile(tile, true);
18567
18686
  }
18568
18687
  catch (e) {
18569
18688
  console.error(e);
@@ -18571,7 +18690,7 @@ var TilesetCadRenderManager;
18571
18690
  });
18572
18691
  cTileset.tileUnload.addEventListener((tile) => {
18573
18692
  try {
18574
- this.mapCTile(tile, false);
18693
+ this.queueTile(tile, false);
18575
18694
  }
18576
18695
  catch (e) {
18577
18696
  console.error(e);
@@ -18594,34 +18713,133 @@ var TilesetCadRenderManager;
18594
18713
  * @param load indicates if we are loading or unloading the tile.
18595
18714
  * @returns
18596
18715
  */
18597
- mapCTile(tile, load) {
18716
+ queueTile(tile, load) {
18598
18717
  const content = tile === null || tile === void 0 ? void 0 : tile.content;
18599
18718
  if (!content) {
18600
18719
  return;
18601
18720
  }
18602
- const regosToQueue = new Map();
18603
18721
  for (let i = 0; i < content.featuresLength; i++) {
18604
18722
  const feature = content.getFeature(i);
18605
- let rego = this.mapTilesetFeature(feature, load);
18606
- if (!(rego === null || rego === void 0 ? void 0 : rego.entityId)) {
18723
+ if (!this.featureQueue.includes(feature)) {
18724
+ this.featureQueue.push(feature);
18725
+ }
18726
+ this.featureQueueStates.set(feature, load);
18727
+ }
18728
+ this.pingFeatureQueue();
18729
+ }
18730
+ /**
18731
+ * Pings the feature queue to process any queued features.
18732
+ * Does nothing if we're already processing.
18733
+ * @returns
18734
+ */
18735
+ pingFeatureQueue() {
18736
+ if (!this.featureQueue.length || this.featureQueueInterval || this.disposed) {
18737
+ return;
18738
+ }
18739
+ this.featureQueueInterval = setInterval(() => {
18740
+ if (this.disposed) {
18741
+ clearInterval(this.featureQueueInterval);
18742
+ this.featureQueueInterval = null;
18743
+ return;
18744
+ }
18745
+ this.processFeatureQueueBatch();
18746
+ if (!this.featureQueue) {
18747
+ clearInterval(this.featureQueueInterval);
18748
+ this.featureQueueInterval = null;
18749
+ }
18750
+ }, 10);
18751
+ }
18752
+ /**
18753
+ * Process a batch of features from the feature queue.
18754
+ */
18755
+ processFeatureQueueBatch() {
18756
+ if (!this.featureQueue.length) {
18757
+ return;
18758
+ }
18759
+ // If features require geomId (don't have bruceId props) then the model tree must be loaded.
18760
+ // If it's not loaded, we simply return and keep waiting.
18761
+ if (!this.modelTree) {
18762
+ /*
18763
+ if (!this.featureQueue[0].getProperty("bruceId")) {
18764
+ return;
18765
+ }
18766
+ */
18767
+ // TODO: For now always requiring it when it's available.
18768
+ // This is because we need to think of a strategy or collapsed items first.
18769
+ if (!this.modelTreeError) {
18770
+ return;
18771
+ }
18772
+ }
18773
+ const BATCH_SIZE = 5000;
18774
+ const batch = this.featureQueue.splice(0, BATCH_SIZE);
18775
+ const regosToStyle = new Map();
18776
+ const featuresToRemove = [];
18777
+ for (const feature of batch) {
18778
+ const load = this.featureQueueStates.get(feature);
18779
+ this.featureQueueStates.delete(feature);
18780
+ if (!load) {
18781
+ featuresToRemove.push(feature);
18782
+ continue;
18783
+ }
18784
+ const result = this.mapTilesetFeature(feature);
18785
+ if (result === null) {
18607
18786
  // Override the default hide state set by the style.
18608
18787
  feature.show = true;
18609
18788
  continue;
18610
18789
  }
18611
- regosToQueue.set(rego.entityId, rego);
18790
+ else if (result) {
18791
+ regosToStyle.set(result.entityId, result);
18792
+ }
18612
18793
  }
18613
- if (this.styler && regosToQueue.size) {
18614
- this.styler.QueueEntities(Array.from(regosToQueue.values()));
18794
+ if (featuresToRemove.length) {
18795
+ const { removedEntityIds } = this.visualsManager.RemoveRegosByVisuals({
18796
+ visuals: featuresToRemove,
18797
+ requestRender: false,
18798
+ menuItemId: this.item.id,
18799
+ doRemove: false
18800
+ });
18801
+ for (const entityId of removedEntityIds) {
18802
+ delete this.loadedCesiumEntities[entityId];
18803
+ }
18804
+ }
18805
+ if (this.styler && regosToStyle.size) {
18806
+ this.styler.QueueEntities(Array.from(regosToStyle.values()));
18807
+ }
18808
+ }
18809
+ evaluateFeatureProps(feature) {
18810
+ var _a;
18811
+ // If we've checked 10 features then we should have a good handle on what props are available.
18812
+ if (this.featurePropsChecked >= 10) {
18813
+ return;
18814
+ }
18815
+ this.featurePropsChecked++;
18816
+ const featureAny = feature;
18817
+ const props = featureAny.getPropertyNames ? featureAny.getPropertyNames() : (_a = featureAny.getPropertyIds) === null || _a === void 0 ? void 0 : _a.call(featureAny);
18818
+ if (!props) {
18819
+ return;
18820
+ }
18821
+ for (const prop of props) {
18822
+ if (!prop) {
18823
+ continue;
18824
+ }
18825
+ const lowered = prop.toLowerCase();
18826
+ if (lowered === "bruceid" || lowered === "id" || lowered === "entityid") {
18827
+ this.featurePropCache.set("entityId", prop);
18828
+ }
18829
+ else if (lowered === "geomid") {
18830
+ this.featurePropCache.set("geomId", prop);
18831
+ }
18832
+ else if (lowered === "brucepath") {
18833
+ this.featurePropCache.set("brucePath", prop);
18834
+ }
18615
18835
  }
18616
- this.viewer.scene.requestRender();
18617
18836
  }
18618
18837
  /**
18619
18838
  * @param feature
18620
- * @param add indicates if we are adding or removing the feature.
18621
18839
  * @returns
18622
18840
  */
18623
- mapTilesetFeature(feature, add) {
18624
- var _a, _b, _c, _d, _e, _f;
18841
+ mapTilesetFeature(feature) {
18842
+ var _a, _b, _c, _d, _e;
18625
18843
  const accountId = (_b = ((_a = this.item.tileset) === null || _a === void 0 ? void 0 : _a.ClientAccountID)) !== null && _b !== void 0 ? _b : this.getters.GetAccountId();
18626
18844
  const canEdit = accountId === this.getters.GetAccountId() && !((_c = this.item.BruceEntity) === null || _c === void 0 ? void 0 : _c.historic);
18627
18845
  let rego = {
@@ -18637,17 +18855,15 @@ var TilesetCadRenderManager;
18637
18855
  tilesetType: Tileset.EType.Cad,
18638
18856
  rootId: this.rootId
18639
18857
  };
18640
- const featureAny = feature;
18641
- const propertyNames = featureAny.getPropertyNames ? featureAny.getPropertyNames() : (_e = featureAny.getPropertyIds) === null || _e === void 0 ? void 0 : _e.call(featureAny);
18642
- if (!propertyNames) {
18643
- return null;
18644
- }
18645
- const setByGeomId = () => {
18646
- const geomIdProp = propertyNames.find(x => String(x).toLowerCase() == "geomid");
18858
+ this.evaluateFeatureProps(feature);
18859
+ // Becoming legacy.
18860
+ // Need to handle collapsed items somehow in newer path first.
18861
+ if (!rego.entityId) {
18862
+ const geomIdProp = this.featurePropCache.get("geomId");
18647
18863
  if (geomIdProp) {
18648
18864
  const geomId = +feature.getProperty(geomIdProp);
18649
18865
  if (geomId != null && (!!geomId || geomId == 0)) {
18650
- const meta = this.getMetaByGeomId(geomId, feature.tileset);
18866
+ const meta = this.getMetaByGeomId(geomId);
18651
18867
  if (meta) {
18652
18868
  rego.entityId = meta.entityId;
18653
18869
  rego.entityTypeId = meta.typeId;
@@ -18656,15 +18872,17 @@ var TilesetCadRenderManager;
18656
18872
  }
18657
18873
  }
18658
18874
  }
18659
- };
18660
- const setByEntityId = () => {
18661
- const bruceIdProp = propertyNames.find(x => (String(x).toLowerCase() == "bruceid"));
18662
- if (bruceIdProp) {
18663
- rego.entityId = feature.getProperty(bruceIdProp);
18875
+ }
18876
+ // Latest path.
18877
+ if (!rego.entityId) {
18878
+ const entityIdProp = this.featurePropCache.get("entityId");
18879
+ if (entityIdProp) {
18880
+ rego.entityId = feature.getProperty(entityIdProp);
18664
18881
  }
18665
- };
18666
- const setByPath = () => {
18667
- const brucePathProp = propertyNames.find(x => String(x).toLowerCase() == "brucepath");
18882
+ }
18883
+ // Super legacy.
18884
+ if (!rego.entityId) {
18885
+ const brucePathProp = this.featurePropCache.get("brucePath");
18668
18886
  if (brucePathProp) {
18669
18887
  const pathStr = feature.getProperty(brucePathProp);
18670
18888
  if (pathStr) {
@@ -18674,20 +18892,13 @@ var TilesetCadRenderManager;
18674
18892
  rego.entityId = path[path.length - 1];
18675
18893
  }
18676
18894
  }
18677
- };
18678
- setByGeomId();
18679
- if (!rego.entityId) {
18680
- setByEntityId();
18681
- }
18682
- if (!rego.entityId) {
18683
- setByPath();
18684
18895
  }
18685
18896
  if (!rego.entityId) {
18686
18897
  return null;
18687
18898
  }
18688
18899
  // Optional menu item restriction.
18689
18900
  // Allows only showing certain entities from a tileset.
18690
- const onlyIds = (_f = this.item.BruceEntity) === null || _f === void 0 ? void 0 : _f.EntityIds;
18901
+ const onlyIds = (_e = this.item.BruceEntity) === null || _e === void 0 ? void 0 : _e.EntityIds;
18691
18902
  if ((onlyIds === null || onlyIds === void 0 ? void 0 : onlyIds.length) && !onlyIds.includes(rego.entityId)) {
18692
18903
  if (this.item.BruceEntity.Ghosts) {
18693
18904
  feature.color = Color.WHITE.clone().withAlpha(0.5);
@@ -18695,74 +18906,60 @@ var TilesetCadRenderManager;
18695
18906
  else {
18696
18907
  feature.show = false;
18697
18908
  }
18698
- return null;
18909
+ return false;
18699
18910
  }
18700
- if (add) {
18701
- // Get the initial hide/show state.
18702
- const state = this.visualsManager.GetState({
18703
- entityId: rego.entityId,
18704
- menuItemId: this.item.id,
18705
- });
18706
- if (this.somethingIsolated == null ||
18707
- // 5s cache.
18708
- (this.somethingIsolatedDateTime && this.somethingIsolatedDateTime.getTime() + 5000 < new Date().getTime())) {
18709
- this.somethingIsolated = this.visualsManager.GetIsIsolatedAny();
18710
- this.somethingIsolatedDateTime = new Date();
18911
+ // Get the initial hide/show state.
18912
+ const state = this.visualsManager.GetState({
18913
+ entityId: rego.entityId,
18914
+ menuItemId: this.item.id,
18915
+ });
18916
+ if (this.somethingIsolated == null ||
18917
+ // 5s cache.
18918
+ (this.somethingIsolatedDateTime && this.somethingIsolatedDateTime.getTime() + 5000 < new Date().getTime())) {
18919
+ this.somethingIsolated = this.visualsManager.GetIsIsolatedAny();
18920
+ this.somethingIsolatedDateTime = new Date();
18921
+ }
18922
+ // Override the default hide state set by the style.
18923
+ let hide = false;
18924
+ if (state) {
18925
+ if (state.hidden) {
18926
+ hide = true;
18711
18927
  }
18712
- // Override the default hide state set by the style.
18713
- let hide = false;
18714
- if (state) {
18715
- if (state.hidden) {
18716
- hide = true;
18717
- }
18718
- else if (state.opacity === 0) {
18719
- hide = true;
18720
- }
18721
- else if (!state.isolated && this.somethingIsolated) {
18722
- hide = true;
18723
- }
18928
+ else if (state.opacity === 0) {
18929
+ hide = true;
18724
18930
  }
18725
- feature.show = !hide;
18726
- // Already exists, so we add this graphic as a sibling.
18727
- if (this.loadedCesiumEntities[rego.entityId]) {
18728
- rego = this.loadedCesiumEntities[rego.entityId];
18729
- if (!rego.visual) {
18730
- // No parent graphic.
18731
- rego.visual = feature;
18931
+ else if (!state.isolated && this.somethingIsolated) {
18932
+ hide = true;
18933
+ }
18934
+ }
18935
+ feature.show = !hide;
18936
+ // Already exists, so we add this graphic as a sibling.
18937
+ if (this.loadedCesiumEntities[rego.entityId]) {
18938
+ rego = this.loadedCesiumEntities[rego.entityId];
18939
+ if (!rego.visual) {
18940
+ // No parent graphic.
18941
+ rego.visual = feature;
18942
+ }
18943
+ else if (rego.visual == feature) ;
18944
+ else {
18945
+ const visual = rego.visual;
18946
+ // Sibling graphic.
18947
+ if (!visual._siblingGraphics) {
18948
+ visual._siblingGraphics = [];
18732
18949
  }
18733
- else if (rego.visual == feature) ;
18734
- else {
18735
- const visual = rego.visual;
18736
- // Sibling graphic.
18737
- if (!visual._siblingGraphics) {
18738
- visual._siblingGraphics = [];
18739
- }
18740
- if (visual._siblingGraphics.indexOf(feature) < 0) {
18741
- visual._siblingGraphics.push(feature);
18742
- }
18950
+ if (visual._siblingGraphics.indexOf(feature) < 0) {
18951
+ visual._siblingGraphics.push(feature);
18743
18952
  }
18744
18953
  }
18745
- this.loadedCesiumEntities[rego.entityId] = rego;
18746
- this.visualsManager.AddRego({
18747
- rego,
18748
- requestRender: false
18749
- });
18750
- return rego;
18751
- }
18752
- else {
18753
- this.visualsManager.RemoveRegos({
18754
- entityId: rego.entityId,
18755
- requestRender: false,
18756
- menuItemId: this.item.id,
18757
- doRemove: false,
18758
- source: VisualsRegister.EUpdateSource.TILESET_DISPOSE
18759
- });
18760
- // Might have to do something smarter since siblings could still be OK.
18761
- this.loadedCesiumEntities[rego.entityId] = null;
18762
- delete this.loadedCesiumEntities[rego.entityId];
18763
18954
  }
18955
+ this.loadedCesiumEntities[rego.entityId] = rego;
18956
+ this.visualsManager.AddRego({
18957
+ rego,
18958
+ requestRender: false
18959
+ });
18960
+ return rego;
18764
18961
  }
18765
- getMetaByGeomId(geomId, tileset) {
18962
+ getMetaByGeomId(geomId) {
18766
18963
  if (this.treeNodeByGeomId == null) {
18767
18964
  if (!this.modelTree) {
18768
18965
  return null;
@@ -18802,8 +18999,8 @@ var TilesetCadRenderManager;
18802
18999
  newFirstFoundCollapsedBranch = cache;
18803
19000
  }
18804
19001
  }
18805
- // Always process children regardless of collapse state
18806
- // This ensures all nodes are mapped, even those under collapsed branches
19002
+ // Always process children regardless of collapse state.
19003
+ // This ensures all nodes are mapped, even those under collapsed branches.
18807
19004
  if (node.children) {
18808
19005
  for (let i = node.children.length - 1; i >= 0; i--) {
18809
19006
  stack.push({
@@ -18828,8 +19025,8 @@ var TilesetCadRenderManager;
18828
19025
  }
18829
19026
  /**
18830
19027
  * Gets the parent node of a given entity.
18831
- * @param entityId The entity ID to find the parent for
18832
- * @returns The parent node or null if no parent exists
19028
+ * @param entityId The entity ID to find the parent for.
19029
+ * @returns The parent node or null if no parent exists.
18833
19030
  */
18834
19031
  getParentNode(entityId) {
18835
19032
  if (this.treeNodeByEntityId == null) {
@@ -18846,8 +19043,8 @@ var TilesetCadRenderManager;
18846
19043
  }
18847
19044
  /**
18848
19045
  * Gets all child nodes of a given entity.
18849
- * @param entityId The entity ID to find children for
18850
- * @returns Array of child nodes
19046
+ * @param entityId The entity ID to find children for.
19047
+ * @returns Array of child nodes.
18851
19048
  */
18852
19049
  getChildNodes(entityId) {
18853
19050
  if (this.treeNodeByEntityId == null) {
@@ -18896,7 +19093,7 @@ var TilesetCadRenderManager;
18896
19093
  }
18897
19094
  /**
18898
19095
  * Gets the root node of the model tree.
18899
- * @returns The root node or null if no tree exists
19096
+ * @returns The root node or null if no tree exists.
18900
19097
  */
18901
19098
  getRootNode() {
18902
19099
  if (this.treeNodeByEntityId == null) {
@@ -18905,7 +19102,7 @@ var TilesetCadRenderManager;
18905
19102
  }
18906
19103
  this.buildModelTreeNodes(this.modelTree);
18907
19104
  }
18908
- // Find the node with no parent (root node)
19105
+ // Find the node with no parent (root node).
18909
19106
  for (const nodeId in this.treeNodeByEntityId) {
18910
19107
  const node = this.treeNodeByEntityId[nodeId];
18911
19108
  if (!node.parentId) {
@@ -18916,8 +19113,8 @@ var TilesetCadRenderManager;
18916
19113
  }
18917
19114
  /**
18918
19115
  * Gets the path from root to a given entity.
18919
- * @param entityId The entity ID to find the path for
18920
- * @returns Array of node IDs representing the path from root to the entity
19116
+ * @param entityId The entity ID to find the path for.
19117
+ * @returns Array of node IDs representing the path from root to the entity.
18921
19118
  */
18922
19119
  getNodePath(entityId) {
18923
19120
  if (this.treeNodeByEntityId == null) {
@@ -18940,8 +19137,8 @@ var TilesetCadRenderManager;
18940
19137
  }
18941
19138
  /**
18942
19139
  * Batch operation to get multiple node paths efficiently.
18943
- * @param entityIds Array of entity IDs to get paths for
18944
- * @returns Map of entityId to path array
19140
+ * @param entityIds Array of entity IDs to get paths for.
19141
+ * @returns Map of entityId to path array.
18945
19142
  */
18946
19143
  getNodePathsBatch(entityIds) {
18947
19144
  if (this.treeNodeByEntityId == null) {
@@ -18968,8 +19165,8 @@ var TilesetCadRenderManager;
18968
19165
  }
18969
19166
  /**
18970
19167
  * Batch operation to get multiple parent nodes efficiently.
18971
- * @param entityIds Array of entity IDs to get parents for
18972
- * @returns Map of entityId to parent node
19168
+ * @param entityIds Array of entity IDs to get parents for.
19169
+ * @returns Map of entityId to parent node.
18973
19170
  */
18974
19171
  getParentNodesBatch(entityIds) {
18975
19172
  if (this.treeNodeByEntityId == null) {
@@ -18992,8 +19189,8 @@ var TilesetCadRenderManager;
18992
19189
  }
18993
19190
  /**
18994
19191
  * Batch operation to get multiple child nodes efficiently.
18995
- * @param entityIds Array of entity IDs to get children for
18996
- * @returns Map of entityId to array of child nodes
19192
+ * @param entityIds Array of entity IDs to get children for.
19193
+ * @returns Map of entityId to array of child nodes.
18997
19194
  */
18998
19195
  getChildNodesBatch(entityIds) {
18999
19196
  if (this.treeNodeByEntityId == null) {
@@ -19003,11 +19200,11 @@ var TilesetCadRenderManager;
19003
19200
  this.buildModelTreeNodes(this.modelTree);
19004
19201
  }
19005
19202
  const children = new Map();
19006
- // Initialize all entityIds with empty arrays
19203
+ // Initialize all entityIds with empty arrays.
19007
19204
  for (const entityId of entityIds) {
19008
19205
  children.set(entityId, []);
19009
19206
  }
19010
- // Build a reverse lookup for efficiency
19207
+ // Build a reverse lookup for efficiency.
19011
19208
  for (const nodeId in this.treeNodeByEntityId) {
19012
19209
  const node = this.treeNodeByEntityId[nodeId];
19013
19210
  if (node.parentId && children.has(node.parentId)) {
@@ -19025,6 +19222,11 @@ var TilesetCadRenderManager;
19025
19222
  }
19026
19223
  doDispose() {
19027
19224
  var _a, _b;
19225
+ if (this.featureQueueInterval) {
19226
+ clearInterval(this.featureQueueInterval);
19227
+ this.featureQueueInterval = null;
19228
+ this.featureQueue = [];
19229
+ }
19028
19230
  if (this.cTileset) {
19029
19231
  const viewer = this.viewer;
19030
19232
  if (!(viewer === null || viewer === void 0 ? void 0 : viewer.isDestroyed()) && this.viewer.scene.primitives.contains(this.cTileset)) {
@@ -26562,9 +26764,6 @@ const ITERATION_KEY$1 = "nextspace-view-render-engine-iteration";
26562
26764
  // 1- new accounts get our token set.
26563
26765
  // 2- we reference to the template account's token.
26564
26766
  const CESIUM_DEFAULT_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiODI1OWQyZC0wYzdlLTRlOTctODFlOC1kYjIwOGYzOWE0NGIiLCJpZCI6MTE3NDg0LCJpYXQiOjE2NzAzODczOTR9.sx0EZdD-Y33FQ7gB_R3CkTsk3KhNpODoQGrnpvSH4UQ";
26565
- // Model-space flag so we know if we're changing from and to model-space.
26566
- // This helps determine if we should instantly transition.
26567
- const MODEL_SPACE_FLAG = "nextspace-model-space";
26568
26767
  /**
26569
26768
  * Creates a new iteration state.
26570
26769
  * This will stop any existing renders from processing to their end.
@@ -26917,7 +27116,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
26917
27116
  });
26918
27117
  }
26919
27118
  }
26920
- viewer[MODEL_SPACE_FLAG] = contentType == ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE;
27119
+ ViewUtils.SetModelSpace(viewer, contentType == ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE);
26921
27120
  let terrain = (bSettings === null || bSettings === void 0 ? void 0 : bSettings.terrain) != null ? bSettings === null || bSettings === void 0 ? void 0 : bSettings.terrain : (_o = defaults.settings) === null || _o === void 0 ? void 0 : _o.terrain;
26922
27121
  if (terrain) {
26923
27122
  // If there is no Cesium token set then we'll swap cesium terrain to flat terrain.
@@ -33318,7 +33517,7 @@ class WidgetViewBar extends Widget.AWidget {
33318
33517
  }
33319
33518
  }
33320
33519
 
33321
- const VERSION = "6.0.4";
33520
+ const VERSION = "6.0.6";
33322
33521
 
33323
- export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, isOutlineChanged, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, AssemblyRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar, WidgetControlViewBar, WidgetControlViewBarSearch, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
33522
+ export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, isOutlineChanged, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, AssemblyRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, DEFAULT_LIVE_PADDING_SECONDS, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar, WidgetControlViewBar, WidgetControlViewBarSearch, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
33324
33523
  //# sourceMappingURL=bruce-cesium.es5.js.map