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.
@@ -5814,6 +5814,9 @@
5814
5814
  this.placementMemory = new PlacementMemory();
5815
5815
  this.forwardingWheel = false;
5816
5816
  this.pendingDrag = null;
5817
+ // Null outside a 3D view.
5818
+ this.horizon = null;
5819
+ this.horizonScratch = new Cesium.Cartesian3();
5817
5820
  this.TrackPointer = (event) => {
5818
5821
  var _a, _b;
5819
5822
  if (event.pointerType && event.pointerType !== "mouse" && event.pointerType !== "pen")
@@ -6001,9 +6004,45 @@
6001
6004
  }
6002
6005
  };
6003
6006
  }
6007
+ /*
6008
+ * Whether the globe hides a position; labels skip the depth test, so this is their only occluder.
6009
+ */
6010
+ IsBeyondHorizon(position) {
6011
+ if (!this.horizon) {
6012
+ return false;
6013
+ }
6014
+ const { ellipsoid, camera, limbSquared } = this.horizon;
6015
+ // Scaled space makes the ellipsoid a unit sphere.
6016
+ const scaled = ellipsoid.transformPositionToScaledSpace(position, this.horizonScratch);
6017
+ const magnitudeSquared = Cesium.Cartesian3.magnitudeSquared(scaled);
6018
+ // Test sub-sea-level points from the surface.
6019
+ if (magnitudeSquared > 0 && magnitudeSquared < 1) {
6020
+ Cesium.Cartesian3.normalize(scaled, scaled);
6021
+ }
6022
+ const toPoint = Cesium.Cartesian3.subtract(scaled, camera, scaled);
6023
+ const along = -Cesium.Cartesian3.dot(toPoint, camera);
6024
+ return along > limbSquared && along * along / Cesium.Cartesian3.magnitudeSquared(toPoint) > limbSquared;
6025
+ }
6026
+ UpdateHorizon() {
6027
+ var _a, _b, _c;
6028
+ const scene = this.viewer.scene;
6029
+ 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);
6030
+ this.horizon = null;
6031
+ if ((scene === null || scene === void 0 ? void 0 : scene.mode) !== Cesium.SceneMode.SCENE3D || !Number.isFinite(position === null || position === void 0 ? void 0 : position.x)) {
6032
+ return;
6033
+ }
6034
+ const ellipsoid = ((_c = scene.globe) === null || _c === void 0 ? void 0 : _c.ellipsoid) || Cesium.Ellipsoid.WGS84;
6035
+ const camera = ellipsoid.transformPositionToScaledSpace(position, new Cesium.Cartesian3());
6036
+ const limbSquared = Cesium.Cartesian3.magnitudeSquared(camera) - 1;
6037
+ // No horizon from underground.
6038
+ if (limbSquared > 0) {
6039
+ this.horizon = { ellipsoid, camera, limbSquared };
6040
+ }
6041
+ }
6004
6042
  Update() {
6005
6043
  var _a, _b;
6006
6044
  this.coordinates = this.MeasureCoordinates();
6045
+ this.UpdateHorizon();
6007
6046
  const rect = (_b = (_a = this.viewer.canvas).getBoundingClientRect) === null || _b === void 0 ? void 0 : _b.call(_a);
6008
6047
  const pointer = this.pointerClient;
6009
6048
  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 ?
@@ -6778,7 +6817,8 @@
6778
6817
  // If we're labelling from a temp label (mouse hover) don't drive opacity by cam distance.
6779
6818
  const hoverOnly = this.Transient && !this.Persistent;
6780
6819
  if (!Number.isFinite(distance) || depth <= 0 || distance < ((_c = this.options.near) !== null && _c !== void 0 ? _c : 0) ||
6781
- distance > ((_d = this.options.far) !== null && _d !== void 0 ? _d : Infinity) || (!this.prePositioned && !hoverOnly && distance >= MAX_DISTANCE)) {
6820
+ distance > ((_d = this.options.far) !== null && _d !== void 0 ? _d : Infinity) || (!this.prePositioned && !hoverOnly && distance >= MAX_DISTANCE) ||
6821
+ layer.IsBeyondHorizon(this._pos3d)) {
6782
6822
  return null;
6783
6823
  }
6784
6824
  const transforms = Cesium.SceneTransforms;
@@ -50703,7 +50743,7 @@ void main() {
50703
50743
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
50704
50744
  })(exports.StyleUtils || (exports.StyleUtils = {}));
50705
50745
 
50706
- const VERSION = "7.4.6";
50746
+ const VERSION = "7.4.7";
50707
50747
  /**
50708
50748
  * Updates the environment instance used by bruce-cesium to one specified.
50709
50749
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.