bruce-cesium 6.5.2 → 6.5.4

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 { Cartes, Entity as Entity$1, Calculator, EntityRelationType, EntityType, Style, ENVIRONMENT, ProjectViewTile, DelayQueue, LRUCache, BruceEvent, ObjectUtils, Geometry, EntityHistoricData, EntityLod, ZoomControl, EntityTag, Tileset, Api, EntityCoords, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, ProgramKey, Bounds, Carto, ProjectView, ProjectViewBookmark, ProjectViewLegacyTile, Camera, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, DistanceDisplayCondition, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, BoundingSphere, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
3
+ import { Cartographic, ColorMaterialProperty, Color, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, Entity, DistanceDisplayCondition, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, PolygonHierarchy, ConstantPositionProperty, PolylineGraphics, ArcType, CornerType, HorizontalOrigin, VerticalOrigin, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, Rectangle, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, Cesium3DTileset, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, BoundingSphere, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -14820,23 +14820,13 @@ var DataLabRenderManager;
14820
14820
  DataLabRenderManager.Manager = Manager;
14821
14821
  })(DataLabRenderManager || (DataLabRenderManager = {}));
14822
14822
 
14823
- const TIME_LAG = 300;
14824
- const POSITION_CHECK_TIMER = 950;
14825
14823
  const DEFAULT_GROUNDED_HEIGHT = 300;
14826
14824
  const MINIMUM_VIEW_AREA_SIZE_DEGREES = 0.01;
14827
14825
  const NET_STEP_PERCENT = 5;
14828
14826
  const BORDER_STEPS = 3;
