bruce-cesium 1.7.6 → 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, Primitive, Cesium3DTileFeature, SceneMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, OrthographicFrustum, JulianDate, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileset, Matrix4, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, ColorMaterialProperty, Matrix3, EasingFunction, GeometryInstance, PolygonPipeline, Cesium3DTileColorBlendMode } 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
  }
@@ -8850,11 +8859,11 @@ function renderLegacyNavigator(params, bookmark, view) {
8850
8859
  * @param view
8851
8860
  */
8852
8861
  function renderNavigator(params, bookmark, view) {
8853
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
8862
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
8854
8863
  return __awaiter(this, void 0, void 0, function () {
8855
- var viewer, scene, vSettings, bSettings, defaults, camera, newLens, curLens, transition, pos, terrain, gOcclusion, hillShades, baseColor, globeHidden, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, entityOpacityMap, entityId, opacity, imagery, renderedRelationEntityIds, curEnabled, newItemIds, _i, curEnabled_1, id, menuItem;
8856
- return __generator(this, function (_4) {
8857
- switch (_4.label) {
8864
+ var viewer, scene, vSettings, bSettings, defaults, camera, newLens, curLens, transition, pos, terrain, gOcclusion, hillShades, baseColor, globeHidden, globeAlpha, shadows, size, ambientOcclusion, AO, lighting, light, quality, fxaa, dateTime, clock, selectedIds, hiddenIds, isolatedIds, entityOpacityMap, entityId, opacity, imagery, renderedRelationEntityIds, curEnabled, newItemIds, _i, curEnabled_1, id, menuItem;
8865
+ return __generator(this, function (_5) {
8866
+ switch (_5.label) {
8858
8867
  case 0:
8859
8868
  viewer = params.manager.Viewer;
8860
8869
  scene = viewer.scene;
@@ -8916,8 +8925,8 @@ function renderNavigator(params, bookmark, view) {
8916
8925
  viewer: params.manager.Viewer,
8917
8926
  })];
8918
8927
  case 1:
8919
- _4.sent();
8920
- _4.label = 2;
8928
+ _5.sent();
8929
+ _5.label = 2;
8921
8930
  case 2:
8922
8931
  gOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.groundOcclusion;
8923
8932
  if (gOcclusion == null) {
@@ -8953,9 +8962,19 @@ function renderNavigator(params, bookmark, view) {
8953
8962
  globeHidden = false;
8954
8963
  }
8955
8964
  scene.globe.show = !globeHidden;
8965
+ globeAlpha = +(bSettings === null || bSettings === void 0 ? void 0 : bSettings.globeAlpha);
8966
+ if (isNaN(globeAlpha)) {
8967
+ globeAlpha = +((_t = defaults.settings) === null || _t === void 0 ? void 0 : _t.globeAlpha);
8968
+ }
8969
+ if (!scene.globe.translucency.enabled) {
8970
+ scene.globe.translucency.enabled = true;
8971
+ scene.globe.translucency.frontFaceAlphaByDistance = new NearFarScalar(400.0, 0.0, 800.0, 1.0);
8972
+ scene.globe.translucency.frontFaceAlphaByDistance.farValue = 1;
8973
+ }
8974
+ scene.globe.translucency.frontFaceAlphaByDistance.nearValue = EnsureNumber(globeAlpha, 1);
8956
8975
  shadows = bSettings === null || bSettings === void 0 ? void 0 : bSettings.shadows;
8957
8976
  if (shadows == null) {
8958
- shadows = (_t = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _t === void 0 ? void 0 : _t.shadows;
8977
+ shadows = (_u = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _u === void 0 ? void 0 : _u.shadows;
8959
8978
  }
8960
8979
  if (shadows == null) {
8961
8980
  shadows = {
@@ -8982,7 +9001,7 @@ function renderNavigator(params, bookmark, view) {
8982
9001
  }
8983
9002
  ambientOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.ambientOcclusion;
8984
9003
  if (ambientOcclusion == null) {
8985
- ambientOcclusion = (_u = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _u === void 0 ? void 0 : _u.ambientOcclusion;
9004
+ ambientOcclusion = (_v = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _v === void 0 ? void 0 : _v.ambientOcclusion;
8986
9005
  }
8987
9006
  if (ambientOcclusion == null) {
8988
9007
  ambientOcclusion = {
@@ -9005,7 +9024,7 @@ function renderNavigator(params, bookmark, view) {
9005
9024
  }
9006
9025
  lighting = bSettings === null || bSettings === void 0 ? void 0 : bSettings.lighting;
9007
9026
  if (lighting == null) {
9008
- lighting = (_v = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _v === void 0 ? void 0 : _v.lighting;
9027
+ lighting = (_w = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _w === void 0 ? void 0 : _w.lighting;
9009
9028
  }
9010
9029
  if (lighting == null) {
9011
9030
  lighting = {
@@ -9020,7 +9039,7 @@ function renderNavigator(params, bookmark, view) {
9020
9039
  }
9021
9040
  quality = bSettings === null || bSettings === void 0 ? void 0 : bSettings.quality;
9022
9041
  if (quality == null) {
9023
- quality = (_w = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _w === void 0 ? void 0 : _w.quality;
9042
+ quality = (_x = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _x === void 0 ? void 0 : _x.quality;
9024
9043
  }
9025
9044
  if (quality == null) {
9026
9045
  quality = {
@@ -9031,7 +9050,7 @@ function renderNavigator(params, bookmark, view) {
9031
9050
  fxaa.enabled = Boolean(quality.fxaa);
9032
9051
  dateTime = bSettings === null || bSettings === void 0 ? void 0 : bSettings.dateTime;
9033
9052
  if (dateTime == null) {
9034
- dateTime = (_x = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _x === void 0 ? void 0 : _x.dateTime;
9053
+ dateTime = (_y = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _y === void 0 ? void 0 : _y.dateTime;
9035
9054
  }
9036
9055
  if (dateTime != null) {
9037
9056
  clock = viewer.clock;
@@ -9039,7 +9058,7 @@ function renderNavigator(params, bookmark, view) {
9039
9058
  }
9040
9059
  selectedIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.selectedEntityIds;
9041
9060
  if (selectedIds == null) {
9042
- selectedIds = (_y = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _y === void 0 ? void 0 : _y.selectedEntityIds;
9061
+ selectedIds = (_z = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _z === void 0 ? void 0 : _z.selectedEntityIds;
9043
9062
  }
9044
9063
  if (selectedIds != null) {
9045
9064
  params.manager.VisualsRegister.ClearSelected();
@@ -9052,7 +9071,7 @@ function renderNavigator(params, bookmark, view) {
9052
9071
  params.manager.VisualsRegister.ClearHidden();
9053
9072
  hiddenIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.hiddenEntityIds;
9054
9073
  if (hiddenIds == null) {
9055
- hiddenIds = (_z = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _z === void 0 ? void 0 : _z.hiddenEntityIds;
9074
+ hiddenIds = (_0 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _0 === void 0 ? void 0 : _0.hiddenEntityIds;
9056
9075
  }
9057
9076
  if (hiddenIds != null) {
9058
9077
  params.manager.VisualsRegister.SetHidden({
@@ -9063,7 +9082,7 @@ function renderNavigator(params, bookmark, view) {
9063
9082
  params.manager.VisualsRegister.ClearIsolated();
9064
9083
  isolatedIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.isolatedEntityIds;
9065
9084
  if (isolatedIds == null) {
9066
- isolatedIds = (_0 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _0 === void 0 ? void 0 : _0.isolatedEntityIds;
9085
+ isolatedIds = (_1 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _1 === void 0 ? void 0 : _1.isolatedEntityIds;
9067
9086
  }
9068
9087
  if (isolatedIds != null) {
9069
9088
  params.manager.VisualsRegister.SetIsolated({
@@ -9074,7 +9093,7 @@ function renderNavigator(params, bookmark, view) {
9074
9093
  params.manager.VisualsRegister.ClearOpacity();
9075
9094
  entityOpacityMap = bSettings === null || bSettings === void 0 ? void 0 : bSettings.entityOpacityMap;
9076
9095
  if (entityOpacityMap == null) {
9077
- entityOpacityMap = (_1 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _1 === void 0 ? void 0 : _1.entityOpacityMap;
9096
+ entityOpacityMap = (_2 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _2 === void 0 ? void 0 : _2.entityOpacityMap;
9078
9097
  }
9079
9098
  if (entityOpacityMap != null) {
9080
9099
  for (entityId in entityOpacityMap) {
@@ -9087,7 +9106,7 @@ function renderNavigator(params, bookmark, view) {
9087
9106
  }
9088
9107
  }
9089
9108
  }
9090
- imagery = (bSettings === null || bSettings === void 0 ? void 0 : bSettings.imagery) != null ? bSettings.imagery : (_2 = defaults.settings) === null || _2 === void 0 ? void 0 : _2.imagery;
9109
+ imagery = (bSettings === null || bSettings === void 0 ? void 0 : bSettings.imagery) != null ? bSettings.imagery : (_3 = defaults.settings) === null || _3 === void 0 ? void 0 : _3.imagery;
9091
9110
  if (imagery == null) {
9092
9111
  // TODO: Need global default.
9093
9112
  imagery = [
@@ -9109,15 +9128,15 @@ function renderNavigator(params, bookmark, view) {
9109
9128
  viewer: params.manager.Viewer,
9110
9129
  })];
9111
9130
  case 3:
9112
- _4.sent();
9131
+ _5.sent();
9113
9132
  renderedRelationEntityIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.renderedEntityRelations;
9114
9133
  if (!renderedRelationEntityIds) {
9115
9134
  renderedRelationEntityIds = [];
9116
9135
  }
9117
9136
  curEnabled = params.manager.GetEnabledItemIds();
9118
- newItemIds = (_3 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _3 !== void 0 ? _3 : [];
9137
+ newItemIds = (_4 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _4 !== void 0 ? _4 : [];
9119
9138
  _i = 0, curEnabled_1 = curEnabled;
9120
- _4.label = 4;
9139
+ _5.label = 4;
9121
9140
  case 4:
9122
9141
  if (!(_i < curEnabled_1.length)) return [3 /*break*/, 7];
9123
9142
  id = curEnabled_1[_i];
@@ -9127,8 +9146,8 @@ function renderNavigator(params, bookmark, view) {
9127
9146
  menuItemId: id
9128
9147
  })];
9129
9148
  case 5:
9130
- _4.sent();
9131
- _4.label = 6;
9149
+ _5.sent();
9150
+ _5.label = 6;
9132
9151
  case 6:
9133
9152
  _i++;
9134
9153
  return [3 /*break*/, 4];
@@ -9141,8 +9160,8 @@ function renderNavigator(params, bookmark, view) {
9141
9160
  bookmark: bookmark
9142
9161
  })];
9143
9162
  case 8:
9144
- _4.sent();
9145
- _4.label = 9;
9163
+ _5.sent();
9164
+ _5.label = 9;
9146
9165
  case 9:
9147
9166
  if (!(renderedRelationEntityIds.length > 0)) return [3 /*break*/, 11];
9148
9167
  menuItem = {
@@ -9158,8 +9177,8 @@ function renderNavigator(params, bookmark, view) {
9158
9177
  item: menuItem
9159
9178
  })];
9160
9179
  case 10:
9161
- _4.sent();
9162
- _4.label = 11;
9180
+ _5.sent();
9181
+ _5.label = 11;
9163
9182
  case 11: return [2 /*return*/];
9164
9183
  }
9165
9184
  });