bruce-cesium 1.7.7 → 1.7.9

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, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, DelayQueue, BatchedDataGetter, EntityRelationType, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, EntityRelation, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, ProgramKey, Camera } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartesian2, Cartographic, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, HeightReference, EllipsoidTerrainProvider, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, SceneMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, KmlDataSource, createOsmBuildings, Cesium3DTileStyle, Cesium3DTileset, Matrix4, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, OrthographicFrustum, JulianDate, NearFarScalar, PolygonPipeline, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, ColorMaterialProperty, Matrix3, EasingFunction, GeometryInstance } from 'cesium';
3
+ import { Cartesian2, Cartographic, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, HeightReference, EllipsoidTerrainProvider, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, SceneMode, HeadingPitchRange, Cesium3DTileColorBlendMode, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, OrthographicFrustum, JulianDate, NearFarScalar, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileset, Matrix4, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ColorMaterialProperty, Matrix3, EasingFunction, GeometryInstance } from 'cesium';
4
4
 
5
5
  var TIME_LAG = 300;
6
6
  var POSITION_CHECK_TIMER = 950;
@@ -5401,6 +5401,10 @@ var TilesetCadRenderManager;
5401
5401
  this.disposed = false;
5402
5402
  this.cTileset = null;
5403
5403
  this.styler = null;
5404
+ // Indicates the hierarchy depth limit has been hit.
5405
+ // This likely means poor data so we have to disable drilling otherwise lag would be too bad.
5406
+ // The result is no entity type IDs are known so most styles fail.
5407
+ this.hasHitDepthLimit = false;
5404
5408
  var viewer = params.viewer, visualsManager = params.register, apiGetter = params.apiGetter, item = params.item;
5405
5409
  this.viewer = viewer;
5406
5410
  this.apiGetter = apiGetter;
@@ -5509,7 +5513,8 @@ var TilesetCadRenderManager;
5509
5513
  }
5510
5514
  };
