bruce-cesium 7.7.8 → 7.7.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.
@@ -97,7 +97,7 @@ __exportStar(require("./widgets/widget-info-view"), exports);
97
97
  __exportStar(require("./widgets/widget-left-panel"), exports);
98
98
  __exportStar(require("./widgets/widget-nav-compass"), exports);
99
99
  __exportStar(require("./widgets/widget-view-bar"), exports);
100
- exports.VERSION = "7.7.8";
100
+ exports.VERSION = "7.7.9";
101
101
  /**
102
102
  * Updates the environment instance used by bruce-cesium to one specified.
103
103
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -5,6 +5,7 @@ const view_utils_1 = require("../../../utils/view-utils");
5
5
  const bruce_models_1 = require("bruce-models");
6
6
  const Cesium = require("cesium");
7
7
  const bruce_cesium_1 = require("src/bruce-cesium");
8
+ const camera_controls_1 = require("../../../viewer/camera-controls");
8
9
  var TilesetGooglePhotosRenderManager;
9
10
  (function (TilesetGooglePhotosRenderManager) {
10
11
  class Manager {
@@ -159,6 +160,8 @@ var TilesetGooglePhotosRenderManager;
159
160
  this.doDispose();
160
161
  return;
161
162
  }
163
+ // Photorealistic tiles cover the Earth, so the camera treats them as the ground when the globe is hidden.
164
+ camera_controls_1.CameraControls.SetGroundTileset(this.cTileset, true);
162
165
  this.viewer.scene.primitives.add(this.cTileset);
163
166
  this.applyColorMask();
164
167
  this.viewer.scene.requestRender();
@@ -1 +1 @@
1
- {"version":3,"file":"tileset-google-photos-render-manager.js","sourceRoot":"","sources":["../../../../../src/rendering/render-managers/tilesets/tileset-google-photos-render-manager.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AACtD,+CAA0E;AAC1E,iCAAiC;AACjC,mDAAiD;AAGjD,IAAiB,gCAAgC,CA8OhD;AA9OD,WAAiB,gCAAgC;IAC7C,MAAa,OAAO;QAKhB,IAAW,QAAQ;YACf,OAAO,IAAI,CAAC,QAAQ,CAAC;Q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AQ;aAC1B,CAAC;YAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YAErB,OAAO,OAAO,CAAC;QACnB,CAAC;QAEM,YAAY,CAAC,OAAsC;YACtD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YACjC,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QACtC,CAAC;KACJ;IA5OY,wCAAO,UA4OnB,CAAA;AACL,CAAC,EA9OgB,gCAAgC,GAAhC,wCAAgC,KAAhC,wCAAgC,QA8OhD"}
1
+ {"version":3,"file":"tileset-google-photos-render-manager.js","sourceRoot":"","sources":["../../../../../src/rendering/render-managers/tilesets/tileset-google-photos-render-manager.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AACtD,+CAA0E;AAC1E,iCAAiC;AACjC,mDAAiD;AAEjD,qEAAiE;AAEjE,IAAiB,gCAAgC,CAgPhD;AAhPD,WAAiB,gCAAgC;IAC7C,MAAa,OAAO;QAKhB,IAAW,QAAQ;YACf,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;QAED,IAAW,OAAO;YACd,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;QAKD,YAAY,MAIX;YAhBO,aAAQ,GAAY,KAAK,CAAC;YAI1B,aAAQ,GAAgC,IAAI,CAAC;YAIrD,6FAA6F;YACrF,iBAAY,GAAY,KAAK,CAAC;YAQlC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;YACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,CAAC;QAEM,OAAO;YACV,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACf,OA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gB,gCAAgC,GAAhC,wCAAgC,KAAhC,wCAAgC,QAgPhD"}
@@ -21,6 +21,32 @@ const ZOOM_EASE = 0.35;
21
21
  const GRAZING_SINE = 0.12;
22
22
  // Closest the view may get to straight up or down while orbiting, in radians, so the camera never flips over.
23
23
  const ORBIT_POLE_MARGIN = Cesium.Math.toRadians(1);
24
+ // How far above the ground a camera coming down from above stops, until pushed on through.
25
+ const GROUND_STANDOFF = 2;
26
+ // Height above the ground within which a descent slows, so the ground is approached rather than hit.
27
+ const GROUND_APPROACH = 10;
28
+ // The slowest a descent gets near the ground, as a share of its usual speed.
29
+ const GROUND_APPROACH_FLOOR = 0.5;
30
+ // How far below the ground a push through it lands, so the camera is clearly under it.
31
+ const GROUND_BREAK_DEPTH = 1.5;
32
+ // Wheel notches of pushing at the ground that take the camera through it, with and without data found below it.
33
+ const PUSH_NOTCHES_DATA_BELOW = 3;
34
+ const PUSH_NOTCHES_NOTHING_BELOW = 10;
35
+ // Pushes further apart than this start counting again.
36
+ const PUSH_WINDOW_MS = 1200;
37
+ // How far below the ground something must reach to count as data underground, in metres.
38
+ const UNDERGROUND_MARGIN = 3;
39
+ // How long a scan of the scene for underground data and stand-in ground is trusted, in milliseconds.
40
+ const SCENE_SCAN_MS = 2000;
41
+ // The most entities one scan looks at, so a large scene is sampled rather than walked each time.
42
+ const SCENE_SCAN_ENTITIES = 3000;
43
+ // Zoom speed, as a share of the usual, toward a point that is a guess (nothing drawn there) or while terrain loads.
44
+ const ZOOM_GUESS_SHARE = 0.5;
45
+ const ZOOM_LOADING_SHARE = 0.7;
46
+ // The highest a camera zooms out to with the globe hidden, which CesiumJS's controller cannot navigate.
47
+ const HIDDEN_GLOBE_MAX_HEIGHT = 10000000;
48
+ // Marks a tileset that stands in for the globe, such as Google's photorealistic tiles.
49
+ const GROUND_TILESET_KEY = "_nextspace_camera_ground";
24
50
  var EDrag;
25
51
  (function (EDrag) {
26
52
  EDrag["Pan"] = "pan";
@@ -54,6 +80,9 @@ var CameraControls;
54
80
  zoomFrame: null,
55
81
  zoomPosition: null,
56
82
  lastDistance: 100,
83
+ push: { notches: 0, at: 0 },
84
+ scan: null,
85
+ undergroundOverride: null,
57
86
  saved: {
58
87
  rotateEventTypes: controller.rotateEventTypes,
59
88
  zoomEventTypes: controller.zoomEventTypes,
@@ -110,6 +139,25 @@ var CameraControls;
110
139
  return Boolean(viewer === null || viewer === void 0 ? void 0 : viewer[CESIUM_CAMERA_CONTROLS_KEY]);
111
140
  }
112
141
  CameraControls.IsAttached = IsAttached;
142
+ /**
143
+ * Marks a tileset as standing in for the globe (Google's photorealistic tiles), so the camera treats it as ground.
144
+ */
145
+ function SetGroundTileset(tileset, isGround) {
146
+ if (tileset) {
147
+ tileset[GROUND_TILESET_KEY] = isGround;
148
+ }
149
+ }
150
+ CameraControls.SetGroundTileset = SetGroundTileset;
151
+ /**
152
+ * Says whether the scene has data underground, which makes the ground easier to push through; null scans for it.
153
+ */
154
+ function SetUndergroundData(viewer, present) {
155
+ const state = viewer === null || viewer === void 0 ? void 0 : viewer[CESIUM_CAMERA_CONTROLS_KEY];
156
+ if (state) {
157
+ state.undergroundOverride = present;
158
+ }
159
+ }
160
+ CameraControls.SetUndergroundData = SetUndergroundData;
113
161
  /**
114
162
  * Switches to navigating model-space measured from the frame getFrame returns, or back to geospatial with null.
115
163
  */
