bruce-cesium 5.0.7 → 5.0.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, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, 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, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } 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, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect, Fullscreen } from 'cesium';
4
4
 
5
5
  const TIME_LAG = 300;
6
6
  const POSITION_CHECK_TIMER = 950;
@@ -8714,6 +8714,8 @@ var EntityLabel;
8714
8714
  this.loadTimeout = null;
8715
8715
  this.loadedName = false;
8716
8716
  this.line = null;
8717
+ // Null = not attempted to load.
8718
+ this.additionalTexts = null;
8717
8719
  this.rego = params.rego;
8718
8720
  this.viewer = params.viewer;
8719
8721
  this.api = params.api;
@@ -8933,6 +8935,7 @@ var EntityLabel;
8933
8935
  }
8934
8936
  this._pos3d = pos3d;
8935
8937
  let text = "Unknown Entity";
8938
+ const additionalTexts = this.additionalTexts ? this.additionalTexts : [];
8936
8939
  if (this.rego) {
8937
8940
  if (this.rego.relation) {
8938
8941
  let type = this.rego.relation.RelationType;
@@ -8960,14 +8963,77 @@ var EntityLabel;
8960
8963
  else {
8961
8964
  text = "Unnamed Entity";
8962
8965
  }
8963
- if (text == "Unnamed Entity" && !this.loadedName) {
8964
- text = "Loading...";
8966
+ // Load any missing information and re-render the label afterwards.
8967
+ if (this.additionalTexts == null || (text == "Unnamed Entity" && !this.loadedName)) {
8968
+ let loadName = false;
8969
+ if ((text == "Unnamed Entity" && !this.loadedName)) {
8970
+ text = "Loading...";
8971
+ loadName = true;
8972
+ }
8965
8973
  clearTimeout(this.loadTimeout);
8966
8974
  this.loadTimeout = setTimeout(async () => {
8975
+ var _a, _b;
8967
8976
  if (this.disposed || this.counter != counter) {
8968
8977
  return;
8969
8978
  }
8970
- await this.loadName();
8979
+ // Load additional texts to display alongside the name.
8980
+ if (this.additionalTexts == null) {
8981
+ const additionalTexts = [];
8982
+ // Rego might not have a known or default Entity Type. Eg: OSM building.
8983
+ if (this.rego.entityTypeId) {
8984
+ let entityType = null;
8985
+ try {
8986
+ const data = await EntityType.Get({
8987
+ api: this.api,
8988
+ entityTypeId: this.rego.entityTypeId
8989
+ });
8990
+ if (data === null || data === void 0 ? void 0 : data.entityType) {
8991
+ entityType = data.entityType;
8992
+ }
8993
+ }
8994
+ // Type could be deleted, however we'll just catch that to show a label instead of nothing.
8995
+ // This is not unusual for Tilesets where the Type that is baked might be outdated.
8996
+ catch (e) {
8997
+ console.error(e);
8998
+ }
8999
+ // Type could be deleted, however we'll just catch that to show a label instead of nothing.
9000
+ // This is not unusual for Tilesets where the Type that is baked might be outdated.
9001
+ if (entityType) {
9002
+ const attributes = (_b = (_a = entityType.VisualSettings) === null || _a === void 0 ? void 0 : _a.label) === null || _b === void 0 ? void 0 : _b.attributes;
9003
+ if (attributes) {
9004
+ try {
9005
+ const { entity } = await Entity$1.Get({
9006
+ api: this.api,
9007
+ entityId: this.rego.entityId,
9008
+ entityTypeId: this.rego.entityTypeId,
9009
+ scenario: this.rego.scenario,
9010
+ schemaId: this.rego.schemaId,
9011
+ migrated: true
9012
+ });
9013
+ for (let i = 0; i < attributes.length; i++) {
9014
+ const value = Entity$1.GetValue({
9015
+ entity: entity,
9016
+ path: attributes[i]
9017
+ });
9018
+ if (value) {
9019
+ additionalTexts.push(value);
9020
+ }
9021
+ }
9022
+ }
9023
+ // Entity doesn't exist.
9024
+ // Likely a graphic with an ID that points to no record.
9025
+ catch (e) {
9026
+ console.error(e);
9027
+ }
9028
+ }
9029
+ }
9030
+ }
9031
+ this.additionalTexts = additionalTexts;
9032
+ }
9033
+ // Load name and apply to rego.
9034
+ if (loadName) {
9035
+ await this.loadName();
9036
+ }
8971
9037
  if (this.disposed || this.counter != counter) {
8972
9038
  return;
8973
9039
  }
@@ -8978,6 +9044,12 @@ var EntityLabel;
8978
9044
  if (this.disposed || this.counter != counter) {
8979
9045
  return;
8980
9046
  }
9047
+ const labelContent = `
9048
+ <div>
9049
+ <div style="margin-bottom:4px">${text}</div>
9050
+ ${additionalTexts.map(attr => `<div>${attr}</div>`).join('')}
9051
+ </div>
9052
+ `;
8981
9053
  let ele = null;
8982
9054
  let lineEle = null;
8983
9055
  if (this.label) {
@@ -8985,7 +9057,7 @@ var EntityLabel;
8985
9057
  }
8986
9058
  else {
8987
9059
  ele = document.createElement("div");
8988
- ele.innerHTML = text;
9060
+ ele.innerHTML = labelContent;
8989
9061
  ele.setAttribute("style", `
8990
9062
  position: absolute;
8991
9063
  z-index: 0;
@@ -9119,6 +9191,13 @@ var EntityLabel;
9119
9191
  addHeight = Math.min(distance, this.viewer.camera.positionCartographic.height) / 7;
9120
9192
  }
9121
9193
  }
9194
+ // The ratio is roughly 1m = 11px on the screen.
9195
+ // So if we want to add additional labels then we'll need to adjust the height.
9196
+ if (additionalTexts === null || additionalTexts === void 0 ? void 0 : additionalTexts.length) {
9197
+ // Each additional text is about 16px tall.
9198
+ // So we get the total px height and divide by 11 to get the meters.
9199
+ addHeight += ((additionalTexts.length * 16) / 11);
9200
+ }
9122
9201
  // Safety check.
9123
9202
  if (!addHeight || addHeight <= 0) {
9124
9203
  addHeight = 0.001;
@@ -26167,19 +26246,28 @@ var Walkthrough;
26167
26246
  });
26168
26247
  let lastCheck;
26169
26248
  let currentTime = new Date();
26170
- data.tickRemoval = viewer.clock.onTick.addEventListener(async () => {
26249
+ const interval = setInterval(() => {
26171
26250
  lastCheck = new Date();
26172
- if (lastCheck.getTime() - currentTime.getTime() > (1000 / 60)) {
26251
+ if (lastCheck.getTime() - currentTime.getTime() >= (1000 / 60)) {
26173
26252
  doMovementTick(viewer);
26174
26253
  currentTime = new Date();
26175
26254
  }
26176
- });
26177
- document.addEventListener("keydown", data.handlerKeyDown = (e) => {
26255
+ }, 1000 / 60);
26256
+ data.tickRemoval = () => {
26257
+ clearInterval(interval);
26258
+ };
26259
+ let keyDown = (e) => {
26178
26260
  checkKeybind(viewer, e.key, true);
26179
- }, false);
26180
- document.addEventListener("keyup", data.handlerKeyUp = (e) => {
26261
+ };
26262
+ document.addEventListener("keydown", keyDown, false);
26263
+ let keyUp = (e) => {
26181
26264
  checkKeybind(viewer, e.key, false);
26182
- }, false);
26265
+ };
26266
+ document.addEventListener("keyup", keyUp, false);
26267
+ data.handlerKeysRemoval = () => {
26268
+ document.removeEventListener("keydown", keyDown);
26269
+ document.removeEventListener("keyup", keyUp);
26270
+ };
26183
26271
  data.handlerScreenSpace.setInputAction((e) => {
26184
26272
  data.actions.set(EAction.Looking, true);
26185
26273
  data.mousePosCurrent = data.mousePosStart = Cartesian2.clone(e.position);
@@ -26201,17 +26289,13 @@ var Walkthrough;
26201
26289
  status: false
26202
26290
  });
26203
26291
  if (data) {
26204
- (_a = data.screenSpaceHandler) === null || _a === void 0 ? void 0 : _a.destroy();
26205
- data.screenSpaceHandler = null;
26292
+ (_a = data.handlerScreenSpace) === null || _a === void 0 ? void 0 : _a.destroy();
26293
+ data.handlerScreenSpace = null;
26206
26294
  (_b = data.tickRemoval) === null || _b === void 0 ? void 0 : _b.call(data);
26207
26295
  data.tickRemoval = null;
26208
- if (data.keyDownHandler) {
26209
- document.removeEventListener("keydown", data.keyDownHandler);
26210
- data.keyDownHandler = null;
26211
- }
26212
- if (data.keyUpHandler) {
26213
- document.removeEventListener("keyup", data.keyUpHandler);
26214
- data.keyUpHandler = null;
26296
+ if (data.handlerKeysRemoval) {
26297
+ data.handlerKeysRemoval();
26298
+ data.handlerKeysRemoval = null;
26215
26299
  }
26216
26300
  }
26217
26301
  }
@@ -29360,7 +29444,7 @@ class WidgetViewBar extends Widget.AWidget {
29360
29444
  }
29361
29445
  }
29362
29446
 
29363
- const VERSION = "5.0.7";
29447
+ const VERSION = "5.0.9";
29364
29448
 
29365
29449
  export { VERSION, CesiumViewMonitor, ViewerUtils, ViewerEventTracker, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, DataLabRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, 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 };
29366
29450
  //# sourceMappingURL=bruce-cesium.es5.js.map