5511
5515
  Manager.prototype.mapTilesetFeature = function (feature) {
5512
- var _a, _b, _c, _d;
5516
+ var _this = this;
5517
+ var _a, _b, _c, _d, _e;
5513
5518
  var rego = {
5514
5519
  entityId: null,
5515
5520
  entityTypeId: null,
@@ -5520,42 +5525,54 @@ var TilesetCadRenderManager;
5520
5525
  tilesetId: (_c = this.item.tileset) === null || _c === void 0 ? void 0 : _c.TilesetID
5521
5526
  };
5522
5527
  var featureAny = feature;
5523
- var propertyNames = featureAny.getPropertyNames ? featureAny.getPropertyNames() : featureAny.getPropertyIds();
5524
- for (var i = 0; i < propertyNames.length; i++) {
5525
- var prop = propertyNames[i];
5526
- var name_1 = String(prop).toLocaleLowerCase();
5527
- if (name_1 == "bruceid") {
5528
- rego.entityId = feature.getProperty(prop);
5529
- break;
5530
- }
5531
- else if (name_1 == "brucepath") {
5532
- var pathStr = feature.getProperty(prop);
5533
- if (pathStr != undefined) {
5534
- var path = pathStr.split("|");
5535
- var entityTypeId = this.getEntityTypeByPath(path);
5536
- rego.entityTypeId = entityTypeId;
5537
- rego.entityId = path[path.length - 1];
5538
- break;
5539
- }
5540
- }
5541
- else if (name_1 == "geomid") {
5542
- var geomId = +feature.getProperty(prop);
5528
+ var propertyNames = featureAny.getPropertyNames ? featureAny.getPropertyNames() : (_d = featureAny.getPropertyIds) === null || _d === void 0 ? void 0 : _d.call(featureAny);
5529
+ if (!propertyNames) {
5530
+ return null;
5531
+ }
5532
+ var setByGeomId = function () {
5533
+ var geomIdProp = propertyNames.find(function (x) { return String(x).toLowerCase() == "geomid"; });
5534
+ if (geomIdProp) {
5535
+ var geomId = +feature.getProperty(geomIdProp);
5543
5536
  if (geomId != null && (!!geomId || geomId == 0)) {
5544
- var meta = this.getMetaByGeomId(geomId, feature.tileset);
5537
+ var meta = _this.getMetaByGeomId(geomId, feature.tileset);
5545
5538
  if (meta) {
5546
5539
  rego.entityId = meta.id;
5547
5540
  rego.entityTypeId = meta.typeId;
5548
- break;
5549
5541
  }
5550
5542
  }
5551
5543
  }
5544
+ };
5545
+ var setByEntityId = function () {
5546
+ var bruceIdProp = propertyNames.find(function (x) { return String(x).toLowerCase() == "bruceid"; });
5547
+ if (bruceIdProp) {
5548
+ rego.entityId = feature.getProperty(bruceIdProp);
5549
+ }
5550
+ };
5551
+ var setByPath = function () {
5552
+ var brucePathProp = propertyNames.find(function (x) { return String(x).toLowerCase() == "brucepath"; });
5553
+ if (brucePathProp) {
5554
+ var pathStr = feature.getProperty(brucePathProp);
5555
+ if (pathStr) {
5556
+ var path = pathStr.split("|");
5557
+ var entityTypeId = _this.getEntityTypeByPath(path);
5558
+ rego.entityTypeId = entityTypeId;
5559
+ rego.entityId = path[path.length - 1];
5560
+ }
5561
+ }
5562
+ };
5563
+ setByGeomId();
5564
+ if (!rego.entityId) {
5565
+ setByEntityId();
5566
+ }
5567
+ if (!rego.entityId) {
5568
+ setByPath();
5552
5569
  }
5553
5570
  if (!rego.entityId) {
5554
5571
  return null;
5555
5572
  }
5556
5573
  // Optional menu item restriction.
5557
5574
  // Allows only showing certain entities from a tileset.
5558
- var onlyIds = (_d = this.item.BruceEntity) === null || _d === void 0 ? void 0 : _d.EntityIds;
5575
+ var onlyIds = (_e = this.item.BruceEntity) === null || _e === void 0 ? void 0 : _e.EntityIds;
5559
5576
  if ((onlyIds === null || onlyIds === void 0 ? void 0 : onlyIds.length) && !onlyIds.includes(rego.entityId)) {
5560
5577
  if (this.item.BruceEntity.Ghosts) {
5561
5578
  feature.color = Color.WHITE.clone().withAlpha(0.5);
@@ -5573,9 +5590,16 @@ var TilesetCadRenderManager;
5573
5590
  Manager.prototype.getMetaByGeomId = function (geomId, tileset) {
5574
5591
  var _a;
5575
5592
  var modelTree = (_a = tileset === null || tileset === void 0 ? void 0 : tileset.extensions) === null || _a === void 0 ? void 0 : _a.modelTree;
5576
- return this.digMetaByGeomId(geomId, modelTree, []);
5593
+ return this.digMetaByGeomId(geomId, modelTree, [], 0);
5577
5594
  };
5578
- Manager.prototype.digMetaByGeomId = function (geomId, branch, path) {
5595
+ Manager.prototype.digMetaByGeomId = function (geomId, branch, path, depth) {
5596
+ if (this.hasHitDepthLimit || depth > 10) {
5597
+ if (!this.hasHitDepthLimit) {
5598
+ console.error("digMetaByGeomId: depth > 10. Disabling further attempts.");
5599
+ this.hasHitDepthLimit = true;
5600
+ }
5601
+ return null;
5602
+ }
5579
5603
  path = [].concat(path);
5580
5604
  path.push(branch.id);
5581
5605
  if (branch.geomId == geomId) {
@@ -5583,7 +5607,7 @@ var TilesetCadRenderManager;
5583
5607
  }
5584
5608
  else if (branch.children) {
5585
5609
  for (var i = 0; i < branch.children.length; i++) {
5586
- var meta = this.digMetaByGeomId(geomId, branch.children[i], path);
5610
+ var meta = this.digMetaByGeomId(geomId, branch.children[i], path, depth + 1);
5587
5611
  if (meta) {
5588
5612
  return meta;
5589
5613
  }