@@ -190,8 +238,27 @@ function shouldControl(state) {
190
238
  if (state.getModelSpaceFrame) {
191
239
  return true;
192
240
  }
241
+ // CesiumJS's controller measures against the globe, so with it hidden these controls keep the camera at any height.
242
+ if (!globeShown(state)) {
243
+ return true;
244
+ }
193
245
  return heightOf(state, camera.positionWC) < GEO_HANDOFF_HEIGHT;
194
246
  }
247
+ function globeShown(state) {
248
+ const globe = state.viewer.scene.globe;
249
+ return Boolean(globe) && globe.show !== false;
250
+ }
251
+ /*
252
+ * The terrain's height at a place from the tiles loaded, undefined with the globe hidden or nothing loaded there.
253
+ */
254
+ function terrainHeightAt(state, carto) {
255
+ const globe = state.viewer.scene.globe;
256
+ if (!carto || !globeShown(state) || typeof globe.getHeight !== "function") {
257
+ return undefined;
258
+ }
259
+ const height = globe.getHeight(carto);
260
+ return Number.isFinite(height) ? height : undefined;
261
+ }
195
262
  function ellipsoidOf(state) {
196
263
  var _a, _b;
197
264
  return (_b = (_a = state.viewer.scene.globe) === null || _a === void 0 ? void 0 : _a.ellipsoid) !== null && _b !== void 0 ? _b : Cesium.Ellipsoid.WGS84;
@@ -218,16 +285,19 @@ function upAt(state, position) {
218
285
  * The level plane standing in for the ground when nothing is drawn under the cursor.
219
286
  */
220
287
  function groundPlane(state) {
288
+ var _a;
221
289
  if (state.getModelSpaceFrame) {
222
290
  const frame = state.getModelSpaceFrame();
223
291
  return Cesium.Plane.fromPointNormal(Cesium.Matrix4.getTranslation(frame, new Cesium.Cartesian3()), upAt(state, null));
224
292
  }
225
293
  const camera = state.viewer.camera;
226
294
  const ellipsoid = ellipsoidOf(state);
227
- const surface = ellipsoid.scaleToGeodeticSurface(camera.positionWC, new Cesium.Cartesian3());
228
- if (!surface) {
295
+ const carto = ellipsoid.cartesianToCartographic(camera.positionWC);
296
+ if (!carto) {
229
297
  return null;
230
298
  }
299
+ // Level with the terrain under the camera, not sea level, so a guess over high ground is not far too deep.
300
+ const surface = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0, ellipsoid);
231
301
  return Cesium.Plane.fromPointNormal(surface, ellipsoid.geodeticSurfaceNormal(surface, new Cesium.Cartesian3()));
232
302
  }
233
303
  /*
@@ -265,14 +335,44 @@ function pickTarget(state, position) {
265
335
  }
266
336
  const plausible = plausibleDistance(state);
267
337
  if (isAhead(camera, picked) && Cesium.Cartesian3.distance(picked, camera.positionWC) < plausible) {
268
- return picked;
338
+ return { point: picked, source: "pick", ground: isGroundPick(state, position) };
269
339
  }
270
340
  const ground = groundPlane(state);
271
341
  const onGround = ground ? Cesium.IntersectionTests.rayPlane(ray, ground) : null;
272
342
  if (isAhead(camera, onGround) && Cesium.Cartesian3.distance(onGround, camera.positionWC) < plausible) {
273
- return onGround;
343
+ // The plane stands in for the ground only where there is ground to stand in for.
344
+ return { point: onGround, source: "plane", ground: !state.getModelSpaceFrame && hasGround(state) };
345
+ }
346
+ return { point: Cesium.Ray.getPoint(ray, state.lastDistance), source: "last", ground: false };
347
+ }
348
+ /*
349
+ * Whether what is drawn under a screen position is the ground: the globe, or a tileset standing in for it.
350
+ */
351
+ function isGroundPick(state, position) {
352
+ var _a, _b, _c;
353
+ if (state.getModelSpaceFrame) {
354
+ return false;
355
+ }
356
+ const scene = state.viewer.scene;
357
+ let picked;
358
+ try {
359
+ picked = typeof scene.pick === "function" ? scene.pick(position) : undefined;
360
+ }
361
+ catch (e) {
362
+ picked = undefined;
363
+ }
364
+ if (!picked) {
365
+ // Nothing pickable means the globe, when it is drawn.
366
+ return globeShown(state);
274
367
  }
275
- return Cesium.Ray.getPoint(ray, state.lastDistance);
368
+ const tileset = (_b = (_a = picked.tileset) !== null && _a !== void 0 ? _a : picked.primitive) !== null && _b !== void 0 ? _b : (_c = picked.content) === null || _c === void 0 ? void 0 : _c.tileset;
369
+ return Boolean(tileset === null || tileset === void 0 ? void 0 : tileset[GROUND_TILESET_KEY]);
370
+ }
371
+ /*
372
+ * Whether there is ground to come down onto: the globe drawn, or a tileset standing in for it.
373
+ */
374
+ function hasGround(state) {
375
+ return globeShown(state) || scanScene(state).groundTileset;
276
376
  }
277
377
  function isAhead(camera, point) {
278
378
  if (!point || !Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) {
@@ -333,14 +433,15 @@ function onPointerDown(state, e) {
333
433
  return;
334
434
  }
335
435
  const position = canvasPosition(viewer, e);
336
- const target = pickTarget(state, position);
337
- if (!target) {
436
+ const picked = pickTarget(state, position);
437
+ if (!picked) {
338
438
  return;
339
439
  }
440
+ const target = picked.point;
340
441
  const camera = viewer.camera;
341
442
  const distance = Cesium.Cartesian3.distance(camera.positionWC, target);
342
443
  state.lastDistance = Math.max(distance, MIN_ZOOM_DISTANCE);
343
- const drag = { kind, pointerId: e.pointerId, last: position, target, up: upAt(state, target), distance };
444
+ const drag = { kind, pointerId: e.pointerId, last: position, target, up: upAt(state, target), distance, picked };
344
445
  if (kind === EDrag.Pan) {
345
446
  drag.plane = panPlane(camera, target, drag.up);
346
447
  }
@@ -383,7 +484,7 @@ function onPointerMove(state, e) {
383
484
  break;
384
485
  case EDrag.Zoom:
385
486
  // Dragging down zooms in, as it does in CesiumJS.
386
- moveAlong(state, drag.direction, drag.target, dy / DRAG_PIXELS_PER_NOTCH);
487
+ moveAlong(state, drag.direction, drag.picked, dy / DRAG_PIXELS_PER_NOTCH);
387
488
  break;
388
489
  }
389
490
  drag.last = position;
@@ -416,6 +517,14 @@ function pan(state, drag, position) {
416
517
  if (length > limit) {
417
518
  Cesium.Cartesian3.multiplyByScalar(delta, limit / length, delta);
418
519
  }
520
+ // A pan never takes a camera above the ground down through it; it keeps the sideways part of the move.
521
+ if (wouldSinkBelowGround(state, camera.position, delta)) {
522
+ const up = upAt(state, camera.position);
523
+ const down = Cesium.Cartesian3.dot(delta, up);
524
+ if (down < 0) {
525
+ Cesium.Cartesian3.subtract(delta, Cesium.Cartesian3.multiplyByScalar(up, down, new Cesium.Cartesian3()), delta);
526
+ }
527
+ }
419
528
  Cesium.Cartesian3.add(camera.position, delta, camera.position);
420
529
  }
421
530
  /*
@@ -437,7 +546,13 @@ function orbit(state, drag, dx, dy) {
437
546
  const right = Cesium.Cartesian3.cross(camera.direction, up, new Cesium.Cartesian3());
438
547
  if (Cesium.Cartesian3.magnitude(right) > Cesium.Math.EPSILON6) {
439
548
  Cesium.Cartesian3.normalize(right, right);
549
+ const before = Cesium.Cartesian3.clone(camera.position);
440
550
  rotateAbout(camera, drag.target, right, pitch);
551
+ // Orbiting does not swing a camera above the ground down through it; the tilt that would is undone.
552
+ const moved = Cesium.Cartesian3.subtract(camera.position, before, new Cesium.Cartesian3());
553
+ if (wouldSinkBelowGround(state, before, moved)) {
554
+ rotateAbout(camera, drag.target, right, -pitch);
555
+ }
441
556
  }
442
557
  levelCamera(camera, upAt(state, camera.position));
443
558
  }
@@ -524,21 +639,261 @@ function moveAlong(state, direction, target, notches) {
524
639
  /*
525
640
  * The move for some notches toward a target along a direction, a share of the distance with a floor so it never stalls.
526
641
  */
527
- function zoomStep(state, direction, target, notches) {
642
+ function zoomStep(state, direction, picked, notches) {
528
643
  const camera = state.viewer.camera;
529
- const distance = Math.max(Cesium.Cartesian3.distance(camera.positionWC, target), MIN_ZOOM_DISTANCE);
644
+ const target = picked.point;
645
+ // Where the camera will be once the glide already under way ends, which this step continues from.
646
+ const from = Cesium.Cartesian3.add(camera.positionWC, state.pendingZoom, new Cesium.Cartesian3());
647
+ const distance = Math.max(Cesium.Cartesian3.distance(from, target), MIN_ZOOM_DISTANCE);
530
648
  state.lastDistance = distance;
531
- let length = distance * ZOOM_SHARE * notches;
649
+ let length = distance * ZOOM_SHARE * notches * zoomSpeedShare(state, picked);
532
650
  // A geospatial camera zooming out hands over to CesiumJS once it is high enough, so only model-space is capped.
533
651
  if (length < 0 && state.getModelSpaceFrame) {
534
652
  const origin = Cesium.Matrix4.getTranslation(state.getModelSpaceFrame(), new Cesium.Cartesian3());
535
- const pending = Cesium.Cartesian3.add(camera.positionWC, state.pendingZoom, new Cesium.Cartesian3());
536
- const range = Cesium.Cartesian3.distance(pending, origin);
653
+ const range = Cesium.Cartesian3.distance(from, origin);
537
654
  length = Math.max(length, range - MODEL_SPACE_MAX_RANGE);
538
655
  if (length >= 0) {
539
656
  return new Cesium.Cartesian3();
540
657
  }
541
658
  }
542
- return Cesium.Cartesian3.multiplyByScalar(Cesium.Cartesian3.normalize(direction, new Cesium.Cartesian3()), length, new Cesium.Cartesian3());
659
+ const unit = Cesium.Cartesian3.normalize(direction, new Cesium.Cartesian3());
660
+ // With the globe hidden there is no hand-over, so zooming out stops where the Earth is a dot.
661
+ if (length < 0 && !state.getModelSpaceFrame && !globeShown(state)) {
662
+ const rise = -Cesium.Cartesian3.dot(unit, upAt(state, from));
663
+ const headroom = HIDDEN_GLOBE_MAX_HEIGHT - heightOf(state, from);
664
+ if (rise > 0) {
665
+ length = Math.max(length, -Math.max(headroom, 0) / rise);
666
+ }
667
+ if (length >= 0) {
668
+ return new Cesium.Cartesian3();
669
+ }
670
+ }
671
+ const step = Cesium.Cartesian3.multiplyByScalar(unit, length, new Cesium.Cartesian3());
672
+ return length > 0 ? resistDescent(state, from, step, picked, notches) : step;
673
+ }
674
+ /*
675
+ * How fast to zoom toward a target: slower toward a guess, or while the terrain that would give a real one loads.
676
+ */
677
+ function zoomSpeedShare(state, picked) {
678
+ let share = 1;
679
+ if (picked.source !== "pick") {
680
+ share *= ZOOM_GUESS_SHARE;
681
+ }
682
+ const globe = state.viewer.scene.globe;
683
+ if (!state.getModelSpaceFrame && globeShown(state) && globe.tilesLoaded === false) {
684
+ share *= ZOOM_LOADING_SHARE;
685
+ }
686
+ return share;
687
+ }
688
+ /*
689
+ * The ground a move comes down onto: the ground picked, else the terrain under where the move ends; null for none.
690
+ */
691
+ function groundUnderMove(state, from, step, picked) {
692
+ var _a, _b;
693
+ if (state.getModelSpaceFrame || !hasGround(state)) {
694
+ return null;
695
+ }
696
+ if (picked === null || picked === void 0 ? void 0 : picked.ground) {
697
+ return { point: picked.point, up: upAt(state, picked.point) };
698
+ }
699
+ if (!globeShown(state)) {
700
+ return null;
701
+ }
702
+ const ellipsoid = ellipsoidOf(state);
703
+ const end = Cesium.Cartesian3.add(from, step, new Cesium.Cartesian3());
704
+ const carto = ellipsoid.cartesianToCartographic(end);
705
+ if (!carto) {
706
+ return null;
707
+ }
708
+ const height = (_b = (_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : terrainHeightAt(state, ellipsoid.cartesianToCartographic(from))) !== null && _b !== void 0 ? _b : 0;
709
+ const point = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, height, ellipsoid);
710
+ return { point, up: ellipsoid.geodeticSurfaceNormal(point, new Cesium.Cartesian3()) };
711
+ }
712
+ /*
713
+ * Whether a move takes a camera that is above the ground to within the stand-off of it or below.
714
+ */
715
+ function wouldSinkBelowGround(state, from, step) {
716
+ const ground = groundUnderMove(state, from, step, null);
717
+ if (!ground) {
718
+ return false;
719
+ }
720
+ const before = Cesium.Cartesian3.dot(Cesium.Cartesian3.subtract(from, ground.point, new Cesium.Cartesian3()), ground.up);
721
+ const after = before + Cesium.Cartesian3.dot(step, ground.up);
722
+ return before > 0 && after < Math.min(GROUND_STANDOFF, before);
723
+ }
724
+ /*
725
+ * Slows a camera coming down from above as it nears the ground and stops it just above, until pushed on enough to
726
+ * pass through; harder when nothing is known to be underground. A camera already below the ground moves freely.
727
+ */
728
+ function resistDescent(state, from, step, picked, notches) {
729
+ const ground = groundUnderMove(state, from, step, picked);
730
+ const length = Cesium.Cartesian3.magnitude(step);
731
+ if (!ground || length === 0) {
732
+ return step;
733
+ }
734
+ const above = Cesium.Cartesian3.dot(Cesium.Cartesian3.subtract(from, ground.point, new Cesium.Cartesian3()), ground.up);
735
+ const unit = Cesium.Cartesian3.divideByScalar(step, length, new Cesium.Cartesian3());
736
+ const sink = -Cesium.Cartesian3.dot(unit, ground.up);
737
+ if (above <= 0 || sink <= 0) {
738
+ return step;
739
+ }
740
+ let allowed = length;
741
+ if (above < GROUND_APPROACH) {
742
+ allowed *= Math.max(above / GROUND_APPROACH, GROUND_APPROACH_FLOOR);
743
+ }
744
+ const toStandOff = Math.max(above - GROUND_STANDOFF, 0) / sink;
745
+ if (allowed <= toStandOff) {
746
+ return Cesium.Cartesian3.multiplyByScalar(unit, allowed, new Cesium.Cartesian3());
747
+ }
748
+ // Held at the stand-off: each push counts, and enough close together go through.
749
+ const now = Date.now();
750
+ if (now - state.push.at > PUSH_WINDOW_MS) {
751
+ state.push.notches = 0;
752
+ }
753
+ state.push.at = now;
754
+ state.push.notches += Math.abs(notches);
755
+ const needed = scanScene(state).undergroundData ? PUSH_NOTCHES_DATA_BELOW : PUSH_NOTCHES_NOTHING_BELOW;
756
+ if (state.push.notches >= needed) {
757
+ state.push.notches = 0;
758
+ // A shallow push would land far along the ground to get under it, so it goes no further than a usual step.
759
+ const through = Math.min((above + GROUND_BREAK_DEPTH) / sink, Math.max(length, (above + GROUND_BREAK_DEPTH) * 4));
760
+ return Cesium.Cartesian3.multiplyByScalar(unit, through, new Cesium.Cartesian3());
761
+ }
762
+ return Cesium.Cartesian3.multiplyByScalar(unit, toStandOff, new Cesium.Cartesian3());
763
+ }
764
+ /*
765
+ * What the scene holds that the camera cares about, rescanned at most every couple of seconds.
766
+ */
767
+ function scanScene(state) {
768
+ var _a, _b;
769
+ const now = Date.now();
770
+ if (state.scan && now - state.scan.at < SCENE_SCAN_MS) {
771
+ return applyOverride(state, state.scan);
772
+ }
773
+ const scene = state.viewer.scene;
774
+ const found = { at: now, undergroundData: false, groundTileset: false };
775
+ // Seeing through the ground is turned on to look at what is under it.
776
+ if ((_b = (_a = scene.globe) === null || _a === void 0 ? void 0 : _a.translucency) === null || _b === void 0 ? void 0 : _b.enabled) {
777
+ found.undergroundData = true;
778
+ }
779
+ const visit = (primitive) => {
780
+ if (!primitive || primitive.show === false || (primitive.isDestroyed && primitive.isDestroyed())) {
781
+ return;
782
+ }
783
+ if (typeof primitive.length === "number" && typeof primitive.get === "function") {
784
+ for (let i = 0; i < primitive.length; i++) {
785
+ visit(primitive.get(i));
786
+ }
787
+ return;
788
+ }
789
+ if (primitive[GROUND_TILESET_KEY]) {
790
+ found.groundTileset = true;
791
+ return;
792
+ }
793
+ if (!found.undergroundData && reachesBelowGround(state, lowestPointOf(primitive))) {
794
+ found.undergroundData = true;
795
+ }
796
+ };
797
+ visit(scene.primitives);
798
+ if (!found.undergroundData) {
799
+ found.undergroundData = entitiesBelowGround(state);
800
+ }
801
+ state.scan = found;
802
+ return applyOverride(state, found);
803
+ }
804
+ function applyOverride(state, found) {
805
+ return state.undergroundOverride == null ? found : { ...found, undergroundData: state.undergroundOverride };
806
+ }
807
+ /*
808
+ * The lowest point of a tileset or model: its root box's lowest corner, or its bounding sphere's centre.
809
+ */
810
+ function lowestPointOf(primitive) {
811
+ var _a, _b, _c;
812
+ const volume = (_a = primitive === null || primitive === void 0 ? void 0 : primitive.root) === null || _a === void 0 ? void 0 : _a.boundingVolume;
813
+ if (volume) {
814
+ const region = Number.isFinite(volume.minimumHeight) && volume.rectangle;
815
+ if (region) {
816
+ return Cesium.Cartesian3.fromRadians(Cesium.Rectangle.center(volume.rectangle).longitude, Cesium.Rectangle.center(volume.rectangle).latitude, volume.minimumHeight);
817
+ }
818
+ const box = volume.boundingVolume;
819
+ const corners = box instanceof Cesium.OrientedBoundingBox && typeof Cesium.OrientedBoundingBox.computeCorners === "function" ? Cesium.OrientedBoundingBox.computeCorners(box) : null;
820
+ if (corners === null || corners === void 0 ? void 0 : corners.length) {
821
+ return lowestOf(corners);
822
+ }
823
+ }
824
+ // A sphere's centre, as its radius reaches below the ground for anything standing on it.
825
+ return (_c = (_b = primitive === null || primitive === void 0 ? void 0 : primitive.boundingSphere) === null || _b === void 0 ? void 0 : _b.center) !== null && _c !== void 0 ? _c : null;
826
+ }
827
+ function lowestOf(points) {
828
+ var _a, _b;
829
+ let lowest = null;
830
+ let lowestHeight = Number.POSITIVE_INFINITY;
831
+ for (const point of points) {
832
+ const height = (_b = (_a = Cesium.Cartographic.fromCartesian(point)) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
833
+ if (height < lowestHeight) {
834
+ lowestHeight = height;
835
+ lowest = point;
836
+ }
837
+ }
838
+ return lowest;
839
+ }
840
+ /*
841
+ * Whether a point is clearly below the ground at its place: the terrain there, else sea level.
842
+ */
843
+ function reachesBelowGround(state, point) {
844
+ var _a;
845
+ if (!point) {
846
+ return false;
847
+ }
848
+ const carto = ellipsoidOf(state).cartesianToCartographic(point);
849
+ if (!carto) {
850
+ return false;
851
+ }
852
+ return carto.height < ((_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0) - UNDERGROUND_MARGIN;
853
+ }
854
+ /*
855
+ * Whether any of the first entities sits clearly below the ground: a point, or a line's first or last vertex.
856
+ */
857
+ function entitiesBelowGround(state) {
858
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
859
+ const viewer = state.viewer;
860
+ const collections = [viewer.entities];
861
+ const sources = viewer.dataSources;
862
+ for (let i = 0; i < ((_a = sources === null || sources === void 0 ? void 0 : sources.length) !== null && _a !== void 0 ? _a : 0); i++) {
863
+ collections.push((_b = sources.get(i)) === null || _b === void 0 ? void 0 : _b.entities);
864
+ }
865
+ const time = (_d = (_c = viewer.clock) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : Cesium.JulianDate.now();
866
+ let seen = 0;
867
+ for (const collection of collections) {
868
+ for (const entity of (_e = collection === null || collection === void 0 ? void 0 : collection.values) !== null && _e !== void 0 ? _e : []) {
869
+ if (seen++ >= SCENE_SCAN_ENTITIES) {
870
+ return false;
871
+ }
872
+ if (!entity || entity.show === false) {
873
+ continue;
874
+ }
875
+ const graphic = (_j = (_h = (_g = (_f = entity.model) !== null && _f !== void 0 ? _f : entity.point) !== null && _g !== void 0 ? _g : entity.billboard) !== null && _h !== void 0 ? _h : entity.box) !== null && _j !== void 0 ? _j : entity.cylinder;
876
+ const reference = (_l = (_k = graphic === null || graphic === void 0 ? void 0 : graphic.heightReference) === null || _k === void 0 ? void 0 : _k.getValue) === null || _l === void 0 ? void 0 : _l.call(_k, time);
877
+ if (reference === Cesium.HeightReference.CLAMP_TO_GROUND) {
878
+ continue;
879
+ }
880
+ const position = (_o = (_m = entity.position) === null || _m === void 0 ? void 0 : _m.getValue) === null || _o === void 0 ? void 0 : _o.call(_m, time);
881
+ if (position) {
882
+ const relative = reference === Cesium.HeightReference.RELATIVE_TO_GROUND;
883
+ const height = relative ? (_p = ellipsoidOf(state).cartesianToCartographic(position)) === null || _p === void 0 ? void 0 : _p.height : null;
884
+ if (relative ? height < -UNDERGROUND_MARGIN : reachesBelowGround(state, position)) {
885
+ return true;
886
+ }
887
+ }
888
+ const line = entity.polyline;
889
+ if (line && !((_r = (_q = line.clampToGround) === null || _q === void 0 ? void 0 : _q.getValue) === null || _r === void 0 ? void 0 : _r.call(_q, time))) {
890
+ const positions = (_u = (_t = (_s = line.positions) === null || _s === void 0 ? void 0 : _s.getValue) === null || _t === void 0 ? void 0 : _t.call(_s, time)) !== null && _u !== void 0 ? _u : [];
891
+ if (positions.length && (reachesBelowGround(state, positions[0]) || reachesBelowGround(state, positions[positions.length - 1]))) {
892
+ return true;
893
+ }
894
+ }
895
+ }
896
+ }
897
+ return false;
543
898
  }
544
899
  //# sourceMappingURL=camera-controls.js.map