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.
@@ -1,6 +1,6 @@
1
1
  import * as Cesium from 'cesium';
2
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, Cartesian3, ClassificationType, ShaderSource, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, ArcType, CornerType, ColorBlendMode, HeadingPitchRoll, Model, JulianDate, Quaternion, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ShadowMode, CustomDataSource, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, GeometryInstance, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, Event, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, Api, Geometry as Geometry$1, EntityLod, UrlUtils, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, ZoomControl, ProjectView, ProjectViewBookmark, EntityRelation, BruceApi, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, HeightReference, Matrix4, ColorBlendMode, Model, ClassificationType, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, DistanceDisplayCondition, ShaderSource, Ellipsoid, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Ion, FeatureDetection, Cesium3DTileset, IonResource, Cesium3DTileColorBlendMode, Intersect, OrthographicFrustum, EasingFunction, WebGLConstants, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CesiumInspector, ClockRange, ShadowMode, DynamicEnvironmentMapManager, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, Event, CustomDataSource, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, GeometryInstance, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Api, Geometry as Geometry$1, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, ClientFileValueMap, Color as Color$1, Bounds, BruceApi, EntityRelation, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -50490,6 +50490,21 @@ var EntityUtils;
50490
50490
  });
50491
50491
  }
50492
50492
  EntityUtils.GetOpacity = GetOpacity;
50493
+ // How far under the surface the camera stays when the ground would hide a buried target.
50494
+ const FLY_TO_UNDERGROUND_CLEARANCE = 0.5;
50495
+ // How far a target's top must sit under the ground to count as buried, past terrain sampling error.
50496
+ const FLY_TO_BURIED_TOLERANCE = 1;
50497
+ /*
50498
+ * The camera's height for a fly-to. A buried target keeps the camera near it, not over the ground.
50499
+ */
50500
+ function GetFlyToCameraHeight(targetHeight, radius, lift, groundHeight, groundOccludes) {
50501
+ const height = targetHeight + lift;
50502
+ if (!(targetHeight + (radius || 0) < groundHeight - FLY_TO_BURIED_TOLERANCE)) {
50503
+ return height < groundHeight ? groundHeight + lift : height;
50504
+ }
50505
+ return groundOccludes ? Math.min(height, groundHeight - FLY_TO_UNDERGROUND_CLEARANCE) : height;
50506
+ }
50507
+ EntityUtils.GetFlyToCameraHeight = GetFlyToCameraHeight;
50493
50508
  async function FlyTo(params) {
50494
50509
  var _a, _b;
50495
50510
  let { entityIds, entities, tileset } = params;
@@ -50533,6 +50548,8 @@ var EntityUtils;
50533
50548
  }
50534
50549
  let destination = null;
50535
50550
  let range = 10;
50551
+ // How big the target is, which tells a buried target from one that reaches the surface.
50552
+ let radius = 0;
50536
50553
  const ENTITY_ID = "FLY_TO_ENTITY";
50537
50554
  if (params.debug) {
50538
50555
  params.viewer.entities.removeById(ENTITY_ID);
@@ -50542,6 +50559,7 @@ var EntityUtils;
50542
50559
  location.sphere.radius = 1;
50543
50560
  }
50544
50561
  destination = location.sphere.center;
50562
+ radius = location.sphere.radius;
50545
50563
  range = location.sphere.radius * 3;
50546
50564
  if (params.debug) {
50547
50565
  params.viewer.entities.add({
@@ -50617,13 +50635,20 @@ var EntityUtils;
50617
50635
  // We'll account for range and the terrain height to give an OK starting point.
50618
50636
  let elevatedPos3d = destination.clone();
50619
50637
  const carto = Cartographic.fromCartesian(destination);
50620
- carto.height += range;
50621
50638
  const { height: terrHeight } = await DrawingUtils.GetTerrainHeight({
50622
50639
  pos3d: destination,
50623
50640
  viewer: params.viewer
50624
50641
  });
50625
- if (carto.height < terrHeight) {
50626
- carto.height = terrHeight + range;
50642
+ if (is2d) {
50643
+ carto.height += range;
50644
+ if (carto.height < terrHeight) {
50645
+ carto.height = terrHeight + range;
50646
+ }
50647
+ }
50648
+ else {
50649
+ const globe = params.viewer.scene.globe;
50650
+ const groundOccludes = Boolean((globe === null || globe === void 0 ? void 0 : globe.show) && globe.depthTestAgainstTerrain);
50651
+ carto.height = GetFlyToCameraHeight(carto.height, radius, range, terrHeight, groundOccludes);
50627
50652
  }
50628
50653
  elevatedPos3d = Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height);
50629
50654
  // If we're working with a cartes3 we can adjust it so the camera is looking from the side at the position.
@@ -60779,7 +60804,7 @@ var StyleUtils;
60779
60804
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60780
60805
  })(StyleUtils || (StyleUtils = {}));
60781
60806
 
60782
- const VERSION = "7.8.2";
60807
+ const VERSION = "7.8.3";
60783
60808
  /**
60784
60809
  * Updates the environment instance used by bruce-cesium to one specified.
60785
60810
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.