14829
- var ESearchStatus;
14830
- (function (ESearchStatus) {
14831
- ESearchStatus[ESearchStatus["LocationFound"] = 1] = "LocationFound";
14832
- ESearchStatus[ESearchStatus["LocationChanged"] = 2] = "LocationChanged";
14833
- ESearchStatus[ESearchStatus["LocationMissing"] = 3] = "LocationMissing";
14834
- })(ESearchStatus || (ESearchStatus = {}));
14835
- /**
14836
- * @param viewer
14837
- * @param center the previously calculated center of the view area. This is in degrees.
14838
- * @returns
14839
- */
14827
+ function isDefined(value) {
14828
+ return value !== null && value !== undefined;
14829
+ }
14840
14830
  function netScanViewForBoundaries(viewer, center) {
14841
14831
  let maxLong = -2 * Math.PI;
14842
14832
  let minLong = 2 * Math.PI;
@@ -14844,7 +14834,6 @@ function netScanViewForBoundaries(viewer, center) {
14844
14834
  let minLat = 2 * Math.PI;
14845
14835
  let found = 0;
14846
14836
  const updateMinMax = (lon, lat) => {
14847
- // Check to see if given lon/lat (in radians) are within valid range.
14848
14837
  if (lon < -Math.PI || lon > Math.PI || lat < -Math.PI / 2 || lat > Math.PI / 2) {
14849
14838
  return;
14850
14839
  }
@@ -14854,13 +14843,13 @@ function netScanViewForBoundaries(viewer, center) {
14854
14843
  minLat = Math.min(minLat, lat);
14855
14844
  };
14856
14845
  const updateMinMaxForPoint = (stepX, stepY) => {
14857
- const x = Math.round(0 + (viewer.container.clientWidth / 100) * (stepX * NET_STEP_PERCENT));
14858
- const y = Math.round(0 + (viewer.container.clientHeight / 100) * (stepY * NET_STEP_PERCENT));
14846
+ const x = Math.round((viewer.container.clientWidth / 100) * (stepX * NET_STEP_PERCENT));
14847
+ const y = Math.round((viewer.container.clientHeight / 100) * (stepY * NET_STEP_PERCENT));
14859
14848
  const winPos = new Cartesian2(x, y);
14860
14849
  try {
14861
- let intersection = getAdjustedGroundIntersectionOfCameraRay(viewer, winPos);
14850
+ const intersection = getAdjustedGroundIntersectionOfCameraRay(viewer, winPos);
14862
14851
  if (intersection) {
14863
- let point = Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
14852
+ const point = Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
14864
14853
  updateMinMax(point.longitude, point.latitude);
14865
14854
  found++;
14866
14855
  }
@@ -14869,115 +14858,78 @@ function netScanViewForBoundaries(viewer, center) {
14869
14858
  console.error(e);
14870
14859
  }
14871
14860
  };
14872
- // Outer circle.
14873
14861
  updateMinMaxForPoint(BORDER_STEPS, BORDER_STEPS);
14874
14862
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, BORDER_STEPS);
14875
14863
  updateMinMaxForPoint(BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
14876
14864
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS, (100 / NET_STEP_PERCENT) - BORDER_STEPS);
14877
- // Inner circle.
14878
14865
  updateMinMaxForPoint(BORDER_STEPS * 2, BORDER_STEPS * 2);
14879
14866
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, BORDER_STEPS * 2);
14880
14867
  updateMinMaxForPoint(BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
14881
14868
  updateMinMaxForPoint((100 / NET_STEP_PERCENT) - BORDER_STEPS * 2, (100 / NET_STEP_PERCENT) - BORDER_STEPS * 2);
14882
- // If we failed to find intersections and a center-point was provided, then we can use that to make some guesses.
14883
- // This happens if terrain is hidden, and there's nothing to intersect with.
14884
14869
  if (center && found <= 0) {
14885
14870
  updateMinMax(Math$1.toRadians(center.longitude), Math$1.toRadians(center.latitude));
14886
14871
  found += 1;
14887
- // We'll use the camera height as an indicator on size of the rect.
14888
- let size = viewer.camera.positionCartographic.height;
14872
+ const size = viewer.camera.positionCartographic.height;
14889
14873
  const pitch = viewer.camera.pitch;
14890
14874
  const distance = size / Math.tan(pitch);
14891
- const p1 = _offsetPoint({
14875
+ const p1 = offsetPoint({
14892
14876
  altitude: center.altitude,
14893
14877
  latitude: center.latitude,
14894
14878
  longitude: center.longitude
14895
14879
  }, distance, 45);
14896
- const p2 = _offsetPoint({
14880
+ const p2 = offsetPoint({
14897
14881
  altitude: center.altitude,
14898
14882
  latitude: center.latitude,
14899
14883
  longitude: center.longitude
14900
14884
  }, -distance, 45);
14901
- if (p1 === null || p1 === void 0 ? void 0 : p1.latitude) {
14885
+ if (isDefined(p1 === null || p1 === void 0 ? void 0 : p1.latitude) && isDefined(p1 === null || p1 === void 0 ? void 0 : p1.longitude)) {
14902
14886
  updateMinMax(Math$1.toRadians(p1.longitude), Math$1.toRadians(p1.latitude));
14903
14887
  }
14904
- if (p2 === null || p2 === void 0 ? void 0 : p2.latitude) {
14888
+ if (isDefined(p2 === null || p2 === void 0 ? void 0 : p2.latitude) && isDefined(p2 === null || p2 === void 0 ? void 0 : p2.longitude)) {
14905
14889
  updateMinMax(Math$1.toRadians(p2.longitude), Math$1.toRadians(p2.latitude));
14906
14890
  }
14907
14891
  }
14908
14892
  if (found > 0) {
14909
- const viewRect = {
14893
+ return {
14910
14894
  east: maxLong,
14911
14895
  west: minLong,
14912
14896
  north: maxLat,
14913
14897
  south: minLat
14914
14898
  };
14915
- return viewRect;
14916
14899
  }
14917
14900
  return null;
14918
14901
  }
14919
- /**
14920
- * Moves a given point by a given distance towards a heading.
14921
- * @param point in degrees.
14922
- * @param distance in meters.
14923
- * @param heading in degrees.
14924
- * @returns
14925
- */
14926
- function _offsetPoint(point, distance, heading) {
14927
- // Radius of earth.
14902
+ function offsetPoint(point, distance, heading) {
14928
14903
  const radius = 6371e3;
14929
- const δ = distance / radius;
14930
- const θ = Math$1.toRadians(heading);
14931
- const φ1 = Math$1.toRadians(point.latitude);
14932
- const λ1 = Math$1.toRadians(point.longitude);
14933
- const sinφ2 = Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ);
14934
- const φ2 = Math.asin(sinφ2);
14935
- const y = Math.sin(θ) * Math.sin(δ) * Math.cos(φ1);
14936
- const x = Math.cos(δ) - Math.sin(φ1) * sinφ2;
14937
- const λ2 = λ1 + Math.atan2(y, x);
14904
+ const delta = distance / radius;
14905
+ const theta = Math$1.toRadians(heading);
14906
+ const phi1 = Math$1.toRadians(point.latitude);
14907
+ const lambda1 = Math$1.toRadians(point.longitude);
14908
+ const sinPhi2 = Math.sin(phi1) * Math.cos(delta) + Math.cos(phi1) * Math.sin(delta) * Math.cos(theta);
14909
+ const phi2 = Math.asin(sinPhi2);
14910
+ const y = Math.sin(theta) * Math.sin(delta) * Math.cos(phi1);
14911
+ const x = Math.cos(delta) - Math.sin(phi1) * sinPhi2;
14912
+ const lambda2 = lambda1 + Math.atan2(y, x);
14938
14913
  return {
14939
14914
  altitude: point.altitude,
14940
- latitude: Math$1.toDegrees(φ2),
14941
- longitude: Math$1.toDegrees(λ2)
14915
+ latitude: Math$1.toDegrees(phi2),
14916
+ longitude: Math$1.toDegrees(lambda2)
14942
14917
  };
14943
14918
  }
14944
- /**
14945
- * @param pos3d
14946
- * @param distance in meters
14947
- * @param heading in degrees
14948
- * @returns
14949
- */
14950
- function _offsetPos3d(pos3d, distance, heading) {
14919
+ function offsetPos3d(pos3d, distance, heading) {
14951
14920
  const carto = Cartographic.fromCartesian(pos3d);
14952
- const newCarto = _offsetPoint({
14921
+ const newCarto = offsetPoint({
14953
14922
  altitude: carto.height,
14954
14923
  latitude: Math$1.toDegrees(carto.latitude),
14955
14924
  longitude: Math$1.toDegrees(carto.longitude)
14956
14925
  }, distance, heading);
14957
14926
  return Cartesian3.fromDegrees(newCarto.longitude, newCarto.latitude, newCarto.altitude);
14958
14927
  }
14959
- /**
14960
- * Returns the intersection of the camera ray with the ground.
14961
- * @param viewer
14962
- * @param screenPos
14963
- * @returns
14964
- */
14965
14928
  function getAdjustedGroundIntersectionOfCameraRay(viewer, screenPos) {
14966
14929
  const ray = viewer.camera.getPickRay(screenPos);
14967
14930
  const intersection = ray ? viewer.scene.globe.pick(ray, viewer.scene) : null;
14968
- if (intersection) {
14969
- return intersection;
14970
- }
14971
- return null;
14931
+ return intersection || null;
14972
14932
  }
14973
- /**
14974
- * Returns the intersection of the camera ray with the ground.
14975
- * If no intersection is found, then a "guess" is made based on the camera angle and height.
14976
- * The guess is made at the center of the view! It ignores the screenPos.
14977
- * @param viewer
14978
- * @param screenPos
14979
- * @returns
14980
- */
14981
14933
  function getGroundCenterOfCameraRay(viewer, screenPos) {
14982
14934
  var _a, _b;
14983
14935
  const ray = viewer.camera.getPickRay(screenPos);
@@ -14985,19 +14937,114 @@ function getGroundCenterOfCameraRay(viewer, screenPos) {
14985
14937
  if (intersection) {
14986
14938
  return intersection;
14987
14939
  }
14988
- // The fallback will be to "guess" where the intersection might be.
14989
- // This happens if terrain is hidden, and there's nothing to intersect with.
14990
- // We will use the camera angle + camera height.
14991
- // Eg: if camera is looking straight down and is 100 meters above the ground, then the intersection will be 100 meters below the camera.
14992
- let cameraHeight = viewer.camera.positionCartographic.height;
14993
- if (!isNaN(cameraHeight) && cameraHeight != null && ((_b = (_a = viewer.camera) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.clone)) {
14940
+ const cameraHeight = viewer.camera.positionCartographic.height;
14941
+ if (!isNaN(cameraHeight) && isDefined(cameraHeight) && ((_b = (_a = viewer.camera) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.clone)) {
14994
14942
  const cameraPos3d = viewer.camera.position.clone();
14995
14943
  const pitch = viewer.camera.pitch;
14996
14944
  const distance = cameraHeight / Math.tan(pitch);
14997
- return _offsetPos3d(cameraPos3d, -distance, Math$1.toDegrees(viewer.camera.heading));
14945
+ return offsetPos3d(cameraPos3d, -distance, Math$1.toDegrees(viewer.camera.heading));
14998
14946
  }
14999
14947
  return null;
15000
14948
  }
14949
+ var ViewGroundArea;
14950
+ (function (ViewGroundArea) {
14951
+ function ToBboxPolygon(bounds) {
14952
+ return `${bounds.west},${bounds.south} ${bounds.west},${bounds.north} ${bounds.east},${bounds.north} ${bounds.east},${bounds.south}`;
14953
+ }
14954
+ ViewGroundArea.ToBboxPolygon = ToBboxPolygon;
14955
+ async function GetViewArea(viewer) {
14956
+ var _a, _b;
14957
+ if (!viewer || viewer.isDestroyed()) {
14958
+ return null;
14959
+ }
14960
+ if (!viewer.container || ((_a = viewer.container.style) === null || _a === void 0 ? void 0 : _a.display) == "none") {
14961
+ return null;
14962
+ }
14963
+ let viewRect = null;
14964
+ let center = null;
14965
+ const camera = viewer.camera;
14966
+ const terrData = await DrawingUtils.GetTerrainHeight({
14967
+ pos3d: camera.position,
14968
+ viewer
14969
+ });
14970
+ const cameraPosition = viewer.camera.positionCartographic;
14971
+ const terrHeight = terrData.error ? cameraPosition.height + DEFAULT_GROUNDED_HEIGHT : terrData.height;
14972
+ if (terrHeight && ((cameraPosition.height - terrHeight) < DEFAULT_GROUNDED_HEIGHT)) {
14973
+ viewRect = {};
14974
+ const viewRectRad = netScanViewForBoundaries(viewer);
14975
+ if (viewRectRad &&
14976
+ isDefined(viewRectRad.east) &&
14977
+ isDefined(viewRectRad.west) &&
14978
+ isDefined(viewRectRad.north) &&
14979
+ isDefined(viewRectRad.south)) {
14980
+ viewRect.east = Math$1.toDegrees(Math.max(viewRectRad.east, cameraPosition.longitude));
14981
+ viewRect.west = Math$1.toDegrees(Math.min(viewRectRad.west, cameraPosition.longitude));
14982
+ viewRect.south = Math$1.toDegrees(Math.min(viewRectRad.south, cameraPosition.latitude));
14983
+ viewRect.north = Math$1.toDegrees(Math.max(viewRectRad.north, cameraPosition.latitude));
14984
+ }
14985
+ else {
14986
+ viewRect.east = Math$1.toDegrees(cameraPosition.longitude);
14987
+ viewRect.west = Math$1.toDegrees(cameraPosition.longitude);
14988
+ viewRect.south = Math$1.toDegrees(cameraPosition.latitude);
14989
+ viewRect.north = Math$1.toDegrees(cameraPosition.latitude);
14990
+ }
14991
+ center = {
14992
+ altitude: camera.positionCartographic.height,
14993
+ latitude: Math$1.toDegrees(camera.positionCartographic.latitude),
14994
+ longitude: Math$1.toDegrees(camera.positionCartographic.longitude)
14995
+ };
14996
+ }
14997
+ else {
14998
+ const windowPosition = new Cartesian2(viewer.container.clientWidth / 2, viewer.container.clientHeight / 2);
14999
+ const intersection = getGroundCenterOfCameraRay(viewer, windowPosition);
15000
+ let point = null;
15001
+ if (intersection) {
15002
+ point = Cartographic.fromCartesian(intersection, viewer.scene.globe.ellipsoid);
15003
+ }
15004
+ if (point) {
15005
+ center = {
15006
+ altitude: point.height,
15007
+ latitude: Math$1.toDegrees(point.latitude),
15008
+ longitude: Math$1.toDegrees(point.longitude)
15009
+ };
15010
+ const viewRectRad = netScanViewForBoundaries(viewer, center);
15011
+ if (viewRectRad) {
15012
+ viewRect = {};
15013
+ viewRect.east = Math$1.toDegrees(viewRectRad.east);
15014
+ viewRect.west = Math$1.toDegrees(viewRectRad.west);
15015
+ viewRect.south = Math$1.toDegrees(viewRectRad.south);
15016
+ viewRect.north = Math$1.toDegrees(viewRectRad.north);
15017
+ }
15018
+ }
15019
+ }
15020
+ if (viewRect) {
15021
+ const centerLong = (viewRect.east + viewRect.west) / 2;
15022
+ const centerLat = (viewRect.north + viewRect.south) / 2;
15023
+ viewRect.east = Math.max(viewRect.east, centerLong + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15024
+ viewRect.west = Math.min(viewRect.west, centerLong - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15025
+ viewRect.south = Math.min(viewRect.south, centerLat - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15026
+ viewRect.north = Math.max(viewRect.north, centerLat + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15027
+ viewRect.alt = (_b = viewer.scene.camera.positionCartographic) === null || _b === void 0 ? void 0 : _b.height;
15028
+ }
15029
+ if (center && viewRect) {
15030
+ return {
15031
+ bounds: viewRect,
15032
+ target: center
15033
+ };
15034
+ }
15035
+ return null;
15036
+ }
15037
+ ViewGroundArea.GetViewArea = GetViewArea;
15038
+ })(ViewGroundArea || (ViewGroundArea = {}));
15039
+
15040
+ const TIME_LAG = 300;
15041
+ const POSITION_CHECK_TIMER = 950;
15042
+ var ESearchStatus;
15043
+ (function (ESearchStatus) {
15044
+ ESearchStatus[ESearchStatus["LocationFound"] = 1] = "LocationFound";
15045
+ ESearchStatus[ESearchStatus["LocationChanged"] = 2] = "LocationChanged";
15046
+ ESearchStatus[ESearchStatus["LocationMissing"] = 3] = "LocationMissing";
15047
+ })(ESearchStatus || (ESearchStatus = {}));
15001
15048
  function areBoundsEqual(a, b) {
15002
15049
  return a.north == b.north && a.south == b.south && a.east == b.east && a.west == b.west;
15003
15050
  }
@@ -15005,7 +15052,7 @@ function arePosEqual(a, b) {
15005
15052
  return a.latitude == b.latitude && a.longitude == b.longitude;
15006
15053
  }
15007
15054
  var CesiumViewMonitor;
15008
- (function (CesiumViewMonitor$$1) {
15055
+ (function (CesiumViewMonitor) {
15009
15056
  /**
15010
15057
  * Monitors and emits events when the Cesium view changes.
15011
15058
  */
@@ -15079,7 +15126,7 @@ var CesiumViewMonitor;
15079
15126
  this.destroyEntity();
15080
15127
  }
15081
15128
  async tryDoUpdate() {
15082
- var _a, _b;
15129
+ var _a;
15083
15130
  if (!this.viewer || this.viewer.isDestroyed()) {
15084
15131
  this.Dispose();
15085
15132
  return ESearchStatus.LocationMissing;
@@ -15087,73 +15134,10 @@ var CesiumViewMonitor;
15087
15134
  if (!this.viewer.container || ((_a = this.viewer.container.style) === null || _a === void 0 ? void 0 : _a.display) == "none") {
15088
15135
  return ESearchStatus.LocationMissing;
15089
15136
  }
15090
- let viewRect = null;
15091
- let center = null;
15092
- const camera = this.viewer.camera;
15093
- const terrData = await DrawingUtils.GetTerrainHeight({
15094
- pos3d: camera.position,
15095
- viewer: this.viewer
15096
- });
15097
- const cameraPosition = this.viewer.camera.positionCartographic;
15098
- const terrHeight = terrData.error ? cameraPosition.height + DEFAULT_GROUNDED_HEIGHT : terrData.height;
15099
- // We are almost at the ground, screw horizon, just load around.
15100
- if (terrHeight && ((cameraPosition.height - terrHeight) < DEFAULT_GROUNDED_HEIGHT)) {
15101
- // View area calculation.
15102
- viewRect = {};
15103
- const viewRectRad = netScanViewForBoundaries(this.viewer);
15104
- if (viewRectRad &&
15105
- viewRectRad.east &&
15106
- viewRectRad.west &&
15107
- viewRectRad.north &&
15108
- viewRectRad.south) {
15109
- viewRect.east = Math$1.toDegrees(Math.max(viewRectRad.east, cameraPosition.longitude));
15110
- viewRect.west = Math$1.toDegrees(Math.min(viewRectRad.west, cameraPosition.longitude));
15111
- viewRect.south = Math$1.toDegrees(Math.min(viewRectRad.south, cameraPosition.latitude));
15112
- viewRect.north = Math$1.toDegrees(Math.max(viewRectRad.north, cameraPosition.latitude));
15113
- }
15114
- else {
15115
- viewRect.east = cameraPosition.longitude;
15116
- viewRect.west = cameraPosition.longitude;
15117
- viewRect.south = cameraPosition.latitude;
15118
- viewRect.north = cameraPosition.latitude;
15119
- }
15120
- center = {};
15121
- center.latitude = Math$1.toDegrees(camera.positionCartographic.latitude);
15122
- center.longitude = Math$1.toDegrees(camera.positionCartographic.longitude);
15123
- }
15124
- else {
15125
- // View area calculation.
15126
- const windowPosition = new Cartesian2(this.viewer.container.clientWidth / 2, this.viewer.container.clientHeight / 2);
15127
- const intersection = getGroundCenterOfCameraRay(this.viewer, windowPosition);
15128
- let point = null;
15129
- if (intersection) {
15130
- point = Cartographic.fromCartesian(intersection, this.viewer.scene.globe.ellipsoid);
15131
- }
15132
- if (point) {
15133
- center = {};
15134
- center.latitude = Math$1.toDegrees(point.latitude);
15135
- center.longitude = Math$1.toDegrees(point.longitude);
15136
- let viewRectRad = netScanViewForBoundaries(this.viewer, center);
15137
- if (viewRectRad) {
15138
- viewRect = {};
15139
- viewRect.east = Math$1.toDegrees(viewRectRad.east);
15140
- viewRect.west = Math$1.toDegrees(viewRectRad.west);
15141
- viewRect.south = Math$1.toDegrees(viewRectRad.south);
15142
- viewRect.north = Math$1.toDegrees(viewRectRad.north);
15143
- }
15144
- }
15145
- }
15146
- // Minimal field of view.
15147
- if (viewRect) {
15148
- const centerLong = (viewRect.east + viewRect.west) / 2;
15149
- const centerLat = (viewRect.north + viewRect.south) / 2;
15150
- viewRect.east = Math.max(viewRect.east, centerLong + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15151
- viewRect.west = Math.min(viewRect.west, centerLong - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15152
- viewRect.south = Math.min(viewRect.south, centerLat - (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15153
- viewRect.north = Math.max(viewRect.north, centerLat + (MINIMUM_VIEW_AREA_SIZE_DEGREES / 2));
15154
- viewRect.alt = (_b = this.viewer.scene.camera.positionCartographic) === null || _b === void 0 ? void 0 : _b.height;
15155
- }
15156
- if (center && viewRect) {
15137
+ const viewArea = await ViewGroundArea.GetViewArea(this.viewer);
15138
+ if ((viewArea === null || viewArea === void 0 ? void 0 : viewArea.target) && (viewArea === null || viewArea === void 0 ? void 0 : viewArea.bounds)) {
15139
+ const center = viewArea.target;
15140
+ const viewRect = viewArea.bounds;
15157
15141
  if ((!this.target || (this.target && !arePosEqual(this.target, center))) ||
15158
15142
  (!this.bounds || (this.bounds && !areBoundsEqual(this.bounds, viewRect)))) {
15159
15143
  this.target = center;
@@ -15204,7 +15188,7 @@ var CesiumViewMonitor;
15204
15188
  this.queuePosition(TIME_LAG);
15205
15189
  }
15206
15190
  }
15207
- CesiumViewMonitor$$1.Monitor = Monitor;
15191
+ CesiumViewMonitor.Monitor = Monitor;
15208
15192
  })(CesiumViewMonitor || (CesiumViewMonitor = {}));
15209
15193
 
15210
15194
  const MAX_BATCHES = 2;
@@ -26215,7 +26199,7 @@ function doMovementTick(viewer) {
26215
26199
  data.actions.get(EAction.Backward)) {
26216
26200
  const heading = getMovementHeading(viewer);
26217
26201
  const pos = viewer.camera.positionCartographic;
26218
- const newPos = _offsetPoint$1({
26202
+ const newPos = _offsetPoint({
26219
26203
  altitude: pos.height,
26220
26204
  latitude: Math$1.toDegrees(pos.latitude),
26221
26205
  longitude: Math$1.toDegrees(pos.longitude)
@@ -26232,7 +26216,7 @@ function doMovementTick(viewer) {
26232
26216
  * @param heading in degrees.
26233
26217
  * @returns
26234
26218
  */
26235
- function _offsetPoint$1(point, distance, heading) {
26219
+ function _offsetPoint(point, distance, heading) {
26236
26220
  // Radius of earth.
26237
26221
  const radius = 6371e3;
26238
26222
  const δ = distance / radius;
@@ -30185,7 +30169,7 @@ var EntityUtils;
30185
30169
  // This gives a better experience than looking straight down.
30186
30170
  if (!is2d) {
30187
30171
  // Combine the elevation with the sideways offset.
30188
- const finalStartingPosition = _offsetPos3d$1(elevatedPos3d, -range, Math$1.toDegrees(params.viewer.camera.heading));
30172
+ const finalStartingPosition = _offsetPos3d(elevatedPos3d, -range, Math$1.toDegrees(params.viewer.camera.heading));
30189
30173
  // Calculate the direction from the elevated and offset starting position towards the destination.
30190
30174
  const direction = Cartesian3.subtract(destination, finalStartingPosition, new Cartesian3());
30191
30175
  Cartesian3.normalize(direction, direction);
@@ -30241,7 +30225,7 @@ var EntityUtils;
30241
30225
  * @param heading in degrees.
30242
30226
  * @returns
30243
30227
  */
30244
- function _offsetPoint$2(point, distance, heading) {
30228
+ function _offsetPoint$1(point, distance, heading) {
30245
30229
  // Radius of earth.
30246
30230
  const radius = 6371e3;
30247
30231
  const δ = distance / radius;
@@ -30265,9 +30249,9 @@ function _offsetPoint$2(point, distance, heading) {
30265
30249
  * @param heading in degrees
30266
30250
  * @returns
30267
30251
  */
30268
- function _offsetPos3d$1(pos3d, distance, heading) {
30252
+ function _offsetPos3d(pos3d, distance, heading) {
30269
30253
  const carto = Cartographic.fromCartesian(pos3d);
30270
- const newCarto = _offsetPoint$2({
30254
+ const newCarto = _offsetPoint$1({
30271
30255
  altitude: carto.height,
30272
30256
  latitude: Math$1.toDegrees(carto.latitude),
30273
30257
  longitude: Math$1.toDegrees(carto.longitude)
@@ -35329,7 +35313,7 @@ class WidgetViewBar extends Widget.AWidget {
35329
35313
  }
35330
35314
  }
35331
35315
 
35332
- const VERSION = "6.5.2";
35316
+ const VERSION = "6.5.4";
35333
35317
  /**
35334
35318
  * Updates the environment instance used by bruce-cesium to one specified.
35335
35319
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -35346,5 +35330,5 @@ const getENVIRONMENT = () => {
35346
35330
  return ENVIRONMENT;
35347
35331
  };
35348
35332
 
35349
- export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, CesiumAnimatedProperty, isOutlineChanged$1 as isOutlineChanged, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, TilesetRenderEngine, ViewRenderEngine, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, 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, CesiumViewMonitor, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
35333
+ export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, CesiumAnimatedProperty, isOutlineChanged$1 as isOutlineChanged, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, TilesetRenderEngine, ViewRenderEngine, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, 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, CesiumViewMonitor, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
35350
35334
  //# sourceMappingURL=bruce-cesium.es5.js.map