bruce-cesium 7.9.3 → 7.9.5
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 +429 -35
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +424 -32
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/viewer/camera-controls.js +428 -32
- 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 +37 -0
- package/package.json +1 -1
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Cesium from 'cesium';
|
|
2
|
-
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature,
|
|
3
|
-
import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, ZoomControl, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Geometry as Geometry$1,
|
|
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, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, JulianDate, Quaternion, HeadingPitchRoll, HeightReference, ConstantPositionProperty, DistanceDisplayCondition, ColorBlendMode, Model, ClassificationType, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, FeatureDetection, Matrix3, NearFarScalar, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileset, OrthographicFrustum, EasingFunction, Intersect, ShadowMode, CustomDataSource, WebGLConstants, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, CesiumInspector, defined, ClockRange, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, Event, CameraEventType, KeyboardEventModifier, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, PolygonPipeline, GeometryInstance, CzmlDataSource } from 'cesium';
|
|
3
|
+
import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, ZoomControl, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Api, Bounds, ClientFileValueMap, Color as Color$1, Geometry as Geometry$1, ProjectView, ProjectViewBookmark, Assembly, EntityCoords, BruceApi, EntityRelation, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Ensures a number is returned from a given value.
|
|
@@ -1367,6 +1367,11 @@ const PUSH_NOTCHES_DATA_BELOW = 3;
|
|
|
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.
|
|
@@ -1380,6 +1385,24 @@ const ZOOM_LOADING_SHARE = 0.7;
|
|
|
1380
1385
|
const HIDDEN_GLOBE_MAX_HEIGHT = 10000000;
|
|
1381
1386
|
// Marks a tileset that stands in for the globe, such as Google's photorealistic tiles.
|
|
1382
1387
|
const GROUND_TILESET_KEY = "_nextspace_camera_ground";
|
|
1388
|
+
// A viewer's own mouse scheme and wheel direction, kept on the viewer so a host may set them before Attach.
|
|
1389
|
+
const MOUSE_KEY = "_nextspace_camera_mouse";
|
|
1390
|
+
// Marks a wheel event these controls turned round, so it is not turned back again.
|
|
1391
|
+
const MIRRORED_WHEEL_KEY = "_nextspace_mirrored";
|
|
1392
|
+
/**
|
|
1393
|
+
* Which mouse buttons pan, orbit and zoom: CesiumJS's own, or a familiar desktop 3D app's.
|
|
1394
|
+
*/
|
|
1395
|
+
var ECameraMouseScheme;
|
|
1396
|
+
(function (ECameraMouseScheme) {
|
|
1397
|
+
// CesiumJS's own: left drag pans, middle or ctrl drag orbits, right drag zooms.
|
|
1398
|
+
ECameraMouseScheme["Default"] = "default";
|
|
1399
|
+
// Autodesk Fusion, Revit, Navisworks and AutoCAD: middle drag pans, shift+middle orbits, ctrl+shift+middle zooms.
|
|
1400
|
+
ECameraMouseScheme["Autodesk"] = "autodesk";
|
|
1401
|
+
// SketchUp: middle drag orbits, shift+middle pans.
|
|
1402
|
+
ECameraMouseScheme["SketchUp"] = "sketchup";
|
|
1403
|
+
})(ECameraMouseScheme || (ECameraMouseScheme = {}));
|
|
1404
|
+
// What a viewer without its own setting uses: the app user's preference, set once for every viewer the app makes.
|
|
1405
|
+
const _mouseDefault = { scheme: ECameraMouseScheme.Default, wheelReversed: false };
|
|
1383
1406
|
var EDrag;
|
|
1384
1407
|
(function (EDrag) {
|
|
1385
1408
|
EDrag["Pan"] = "pan";
|
|
@@ -1395,7 +1418,7 @@ var CameraControls;
|
|
|
1395
1418
|
* Takes over mouse drag and wheel navigation close to the ground; CesiumJS keeps planet scale, pinch and look.
|
|
1396
1419
|
*/
|
|
1397
1420
|
function Attach(viewer) {
|
|
1398
|
-
var _a, _b, _c;
|
|
1421
|
+
var _a, _b, _c, _d;
|
|
1399
1422
|
if (!viewer || viewer.isDestroyed() || viewer[CESIUM_CAMERA_CONTROLS_KEY]) {
|
|
1400
1423
|
return;
|
|
1401
1424
|
}
|
|
@@ -1416,15 +1439,18 @@ var CameraControls;
|
|
|
1416
1439
|
push: { notches: 0, at: 0 },
|
|
1417
1440
|
scan: null,
|
|
1418
1441
|
undergroundOverride: null,
|
|
1442
|
+
surface: { above: false, through: false, until: 0, at: null },
|
|
1419
1443
|
saved: {
|
|
1420
1444
|
rotateEventTypes: controller.rotateEventTypes,
|
|
1421
1445
|
zoomEventTypes: controller.zoomEventTypes,
|
|
1422
1446
|
tiltEventTypes: controller.tiltEventTypes,
|
|
1447
|
+
translateEventTypes: controller.translateEventTypes,
|
|
1423
1448
|
enableCollisionDetection: controller.enableCollisionDetection,
|
|
1424
1449
|
backFaceAlpha: (_b = (_a = scene.globe) === null || _a === void 0 ? void 0 : _a.translucency) === null || _b === void 0 ? void 0 : _b.backFaceAlpha,
|
|
1425
1450
|
showSkirts: (_c = scene.globe) === null || _c === void 0 ? void 0 : _c.showSkirts
|
|
1426
1451
|
},
|
|
1427
1452
|
ours: false,
|
|
1453
|
+
cesiumScheme: null,
|
|
1428
1454
|
removals: []
|
|
1429
1455
|
};
|
|
1430
1456
|
viewer[CESIUM_CAMERA_CONTROLS_KEY] = state;
|
|
@@ -1440,7 +1466,13 @@ var CameraControls;
|
|
|
1440
1466
|
listen(window, "pointerup", (e) => onPointerUp(state, e));
|
|
1441
1467
|
listen(window, "pointercancel", (e) => onPointerUp(state, e));
|
|
1442
1468
|
listen(canvas, "wheel", (e) => onWheel(state, e), { passive: true });
|
|
1443
|
-
|
|
1469
|
+
// Caught before the canvas sees it, so CesiumJS's controller and these controls both get the turned wheel.
|
|
1470
|
+
const wheelHost = (_d = canvas.parentElement) !== null && _d !== void 0 ? _d : window;
|
|
1471
|
+
listen(wheelHost, "wheel", (e) => mirrorWheel(state, e), { capture: true, passive: false });
|
|
1472
|
+
state.removals.push(scene.preUpdate.addEventListener(() => {
|
|
1473
|
+
syncController(state);
|
|
1474
|
+
keepAboveGround(state);
|
|
1475
|
+
}));
|
|
1444
1476
|
syncController(state);
|
|
1445
1477
|
scene.requestRender();
|
|
1446
1478
|
}
|
|
@@ -1472,6 +1504,52 @@ var CameraControls;
|
|
|
1472
1504
|
return Boolean(viewer === null || viewer === void 0 ? void 0 : viewer[CESIUM_CAMERA_CONTROLS_KEY]);
|
|
1473
1505
|
}
|
|
1474
1506
|
CameraControls.IsAttached = IsAttached;
|
|
1507
|
+
/**
|
|
1508
|
+
* Picks which mouse buttons pan, orbit and zoom, here and for CesiumJS's controller above the hand-over height.
|
|
1509
|
+
*/
|
|
1510
|
+
function SetMouseScheme(viewer, scheme) {
|
|
1511
|
+
if (!viewer || viewer.isDestroyed()) {
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
viewer[MOUSE_KEY] = { ...viewer[MOUSE_KEY], scheme: knownScheme(scheme) };
|
|
1515
|
+
const state = viewer[CESIUM_CAMERA_CONTROLS_KEY];
|
|
1516
|
+
if (state && !state.ours) {
|
|
1517
|
+
applyCesiumGestures(state);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
CameraControls.SetMouseScheme = SetMouseScheme;
|
|
1521
|
+
/**
|
|
1522
|
+
* Sets the scheme for every viewer without its own, such as the app user's preference; viewers follow next frame.
|
|
1523
|
+
*/
|
|
1524
|
+
function SetMouseSchemeDefault(scheme) {
|
|
1525
|
+
_mouseDefault.scheme = knownScheme(scheme);
|
|
1526
|
+
}
|
|
1527
|
+
CameraControls.SetMouseSchemeDefault = SetMouseSchemeDefault;
|
|
1528
|
+
function GetMouseScheme(viewer) {
|
|
1529
|
+
return mouseOf(viewer).scheme;
|
|
1530
|
+
}
|
|
1531
|
+
CameraControls.GetMouseScheme = GetMouseScheme;
|
|
1532
|
+
/**
|
|
1533
|
+
* Makes wheel forward zoom out instead of in, for these controls and CesiumJS's controller alike.
|
|
1534
|
+
*/
|
|
1535
|
+
function SetMouseWheelReversed(viewer, reversed) {
|
|
1536
|
+
if (!viewer || viewer.isDestroyed()) {
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
viewer[MOUSE_KEY] = { ...viewer[MOUSE_KEY], wheelReversed: Boolean(reversed) };
|
|
1540
|
+
}
|
|
1541
|
+
CameraControls.SetMouseWheelReversed = SetMouseWheelReversed;
|
|
1542
|
+
/**
|
|
1543
|
+
* Sets the wheel direction for every viewer without its own, such as the app user's preference.
|
|
1544
|
+
*/
|
|
1545
|
+
function SetMouseWheelReversedDefault(reversed) {
|
|
1546
|
+
_mouseDefault.wheelReversed = Boolean(reversed);
|
|
1547
|
+
}
|
|
1548
|
+
CameraControls.SetMouseWheelReversedDefault = SetMouseWheelReversedDefault;
|
|
1549
|
+
function GetMouseWheelReversed(viewer) {
|
|
1550
|
+
return mouseOf(viewer).wheelReversed;
|
|
1551
|
+
}
|
|
1552
|
+
CameraControls.GetMouseWheelReversed = GetMouseWheelReversed;
|
|
1475
1553
|
/**
|
|
1476
1554
|
* Marks a tileset as standing in for the globe (Google's photorealistic tiles), so the camera treats it as ground.
|
|
1477
1555
|
*/
|
|
@@ -1529,11 +1607,67 @@ var CameraControls;
|
|
|
1529
1607
|
}
|
|
1530
1608
|
CameraControls.SetModelSpace = SetModelSpace;
|
|
1531
1609
|
})(CameraControls || (CameraControls = {}));
|
|
1610
|
+
/*
|
|
1611
|
+
* The scheme and wheel direction a viewer uses: its own where set, else the app default.
|
|
1612
|
+
*/
|
|
1613
|
+
function mouseOf(viewer) {
|
|
1614
|
+
var _a, _b;
|
|
1615
|
+
const own = viewer === null || viewer === void 0 ? void 0 : viewer[MOUSE_KEY];
|
|
1616
|
+
return {
|
|
1617
|
+
scheme: (_a = own === null || own === void 0 ? void 0 : own.scheme) !== null && _a !== void 0 ? _a : _mouseDefault.scheme,
|
|
1618
|
+
wheelReversed: (_b = own === null || own === void 0 ? void 0 : own.wheelReversed) !== null && _b !== void 0 ? _b : _mouseDefault.wheelReversed
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
/*
|
|
1622
|
+
* A scheme this version knows, or Default for one saved by a newer app or mistyped.
|
|
1623
|
+
*/
|
|
1624
|
+
function knownScheme(scheme) {
|
|
1625
|
+
return Object.values(ECameraMouseScheme).includes(scheme) ? scheme : ECameraMouseScheme.Default;
|
|
1626
|
+
}
|
|
1532
1627
|
function restoreCesiumGestures(state) {
|
|
1533
1628
|
const controller = state.viewer.scene.screenSpaceCameraController;
|
|
1534
1629
|
controller.rotateEventTypes = state.saved.rotateEventTypes;
|
|
1535
1630
|
controller.zoomEventTypes = state.saved.zoomEventTypes;
|
|
1536
1631
|
controller.tiltEventTypes = state.saved.tiltEventTypes;
|
|
1632
|
+
if (state.saved.translateEventTypes !== undefined) {
|
|
1633
|
+
controller.translateEventTypes = state.saved.translateEventTypes;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
/*
|
|
1637
|
+
* Gives CesiumJS's controller its own gestures under the mouse scheme, so the buttons do not swap at the hand-over.
|
|
1638
|
+
*/
|
|
1639
|
+
function applyCesiumGestures(state) {
|
|
1640
|
+
restoreCesiumGestures(state);
|
|
1641
|
+
const scheme = mouseOf(state.viewer).scheme;
|
|
1642
|
+
state.cesiumScheme = scheme;
|
|
1643
|
+
if (scheme === ECameraMouseScheme.Default) {
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
const middle = CameraEventType.MIDDLE_DRAG;
|
|
1647
|
+
const shiftMiddle = { eventType: middle, modifier: KeyboardEventModifier.SHIFT };
|
|
1648
|
+
const tilt = asEventTypes(state.saved.tiltEventTypes);
|
|
1649
|
+
// A host that moved CesiumJS's middle drag elsewhere has its own mapping, which is left alone.
|
|
1650
|
+
if (!tilt.includes(middle)) {
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
// CesiumJS orbits with tilt and pans with rotate in 3D, or translate in 2D and Columbus view.
|
|
1654
|
+
const orbit = scheme === ECameraMouseScheme.Autodesk ? shiftMiddle : middle;
|
|
1655
|
+
const pan = scheme === ECameraMouseScheme.Autodesk ? middle : shiftMiddle;
|
|
1656
|
+
const controller = state.viewer.scene.screenSpaceCameraController;
|
|
1657
|
+
controller.tiltEventTypes = tilt.map((type) => (type === middle ? orbit : type));
|
|
1658
|
+
controller.rotateEventTypes = [...asEventTypes(state.saved.rotateEventTypes), pan];
|
|
1659
|
+
if (state.saved.translateEventTypes !== undefined) {
|
|
1660
|
+
controller.translateEventTypes = [...asEventTypes(state.saved.translateEventTypes), pan];
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
/*
|
|
1664
|
+
* CesiumJS takes one event type or a list of them; this always gives a list.
|
|
1665
|
+
*/
|
|
1666
|
+
function asEventTypes(types) {
|
|
1667
|
+
if (types == null) {
|
|
1668
|
+
return [];
|
|
1669
|
+
}
|
|
1670
|
+
return Array.isArray(types) ? types : [types];
|
|
1537
1671
|
}
|
|
1538
1672
|
/*
|
|
1539
1673
|
* Decides each frame who has the mouse: these controls near the ground, CesiumJS for planets, orthographic and tracking.
|
|
@@ -1545,6 +1679,9 @@ function syncController(state) {
|
|
|
1545
1679
|
}
|
|
1546
1680
|
const ours = shouldControl(state);
|
|
1547
1681
|
if (ours === state.ours) {
|
|
1682
|
+
if (!ours && state.cesiumScheme !== mouseOf(viewer).scheme) {
|
|
1683
|
+
applyCesiumGestures(state);
|
|
1684
|
+
}
|
|
1548
1685
|
return;
|
|
1549
1686
|
}
|
|
1550
1687
|
state.ours = ours;
|
|
@@ -1555,7 +1692,7 @@ function syncController(state) {
|
|
|
1555
1692
|
controller.tiltEventTypes = [CameraEventType.PINCH];
|
|
1556
1693
|
}
|
|
1557
1694
|
else {
|
|
1558
|
-
|
|
1695
|
+
applyCesiumGestures(state);
|
|
1559
1696
|
}
|
|
1560
1697
|
}
|
|
1561
1698
|
function shouldControl(state) {
|
|
@@ -1592,6 +1729,38 @@ function terrainHeightAt(state, carto) {
|
|
|
1592
1729
|
const height = globe.getHeight(carto);
|
|
1593
1730
|
return Number.isFinite(height) ? height : undefined;
|
|
1594
1731
|
}
|
|
1732
|
+
/*
|
|
1733
|
+
* The ground's height at a place: the loaded terrain, or the tileset standing in for a hidden globe.
|
|
1734
|
+
*/
|
|
1735
|
+
function groundHeightAt(state, carto) {
|
|
1736
|
+
var _a;
|
|
1737
|
+
if (globeShown(state)) {
|
|
1738
|
+
return terrainHeightAt(state, carto);
|
|
1739
|
+
}
|
|
1740
|
+
const tileset = scanScene(state).ground;
|
|
1741
|
+
if (!carto || !tileset || ((_a = tileset.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(tileset)) || typeof tileset.getHeight !== "function") {
|
|
1742
|
+
return undefined;
|
|
1743
|
+
}
|
|
1744
|
+
try {
|
|
1745
|
+
// Only tiles drawn this frame answer, which near the camera are the finest loaded.
|
|
1746
|
+
const height = tileset.getHeight(carto, state.viewer.scene);
|
|
1747
|
+
return Number.isFinite(height) && height > GROUND_FLOOR ? height : undefined;
|
|
1748
|
+
}
|
|
1749
|
+
catch (e) {
|
|
1750
|
+
return undefined;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
/*
|
|
1754
|
+
* Whether the ground is still loading: the globe's tiles, or the stand-in tileset's.
|
|
1755
|
+
*/
|
|
1756
|
+
function groundLoading(state) {
|
|
1757
|
+
var _a;
|
|
1758
|
+
if (globeShown(state)) {
|
|
1759
|
+
return state.viewer.scene.globe.tilesLoaded === false;
|
|
1760
|
+
}
|
|
1761
|
+
const tileset = scanScene(state).ground;
|
|
1762
|
+
return Boolean(tileset && !((_a = tileset.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(tileset)) && tileset.tilesLoaded === false);
|
|
1763
|
+
}
|
|
1595
1764
|
function ellipsoidOf(state) {
|
|
1596
1765
|
var _a, _b;
|
|
1597
1766
|
return (_b = (_a = state.viewer.scene.globe) === null || _a === void 0 ? void 0 : _a.ellipsoid) !== null && _b !== void 0 ? _b : Ellipsoid.WGS84;
|
|
@@ -1629,8 +1798,8 @@ function groundPlane(state) {
|
|
|
1629
1798
|
if (!carto) {
|
|
1630
1799
|
return null;
|
|
1631
1800
|
}
|
|
1632
|
-
// Level with the
|
|
1633
|
-
const surface = Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a =
|
|
1801
|
+
// Level with the ground under the camera, not sea level, so a guess over high ground is not far too deep.
|
|
1802
|
+
const surface = Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a = groundHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0, ellipsoid);
|
|
1634
1803
|
return Plane.fromPointNormal(surface, ellipsoid.geodeticSurfaceNormal(surface, new Cartesian3()));
|
|
1635
1804
|
}
|
|
1636
1805
|
/*
|
|
@@ -1654,6 +1823,15 @@ const GAP_SLACK = 0.5;
|
|
|
1654
1823
|
// Directions around the centre, and how many must hold nearer pixels for the centre to be surrounded.
|
|
1655
1824
|
const GAP_SECTORS = 8;
|
|
1656
1825
|
const GAP_SECTORS_NEAR = 6;
|
|
1826
|
+
// How far around the cursor, in CSS pixels, nearer parts limit a zoom, and the most buffer pixels read.
|
|
1827
|
+
const CLEARANCE_RADIUS_PX = 24;
|
|
1828
|
+
const CLEARANCE_RADIUS_MAX = 64;
|
|
1829
|
+
// The share of that window that must be nearer, so a stray pixel or a thin cable does not slow the zoom.
|
|
1830
|
+
const CLEARANCE_SHARE = 0.05;
|
|
1831
|
+
// A pixel at least this share of the level ground's distance on its ray is ground, and never limits.
|
|
1832
|
+
const CLEARANCE_GROUND = 0.9;
|
|
1833
|
+
// A pan or orbit grabbing this many times farther than the reach grabs at the reach instead.
|
|
1834
|
+
const CLEARANCE_GRAB = 2;
|
|
1657
1835
|
const PACKED_DEPTH = new Cartesian4(1, 1 / 255, 1 / 65025, 1 / 16581375);
|
|
1658
1836
|
/*
|
|
1659
1837
|
* Distances along the view axis drawn around a window position, rows bottom-up, Infinity where nothing is drawn.
|
|
@@ -1702,6 +1880,21 @@ function readDepthDistances(scene, position, radius) {
|
|
|
1702
1880
|
}
|
|
1703
1881
|
return distances;
|
|
1704
1882
|
}
|
|
1883
|
+
/*
|
|
1884
|
+
* The depth window around a position for the gap search and the reach, or null when unreadable.
|
|
1885
|
+
*/
|
|
1886
|
+
function readWindow(scene, position) {
|
|
1887
|
+
const scale = scene.drawingBufferWidth / scene.canvas.clientWidth;
|
|
1888
|
+
const clearance = Math.min(Math.round(CLEARANCE_RADIUS_PX * (Number.isFinite(scale) ? scale : 1)), CLEARANCE_RADIUS_MAX);
|
|
1889
|
+
const radius = Math.max(GAP_RADII[GAP_RADII.length - 1], clearance);
|
|
1890
|
+
try {
|
|
1891
|
+
const distances = readDepthDistances(scene, position, radius);
|
|
1892
|
+
return distances ? { distances, radius } : null;
|
|
1893
|
+
}
|
|
1894
|
+
catch (e) {
|
|
1895
|
+
return null;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1705
1898
|
/*
|
|
1706
1899
|
* Offsets of the surface pixel around the centre for each radius where clearly nearer pixels surround it.
|
|
1707
1900
|
*/
|
|
@@ -1739,15 +1932,7 @@ function FindGapSurfaces(distances, radius) {
|
|
|
1739
1932
|
/*
|
|
1740
1933
|
* The point cloud surface around a pick that looked through a gap between its points, or null when it did not.
|
|
1741
1934
|
*/
|
|
1742
|
-
function fillGap(scene, position, picked) {
|
|
1743
|
-
const radius = GAP_RADII[GAP_RADII.length - 1];
|
|
1744
|
-
let distances = null;
|
|
1745
|
-
try {
|
|
1746
|
-
distances = readDepthDistances(scene, position, radius);
|
|
1747
|
-
}
|
|
1748
|
-
catch (e) {
|
|
1749
|
-
return null;
|
|
1750
|
-
}
|
|
1935
|
+
function fillGap(scene, position, picked, distances, radius) {
|
|
1751
1936
|
if (!distances) {
|
|
1752
1937
|
return null;
|
|
1753
1938
|
}
|
|
@@ -1767,9 +1952,80 @@ function fillGap(scene, position, picked) {
|
|
|
1767
1952
|
return null;
|
|
1768
1953
|
}
|
|
1769
1954
|
/*
|
|
1770
|
-
* The
|
|
1955
|
+
* The view-axis distance within which a share of the window around the cursor is drawn, ground aside.
|
|
1956
|
+
*/
|
|
1957
|
+
function NearClearance(distances, radius, groundAt) {
|
|
1958
|
+
const width = 2 * radius + 1;
|
|
1959
|
+
const near = [];
|
|
1960
|
+
for (let dy = -radius; dy <= radius; dy++) {
|
|
1961
|
+
for (let dx = -radius; dx <= radius; dx++) {
|
|
1962
|
+
const distance = distances[(radius + dy) * width + (radius + dx)];
|
|
1963
|
+
if (!Number.isFinite(distance)) {
|
|
1964
|
+
continue;
|
|
1965
|
+
}
|
|
1966
|
+
const ground = groundAt ? groundAt(dx, dy) : Infinity;
|
|
1967
|
+
if (!(ground > 0 && distance >= ground * CLEARANCE_GROUND)) {
|
|
1968
|
+
near.push(distance);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
const needed = Math.max(1, Math.ceil(width * width * CLEARANCE_SHARE));
|
|
1973
|
+
if (near.length < needed) {
|
|
1974
|
+
return Infinity;
|
|
1975
|
+
}
|
|
1976
|
+
near.sort((a, b) => a - b);
|
|
1977
|
+
return near[needed - 1];
|
|
1978
|
+
}
|
|
1979
|
+
/*
|
|
1980
|
+
* The level ground's view-axis distance through each window pixel, or null when there is no ground.
|
|
1981
|
+
*/
|
|
1982
|
+
function groundDistances(state, position) {
|
|
1983
|
+
const scene = state.viewer.scene;
|
|
1984
|
+
const camera = scene.camera;
|
|
1985
|
+
const frustum = camera.frustum;
|
|
1986
|
+
if (!(state.getModelSpaceFrame || hasGround(state)) ||
|
|
1987
|
+
typeof (frustum === null || frustum === void 0 ? void 0 : frustum.getPixelDimensions) !== "function") {
|
|
1988
|
+
return null;
|
|
1989
|
+
}
|
|
1990
|
+
const plane = groundPlane(state);
|
|
1991
|
+
if (!plane) {
|
|
1992
|
+
return null;
|
|
1993
|
+
}
|
|
1994
|
+
const width = scene.drawingBufferWidth;
|
|
1995
|
+
const height = scene.drawingBufferHeight;
|
|
1996
|
+
// The size of one buffer pixel one metre ahead, which turns a pixel offset into a ray direction.
|
|
1997
|
+
const pixel = frustum.getPixelDimensions(width, height, 1, 1, new Cartesian2());
|
|
1998
|
+
const above = Plane.getPointDistance(plane, camera.positionWC);
|
|
1999
|
+
const normal = plane.normal;
|
|
2000
|
+
const along = Cartesian3.dot(camera.directionWC, normal);
|
|
2001
|
+
const right = Cartesian3.dot(camera.rightWC, normal);
|
|
2002
|
+
const up = Cartesian3.dot(camera.upWC, normal);
|
|
2003
|
+
// The cursor's offset from the centre in buffer pixels, rows bottom-up as the window's are.
|
|
2004
|
+
const x = Math.floor(position.x * width / scene.canvas.clientWidth) + 0.5 - width / 2;
|
|
2005
|
+
const y = height / 2 - Math.floor(position.y * height / scene.canvas.clientHeight) - 0.5;
|
|
2006
|
+
return (dx, dy) => {
|
|
2007
|
+
const rate = along + (x + dx) * pixel.x * right + (y + dy) * pixel.y * up;
|
|
2008
|
+
return rate < 0 ? -above / rate : Infinity;
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
/*
|
|
2012
|
+
* The point under a screen position, and how far a zoom toward it may go before passing parts beside it.
|
|
1771
2013
|
*/
|
|
1772
2014
|
function pickTarget(state, position) {
|
|
2015
|
+
const scene = state.viewer.scene;
|
|
2016
|
+
// Read before anything else picks, while the depth still holds the frame on screen.
|
|
2017
|
+
const depths = scene.pickPositionSupported ? readWindow(scene, position) : null;
|
|
2018
|
+
const target = pickPoint(state, position, depths);
|
|
2019
|
+
if (target && depths) {
|
|
2020
|
+
target.reach = NearClearance(depths.distances, depths.radius, groundDistances(state, position));
|
|
2021
|
+
target.reachFrom = Cartesian3.clone(state.viewer.camera.positionWC);
|
|
2022
|
+
}
|
|
2023
|
+
return target;
|
|
2024
|
+
}
|
|
2025
|
+
/*
|
|
2026
|
+
* The point under a screen position: what is drawn there, else the ground plane, else a point at the last distance.
|
|
2027
|
+
*/
|
|
2028
|
+
function pickPoint(state, position, depths) {
|
|
1773
2029
|
const viewer = state.viewer;
|
|
1774
2030
|
const scene = viewer.scene;
|
|
1775
2031
|
const camera = viewer.camera;
|
|
@@ -1794,12 +2050,16 @@ function pickTarget(state, position) {
|
|
|
1794
2050
|
}
|
|
1795
2051
|
const plausible = plausibleDistance(state);
|
|
1796
2052
|
// A click between point cloud points sees the background; turning or zooming about that throws the camera far off.
|
|
1797
|
-
const surface =
|
|
2053
|
+
const surface = depths ? fillGap(scene, position, ahead !== null && ahead !== void 0 ? ahead : null, depths.distances, depths.radius) : null;
|
|
1798
2054
|
if (isAhead(camera, surface) && Cartesian3.distance(surface, camera.positionWC) < plausible) {
|
|
1799
2055
|
return { point: surface, source: "pick", ground: false };
|
|
1800
2056
|
}
|
|
1801
2057
|
if (isAhead(camera, picked) && Cartesian3.distance(picked, camera.positionWC) < plausible) {
|
|
1802
|
-
|
|
2058
|
+
const ground = isGroundPick(state, position);
|
|
2059
|
+
// Right after a jump a stand-in tileset's coarse tiles cut far under the curve; use sea level.
|
|
2060
|
+
if (!ground || globeShown(state) || heightOf(state, picked) > GROUND_FLOOR) {
|
|
2061
|
+
return { point: picked, source: "pick", ground };
|
|
2062
|
+
}
|
|
1803
2063
|
}
|
|
1804
2064
|
const ground = groundPlane(state);
|
|
1805
2065
|
const onGround = ground ? IntersectionTests.rayPlane(ray, ground) : null;
|
|
@@ -1846,9 +2106,18 @@ function isAhead(camera, point) {
|
|
|
1846
2106
|
return Cartesian3.dot(toPoint, camera.directionWC) > 0;
|
|
1847
2107
|
}
|
|
1848
2108
|
/*
|
|
1849
|
-
* Picks which gesture a button and its modifiers start
|
|
2109
|
+
* Picks which gesture a button and its modifiers start under the mouse scheme; Default matches CesiumJS's own mapping.
|
|
1850
2110
|
*/
|
|
1851
|
-
function dragKind(e) {
|
|
2111
|
+
function dragKind(e, scheme) {
|
|
2112
|
+
if (scheme === ECameraMouseScheme.Autodesk && e.button === 1) {
|
|
2113
|
+
if (e.shiftKey && e.ctrlKey) {
|
|
2114
|
+
return EDrag.Zoom;
|
|
2115
|
+
}
|
|
2116
|
+
return e.shiftKey ? EDrag.Orbit : EDrag.Pan;
|
|
2117
|
+
}
|
|
2118
|
+
if (scheme === ECameraMouseScheme.SketchUp && e.button === 1) {
|
|
2119
|
+
return e.shiftKey ? EDrag.Pan : EDrag.Orbit;
|
|
2120
|
+
}
|
|
1852
2121
|
if (e.shiftKey) {
|
|
1853
2122
|
// Shift drag looks around, which CesiumJS still handles.
|
|
1854
2123
|
return null;
|
|
@@ -1892,7 +2161,7 @@ function onPointerDown(state, e) {
|
|
|
1892
2161
|
return;
|
|
1893
2162
|
}
|
|
1894
2163
|
}
|
|
1895
|
-
const kind = dragKind(e);
|
|
2164
|
+
const kind = dragKind(e, mouseOf(viewer).scheme);
|
|
1896
2165
|
if (!kind || !allows(state, kind)) {
|
|
1897
2166
|
return;
|
|
1898
2167
|
}
|
|
@@ -1901,8 +2170,8 @@ function onPointerDown(state, e) {
|
|
|
1901
2170
|
if (!picked) {
|
|
1902
2171
|
return;
|
|
1903
2172
|
}
|
|
1904
|
-
const target = picked.point;
|
|
1905
2173
|
const camera = viewer.camera;
|
|
2174
|
+
const target = kind === EDrag.Zoom ? picked.point : GrabPoint(camera, position, picked);
|
|
1906
2175
|
const distance = Cartesian3.distance(camera.positionWC, target);
|
|
1907
2176
|
state.lastDistance = Math.max(distance, MIN_ZOOM_DISTANCE);
|
|
1908
2177
|
const drag = { kind, pointerId: e.pointerId, last: position, target, up: upAt(state, target), distance, picked };
|
|
@@ -1910,10 +2179,28 @@ function onPointerDown(state, e) {
|
|
|
1910
2179
|
drag.plane = panPlane(camera, target, drag.up);
|
|
1911
2180
|
}
|
|
1912
2181
|
else if (kind === EDrag.Zoom) {
|
|
2182
|
+
holdSurface(state);
|
|
1913
2183
|
drag.direction = Cartesian3.normalize(Cartesian3.subtract(target, camera.positionWC, new Cartesian3()), new Cartesian3());
|
|
1914
2184
|
}
|
|
1915
2185
|
state.drag = drag;
|
|
1916
2186
|
}
|
|
2187
|
+
/*
|
|
2188
|
+
* Where a pan or orbit takes hold: the pick, or beside the cursor when it looked far past parts there.
|
|
2189
|
+
*/
|
|
2190
|
+
function GrabPoint(camera, position, picked) {
|
|
2191
|
+
const reach = picked.reach;
|
|
2192
|
+
const ray = camera.getPickRay(position);
|
|
2193
|
+
if (!ray || reach == null || !Number.isFinite(reach)) {
|
|
2194
|
+
return picked.point;
|
|
2195
|
+
}
|
|
2196
|
+
const facing = Cartesian3.dot(ray.direction, camera.directionWC);
|
|
2197
|
+
const depth = Cartesian3.dot(Cartesian3.subtract(picked.point, camera.positionWC, new Cartesian3()), camera.directionWC);
|
|
2198
|
+
if (facing <= 0 || depth <= reach * CLEARANCE_GRAB) {
|
|
2199
|
+
return picked.point;
|
|
2200
|
+
}
|
|
2201
|
+
// The reach is along the view axis, so the ray goes a little further to the same depth.
|
|
2202
|
+
return Ray.getPoint(ray, Math.max(reach, MIN_ZOOM_DISTANCE) / facing);
|
|
2203
|
+
}
|
|
1917
2204
|
/*
|
|
1918
2205
|
* A level plane through the grabbed point, or one facing the camera when the level one is seen edge on.
|
|
1919
2206
|
*/
|
|
@@ -2062,6 +2349,7 @@ function onWheel(state, e) {
|
|
|
2062
2349
|
if (!target || !ray) {
|
|
2063
2350
|
return;
|
|
2064
2351
|
}
|
|
2352
|
+
holdSurface(state);
|
|
2065
2353
|
const step = zoomStep(state, ray.direction, target, notches);
|
|
2066
2354
|
Cartesian3.add(state.pendingZoom, step, state.pendingZoom);
|
|
2067
2355
|
state.zoomPosition = Cartesian3.clone(camera.position);
|
|
@@ -2069,6 +2357,37 @@ function onWheel(state, e) {
|
|
|
2069
2357
|
state.zoomFrame = requestAnimationFrame(() => easeZoom(state));
|
|
2070
2358
|
}
|
|
2071
2359
|
}
|
|
2360
|
+
/*
|
|
2361
|
+
* Swaps a wheel event over the scene for one turned round, so wheel forward zooms out when the user asked for that.
|
|
2362
|
+
*/
|
|
2363
|
+
function mirrorWheel(state, e) {
|
|
2364
|
+
const viewer = state.viewer;
|
|
2365
|
+
const canvas = viewer.isDestroyed() ? null : viewer.scene.canvas;
|
|
2366
|
+
if (!canvas || e.target !== canvas || e[MIRRORED_WHEEL_KEY] || !mouseOf(viewer).wheelReversed) {
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
e.stopImmediatePropagation();
|
|
2370
|
+
e.preventDefault();
|
|
2371
|
+
const mirrored = new WheelEvent("wheel", {
|
|
2372
|
+
bubbles: true,
|
|
2373
|
+
cancelable: true,
|
|
2374
|
+
clientX: e.clientX,
|
|
2375
|
+
clientY: e.clientY,
|
|
2376
|
+
screenX: e.screenX,
|
|
2377
|
+
screenY: e.screenY,
|
|
2378
|
+
ctrlKey: e.ctrlKey,
|
|
2379
|
+
shiftKey: e.shiftKey,
|
|
2380
|
+
altKey: e.altKey,
|
|
2381
|
+
metaKey: e.metaKey,
|
|
2382
|
+
buttons: e.buttons,
|
|
2383
|
+
deltaMode: e.deltaMode,
|
|
2384
|
+
deltaX: e.deltaX,
|
|
2385
|
+
deltaY: -e.deltaY,
|
|
2386
|
+
deltaZ: e.deltaZ
|
|
2387
|
+
});
|
|
2388
|
+
mirrored[MIRRORED_WHEEL_KEY] = true;
|
|
2389
|
+
canvas.dispatchEvent(mirrored);
|
|
2390
|
+
}
|
|
2072
2391
|
/*
|
|
2073
2392
|
* Applies part of the outstanding wheel movement each frame, so a notch glides rather than jumps.
|
|
2074
2393
|
*/
|
|
@@ -2090,6 +2409,8 @@ function easeZoom(state) {
|
|
|
2090
2409
|
const step = Cartesian3.multiplyByScalar(state.pendingZoom, share, new Cartesian3());
|
|
2091
2410
|
Cartesian3.subtract(state.pendingZoom, step, state.pendingZoom);
|
|
2092
2411
|
Cartesian3.add(viewer.camera.position, step, viewer.camera.position);
|
|
2412
|
+
zoomMoved(state);
|
|
2413
|
+
keepAboveGround(state);
|
|
2093
2414
|
state.zoomPosition = Cartesian3.clone(viewer.camera.position);
|
|
2094
2415
|
viewer.scene.requestRender();
|
|
2095
2416
|
if (share < 1) {
|
|
@@ -2099,6 +2420,7 @@ function easeZoom(state) {
|
|
|
2099
2420
|
function moveAlong(state, direction, target, notches) {
|
|
2100
2421
|
const step = zoomStep(state, direction, target, notches);
|
|
2101
2422
|
Cartesian3.add(state.viewer.camera.position, step, state.viewer.camera.position);
|
|
2423
|
+
zoomMoved(state);
|
|
2102
2424
|
}
|
|
2103
2425
|
/*
|
|
2104
2426
|
* The move for some notches toward a target along a direction, a share of the distance with a floor so it never stalls.
|
|
@@ -2108,7 +2430,14 @@ function zoomStep(state, direction, picked, notches) {
|
|
|
2108
2430
|
const target = picked.point;
|
|
2109
2431
|
// Where the camera will be once the glide already under way ends, which this step continues from.
|
|
2110
2432
|
const from = Cartesian3.add(camera.positionWC, state.pendingZoom, new Cartesian3());
|
|
2111
|
-
const
|
|
2433
|
+
const unit = Cartesian3.normalize(direction, new Cartesian3());
|
|
2434
|
+
let distance = Cartesian3.distance(from, target);
|
|
2435
|
+
// Between parts of a model, each step goes as far as it would on the nearest part around the cursor.
|
|
2436
|
+
if (picked.reach != null && picked.reachFrom) {
|
|
2437
|
+
const travelled = Cartesian3.dot(Cartesian3.subtract(from, picked.reachFrom, new Cartesian3()), unit);
|
|
2438
|
+
distance = Math.min(distance, picked.reach - travelled);
|
|
2439
|
+
}
|
|
2440
|
+
distance = Math.max(distance, MIN_ZOOM_DISTANCE);
|
|
2112
2441
|
state.lastDistance = distance;
|
|
2113
2442
|
let length = distance * ZOOM_SHARE * notches * zoomSpeedShare(state, picked);
|
|
2114
2443
|
// A geospatial camera zooming out hands over to CesiumJS once it is high enough, so only model-space is capped.
|
|
@@ -2120,7 +2449,6 @@ function zoomStep(state, direction, picked, notches) {
|
|
|
2120
2449
|
return new Cartesian3();
|
|
2121
2450
|
}
|
|
2122
2451
|
}
|
|
2123
|
-
const unit = Cartesian3.normalize(direction, new Cartesian3());
|
|
2124
2452
|
// With the globe hidden there is no hand-over, so zooming out stops where the Earth is a dot.
|
|
2125
2453
|
if (length < 0 && !state.getModelSpaceFrame && !globeShown(state)) {
|
|
2126
2454
|
const rise = -Cartesian3.dot(unit, upAt(state, from));
|
|
@@ -2136,15 +2464,14 @@ function zoomStep(state, direction, picked, notches) {
|
|
|
2136
2464
|
return length > 0 ? resistDescent(state, from, step, picked, notches) : step;
|
|
2137
2465
|
}
|
|
2138
2466
|
/*
|
|
2139
|
-
* How fast to zoom toward a target: slower toward a guess, or while the
|
|
2467
|
+
* How fast to zoom toward a target: slower toward a guess, or while the ground that would give a real one loads.
|
|
2140
2468
|
*/
|
|
2141
2469
|
function zoomSpeedShare(state, picked) {
|
|
2142
2470
|
let share = 1;
|
|
2143
2471
|
if (picked.source !== "pick") {
|
|
2144
2472
|
share *= ZOOM_GUESS_SHARE;
|
|
2145
2473
|
}
|
|
2146
|
-
|
|
2147
|
-
if (!state.getModelSpaceFrame && globeShown(state) && globe.tilesLoaded === false) {
|
|
2474
|
+
if (!state.getModelSpaceFrame && groundLoading(state)) {
|
|
2148
2475
|
share *= ZOOM_LOADING_SHARE;
|
|
2149
2476
|
}
|
|
2150
2477
|
return share;
|
|
@@ -2160,16 +2487,17 @@ function groundUnderMove(state, from, step, picked) {
|
|
|
2160
2487
|
if (picked === null || picked === void 0 ? void 0 : picked.ground) {
|
|
2161
2488
|
return { point: picked.point, up: upAt(state, picked.point) };
|
|
2162
2489
|
}
|
|
2163
|
-
if (!globeShown(state)) {
|
|
2164
|
-
return null;
|
|
2165
|
-
}
|
|
2166
2490
|
const ellipsoid = ellipsoidOf(state);
|
|
2167
2491
|
const end = Cartesian3.add(from, step, new Cartesian3());
|
|
2168
2492
|
const carto = ellipsoid.cartesianToCartographic(end);
|
|
2169
2493
|
if (!carto) {
|
|
2170
2494
|
return null;
|
|
2171
2495
|
}
|
|
2172
|
-
|
|
2496
|
+
// Unloaded terrain counts as sea level; an unknown stand-in tileset counts as nothing.
|
|
2497
|
+
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);
|
|
2498
|
+
if (height == null) {
|
|
2499
|
+
return null;
|
|
2500
|
+
}
|
|
2173
2501
|
const point = Cartesian3.fromRadians(carto.longitude, carto.latitude, height, ellipsoid);
|
|
2174
2502
|
return { point, up: ellipsoid.geodeticSurfaceNormal(point, new Cartesian3()) };
|
|
2175
2503
|
}
|
|
@@ -2219,12 +2547,77 @@ function resistDescent(state, from, step, picked, notches) {
|
|
|
2219
2547
|
const needed = scanScene(state).undergroundData ? PUSH_NOTCHES_DATA_BELOW : PUSH_NOTCHES_NOTHING_BELOW;
|
|
2220
2548
|
if (state.push.notches >= needed) {
|
|
2221
2549
|
state.push.notches = 0;
|
|
2550
|
+
state.surface = { above: false, through: true, until: now + SURFACE_HOLD_MS, at: null };
|
|
2222
2551
|
// A shallow push would land far along the ground to get under it, so it goes no further than a usual step.
|
|
2223
2552
|
const through = Math.min((above + GROUND_BREAK_DEPTH) / sink, Math.max(length, (above + GROUND_BREAK_DEPTH) * 4));
|
|
2224
2553
|
return Cartesian3.multiplyByScalar(unit, through, new Cartesian3());
|
|
2225
2554
|
}
|
|
2226
2555
|
return Cartesian3.multiplyByScalar(unit, toStandOff, new Cartesian3());
|
|
2227
2556
|
}
|
|
2557
|
+
/*
|
|
2558
|
+
* The camera's height above the loaded ground under it, or undefined without ground or in model-space.
|
|
2559
|
+
*/
|
|
2560
|
+
function heightAboveGround(state) {
|
|
2561
|
+
if (state.getModelSpaceFrame || !hasGround(state)) {
|
|
2562
|
+
return undefined;
|
|
2563
|
+
}
|
|
2564
|
+
const carto = ellipsoidOf(state).cartesianToCartographic(state.viewer.camera.positionWC);
|
|
2565
|
+
const ground = carto ? groundHeightAt(state, carto) : undefined;
|
|
2566
|
+
return ground == null ? undefined : carto.height - ground;
|
|
2567
|
+
}
|
|
2568
|
+
/*
|
|
2569
|
+
* Notes whether the camera is above the ground as a zoom begins, unless it is being pushed through it.
|
|
2570
|
+
*/
|
|
2571
|
+
function holdSurface(state) {
|
|
2572
|
+
var _a;
|
|
2573
|
+
const now = Date.now();
|
|
2574
|
+
if (state.surface.through && now < state.surface.until) {
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
const at = Cartesian3.clone(state.viewer.camera.positionWC);
|
|
2578
|
+
// Ground not loaded yet counts as sea level, as it does for a descent.
|
|
2579
|
+
const above = (_a = heightAboveGround(state)) !== null && _a !== void 0 ? _a : (hasGround(state) && !state.getModelSpaceFrame ? heightOf(state, at) : undefined);
|
|
2580
|
+
state.surface = { above: above != null && above > 0, through: false, until: now + SURFACE_HOLD_MS, at };
|
|
2581
|
+
}
|
|
2582
|
+
/*
|
|
2583
|
+
* Lifts a camera a zoom kept above the ground back over finer ground that loads in higher.
|
|
2584
|
+
*/
|
|
2585
|
+
function keepAboveGround(state) {
|
|
2586
|
+
const surface = state.surface;
|
|
2587
|
+
const now = Date.now();
|
|
2588
|
+
if (!surface.above || !state.ours || now > surface.until + SURFACE_LOADING_MS) {
|
|
2589
|
+
return;
|
|
2590
|
+
}
|
|
2591
|
+
// Ground that has finished loading does not move under a still camera.
|
|
2592
|
+
if (now > surface.until && !groundLoading(state)) {
|
|
2593
|
+
return;
|
|
2594
|
+
}
|
|
2595
|
+
const camera = state.viewer.camera;
|
|
2596
|
+
// A bookmark, fly-to or pan moved it since, which may mean to go below the ground.
|
|
2597
|
+
if (!surface.at || !Cartesian3.equalsEpsilon(camera.positionWC, surface.at, 0, 1e-3)) {
|
|
2598
|
+
surface.above = false;
|
|
2599
|
+
return;
|
|
2600
|
+
}
|
|
2601
|
+
const above = heightAboveGround(state);
|
|
2602
|
+
if (above == null || above >= GROUND_STANDOFF / 2) {
|
|
2603
|
+
return;
|
|
2604
|
+
}
|
|
2605
|
+
const ellipsoid = ellipsoidOf(state);
|
|
2606
|
+
const carto = ellipsoid.cartesianToCartographic(camera.positionWC);
|
|
2607
|
+
Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height - above + GROUND_STANDOFF, ellipsoid, camera.position);
|
|
2608
|
+
// What is left of the glide would take it straight back down.
|
|
2609
|
+
state.pendingZoom = new Cartesian3();
|
|
2610
|
+
surface.at = Cartesian3.clone(camera.position);
|
|
2611
|
+
state.viewer.scene.requestRender();
|
|
2612
|
+
}
|
|
2613
|
+
/*
|
|
2614
|
+
* Notes where a zoom just put the camera, so the ground hold can tell its moves from others.
|
|
2615
|
+
*/
|
|
2616
|
+
function zoomMoved(state) {
|
|
2617
|
+
if (state.surface.at) {
|
|
2618
|
+
Cartesian3.clone(state.viewer.camera.positionWC, state.surface.at);
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2228
2621
|
/*
|
|
2229
2622
|
* What the scene holds that the camera cares about, rescanned at most every couple of seconds.
|
|
2230
2623
|
*/
|
|
@@ -2235,7 +2628,7 @@ function scanScene(state) {
|
|
|
2235
2628
|
return applyOverride(state, state.scan);
|
|
2236
2629
|
}
|
|
2237
2630
|
const scene = state.viewer.scene;
|
|
2238
|
-
const found = { at: now, undergroundData: false, groundTileset: false };
|
|
2631
|
+
const found = { at: now, undergroundData: false, groundTileset: false, ground: null };
|
|
2239
2632
|
// Seeing through the ground is turned on to look at what is under it.
|
|
2240
2633
|
if ((_b = (_a = scene.globe) === null || _a === void 0 ? void 0 : _a.translucency) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
2241
2634
|
found.undergroundData = true;
|
|
@@ -2252,6 +2645,7 @@ function scanScene(state) {
|
|
|
2252
2645
|
}
|
|
2253
2646
|
if (primitive[GROUND_TILESET_KEY]) {
|
|
2254
2647
|
found.groundTileset = true;
|
|
2648
|
+
found.ground = primitive;
|
|
2255
2649
|
return;
|
|
2256
2650
|
}
|
|
2257
2651
|
if (!found.undergroundData && reachesBelowGround(state, lowestPointOf(primitive))) {
|
|
@@ -62094,7 +62488,7 @@ var StyleUtils;
|
|
|
62094
62488
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
62095
62489
|
})(StyleUtils || (StyleUtils = {}));
|
|
62096
62490
|
|
|
62097
|
-
const VERSION = "7.9.
|
|
62491
|
+
const VERSION = "7.9.5";
|
|
62098
62492
|
/**
|
|
62099
62493
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
62100
62494
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|
|
@@ -62111,5 +62505,5 @@ const getENVIRONMENT = () => {
|
|
|
62111
62505
|
return ENVIRONMENT;
|
|
62112
62506
|
};
|
|
62113
62507
|
|
|
62114
|
-
export { VERSION, setENVIRONMENT, getENVIRONMENT, ClusterItems, PointClustering, PointClusterSize, CesiumAnimatedInOut, DisplacedSurfacePrimitive, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, extractMetadataFromFileUrl, EntityRenderEnginePolygon, EntityRenderEnginePolyline, TextureFrameSeriesAnimator, TextureValueLabels, MenuItemCreator, MenuItemManager, MenuItemStyles, MenuItemStyleOverlay, CesiumParabola, EntityLabel, EntityLabelGroup, LiveCursor, SharedGetters, EntitySimulation, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, createTileset, TilesetRenderEngine, ViewRenderEngine, VisualRegisterCuller, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, CESIUM_MODEL_SPACE_POSITIONING_KEY, DEFAULT_LIVE_PADDING_SECONDS, DEFAULT_BRIGHTNESS_SHIFT, DEFAULT_LIGHT_INTENSITY, LIGHTING_SETTINGS_VERSION, LIGHT_INTENSITY_COMPENSATION, MAX_COMPENSATED_LIGHT_INTENSITY, ViewUtils, CesiumMapGrid, GltfGenerator, GltfGizmo, DeviceProfile, CesiumViewMonitor, CameraControls, FindGapSurfaces, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, WidgetLeftPanelTabDashboard, EMenuItemState, WidgetLeftPanelTabMenuItems, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, ECursor, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, CreateTabIconSvg, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
|
|
62508
|
+
export { VERSION, setENVIRONMENT, getENVIRONMENT, ClusterItems, PointClustering, PointClusterSize, CesiumAnimatedInOut, DisplacedSurfacePrimitive, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, extractMetadataFromFileUrl, EntityRenderEnginePolygon, EntityRenderEnginePolyline, TextureFrameSeriesAnimator, TextureValueLabels, MenuItemCreator, MenuItemManager, MenuItemStyles, MenuItemStyleOverlay, CesiumParabola, EntityLabel, EntityLabelGroup, LiveCursor, SharedGetters, EntitySimulation, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, createTileset, TilesetRenderEngine, ViewRenderEngine, VisualRegisterCuller, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, CESIUM_MODEL_SPACE_POSITIONING_KEY, DEFAULT_LIVE_PADDING_SECONDS, DEFAULT_BRIGHTNESS_SHIFT, DEFAULT_LIGHT_INTENSITY, LIGHTING_SETTINGS_VERSION, LIGHT_INTENSITY_COMPENSATION, MAX_COMPENSATED_LIGHT_INTENSITY, ViewUtils, CesiumMapGrid, GltfGenerator, GltfGizmo, DeviceProfile, CesiumViewMonitor, ECameraMouseScheme, CameraControls, FindGapSurfaces, NearClearance, GrabPoint, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, WidgetLeftPanelTabDashboard, EMenuItemState, WidgetLeftPanelTabMenuItems, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, ECursor, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, CreateTabIconSvg, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
|
|
62115
62509
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|