bruce-cesium 1.7.7 → 1.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.
@@ -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;
@@ -5509,7 +5509,7 @@ var TilesetCadRenderManager;
5509
5509
  }
5510
5510
  };
5511
5511
  Manager.prototype.mapTilesetFeature = function (feature) {
5512
- var _a, _b, _c, _d;
5512
+ var _a, _b, _c, _d, _e;
5513
5513
  var rego = {
5514
5514
  entityId: null,
5515
5515
  entityTypeId: null,
@@ -5520,33 +5520,38 @@ var TilesetCadRenderManager;
5520
5520
  tilesetId: (_c = this.item.tileset) === null || _c === void 0 ? void 0 : _c.TilesetID
5521
5521
  };
5522
5522
  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;
5523
+ var propertyNames = featureAny.getPropertyNames ? featureAny.getPropertyNames() : (_d = featureAny.getPropertyIds) === null || _d === void 0 ? void 0 : _d.call(featureAny);
5524
+ if (!propertyNames) {
5525
+ return null;
5526
+ }
5527
+ // GeomId is higher priority than using entityId directly as we need entityTypeId as well.
5528
+ var geomIdProp = propertyNames.find(function (x) { return String(x).toLowerCase() == "geomid"; });
5529
+ if (geomIdProp) {
5530
+ var geomId = +feature.getProperty(geomIdProp);
5531
+ if (geomId != null && (!!geomId || geomId == 0)) {
5532
+ var meta = this.getMetaByGeomId(geomId, feature.tileset);
5533
+ if (meta) {
5534
+ rego.entityId = meta.id;
5535
+ rego.entityTypeId = meta.typeId;
5536
+ }
5537
+ }
5538
+ }
5539
+ if (!rego.entityId) {
5540
+ var bruceIdProp = propertyNames.find(function (x) { return String(x).toLowerCase() == "bruceid"; });
5541
+ if (bruceIdProp) {
5542
+ rego.entityId = feature.getProperty(bruceIdProp);
5530
5543
  }
5531
- else if (name_1 == "brucepath") {
5532
- var pathStr = feature.getProperty(prop);
5533
- if (pathStr != undefined) {
5544
+ }
5545
+ // Legacy.
5546
+ if (!rego.entityId) {
5547
+ var brucePathProp = propertyNames.find(function (x) { return String(x).toLowerCase() == "brucepath"; });
5548
+ if (brucePathProp) {
5549
+ var pathStr = feature.getProperty(brucePathProp);
5550
+ if (pathStr) {
5534
5551
  var path = pathStr.split("|");
5535
5552
  var entityTypeId = this.getEntityTypeByPath(path);
5536
5553
  rego.entityTypeId = entityTypeId;
5537
5554
  rego.entityId = path[path.length - 1];
5538
- break;
5539
- }
5540
- }
5541
- else if (name_1 == "geomid") {
5542
- var geomId = +feature.getProperty(prop);
5543
- if (geomId != null && (!!geomId || geomId == 0)) {
5544
- var meta = this.getMetaByGeomId(geomId, feature.tileset);
5545
- if (meta) {
5546
- rego.entityId = meta.id;
5547
- rego.entityTypeId = meta.typeId;
5548
- break;
5549
- }
5550
5555
  }
5551
5556
  }
5552
5557
  }
@@ -5555,7 +5560,7 @@ var TilesetCadRenderManager;
5555
5560
  }
5556
5561
  // Optional menu item restriction.
5557
5562
  // Allows only showing certain entities from a tileset.
5558
- var onlyIds = (_d = this.item.BruceEntity) === null || _d === void 0 ? void 0 : _d.EntityIds;
5563
+ var onlyIds = (_e = this.item.BruceEntity) === null || _e === void 0 ? void 0 : _e.EntityIds;
5559
5564
  if ((onlyIds === null || onlyIds === void 0 ? void 0 : onlyIds.length) && !onlyIds.includes(rego.entityId)) {
5560
5565
  if (this.item.BruceEntity.Ghosts) {
5561
5566
  feature.color = Color.WHITE.clone().withAlpha(0.5);
@@ -5573,9 +5578,13 @@ var TilesetCadRenderManager;
5573
5578
  Manager.prototype.getMetaByGeomId = function (geomId, tileset) {
5574
5579
  var _a;
5575
5580
  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, []);
5581
+ return this.digMetaByGeomId(geomId, modelTree, [], 0);
5577
5582
  };
5578
- Manager.prototype.digMetaByGeomId = function (geomId, branch, path) {
5583
+ Manager.prototype.digMetaByGeomId = function (geomId, branch, path, depth) {
5584
+ if (depth > 8) {
5585
+ console.error("digMetaByGeomId: depth > 8");
5586
+ return null;
5587
+ }
5579
5588
  path = [].concat(path);
5580
5589
  path.push(branch.id);
5581
5590
  if (branch.geomId == geomId) {
@@ -5583,7 +5592,7 @@ var TilesetCadRenderManager;
5583
5592
  }
5584
5593
  else if (branch.children) {
5585
5594
  for (var i = 0; i < branch.children.length; i++) {
5586
- var meta = this.digMetaByGeomId(geomId, branch.children[i], path);
5595
+ var meta = this.digMetaByGeomId(geomId, branch.children[i], path, depth + 1);
5587
5596
  if (meta) {
5588
5597
  return meta;
5589
5598
  }