bruce-cesium 7.2.8 → 7.2.9

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.
@@ -42346,7 +42346,7 @@
42346
42346
 
42347
42347
  (function (DisplacedSurfacePrimitive) {
42348
42348
  // Grid densities a tile can draw at, coarsest first.
42349
- const TIERS = [32, 64, 128, 192];
42349
+ const TIERS = [32, 64, 128, 192, 256, 384];
42350
42350
  // Tiles per side the extent is cut into.
42351
42351
  const TILES_PER_SIDE = 6;
42352
42352
  // Screen pixels one grid cell should cover. Lower means finer meshes sooner.
@@ -42994,6 +42994,7 @@ void main() {
42994
42994
  const camera = frameState.camera;
42995
42995
  const fovy = camera.frustum && camera.frustum.fovy ? camera.frustum.fovy : Cesium.Math.PI_OVER_THREE;
42996
42996
  const pixelsPerRadian = frameState.context.drawingBufferHeight / fovy;
42997
+ const ceiling = this.tierCeiling();
42997
42998
  for (const tile of this.tiles) {
42998
42999
  if (!tile.centre) {
42999
43000
  tile.tier = TIERS[0];
@@ -43004,13 +43005,33 @@ void main() {
43004
43005
  const wanted = screenPixels / TARGET_CELL_PIXELS;
43005
43006
  let tier = TIERS[0];
43006
43007
  for (const candidate of TIERS) {
43007
- if (candidate <= wanted) {
43008
+ if (candidate <= wanted && candidate <= ceiling) {
43008
43009
  tier = candidate;
43009
43010
  }
43010
43011
  }
43011
43012
  tile.tier = tier;
43012
43013
  }
43013
43014
  }
43015
+ /*
43016
+ * The finest tier worth drawing for this surface, from the texture behind it.
43017
+ *
43018
+ * Subdividing past one vertex per texel spends vertices resolving detail the source does not
43019
+ * carry, so the ladder is capped one step above the texel count rather than run to its top.
43020
+ */
43021
+ tierCeiling() {
43022
+ const source = this.source;
43023
+ if (!source || !source.width || !source.height) {
43024
+ return TIERS[TIERS.length - 1];
43025
+ }
43026
+ const perSide = Math.sqrt(this.tiles.length) || TILES_PER_SIDE;
43027
+ const texelsPerTile = Math.max(source.width, source.height) / perSide;
43028
+ for (const candidate of TIERS) {
43029
+ if (candidate >= texelsPerTile) {
43030
+ return candidate;
43031
+ }
43032
+ }
43033
+ return TIERS[TIERS.length - 1];
43034
+ }
43014
43035
  shouldReselect(frameState, nowMs) {
43015
43036
  if (this.selectionDirty) {
43016
43037
  return true;
@@ -43023,9 +43044,23 @@ void main() {
43023
43044
  return true;
43024
43045
  }
43025
43046
  const moved = Cesium.Cartesian3.distance(eye, this.lastEyePosition);
43026
- const anchor = this.tiles[0].centre;
43027
- const reference = anchor ? Math.max(1, Cesium.Cartesian3.distance(eye, anchor)) : 1;
43028
- return moved / reference > MOVEMENT_THRESHOLD;
43047
+ return moved / this.nearestTileDistance(eye) > MOVEMENT_THRESHOLD;
43048
+ }
43049
+ /*
43050
+ * Distance to the closest tile, measured the way selectTiers measures each one.
43051
+ */
43052
+ nearestTileDistance(eye) {
43053
+ let nearest = Number.POSITIVE_INFINITY;
43054
+ for (const tile of this.tiles) {
43055
+ if (!tile.centre) {
43056
+ continue;
43057
+ }
43058
+ const distance = Cesium.Cartesian3.distance(eye, tile.centre) - tile.radius;
43059
+ if (distance < nearest) {
43060
+ nearest = distance;
43061
+ }
43062
+ }
43063
+ return isFinite(nearest) ? Math.max(1, nearest) : 1;
43029
43064
  }
43030
43065
  commandFor(context, tile, mesh) {
43031
43066
  if (!this.shaderProgram) {
@@ -45741,7 +45776,7 @@ void main() {
45741
45776
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
45742
45777
  })(exports.StyleUtils || (exports.StyleUtils = {}));
45743
45778
 
45744
- const VERSION = "7.2.8";
45779
+ const VERSION = "7.2.9";
45745
45780
  /**
45746
45781
  * Updates the environment instance used by bruce-cesium to one specified.
45747
45782
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.