bruce-cesium 7.4.6 → 7.4.7

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, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, ColorBlendMode, Model, Ellipsoid, Cartesian2, SceneTransforms, ShaderSource, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, FeatureDetection, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, SceneMode, HeadingPitchRange, Ion, IonResource, Cesium3DTileStyle, Cesium3DTileColorBlendMode, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, Intersect, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CustomDataSource, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Api, Calculator, ClientFile, Entity as Entity$1, EntityTag, EntityType, ObjectUtils, Style, Carto, Geometry as Geometry$1, EntityLod, BruceEvent, EntityCoords, MenuItem, Tileset, ClientFileValueMap, Color as Color$1, ProjectView, ProjectViewBookmark, ZoomControl, Bounds, DataLab, DelayQueue, AccountConcept, EntityRelation, BruceApi, RecordChangeFeed, ProgramKey, ProjectViewLegacyTile, EntitySource, Camera, Account, AccountLimits, Session, UrlUtils, ProjectViewBookmarkGroup, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType, EntityHistoricData } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, HeightReference, ColorBlendMode, HeadingPitchRoll, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, JulianDate, Quaternion, ImageMaterialProperty, DistanceDisplayCondition, PolygonHierarchy, PolylineGraphics, Rectangle, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, FeatureDetection, SceneMode, GeoJsonDataSource, Ion, IonResource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileColorBlendMode, Intersect, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, ScreenSpaceEventHandler, ScreenSpaceEventType, GeometryInstance, Fullscreen, CustomDataSource, CzmlDataSource } from 'cesium';
3
+ import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, Api, Carto, Geometry as Geometry$1, ClientFileValueMap, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, Bounds, DataLab, DelayQueue, AccountConcept, EntityRelation, BruceApi, RecordChangeFeed, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, UrlUtils, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, ProjectViewBookmarkGroup, EntityRelationType, EntityHistoricData } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -5830,6 +5830,9 @@ var EntityLabel;
5830
5830
  this.placementMemory = new PlacementMemory();
5831
5831
  this.forwardingWheel = false;
5832
5832
  this.pendingDrag = null;
5833
+ // Null outside a 3D view.
5834
+ this.horizon = null;
5835
+ this.horizonScratch = new Cartesian3();
5833
5836
  this.TrackPointer = (event) => {
5834
5837
  var _a, _b;
5835
5838
  if (event.pointerType && event.pointerType !== "mouse" && event.pointerType !== "pen")
@@ -6017,9 +6020,45 @@ var EntityLabel;
6017
6020
  }
6018
6021
  };
6019
6022
  }
6023
+ /*
6024
+ * Whether the globe hides a position; labels skip the depth test, so this is their only occluder.
6025
+ */
6026
+ IsBeyondHorizon(position) {
6027
+ if (!this.horizon) {
6028
+ return false;
6029
+ }
6030
+ const { ellipsoid, camera, limbSquared } = this.horizon;
6031
+ // Scaled space makes the ellipsoid a unit sphere.
6032
+ const scaled = ellipsoid.transformPositionToScaledSpace(position, this.horizonScratch);
6033
+ const magnitudeSquared = Cartesian3.magnitudeSquared(scaled);
6034
+ // Test sub-sea-level points from the surface.
6035
+ if (magnitudeSquared > 0 && magnitudeSquared < 1) {
6036
+ Cartesian3.normalize(scaled, scaled);
6037
+ }
6038
+ const toPoint = Cartesian3.subtract(scaled, camera, scaled);
6039
+ const along = -Cartesian3.dot(toPoint, camera);
6040
+ return along > limbSquared && along * along / Cartesian3.magnitudeSquared(toPoint) > limbSquared;
6041
+ }
6042
+ UpdateHorizon() {
6043
+ var _a, _b, _c;
6044
+ const scene = this.viewer.scene;
6045
+ const position = ((_a = scene === null || scene === void 0 ? void 0 : scene.camera) === null || _a === void 0 ? void 0 : _a.positionWC) || ((_b = scene === null || scene === void 0 ? void 0 : scene.camera) === null || _b === void 0 ? void 0 : _b.position);
6046
+ this.horizon = null;
6047
+ if ((scene === null || scene === void 0 ? void 0 : scene.mode) !== SceneMode.SCENE3D || !Number.isFinite(position === null || position === void 0 ? void 0 : position.x)) {
6048
+ return;
6049
+ }
6050
+ const ellipsoid = ((_c = scene.globe) === null || _c === void 0 ? void 0 : _c.ellipsoid) || Ellipsoid.WGS84;
6051
+ const camera = ellipsoid.transformPositionToScaledSpace(position, new Cartesian3());
6052
+ const limbSquared = Cartesian3.magnitudeSquared(camera) - 1;
6053
+ // No horizon from underground.
6054
+ if (limbSquared > 0) {
6055
+ this.horizon = { ellipsoid, camera, limbSquared };
6056
+ }
6057
+ }
6020
6058
  Update() {
6021
6059
  var _a, _b;
6022
6060
  this.coordinates = this.MeasureCoordinates();
6061
+ this.UpdateHorizon();
6023
6062
  const rect = (_b = (_a = this.viewer.canvas).getBoundingClientRect) === null || _b === void 0 ? void 0 : _b.call(_a);
6024
6063
  const pointer = this.pointerClient;
6025
6064
  this.pointer = pointer && (rect === null || rect === void 0 ? void 0 : rect.width) && (rect === null || rect === void 0 ? void 0 : rect.height) && pointer.x >= rect.left && pointer.x < rect.right && pointer.y >= rect.top && pointer.y < rect.bottom ?
@@ -6794,7 +6833,8 @@ var EntityLabel;
6794
6833
  // If we're labelling from a temp label (mouse hover) don't drive opacity by cam distance.
6795
6834
  const hoverOnly = this.Transient && !this.Persistent;
6796
6835
  if (!Number.isFinite(distance) || depth <= 0 || distance < ((_c = this.options.near) !== null && _c !== void 0 ? _c : 0) ||
6797
- distance > ((_d = this.options.far) !== null && _d !== void 0 ? _d : Infinity) || (!this.prePositioned && !hoverOnly && distance >= MAX_DISTANCE)) {
6836
+ distance > ((_d = this.options.far) !== null && _d !== void 0 ? _d : Infinity) || (!this.prePositioned && !hoverOnly && distance >= MAX_DISTANCE) ||
6837
+ layer.IsBeyondHorizon(this._pos3d)) {
6798
6838
  return null;
6799
6839
  }
6800
6840
  const transforms = SceneTransforms;
@@ -50843,7 +50883,7 @@ var StyleUtils;
50843
50883
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
50844
50884
  })(StyleUtils || (StyleUtils = {}));
50845
50885
 
50846
- const VERSION = "7.4.6";
50886
+ const VERSION = "7.4.7";
50847
50887
  /**
50848
50888
  * Updates the environment instance used by bruce-cesium to one specified.
50849
50889
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.