bruce-cesium 7.8.2 → 7.8.3

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.
@@ -50359,6 +50359,21 @@
50359
50359
  });
50360
50360
  }
50361
50361
  EntityUtils.GetOpacity = GetOpacity;
50362
+ // How far under the surface the camera stays when the ground would hide a buried target.
50363
+ const FLY_TO_UNDERGROUND_CLEARANCE = 0.5;
50364
+ // How far a target's top must sit under the ground to count as buried, past terrain sampling error.
50365
+ const FLY_TO_BURIED_TOLERANCE = 1;
50366
+ /*
50367
+ * The camera's height for a fly-to. A buried target keeps the camera near it, not over the ground.
50368
+ */
50369
+ function GetFlyToCameraHeight(targetHeight, radius, lift, groundHeight, groundOccludes) {
50370
+ const height = targetHeight + lift;
50371
+ if (!(targetHeight + (radius || 0) < groundHeight - FLY_TO_BURIED_TOLERANCE)) {
50372
+ return height < groundHeight ? groundHeight + lift : height;
50373
+ }
50374
+ return groundOccludes ? Math.min(height, groundHeight - FLY_TO_UNDERGROUND_CLEARANCE) : height;
50375
+ }
50376
+ EntityUtils.GetFlyToCameraHeight = GetFlyToCameraHeight;
50362
50377
  async function FlyTo(params) {
50363
50378
  var _a, _b;
50364
50379
  let { entityIds, entities, tileset } = params;
@@ -50402,6 +50417,8 @@
50402
50417
  }
50403
50418
  let destination = null;
50404
50419
  let range = 10;
50420
+ // How big the target is, which tells a buried target from one that reaches the surface.
50421
+ let radius = 0;
50405
50422
  const ENTITY_ID = "FLY_TO_ENTITY";
50406
50423
  if (params.debug) {
50407
50424
  params.viewer.entities.removeById(ENTITY_ID);
@@ -50411,6 +50428,7 @@
50411
50428
  location.sphere.radius = 1;
50412
50429
  }
50413
50430
  destination = location.sphere.center;
50431
+ radius = location.sphere.radius;
50414
50432
  range = location.sphere.radius * 3;
50415
50433
  if (params.debug) {
50416
50434
  params.viewer.entities.add({
@@ -50486,13 +50504,20 @@
50486
50504
  // We'll account for range and the terrain height to give an OK starting point.
50487
50505
  let elevatedPos3d = destination.clone();
50488
50506
  const carto = Cesium.Cartographic.fromCartesian(destination);
50489
- carto.height += range;
50490
50507
  const { height: terrHeight } = await exports.DrawingUtils.GetTerrainHeight({
50491
50508
  pos3d: destination,
50492
50509
  viewer: params.viewer
50493
50510
  });
50494
- if (carto.height < terrHeight) {
50495
- carto.height = terrHeight + range;
50511
+ if (is2d) {
50512
+ carto.height += range;
50513
+ if (carto.height < terrHeight) {
50514
+ carto.height = terrHeight + range;
50515
+ }
50516
+ }
50517
+ else {
50518
+ const globe = params.viewer.scene.globe;
50519
+ const groundOccludes = Boolean((globe === null || globe === void 0 ? void 0 : globe.show) && globe.depthTestAgainstTerrain);
50520
+ carto.height = GetFlyToCameraHeight(carto.height, radius, range, terrHeight, groundOccludes);
50496
50521
  }
50497
50522
  elevatedPos3d = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height);
50498
50523
  // If we're working with a cartes3 we can adjust it so the camera is looking from the side at the position.
@@ -60609,7 +60634,7 @@ void main() {
60609
60634
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60610
60635
  })(exports.StyleUtils || (exports.StyleUtils = {}));
60611
60636
 
60612
- const VERSION = "7.8.2";
60637
+ const VERSION = "7.8.3";
60613
60638
  /**
60614
60639
  * Updates the environment instance used by bruce-cesium to one specified.
60615
60640
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.