bruce-cesium 7.9.3 → 7.9.4
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.
- package/dist/bruce-cesium.es5.js +256 -30
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +255 -27
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/viewer/camera-controls.js +255 -27
- package/dist/lib/viewer/camera-controls.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/viewer/camera-controls.d.ts +11 -0
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -1367,6 +1367,11 @@ void main()
|
|
|
1367
1367
|
const PUSH_NOTCHES_NOTHING_BELOW = 10;
|
|
1368
1368
|
// Pushes further apart than this start counting again.
|
|
1369
1369
|
const PUSH_WINDOW_MS = 1200;
|
|
1370
|
+
// How long after a zoom newly loaded terrain may lift the camera, and how much longer while loading.
|
|
1371
|
+
const SURFACE_HOLD_MS = 4000;
|
|
1372
|
+
const SURFACE_LOADING_MS = 30000;
|
|
1373
|
+
// No visible ground lies lower; a stand-in tileset below this is a coarse tile cutting under the curve.
|
|
1374
|
+
const GROUND_FLOOR = -500;
|
|
1370
1375
|
// How far below the ground something must reach to count as data underground, in metres.
|
|
1371
1376
|
const UNDERGROUND_MARGIN = 3;
|
|
1372
1377
|
// How long a scan of the scene for underground data and stand-in ground is trusted, in milliseconds.
|
|
@@ -1412,6 +1417,7 @@ void main()
|
|
|
1412
1417
|
push: { notches: 0, at: 0 },
|
|
1413
1418
|
scan: null,
|
|
1414
1419
|
undergroundOverride: null,
|
|
1420
|
+
surface: { above: false, through: false, until: 0, at: null },
|
|
1415
1421
|
saved: {
|
|
1416
1422
|
rotateEventTypes: controller.rotateEventTypes,
|
|
1417
1423
|
zoomEventTypes: controller.zoomEventTypes,
|
|
@@ -1436,7 +1442,10 @@ void main()
|
|
|
1436
1442
|
listen(window, "pointerup", (e) => onPointerUp(state, e));
|
|
1437
1443
|
listen(window, "pointercancel", (e) => onPointerUp(state, e));
|
|
1438
1444
|
listen(canvas, "wheel", (e) => onWheel(state, e), { passive: true });
|
|
1439
|
-
state.removals.push(scene.preUpdate.addEventListener(() =>
|
|
1445
|
+
state.removals.push(scene.preUpdate.addEventListener(() => {
|
|
1446
|
+
syncController(state);
|
|
1447
|
+
keepAboveGround(state);
|
|
1448
|
+
}));
|
|
1440
1449
|
syncController(state);
|
|
1441
1450
|
scene.requestRender();
|
|
1442
1451
|
}
|
|
@@ -1588,6 +1597,38 @@ void main()
|
|
|
1588
1597
|
const height = globe.getHeight(carto);
|
|
1589
1598
|
return Number.isFinite(height) ? height : undefined;
|
|
1590
1599
|
}
|
|
1600
|
+
/*
|
|
1601
|
+
* The ground's height at a place: the loaded terrain, or the tileset standing in for a hidden globe.
|
|
1602
|
+
*/
|
|
1603
|
+
function groundHeightAt(state, carto) {
|
|
1604
|
+
var _a;
|
|
1605
|
+
if (globeShown(state)) {
|
|
1606
|
+
return terrainHeightAt(state, carto);
|
|
1607
|
+
}
|
|
1608
|
+
const tileset = scanScene(state).ground;
|
|
1609
|
+
if (!carto || !tileset || ((_a = tileset.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(tileset)) || typeof tileset.getHeight !== "function") {
|
|
1610
|
+
return undefined;
|
|
1611
|
+
}
|
|
1612
|
+
try {
|
|
1613
|
+
// Only tiles drawn this frame answer, which near the camera are the finest loaded.
|
|
1614
|
+
const height = tileset.getHeight(carto, state.viewer.scene);
|
|
1615
|
+
return Number.isFinite(height) && height > GROUND_FLOOR ? height : undefined;
|
|
1616
|
+
}
|
|
1617
|
+
catch (e) {
|
|
1618
|
+
return undefined;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
/*
|
|
1622
|
+
* Whether the ground is still loading: the globe's tiles, or the stand-in tileset's.
|
|
1623
|
+
*/
|
|
1624
|
+
function groundLoading(state) {
|
|
1625
|
+
var _a;
|
|
1626
|
+
if (globeShown(state)) {
|
|
1627
|
+
return state.viewer.scene.globe.tilesLoaded === false;
|
|
1628
|
+
}
|
|
1629
|
+
const tileset = scanScene(state).ground;
|
|
1630
|
+
return Boolean(tileset && !((_a = tileset.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(tileset)) && tileset.tilesLoaded === false);
|
|
1631
|
+
}
|
|
1591
1632
|
function ellipsoidOf(state) {
|
|
1592
1633
|
var _a, _b;
|
|
1593
1634
|
return (_b = (_a = state.viewer.scene.globe) === null || _a === void 0 ? void 0 : _a.ellipsoid) !== null && _b !== void 0 ? _b : Cesium.Ellipsoid.WGS84;
|
|
@@ -1625,8 +1666,8 @@ void main()
|
|
|
1625
1666
|
if (!carto) {
|
|
1626
1667
|
return null;
|
|
1627
1668
|
}
|
|
1628
|
-
// Level with the
|
|
1629
|
-
const surface = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a =
|
|
1669
|
+
// Level with the ground under the camera, not sea level, so a guess over high ground is not far too deep.
|
|
1670
|
+
const surface = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a = groundHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0, ellipsoid);
|
|
1630
1671
|
return Cesium.Plane.fromPointNormal(surface, ellipsoid.geodeticSurfaceNormal(surface, new Cesium.Cartesian3()));
|
|
1631
1672
|
}
|
|
1632
1673
|
/*
|
|
@@ -1650,6 +1691,15 @@ void main()
|
|
|
1650
1691
|
// Directions around the centre, and how many must hold nearer pixels for the centre to be surrounded.
|
|
1651
1692
|
const GAP_SECTORS = 8;
|
|
1652
1693
|
const GAP_SECTORS_NEAR = 6;
|
|
1694
|
+
// How far around the cursor, in CSS pixels, nearer parts limit a zoom, and the most buffer pixels read.
|
|
1695
|
+
const CLEARANCE_RADIUS_PX = 24;
|
|
1696
|
+
const CLEARANCE_RADIUS_MAX = 64;
|
|
1697
|
+
// The share of that window that must be nearer, so a stray pixel or a thin cable does not slow the zoom.
|
|
1698
|
+
const CLEARANCE_SHARE = 0.05;
|
|
1699
|
+
// A pixel at least this share of the level ground's distance on its ray is ground, and never limits.
|
|
1700
|
+
const CLEARANCE_GROUND = 0.9;
|
|
1701
|
+
// A pan or orbit grabbing this many times farther than the reach grabs at the reach instead.
|
|
1702
|
+
const CLEARANCE_GRAB = 2;
|
|
1653
1703
|
const PACKED_DEPTH = new Cesium.Cartesian4(1, 1 / 255, 1 / 65025, 1 / 16581375);
|
|
1654
1704
|
/*
|
|
1655
1705
|
* Distances along the view axis drawn around a window position, rows bottom-up, Infinity where nothing is drawn.
|
|
@@ -1698,6 +1748,21 @@ void main()
|
|
|
1698
1748
|
}
|
|
1699
1749
|
return distances;
|
|
1700
1750
|
}
|
|
1751
|
+
/*
|
|
1752
|
+
* The depth window around a position for the gap search and the reach, or null when unreadable.
|
|
1753
|
+
*/
|
|
1754
|
+
function readWindow(scene, position) {
|
|
1755
|
+
const scale = scene.drawingBufferWidth / scene.canvas.clientWidth;
|
|
1756
|
+
const clearance = Math.min(Math.round(CLEARANCE_RADIUS_PX * (Number.isFinite(scale) ? scale : 1)), CLEARANCE_RADIUS_MAX);
|
|
1757
|
+
const radius = Math.max(GAP_RADII[GAP_RADII.length - 1], clearance);
|
|
1758
|
+
try {
|
|
1759
|
+
const distances = readDepthDistances(scene, position, radius);
|
|
1760
|
+
return distances ? { distances, radius } : null;
|
|
1761
|
+
}
|
|
1762
|
+
catch (e) {
|
|
1763
|
+
return null;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1701
1766
|
/*
|
|
1702
1767
|
* Offsets of the surface pixel around the centre for each radius where clearly nearer pixels surround it.
|
|
1703
1768
|
*/
|
|
@@ -1735,15 +1800,7 @@ void main()
|
|
|
1735
1800
|
/*
|
|
1736
1801
|
* The point cloud surface around a pick that looked through a gap between its points, or null when it did not.
|
|
1737
1802
|
*/
|
|
1738
|
-
function fillGap(scene, position, picked) {
|
|
1739
|
-
const radius = GAP_RADII[GAP_RADII.length - 1];
|
|
1740
|
-
let distances = null;
|
|
1741
|
-
try {
|
|
1742
|
-
distances = readDepthDistances(scene, position, radius);
|
|
1743
|
-
}
|
|
1744
|
-
catch (e) {
|
|
1745
|
-
return null;
|
|
1746
|
-
}
|
|
1803
|
+
function fillGap(scene, position, picked, distances, radius) {
|
|
1747
1804
|
if (!distances) {
|
|
1748
1805
|
return null;
|
|
1749
1806
|
}
|
|
@@ -1763,9 +1820,80 @@ void main()
|
|
|
1763
1820
|
return null;
|
|
1764
1821
|
}
|
|
1765
1822
|
/*
|
|
1766
|
-
* The
|
|
1823
|
+
* The view-axis distance within which a share of the window around the cursor is drawn, ground aside.
|
|
1824
|
+
*/
|
|
1825
|
+
function NearClearance(distances, radius, groundAt) {
|
|
1826
|
+
const width = 2 * radius + 1;
|
|
1827
|
+
const near = [];
|
|
1828
|
+
for (let dy = -radius; dy <= radius; dy++) {
|
|
1829
|
+
for (let dx = -radius; dx <= radius; dx++) {
|
|
1830
|
+
const distance = distances[(radius + dy) * width + (radius + dx)];
|
|
1831
|
+
if (!Number.isFinite(distance)) {
|
|
1832
|
+
continue;
|
|
1833
|
+
}
|
|
1834
|
+
const ground = groundAt ? groundAt(dx, dy) : Infinity;
|
|
1835
|
+
if (!(ground > 0 && distance >= ground * CLEARANCE_GROUND)) {
|
|
1836
|
+
near.push(distance);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
const needed = Math.max(1, Math.ceil(width * width * CLEARANCE_SHARE));
|
|
1841
|
+
if (near.length < needed) {
|
|
1842
|
+
return Infinity;
|
|
1843
|
+
}
|
|
1844
|
+
near.sort((a, b) => a - b);
|
|
1845
|
+
return near[needed - 1];
|
|
1846
|
+
}
|
|
1847
|
+
/*
|
|
1848
|
+
* The level ground's view-axis distance through each window pixel, or null when there is no ground.
|
|
1849
|
+
*/
|
|
1850
|
+
function groundDistances(state, position) {
|
|
1851
|
+
const scene = state.viewer.scene;
|
|
1852
|
+
const camera = scene.camera;
|
|
1853
|
+
const frustum = camera.frustum;
|
|
1854
|
+
if (!(state.getModelSpaceFrame || hasGround(state)) ||
|
|
1855
|
+
typeof (frustum === null || frustum === void 0 ? void 0 : frustum.getPixelDimensions) !== "function") {
|
|
1856
|
+
return null;
|
|
1857
|
+
}
|
|
1858
|
+
const plane = groundPlane(state);
|
|
1859
|
+
if (!plane) {
|
|
1860
|
+
return null;
|
|
1861
|
+
}
|
|
1862
|
+
const width = scene.drawingBufferWidth;
|
|
1863
|
+
const height = scene.drawingBufferHeight;
|
|
1864
|
+
// The size of one buffer pixel one metre ahead, which turns a pixel offset into a ray direction.
|
|
1865
|
+
const pixel = frustum.getPixelDimensions(width, height, 1, 1, new Cesium.Cartesian2());
|
|
1866
|
+
const above = Cesium.Plane.getPointDistance(plane, camera.positionWC);
|
|
1867
|
+
const normal = plane.normal;
|
|
1868
|
+
const along = Cesium.Cartesian3.dot(camera.directionWC, normal);
|
|
1869
|
+
const right = Cesium.Cartesian3.dot(camera.rightWC, normal);
|
|
1870
|
+
const up = Cesium.Cartesian3.dot(camera.upWC, normal);
|
|
1871
|
+
// The cursor's offset from the centre in buffer pixels, rows bottom-up as the window's are.
|
|
1872
|
+
const x = Math.floor(position.x * width / scene.canvas.clientWidth) + 0.5 - width / 2;
|
|
1873
|
+
const y = height / 2 - Math.floor(position.y * height / scene.canvas.clientHeight) - 0.5;
|
|
1874
|
+
return (dx, dy) => {
|
|
1875
|
+
const rate = along + (x + dx) * pixel.x * right + (y + dy) * pixel.y * up;
|
|
1876
|
+
return rate < 0 ? -above / rate : Infinity;
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
/*
|
|
1880
|
+
* The point under a screen position, and how far a zoom toward it may go before passing parts beside it.
|
|
1767
1881
|
*/
|
|
1768
1882
|
function pickTarget(state, position) {
|
|
1883
|
+
const scene = state.viewer.scene;
|
|
1884
|
+
// Read before anything else picks, while the depth still holds the frame on screen.
|
|
1885
|
+
const depths = scene.pickPositionSupported ? readWindow(scene, position) : null;
|
|
1886
|
+
const target = pickPoint(state, position, depths);
|
|
1887
|
+
if (target && depths) {
|
|
1888
|
+
target.reach = NearClearance(depths.distances, depths.radius, groundDistances(state, position));
|
|
1889
|
+
target.reachFrom = Cesium.Cartesian3.clone(state.viewer.camera.positionWC);
|
|
1890
|
+
}
|
|
1891
|
+
return target;
|
|
1892
|
+
}
|
|
1893
|
+
/*
|
|
1894
|
+
* The point under a screen position: what is drawn there, else the ground plane, else a point at the last distance.
|
|
1895
|
+
*/
|
|
1896
|
+
function pickPoint(state, position, depths) {
|
|
1769
1897
|
const viewer = state.viewer;
|
|
1770
1898
|
const scene = viewer.scene;
|
|
1771
1899
|
const camera = viewer.camera;
|
|
@@ -1790,12 +1918,16 @@ void main()
|
|
|
1790
1918
|
}
|
|
1791
1919
|
const plausible = plausibleDistance(state);
|
|
1792
1920
|
// A click between point cloud points sees the background; turning or zooming about that throws the camera far off.
|
|
1793
|
-
const surface =
|
|
1921
|
+
const surface = depths ? fillGap(scene, position, ahead !== null && ahead !== void 0 ? ahead : null, depths.distances, depths.radius) : null;
|
|
1794
1922
|
if (isAhead(camera, surface) && Cesium.Cartesian3.distance(surface, camera.positionWC) < plausible) {
|
|
1795
1923
|
return { point: surface, source: "pick", ground: false };
|
|
1796
1924
|
}
|
|
1797
1925
|
if (isAhead(camera, picked) && Cesium.Cartesian3.distance(picked, camera.positionWC) < plausible) {
|
|
1798
|
-
|
|
1926
|
+
const ground = isGroundPick(state, position);
|
|
1927
|
+
// Right after a jump a stand-in tileset's coarse tiles cut far under the curve; use sea level.
|
|
1928
|
+
if (!ground || globeShown(state) || heightOf(state, picked) > GROUND_FLOOR) {
|
|
1929
|
+
return { point: picked, source: "pick", ground };
|
|
1930
|
+
}
|
|
1799
1931
|
}
|
|
1800
1932
|
const ground = groundPlane(state);
|
|
1801
1933
|
const onGround = ground ? Cesium.IntersectionTests.rayPlane(ray, ground) : null;
|
|
@@ -1897,8 +2029,8 @@ void main()
|
|
|
1897
2029
|
if (!picked) {
|
|
1898
2030
|
return;
|
|
1899
2031
|
}
|
|
1900
|
-
const target = picked.point;
|
|
1901
2032
|
const camera = viewer.camera;
|
|
2033
|
+
const target = kind === EDrag.Zoom ? picked.point : GrabPoint(camera, position, picked);
|
|
1902
2034
|
const distance = Cesium.Cartesian3.distance(camera.positionWC, target);
|
|
1903
2035
|
state.lastDistance = Math.max(distance, MIN_ZOOM_DISTANCE);
|
|
1904
2036
|
const drag = { kind, pointerId: e.pointerId, last: position, target, up: upAt(state, target), distance, picked };
|
|
@@ -1906,10 +2038,28 @@ void main()
|
|
|
1906
2038
|
drag.plane = panPlane(camera, target, drag.up);
|
|
1907
2039
|
}
|
|
1908
2040
|
else if (kind === EDrag.Zoom) {
|
|
2041
|
+
holdSurface(state);
|
|
1909
2042
|
drag.direction = Cesium.Cartesian3.normalize(Cesium.Cartesian3.subtract(target, camera.positionWC, new Cesium.Cartesian3()), new Cesium.Cartesian3());
|
|
1910
2043
|
}
|
|
1911
2044
|
state.drag = drag;
|
|
1912
2045
|
}
|
|
2046
|
+
/*
|
|
2047
|
+
* Where a pan or orbit takes hold: the pick, or beside the cursor when it looked far past parts there.
|
|
2048
|
+
*/
|
|
2049
|
+
function GrabPoint(camera, position, picked) {
|
|
2050
|
+
const reach = picked.reach;
|
|
2051
|
+
const ray = camera.getPickRay(position);
|
|
2052
|
+
if (!ray || reach == null || !Number.isFinite(reach)) {
|
|
2053
|
+
return picked.point;
|
|
2054
|
+
}
|
|
2055
|
+
const facing = Cesium.Cartesian3.dot(ray.direction, camera.directionWC);
|
|
2056
|
+
const depth = Cesium.Cartesian3.dot(Cesium.Cartesian3.subtract(picked.point, camera.positionWC, new Cesium.Cartesian3()), camera.directionWC);
|
|
2057
|
+
if (facing <= 0 || depth <= reach * CLEARANCE_GRAB) {
|
|
2058
|
+
return picked.point;
|
|
2059
|
+
}
|
|
2060
|
+
// The reach is along the view axis, so the ray goes a little further to the same depth.
|
|
2061
|
+
return Cesium.Ray.getPoint(ray, Math.max(reach, MIN_ZOOM_DISTANCE) / facing);
|
|
2062
|
+
}
|
|
1913
2063
|
/*
|
|
1914
2064
|
* A level plane through the grabbed point, or one facing the camera when the level one is seen edge on.
|
|
1915
2065
|
*/
|
|
@@ -2058,6 +2208,7 @@ void main()
|
|
|
2058
2208
|
if (!target || !ray) {
|
|
2059
2209
|
return;
|
|
2060
2210
|
}
|
|
2211
|
+
holdSurface(state);
|
|
2061
2212
|
const step = zoomStep(state, ray.direction, target, notches);
|
|
2062
2213
|
Cesium.Cartesian3.add(state.pendingZoom, step, state.pendingZoom);
|
|
2063
2214
|
state.zoomPosition = Cesium.Cartesian3.clone(camera.position);
|
|
@@ -2086,6 +2237,8 @@ void main()
|
|
|
2086
2237
|
const step = Cesium.Cartesian3.multiplyByScalar(state.pendingZoom, share, new Cesium.Cartesian3());
|
|
2087
2238
|
Cesium.Cartesian3.subtract(state.pendingZoom, step, state.pendingZoom);
|
|
2088
2239
|
Cesium.Cartesian3.add(viewer.camera.position, step, viewer.camera.position);
|
|
2240
|
+
zoomMoved(state);
|
|
2241
|
+
keepAboveGround(state);
|
|
2089
2242
|
state.zoomPosition = Cesium.Cartesian3.clone(viewer.camera.position);
|
|
2090
2243
|
viewer.scene.requestRender();
|
|
2091
2244
|
if (share < 1) {
|
|
@@ -2095,6 +2248,7 @@ void main()
|
|
|
2095
2248
|
function moveAlong(state, direction, target, notches) {
|
|
2096
2249
|
const step = zoomStep(state, direction, target, notches);
|
|
2097
2250
|
Cesium.Cartesian3.add(state.viewer.camera.position, step, state.viewer.camera.position);
|
|
2251
|
+
zoomMoved(state);
|
|
2098
2252
|
}
|
|
2099
2253
|
/*
|
|
2100
2254
|
* The move for some notches toward a target along a direction, a share of the distance with a floor so it never stalls.
|
|
@@ -2104,7 +2258,14 @@ void main()
|
|
|
2104
2258
|
const target = picked.point;
|
|
2105
2259
|
// Where the camera will be once the glide already under way ends, which this step continues from.
|
|
2106
2260
|
const from = Cesium.Cartesian3.add(camera.positionWC, state.pendingZoom, new Cesium.Cartesian3());
|
|
2107
|
-
const
|
|
2261
|
+
const unit = Cesium.Cartesian3.normalize(direction, new Cesium.Cartesian3());
|
|
2262
|
+
let distance = Cesium.Cartesian3.distance(from, target);
|
|
2263
|
+
// Between parts of a model, each step goes as far as it would on the nearest part around the cursor.
|
|
2264
|
+
if (picked.reach != null && picked.reachFrom) {
|
|
2265
|
+
const travelled = Cesium.Cartesian3.dot(Cesium.Cartesian3.subtract(from, picked.reachFrom, new Cesium.Cartesian3()), unit);
|
|
2266
|
+
distance = Math.min(distance, picked.reach - travelled);
|
|
2267
|
+
}
|
|
2268
|
+
distance = Math.max(distance, MIN_ZOOM_DISTANCE);
|
|
2108
2269
|
state.lastDistance = distance;
|
|
2109
2270
|
let length = distance * ZOOM_SHARE * notches * zoomSpeedShare(state, picked);
|
|
2110
2271
|
// A geospatial camera zooming out hands over to CesiumJS once it is high enough, so only model-space is capped.
|
|
@@ -2116,7 +2277,6 @@ void main()
|
|
|
2116
2277
|
return new Cesium.Cartesian3();
|
|
2117
2278
|
}
|
|
2118
2279
|
}
|
|
2119
|
-
const unit = Cesium.Cartesian3.normalize(direction, new Cesium.Cartesian3());
|
|
2120
2280
|
// With the globe hidden there is no hand-over, so zooming out stops where the Earth is a dot.
|
|
2121
2281
|
if (length < 0 && !state.getModelSpaceFrame && !globeShown(state)) {
|
|
2122
2282
|
const rise = -Cesium.Cartesian3.dot(unit, upAt(state, from));
|
|
@@ -2132,15 +2292,14 @@ void main()
|
|
|
2132
2292
|
return length > 0 ? resistDescent(state, from, step, picked, notches) : step;
|
|
2133
2293
|
}
|
|
2134
2294
|
/*
|
|
2135
|
-
* How fast to zoom toward a target: slower toward a guess, or while the
|
|
2295
|
+
* How fast to zoom toward a target: slower toward a guess, or while the ground that would give a real one loads.
|
|
2136
2296
|
*/
|
|
2137
2297
|
function zoomSpeedShare(state, picked) {
|
|
2138
2298
|
let share = 1;
|
|
2139
2299
|
if (picked.source !== "pick") {
|
|
2140
2300
|
share *= ZOOM_GUESS_SHARE;
|
|
2141
2301
|
}
|
|
2142
|
-
|
|
2143
|
-
if (!state.getModelSpaceFrame && globeShown(state) && globe.tilesLoaded === false) {
|
|
2302
|
+
if (!state.getModelSpaceFrame && groundLoading(state)) {
|
|
2144
2303
|
share *= ZOOM_LOADING_SHARE;
|
|
2145
2304
|
}
|
|
2146
2305
|
return share;
|
|
@@ -2156,16 +2315,17 @@ void main()
|
|
|
2156
2315
|
if (picked === null || picked === void 0 ? void 0 : picked.ground) {
|
|
2157
2316
|
return { point: picked.point, up: upAt(state, picked.point) };
|
|
2158
2317
|
}
|
|
2159
|
-
if (!globeShown(state)) {
|
|
2160
|
-
return null;
|
|
2161
|
-
}
|
|
2162
2318
|
const ellipsoid = ellipsoidOf(state);
|
|
2163
2319
|
const end = Cesium.Cartesian3.add(from, step, new Cesium.Cartesian3());
|
|
2164
2320
|
const carto = ellipsoid.cartesianToCartographic(end);
|
|
2165
2321
|
if (!carto) {
|
|
2166
2322
|
return null;
|
|
2167
2323
|
}
|
|
2168
|
-
|
|
2324
|
+
// Unloaded terrain counts as sea level; an unknown stand-in tileset counts as nothing.
|
|
2325
|
+
const height = (_b = (_a = groundHeightAt(state, carto)) !== null && _a !== void 0 ? _a : groundHeightAt(state, ellipsoid.cartesianToCartographic(from))) !== null && _b !== void 0 ? _b : (globeShown(state) ? 0 : null);
|
|
2326
|
+
if (height == null) {
|
|
2327
|
+
return null;
|
|
2328
|
+
}
|
|
2169
2329
|
const point = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, height, ellipsoid);
|
|
2170
2330
|
return { point, up: ellipsoid.geodeticSurfaceNormal(point, new Cesium.Cartesian3()) };
|
|
2171
2331
|
}
|
|
@@ -2215,12 +2375,77 @@ void main()
|
|
|
2215
2375
|
const needed = scanScene(state).undergroundData ? PUSH_NOTCHES_DATA_BELOW : PUSH_NOTCHES_NOTHING_BELOW;
|
|
2216
2376
|
if (state.push.notches >= needed) {
|
|
2217
2377
|
state.push.notches = 0;
|
|
2378
|
+
state.surface = { above: false, through: true, until: now + SURFACE_HOLD_MS, at: null };
|
|
2218
2379
|
// A shallow push would land far along the ground to get under it, so it goes no further than a usual step.
|
|
2219
2380
|
const through = Math.min((above + GROUND_BREAK_DEPTH) / sink, Math.max(length, (above + GROUND_BREAK_DEPTH) * 4));
|
|
2220
2381
|
return Cesium.Cartesian3.multiplyByScalar(unit, through, new Cesium.Cartesian3());
|
|
2221
2382
|
}
|
|
2222
2383
|
return Cesium.Cartesian3.multiplyByScalar(unit, toStandOff, new Cesium.Cartesian3());
|
|
2223
2384
|
}
|
|
2385
|
+
/*
|
|
2386
|
+
* The camera's height above the loaded ground under it, or undefined without ground or in model-space.
|
|
2387
|
+
*/
|
|
2388
|
+
function heightAboveGround(state) {
|
|
2389
|
+
if (state.getModelSpaceFrame || !hasGround(state)) {
|
|
2390
|
+
return undefined;
|
|
2391
|
+
}
|
|
2392
|
+
const carto = ellipsoidOf(state).cartesianToCartographic(state.viewer.camera.positionWC);
|
|
2393
|
+
const ground = carto ? groundHeightAt(state, carto) : undefined;
|
|
2394
|
+
return ground == null ? undefined : carto.height - ground;
|
|
2395
|
+
}
|
|
2396
|
+
/*
|
|
2397
|
+
* Notes whether the camera is above the ground as a zoom begins, unless it is being pushed through it.
|
|
2398
|
+
*/
|
|
2399
|
+
function holdSurface(state) {
|
|
2400
|
+
var _a;
|
|
2401
|
+
const now = Date.now();
|
|
2402
|
+
if (state.surface.through && now < state.surface.until) {
|
|
2403
|
+
return;
|
|
2404
|
+
}
|
|
2405
|
+
const at = Cesium.Cartesian3.clone(state.viewer.camera.positionWC);
|
|
2406
|
+
// Ground not loaded yet counts as sea level, as it does for a descent.
|
|
2407
|
+
const above = (_a = heightAboveGround(state)) !== null && _a !== void 0 ? _a : (hasGround(state) && !state.getModelSpaceFrame ? heightOf(state, at) : undefined);
|
|
2408
|
+
state.surface = { above: above != null && above > 0, through: false, until: now + SURFACE_HOLD_MS, at };
|
|
2409
|
+
}
|
|
2410
|
+
/*
|
|
2411
|
+
* Lifts a camera a zoom kept above the ground back over finer ground that loads in higher.
|
|
2412
|
+
*/
|
|
2413
|
+
function keepAboveGround(state) {
|
|
2414
|
+
const surface = state.surface;
|
|
2415
|
+
const now = Date.now();
|
|
2416
|
+
if (!surface.above || !state.ours || now > surface.until + SURFACE_LOADING_MS) {
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
// Ground that has finished loading does not move under a still camera.
|
|
2420
|
+
if (now > surface.until && !groundLoading(state)) {
|
|
2421
|
+
return;
|
|
2422
|
+
}
|
|
2423
|
+
const camera = state.viewer.camera;
|
|
2424
|
+
// A bookmark, fly-to or pan moved it since, which may mean to go below the ground.
|
|
2425
|
+
if (!surface.at || !Cesium.Cartesian3.equalsEpsilon(camera.positionWC, surface.at, 0, 1e-3)) {
|
|
2426
|
+
surface.above = false;
|
|
2427
|
+
return;
|
|
2428
|
+
}
|
|
2429
|
+
const above = heightAboveGround(state);
|
|
2430
|
+
if (above == null || above >= GROUND_STANDOFF / 2) {
|
|
2431
|
+
return;
|
|
2432
|
+
}
|
|
2433
|
+
const ellipsoid = ellipsoidOf(state);
|
|
2434
|
+
const carto = ellipsoid.cartesianToCartographic(camera.positionWC);
|
|
2435
|
+
Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height - above + GROUND_STANDOFF, ellipsoid, camera.position);
|
|
2436
|
+
// What is left of the glide would take it straight back down.
|
|
2437
|
+
state.pendingZoom = new Cesium.Cartesian3();
|
|
2438
|
+
surface.at = Cesium.Cartesian3.clone(camera.position);
|
|
2439
|
+
state.viewer.scene.requestRender();
|
|
2440
|
+
}
|
|
2441
|
+
/*
|
|
2442
|
+
* Notes where a zoom just put the camera, so the ground hold can tell its moves from others.
|
|
2443
|
+
*/
|
|
2444
|
+
function zoomMoved(state) {
|
|
2445
|
+
if (state.surface.at) {
|
|
2446
|
+
Cesium.Cartesian3.clone(state.viewer.camera.positionWC, state.surface.at);
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2224
2449
|
/*
|
|
2225
2450
|
* What the scene holds that the camera cares about, rescanned at most every couple of seconds.
|
|
2226
2451
|
*/
|
|
@@ -2231,7 +2456,7 @@ void main()
|
|
|
2231
2456
|
return applyOverride(state, state.scan);
|
|
2232
2457
|
}
|
|
2233
2458
|
const scene = state.viewer.scene;
|
|
2234
|
-
const found = { at: now, undergroundData: false, groundTileset: false };
|
|
2459
|
+
const found = { at: now, undergroundData: false, groundTileset: false, ground: null };
|
|
2235
2460
|
// Seeing through the ground is turned on to look at what is under it.
|
|
2236
2461
|
if ((_b = (_a = scene.globe) === null || _a === void 0 ? void 0 : _a.translucency) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
2237
2462
|
found.undergroundData = true;
|
|
@@ -2248,6 +2473,7 @@ void main()
|
|
|
2248
2473
|
}
|
|
2249
2474
|
if (primitive[GROUND_TILESET_KEY]) {
|
|
2250
2475
|
found.groundTileset = true;
|
|
2476
|
+
found.ground = primitive;
|
|
2251
2477
|
return;
|
|
2252
2478
|
}
|
|
2253
2479
|
if (!found.undergroundData && reachesBelowGround(state, lowestPointOf(primitive))) {
|
|
@@ -61924,7 +62150,7 @@ void main() {
|
|
|
61924
62150
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
61925
62151
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
61926
62152
|
|
|
61927
|
-
const VERSION = "7.9.
|
|
62153
|
+
const VERSION = "7.9.4";
|
|
61928
62154
|
/**
|
|
61929
62155
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
61930
62156
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|
|
@@ -61966,6 +62192,8 @@ void main() {
|
|
|
61966
62192
|
exports.LIGHT_INTENSITY_COMPENSATION = LIGHT_INTENSITY_COMPENSATION;
|
|
61967
62193
|
exports.MAX_COMPENSATED_LIGHT_INTENSITY = MAX_COMPENSATED_LIGHT_INTENSITY;
|
|
61968
62194
|
exports.FindGapSurfaces = FindGapSurfaces;
|
|
62195
|
+
exports.NearClearance = NearClearance;
|
|
62196
|
+
exports.GrabPoint = GrabPoint;
|
|
61969
62197
|
exports.Draw3dPolygon = Draw3dPolygon;
|
|
61970
62198
|
exports.Draw3dPolyline = Draw3dPolyline;
|
|
61971
62199
|
exports.WidgetControlViewBarSearch = WidgetControlViewBarSearch;
|