bruce-cesium 7.7.7 → 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.
- package/dist/bruce-cesium.es5.js +2649 -69
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +2628 -66
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +6 -1
- package/dist/lib/bruce-cesium.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-model3d.js +2 -2
- package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-polygon.js +5 -4
- package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-polyline.js +2 -1
- package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -1
- package/dist/lib/rendering/render-managers/common/entity-simulation.js +1 -1
- package/dist/lib/rendering/render-managers/common/entity-simulation.js.map +1 -1
- package/dist/lib/rendering/render-managers/tilesets/tileset-google-photos-render-manager.js +3 -0
- package/dist/lib/rendering/render-managers/tilesets/tileset-google-photos-render-manager.js.map +1 -1
- package/dist/lib/rendering/tileset-render-engine.js +47 -14
- package/dist/lib/rendering/tileset-render-engine.js.map +1 -1
- package/dist/lib/rendering/view-render-engine.js +30 -24
- package/dist/lib/rendering/view-render-engine.js.map +1 -1
- package/dist/lib/rendering/visuals-register.js +93 -8
- package/dist/lib/rendering/visuals-register.js.map +1 -1
- package/dist/lib/rendering/xgrids-render-engine.js +20 -3
- package/dist/lib/rendering/xgrids-render-engine.js.map +1 -1
- package/dist/lib/utils/cesium-map-grid.js +807 -0
- package/dist/lib/utils/cesium-map-grid.js.map +1 -0
- package/dist/lib/utils/device-profile.js +302 -0
- package/dist/lib/utils/device-profile.js.map +1 -0
- package/dist/lib/utils/gltf-generator.js +307 -0
- package/dist/lib/utils/gltf-generator.js.map +1 -0
- package/dist/lib/utils/gltf-gizmo.js +136 -0
- package/dist/lib/utils/gltf-gizmo.js.map +1 -0
- package/dist/lib/utils/view-utils.js +9 -0
- package/dist/lib/utils/view-utils.js.map +1 -1
- package/dist/lib/viewer/camera-controls.js +899 -0
- package/dist/lib/viewer/camera-controls.js.map +1 -0
- package/dist/lib/viewer/viewer-utils.js +9 -1
- package/dist/lib/viewer/viewer-utils.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +6 -1
- package/dist/types/rendering/tileset-render-engine.d.ts +10 -2
- package/dist/types/rendering/view-render-engine.d.ts +4 -0
- package/dist/types/rendering/visuals-register.d.ts +4 -0
- package/dist/types/rendering/xgrids-render-engine.d.ts +2 -0
- package/dist/types/utils/cesium-map-grid.d.ts +23 -0
- package/dist/types/utils/device-profile.d.ts +84 -0
- package/dist/types/utils/gltf-generator.d.ts +104 -0
- package/dist/types/utils/gltf-gizmo.d.ts +18 -0
- package/dist/types/utils/view-utils.d.ts +4 -0
- package/dist/types/viewer/camera-controls.d.ts +27 -0
- package/dist/types/viewer/viewer-utils.d.ts +1 -0
- package/package.json +3 -2
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, 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,
|
|
3
|
-
import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Api, Bounds, ClientFileValueMap, Color as Color$1,
|
|
2
|
+
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, 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, ColorBlendMode, Model, ClassificationType, HorizontalOrigin, VerticalOrigin, ArcType, CornerType, SceneMode, IntersectionTests, Ray, SceneTransforms, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, OrthographicFrustum, EasingFunction, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ShadowMode, CustomDataSource, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, GeometryInstance, Event, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, 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, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Api, Geometry as Geometry$1, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, ZoomControl, ProjectView, ProjectViewBookmark, EntityRelation, BruceApi, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, 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.
|
|
@@ -907,6 +907,901 @@ function CompareCPolygonHierarchies(a, b) {
|
|
|
907
907
|
return true;
|
|
908
908
|
}
|
|
909
909
|
|
|
910
|
+
const CESIUM_CAMERA_CONTROLS_KEY = "_nextspace_camera_controls";
|
|
911
|
+
// How far a wheel notch or its drag equivalent moves the camera, as a share of the distance to what it points at.
|
|
912
|
+
const ZOOM_SHARE = 0.18;
|
|
913
|
+
// The distance a zoom step treats anything closer as, so the camera keeps moving through a surface instead of stalling.
|
|
914
|
+
const MIN_ZOOM_DISTANCE = 4;
|
|
915
|
+
// How far from the origin zooming out may take a model-space camera, beyond which the scene is a dot on a planet.
|
|
916
|
+
const MODEL_SPACE_MAX_RANGE = 250000;
|
|
917
|
+
// Above this height a geospatial scene is a planet, which CesiumJS's own controller navigates better.
|
|
918
|
+
const GEO_HANDOFF_HEIGHT = 15000;
|
|
919
|
+
// The furthest a depth pick is trusted from a camera close to the ground; further up the limit grows with height.
|
|
920
|
+
const PLAUSIBLE_PICK_FLOOR = 1000;
|
|
921
|
+
// Pixels of right drag that make one wheel notch.
|
|
922
|
+
const DRAG_PIXELS_PER_NOTCH = 40;
|
|
923
|
+
// Share of the outstanding wheel movement applied each animation frame.
|
|
924
|
+
const ZOOM_EASE = 0.35;
|
|
925
|
+
// A pan plane seen closer to edge on than this (sine of the angle) is swapped for one facing the camera.
|
|
926
|
+
const GRAZING_SINE = 0.12;
|
|
927
|
+
// Closest the view may get to straight up or down while orbiting, in radians, so the camera never flips over.
|
|
928
|
+
const ORBIT_POLE_MARGIN = Math$1.toRadians(1);
|
|
929
|
+
// How far above the ground a camera coming down from above stops, until pushed on through.
|
|
930
|
+
const GROUND_STANDOFF = 2;
|
|
931
|
+
// Height above the ground within which a descent slows, so the ground is approached rather than hit.
|
|
932
|
+
const GROUND_APPROACH = 10;
|
|
933
|
+
// The slowest a descent gets near the ground, as a share of its usual speed.
|
|
934
|
+
const GROUND_APPROACH_FLOOR = 0.5;
|
|
935
|
+
// How far below the ground a push through it lands, so the camera is clearly under it.
|
|
936
|
+
const GROUND_BREAK_DEPTH = 1.5;
|
|
937
|
+
// Wheel notches of pushing at the ground that take the camera through it, with and without data found below it.
|
|
938
|
+
const PUSH_NOTCHES_DATA_BELOW = 3;
|
|
939
|
+
const PUSH_NOTCHES_NOTHING_BELOW = 10;
|
|
940
|
+
// Pushes further apart than this start counting again.
|
|
941
|
+
const PUSH_WINDOW_MS = 1200;
|
|
942
|
+
// How far below the ground something must reach to count as data underground, in metres.
|
|
943
|
+
const UNDERGROUND_MARGIN = 3;
|
|
944
|
+
// How long a scan of the scene for underground data and stand-in ground is trusted, in milliseconds.
|
|
945
|
+
const SCENE_SCAN_MS = 2000;
|
|
946
|
+
// The most entities one scan looks at, so a large scene is sampled rather than walked each time.
|
|
947
|
+
const SCENE_SCAN_ENTITIES = 3000;
|
|
948
|
+
// Zoom speed, as a share of the usual, toward a point that is a guess (nothing drawn there) or while terrain loads.
|
|
949
|
+
const ZOOM_GUESS_SHARE = 0.5;
|
|
950
|
+
const ZOOM_LOADING_SHARE = 0.7;
|
|
951
|
+
// The highest a camera zooms out to with the globe hidden, which CesiumJS's controller cannot navigate.
|
|
952
|
+
const HIDDEN_GLOBE_MAX_HEIGHT = 10000000;
|
|
953
|
+
// Marks a tileset that stands in for the globe, such as Google's photorealistic tiles.
|
|
954
|
+
const GROUND_TILESET_KEY = "_nextspace_camera_ground";
|
|
955
|
+
var EDrag;
|
|
956
|
+
(function (EDrag) {
|
|
957
|
+
EDrag["Pan"] = "pan";
|
|
958
|
+
EDrag["Orbit"] = "orbit";
|
|
959
|
+
EDrag["Zoom"] = "zoom";
|
|
960
|
+
})(EDrag || (EDrag = {}));
|
|
961
|
+
/**
|
|
962
|
+
* Mouse navigation that keeps moving near, through and below the ground, where CesiumJS's own controller stalls.
|
|
963
|
+
*/
|
|
964
|
+
var CameraControls;
|
|
965
|
+
(function (CameraControls) {
|
|
966
|
+
/**
|
|
967
|
+
* Takes over mouse drag and wheel navigation close to the ground; CesiumJS keeps planet scale, pinch and look.
|
|
968
|
+
*/
|
|
969
|
+
function Attach(viewer) {
|
|
970
|
+
var _a, _b, _c;
|
|
971
|
+
if (!viewer || viewer.isDestroyed() || viewer[CESIUM_CAMERA_CONTROLS_KEY]) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
const scene = viewer.scene;
|
|
975
|
+
const controller = scene === null || scene === void 0 ? void 0 : scene.screenSpaceCameraController;
|
|
976
|
+
if (!controller || !scene.canvas || !scene.preUpdate) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
const state = {
|
|
980
|
+
viewer,
|
|
981
|
+
getModelSpaceFrame: null,
|
|
982
|
+
drag: null,
|
|
983
|
+
touches: new Set(),
|
|
984
|
+
pendingZoom: new Cartesian3(),
|
|
985
|
+
zoomFrame: null,
|
|
986
|
+
zoomPosition: null,
|
|
987
|
+
lastDistance: 100,
|
|
988
|
+
push: { notches: 0, at: 0 },
|
|
989
|
+
scan: null,
|
|
990
|
+
undergroundOverride: null,
|
|
991
|
+
saved: {
|
|
992
|
+
rotateEventTypes: controller.rotateEventTypes,
|
|
993
|
+
zoomEventTypes: controller.zoomEventTypes,
|
|
994
|
+
tiltEventTypes: controller.tiltEventTypes,
|
|
995
|
+
enableCollisionDetection: controller.enableCollisionDetection,
|
|
996
|
+
backFaceAlpha: (_b = (_a = scene.globe) === null || _a === void 0 ? void 0 : _a.translucency) === null || _b === void 0 ? void 0 : _b.backFaceAlpha,
|
|
997
|
+
showSkirts: (_c = scene.globe) === null || _c === void 0 ? void 0 : _c.showSkirts
|
|
998
|
+
},
|
|
999
|
+
ours: false,
|
|
1000
|
+
removals: []
|
|
1001
|
+
};
|
|
1002
|
+
viewer[CESIUM_CAMERA_CONTROLS_KEY] = state;
|
|
1003
|
+
// The camera may go below the ground; zooming slows near a surface, so it takes a deliberate push.
|
|
1004
|
+
controller.enableCollisionDetection = false;
|
|
1005
|
+
const canvas = scene.canvas;
|
|
1006
|
+
const listen = (target, type, handler, options) => {
|
|
1007
|
+
target.addEventListener(type, handler, options);
|
|
1008
|
+
state.removals.push(() => target.removeEventListener(type, handler, options));
|
|
1009
|
+
};
|
|
1010
|
+
listen(canvas, "pointerdown", (e) => onPointerDown(state, e));
|
|
1011
|
+
listen(window, "pointermove", (e) => onPointerMove(state, e));
|
|
1012
|
+
listen(window, "pointerup", (e) => onPointerUp(state, e));
|
|
1013
|
+
listen(window, "pointercancel", (e) => onPointerUp(state, e));
|
|
1014
|
+
listen(canvas, "wheel", (e) => onWheel(state, e), { passive: true });
|
|
1015
|
+
state.removals.push(scene.preUpdate.addEventListener(() => syncController(state)));
|
|
1016
|
+
syncController(state);
|
|
1017
|
+
scene.requestRender();
|
|
1018
|
+
}
|
|
1019
|
+
CameraControls.Attach = Attach;
|
|
1020
|
+
/**
|
|
1021
|
+
* Hands navigation back to CesiumJS's own camera controller, as it was before Attach.
|
|
1022
|
+
*/
|
|
1023
|
+
function Detach(viewer) {
|
|
1024
|
+
const state = viewer === null || viewer === void 0 ? void 0 : viewer[CESIUM_CAMERA_CONTROLS_KEY];
|
|
1025
|
+
if (!state) {
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
SetModelSpace(viewer, null);
|
|
1029
|
+
viewer[CESIUM_CAMERA_CONTROLS_KEY] = null;
|
|
1030
|
+
state.removals.forEach((removal) => removal());
|
|
1031
|
+
state.removals = [];
|
|
1032
|
+
if (state.zoomFrame != null) {
|
|
1033
|
+
cancelAnimationFrame(state.zoomFrame);
|
|
1034
|
+
}
|
|
1035
|
+
if (viewer.isDestroyed()) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
restoreCesiumGestures(state);
|
|
1039
|
+
viewer.scene.screenSpaceCameraController.enableCollisionDetection = state.saved.enableCollisionDetection;
|
|
1040
|
+
viewer.scene.requestRender();
|
|
1041
|
+
}
|
|
1042
|
+
CameraControls.Detach = Detach;
|
|
1043
|
+
function IsAttached(viewer) {
|
|
1044
|
+
return Boolean(viewer === null || viewer === void 0 ? void 0 : viewer[CESIUM_CAMERA_CONTROLS_KEY]);
|
|
1045
|
+
}
|
|
1046
|
+
CameraControls.IsAttached = IsAttached;
|
|
1047
|
+
/**
|
|
1048
|
+
* Marks a tileset as standing in for the globe (Google's photorealistic tiles), so the camera treats it as ground.
|
|
1049
|
+
*/
|
|
1050
|
+
function SetGroundTileset(tileset, isGround) {
|
|
1051
|
+
if (tileset) {
|
|
1052
|
+
tileset[GROUND_TILESET_KEY] = isGround;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
CameraControls.SetGroundTileset = SetGroundTileset;
|
|
1056
|
+
/**
|
|
1057
|
+
* Says whether the scene has data underground, which makes the ground easier to push through; null scans for it.
|
|
1058
|
+
*/
|
|
1059
|
+
function SetUndergroundData(viewer, present) {
|
|
1060
|
+
const state = viewer === null || viewer === void 0 ? void 0 : viewer[CESIUM_CAMERA_CONTROLS_KEY];
|
|
1061
|
+
if (state) {
|
|
1062
|
+
state.undergroundOverride = present;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
CameraControls.SetUndergroundData = SetUndergroundData;
|
|
1066
|
+
/**
|
|
1067
|
+
* Switches to navigating model-space measured from the frame getFrame returns, or back to geospatial with null.
|
|
1068
|
+
*/
|
|
1069
|
+
function SetModelSpace(viewer, getFrame) {
|
|
1070
|
+
const state = viewer === null || viewer === void 0 ? void 0 : viewer[CESIUM_CAMERA_CONTROLS_KEY];
|
|
1071
|
+
if (!state || viewer.isDestroyed()) {
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
const wasModelSpace = Boolean(state.getModelSpaceFrame);
|
|
1075
|
+
state.getModelSpaceFrame = getFrame !== null && getFrame !== void 0 ? getFrame : null;
|
|
1076
|
+
syncController(state);
|
|
1077
|
+
if (wasModelSpace === Boolean(getFrame)) {
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
const globe = viewer.scene.globe;
|
|
1081
|
+
const translucency = globe === null || globe === void 0 ? void 0 : globe.translucency;
|
|
1082
|
+
if (getFrame) {
|
|
1083
|
+
// The ground is see-through from below, so what stands on it stays in view underground.
|
|
1084
|
+
if (translucency && typeof translucency.backFaceAlpha === "number") {
|
|
1085
|
+
translucency.backFaceAlpha = 0.5;
|
|
1086
|
+
}
|
|
1087
|
+
// Skirts hide seams flat model-space ground never has, and below it they are walls.
|
|
1088
|
+
if (typeof state.saved.showSkirts === "boolean") {
|
|
1089
|
+
globe.showSkirts = false;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
if (translucency && typeof state.saved.backFaceAlpha === "number") {
|
|
1094
|
+
translucency.backFaceAlpha = state.saved.backFaceAlpha;
|
|
1095
|
+
}
|
|
1096
|
+
if (typeof state.saved.showSkirts === "boolean") {
|
|
1097
|
+
globe.showSkirts = state.saved.showSkirts;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
viewer.scene.requestRender();
|
|
1101
|
+
}
|
|
1102
|
+
CameraControls.SetModelSpace = SetModelSpace;
|
|
1103
|
+
})(CameraControls || (CameraControls = {}));
|
|
1104
|
+
function restoreCesiumGestures(state) {
|
|
1105
|
+
const controller = state.viewer.scene.screenSpaceCameraController;
|
|
1106
|
+
controller.rotateEventTypes = state.saved.rotateEventTypes;
|
|
1107
|
+
controller.zoomEventTypes = state.saved.zoomEventTypes;
|
|
1108
|
+
controller.tiltEventTypes = state.saved.tiltEventTypes;
|
|
1109
|
+
}
|
|
1110
|
+
/*
|
|
1111
|
+
* Decides each frame who has the mouse: these controls near the ground, CesiumJS for planets, orthographic and tracking.
|
|
1112
|
+
*/
|
|
1113
|
+
function syncController(state) {
|
|
1114
|
+
const viewer = state.viewer;
|
|
1115
|
+
if (viewer.isDestroyed() || state.drag) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const ours = shouldControl(state);
|
|
1119
|
+
if (ours === state.ours) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
state.ours = ours;
|
|
1123
|
+
if (ours) {
|
|
1124
|
+
const controller = viewer.scene.screenSpaceCameraController;
|
|
1125
|
+
controller.rotateEventTypes = [];
|
|
1126
|
+
controller.zoomEventTypes = [CameraEventType.PINCH];
|
|
1127
|
+
controller.tiltEventTypes = [CameraEventType.PINCH];
|
|
1128
|
+
}
|
|
1129
|
+
else {
|
|
1130
|
+
restoreCesiumGestures(state);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
function shouldControl(state) {
|
|
1134
|
+
const viewer = state.viewer;
|
|
1135
|
+
const camera = viewer.camera;
|
|
1136
|
+
if (viewer.scene.mode !== SceneMode.SCENE3D || camera.frustum instanceof OrthographicFrustum) {
|
|
1137
|
+
return false;
|
|
1138
|
+
}
|
|
1139
|
+
// A camera following something is CesiumJS's to move.
|
|
1140
|
+
if (!Matrix4.equals(camera.transform, Matrix4.IDENTITY)) {
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
if (state.getModelSpaceFrame) {
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1146
|
+
// CesiumJS's controller measures against the globe, so with it hidden these controls keep the camera at any height.
|
|
1147
|
+
if (!globeShown(state)) {
|
|
1148
|
+
return true;
|
|
1149
|
+
}
|
|
1150
|
+
return heightOf(state, camera.positionWC) < GEO_HANDOFF_HEIGHT;
|
|
1151
|
+
}
|
|
1152
|
+
function globeShown(state) {
|
|
1153
|
+
const globe = state.viewer.scene.globe;
|
|
1154
|
+
return Boolean(globe) && globe.show !== false;
|
|
1155
|
+
}
|
|
1156
|
+
/*
|
|
1157
|
+
* The terrain's height at a place from the tiles loaded, undefined with the globe hidden or nothing loaded there.
|
|
1158
|
+
*/
|
|
1159
|
+
function terrainHeightAt(state, carto) {
|
|
1160
|
+
const globe = state.viewer.scene.globe;
|
|
1161
|
+
if (!carto || !globeShown(state) || typeof globe.getHeight !== "function") {
|
|
1162
|
+
return undefined;
|
|
1163
|
+
}
|
|
1164
|
+
const height = globe.getHeight(carto);
|
|
1165
|
+
return Number.isFinite(height) ? height : undefined;
|
|
1166
|
+
}
|
|
1167
|
+
function ellipsoidOf(state) {
|
|
1168
|
+
var _a, _b;
|
|
1169
|
+
return (_b = (_a = state.viewer.scene.globe) === null || _a === void 0 ? void 0 : _a.ellipsoid) !== null && _b !== void 0 ? _b : Ellipsoid.WGS84;
|
|
1170
|
+
}
|
|
1171
|
+
function heightOf(state, position) {
|
|
1172
|
+
const carto = ellipsoidOf(state).cartesianToCartographic(position);
|
|
1173
|
+
return carto ? carto.height : Number.POSITIVE_INFINITY;
|
|
1174
|
+
}
|
|
1175
|
+
function canvasPosition(viewer, e) {
|
|
1176
|
+
const rect = viewer.scene.canvas.getBoundingClientRect();
|
|
1177
|
+
return new Cartesian2(e.clientX - rect.left, e.clientY - rect.top);
|
|
1178
|
+
}
|
|
1179
|
+
/*
|
|
1180
|
+
* Up at a point: the model-space frame's up in model-space, else the ellipsoid's surface normal there.
|
|
1181
|
+
*/
|
|
1182
|
+
function upAt(state, position) {
|
|
1183
|
+
if (state.getModelSpaceFrame) {
|
|
1184
|
+
const up = Matrix4.multiplyByPointAsVector(state.getModelSpaceFrame(), Cartesian3.UNIT_Z, new Cartesian3());
|
|
1185
|
+
return Cartesian3.normalize(up, up);
|
|
1186
|
+
}
|
|
1187
|
+
return ellipsoidOf(state).geodeticSurfaceNormal(position, new Cartesian3());
|
|
1188
|
+
}
|
|
1189
|
+
/*
|
|
1190
|
+
* The level plane standing in for the ground when nothing is drawn under the cursor.
|
|
1191
|
+
*/
|
|
1192
|
+
function groundPlane(state) {
|
|
1193
|
+
var _a;
|
|
1194
|
+
if (state.getModelSpaceFrame) {
|
|
1195
|
+
const frame = state.getModelSpaceFrame();
|
|
1196
|
+
return Plane.fromPointNormal(Matrix4.getTranslation(frame, new Cartesian3()), upAt(state, null));
|
|
1197
|
+
}
|
|
1198
|
+
const camera = state.viewer.camera;
|
|
1199
|
+
const ellipsoid = ellipsoidOf(state);
|
|
1200
|
+
const carto = ellipsoid.cartesianToCartographic(camera.positionWC);
|
|
1201
|
+
if (!carto) {
|
|
1202
|
+
return null;
|
|
1203
|
+
}
|
|
1204
|
+
// Level with the terrain under the camera, not sea level, so a guess over high ground is not far too deep.
|
|
1205
|
+
const surface = Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0, ellipsoid);
|
|
1206
|
+
return Plane.fromPointNormal(surface, ellipsoid.geodeticSurfaceNormal(surface, new Cartesian3()));
|
|
1207
|
+
}
|
|
1208
|
+
/*
|
|
1209
|
+
* How far away a depth pick is believable, since below ground the depth buffer can hold the globe's inside.
|
|
1210
|
+
*/
|
|
1211
|
+
function plausibleDistance(state) {
|
|
1212
|
+
const camera = state.viewer.camera;
|
|
1213
|
+
if (state.getModelSpaceFrame) {
|
|
1214
|
+
const origin = Matrix4.getTranslation(state.getModelSpaceFrame(), new Cartesian3());
|
|
1215
|
+
return Math.max(PLAUSIBLE_PICK_FLOOR, Cartesian3.distance(camera.positionWC, origin) * 10);
|
|
1216
|
+
}
|
|
1217
|
+
const height = Math.abs(heightOf(state, camera.positionWC) - (Number(state.viewer.scene.globeHeight) || 0));
|
|
1218
|
+
const horizon = Math.sqrt(2 * ellipsoidOf(state).maximumRadius * Math.max(height, 0));
|
|
1219
|
+
return Math.max(PLAUSIBLE_PICK_FLOOR, height * 10, horizon * 1.5);
|
|
1220
|
+
}
|
|
1221
|
+
/*
|
|
1222
|
+
* The point under a screen position: what is drawn there, else the ground plane, else a point at the last distance.
|
|
1223
|
+
*/
|
|
1224
|
+
function pickTarget(state, position) {
|
|
1225
|
+
const viewer = state.viewer;
|
|
1226
|
+
const scene = viewer.scene;
|
|
1227
|
+
const camera = viewer.camera;
|
|
1228
|
+
const ray = camera.getPickRay(position);
|
|
1229
|
+
if (!ray) {
|
|
1230
|
+
return null;
|
|
1231
|
+
}
|
|
1232
|
+
let picked;
|
|
1233
|
+
if (scene.pickPositionSupported) {
|
|
1234
|
+
try {
|
|
1235
|
+
picked = scene.pickPosition(position);
|
|
1236
|
+
}
|
|
1237
|
+
catch (e) {
|
|
1238
|
+
picked = null;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
const plausible = plausibleDistance(state);
|
|
1242
|
+
if (isAhead(camera, picked) && Cartesian3.distance(picked, camera.positionWC) < plausible) {
|
|
1243
|
+
return { point: picked, source: "pick", ground: isGroundPick(state, position) };
|
|
1244
|
+
}
|
|
1245
|
+
const ground = groundPlane(state);
|
|
1246
|
+
const onGround = ground ? IntersectionTests.rayPlane(ray, ground) : null;
|
|
1247
|
+
if (isAhead(camera, onGround) && Cartesian3.distance(onGround, camera.positionWC) < plausible) {
|
|
1248
|
+
// The plane stands in for the ground only where there is ground to stand in for.
|
|
1249
|
+
return { point: onGround, source: "plane", ground: !state.getModelSpaceFrame && hasGround(state) };
|
|
1250
|
+
}
|
|
1251
|
+
return { point: Ray.getPoint(ray, state.lastDistance), source: "last", ground: false };
|
|
1252
|
+
}
|
|
1253
|
+
/*
|
|
1254
|
+
* Whether what is drawn under a screen position is the ground: the globe, or a tileset standing in for it.
|
|
1255
|
+
*/
|
|
1256
|
+
function isGroundPick(state, position) {
|
|
1257
|
+
var _a, _b, _c;
|
|
1258
|
+
if (state.getModelSpaceFrame) {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
const scene = state.viewer.scene;
|
|
1262
|
+
let picked;
|
|
1263
|
+
try {
|
|
1264
|
+
picked = typeof scene.pick === "function" ? scene.pick(position) : undefined;
|
|
1265
|
+
}
|
|
1266
|
+
catch (e) {
|
|
1267
|
+
picked = undefined;
|
|
1268
|
+
}
|
|
1269
|
+
if (!picked) {
|
|
1270
|
+
// Nothing pickable means the globe, when it is drawn.
|
|
1271
|
+
return globeShown(state);
|
|
1272
|
+
}
|
|
1273
|
+
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;
|
|
1274
|
+
return Boolean(tileset === null || tileset === void 0 ? void 0 : tileset[GROUND_TILESET_KEY]);
|
|
1275
|
+
}
|
|
1276
|
+
/*
|
|
1277
|
+
* Whether there is ground to come down onto: the globe drawn, or a tileset standing in for it.
|
|
1278
|
+
*/
|
|
1279
|
+
function hasGround(state) {
|
|
1280
|
+
return globeShown(state) || scanScene(state).groundTileset;
|
|
1281
|
+
}
|
|
1282
|
+
function isAhead(camera, point) {
|
|
1283
|
+
if (!point || !Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) {
|
|
1284
|
+
return false;
|
|
1285
|
+
}
|
|
1286
|
+
const toPoint = Cartesian3.subtract(point, camera.positionWC, new Cartesian3());
|
|
1287
|
+
return Cartesian3.dot(toPoint, camera.directionWC) > 0;
|
|
1288
|
+
}
|
|
1289
|
+
/*
|
|
1290
|
+
* Picks which gesture a button and its modifiers start, matching CesiumJS's own mapping.
|
|
1291
|
+
*/
|
|
1292
|
+
function dragKind(e) {
|
|
1293
|
+
if (e.shiftKey) {
|
|
1294
|
+
// Shift drag looks around, which CesiumJS still handles.
|
|
1295
|
+
return null;
|
|
1296
|
+
}
|
|
1297
|
+
if (e.button === 1 || (e.ctrlKey && (e.button === 0 || e.button === 2))) {
|
|
1298
|
+
return EDrag.Orbit;
|
|
1299
|
+
}
|
|
1300
|
+
if (e.button === 0) {
|
|
1301
|
+
return EDrag.Pan;
|
|
1302
|
+
}
|
|
1303
|
+
if (e.button === 2) {
|
|
1304
|
+
return EDrag.Zoom;
|
|
1305
|
+
}
|
|
1306
|
+
return null;
|
|
1307
|
+
}
|
|
1308
|
+
function allows(state, kind) {
|
|
1309
|
+
const controller = state.viewer.scene.screenSpaceCameraController;
|
|
1310
|
+
if (!controller.enableInputs) {
|
|
1311
|
+
return false;
|
|
1312
|
+
}
|
|
1313
|
+
switch (kind) {
|
|
1314
|
+
case EDrag.Pan:
|
|
1315
|
+
return controller.enableRotate;
|
|
1316
|
+
case EDrag.Orbit:
|
|
1317
|
+
return controller.enableTilt;
|
|
1318
|
+
case EDrag.Zoom:
|
|
1319
|
+
return controller.enableZoom;
|
|
1320
|
+
}
|
|
1321
|
+
return false;
|
|
1322
|
+
}
|
|
1323
|
+
function onPointerDown(state, e) {
|
|
1324
|
+
const viewer = state.viewer;
|
|
1325
|
+
if (viewer.isDestroyed() || !state.ours) {
|
|
1326
|
+
return;
|
|
1327
|
+
}
|
|
1328
|
+
if (e.pointerType === "touch") {
|
|
1329
|
+
state.touches.add(e.pointerId);
|
|
1330
|
+
// A second finger makes it a pinch, which CesiumJS handles.
|
|
1331
|
+
if (state.touches.size > 1) {
|
|
1332
|
+
endDrag(state);
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
const kind = dragKind(e);
|
|
1337
|
+
if (!kind || !allows(state, kind)) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const position = canvasPosition(viewer, e);
|
|
1341
|
+
const picked = pickTarget(state, position);
|
|
1342
|
+
if (!picked) {
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
const target = picked.point;
|
|
1346
|
+
const camera = viewer.camera;
|
|
1347
|
+
const distance = Cartesian3.distance(camera.positionWC, target);
|
|
1348
|
+
state.lastDistance = Math.max(distance, MIN_ZOOM_DISTANCE);
|
|
1349
|
+
const drag = { kind, pointerId: e.pointerId, last: position, target, up: upAt(state, target), distance, picked };
|
|
1350
|
+
if (kind === EDrag.Pan) {
|
|
1351
|
+
drag.plane = panPlane(camera, target, drag.up);
|
|
1352
|
+
}
|
|
1353
|
+
else if (kind === EDrag.Zoom) {
|
|
1354
|
+
drag.direction = Cartesian3.normalize(Cartesian3.subtract(target, camera.positionWC, new Cartesian3()), new Cartesian3());
|
|
1355
|
+
}
|
|
1356
|
+
state.drag = drag;
|
|
1357
|
+
}
|
|
1358
|
+
/*
|
|
1359
|
+
* A level plane through the grabbed point, or one facing the camera when the level one is seen edge on.
|
|
1360
|
+
*/
|
|
1361
|
+
function panPlane(camera, target, up) {
|
|
1362
|
+
if (Math.abs(Cartesian3.dot(camera.directionWC, up)) > GRAZING_SINE) {
|
|
1363
|
+
return Plane.fromPointNormal(target, up);
|
|
1364
|
+
}
|
|
1365
|
+
return Plane.fromPointNormal(target, Cartesian3.negate(camera.directionWC, new Cartesian3()));
|
|
1366
|
+
}
|
|
1367
|
+
function onPointerMove(state, e) {
|
|
1368
|
+
const drag = state.drag;
|
|
1369
|
+
const viewer = state.viewer;
|
|
1370
|
+
if (!drag || drag.pointerId !== e.pointerId || viewer.isDestroyed()) {
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
if (!allows(state, drag.kind)) {
|
|
1374
|
+
endDrag(state);
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
const position = canvasPosition(viewer, e);
|
|
1378
|
+
const dx = position.x - drag.last.x;
|
|
1379
|
+
const dy = position.y - drag.last.y;
|
|
1380
|
+
if (dx === 0 && dy === 0) {
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
switch (drag.kind) {
|
|
1384
|
+
case EDrag.Pan:
|
|
1385
|
+
pan(state, drag, position);
|
|
1386
|
+
break;
|
|
1387
|
+
case EDrag.Orbit:
|
|
1388
|
+
orbit(state, drag, dx, dy);
|
|
1389
|
+
break;
|
|
1390
|
+
case EDrag.Zoom:
|
|
1391
|
+
// Dragging down zooms in, as it does in CesiumJS.
|
|
1392
|
+
moveAlong(state, drag.direction, drag.picked, dy / DRAG_PIXELS_PER_NOTCH);
|
|
1393
|
+
break;
|
|
1394
|
+
}
|
|
1395
|
+
drag.last = position;
|
|
1396
|
+
viewer.scene.requestRender();
|
|
1397
|
+
}
|
|
1398
|
+
function onPointerUp(state, e) {
|
|
1399
|
+
var _a;
|
|
1400
|
+
state.touches.delete(e.pointerId);
|
|
1401
|
+
if (((_a = state.drag) === null || _a === void 0 ? void 0 : _a.pointerId) === e.pointerId) {
|
|
1402
|
+
endDrag(state);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
function endDrag(state) {
|
|
1406
|
+
state.drag = null;
|
|
1407
|
+
}
|
|
1408
|
+
/*
|
|
1409
|
+
* Slides the camera so the grabbed point stays under the cursor.
|
|
1410
|
+
*/
|
|
1411
|
+
function pan(state, drag, position) {
|
|
1412
|
+
const camera = state.viewer.camera;
|
|
1413
|
+
const ray = camera.getPickRay(position);
|
|
1414
|
+
const hit = ray ? IntersectionTests.rayPlane(ray, drag.plane) : null;
|
|
1415
|
+
if (!isAhead(camera, hit)) {
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
const delta = Cartesian3.subtract(drag.target, hit, new Cartesian3());
|
|
1419
|
+
// Near the horizon a pixel covers kilometres, so one move is capped at a few times the grab distance.
|
|
1420
|
+
const limit = Math.max(drag.distance, MIN_ZOOM_DISTANCE) * 3;
|
|
1421
|
+
const length = Cartesian3.magnitude(delta);
|
|
1422
|
+
if (length > limit) {
|
|
1423
|
+
Cartesian3.multiplyByScalar(delta, limit / length, delta);
|
|
1424
|
+
}
|
|
1425
|
+
// A pan never takes a camera above the ground down through it; it keeps the sideways part of the move.
|
|
1426
|
+
if (wouldSinkBelowGround(state, camera.position, delta)) {
|
|
1427
|
+
const up = upAt(state, camera.position);
|
|
1428
|
+
const down = Cartesian3.dot(delta, up);
|
|
1429
|
+
if (down < 0) {
|
|
1430
|
+
Cartesian3.subtract(delta, Cartesian3.multiplyByScalar(up, down, new Cartesian3()), delta);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
Cartesian3.add(camera.position, delta, camera.position);
|
|
1434
|
+
}
|
|
1435
|
+
/*
|
|
1436
|
+
* Turns the camera around the grabbed point: sideways about up there, and up or down about the camera's right.
|
|
1437
|
+
*/
|
|
1438
|
+
function orbit(state, drag, dx, dy) {
|
|
1439
|
+
const viewer = state.viewer;
|
|
1440
|
+
const camera = viewer.camera;
|
|
1441
|
+
const canvas = viewer.scene.canvas;
|
|
1442
|
+
const up = drag.up;
|
|
1443
|
+
const heading = -dx / Math.max(canvas.clientWidth, 1) * Math.PI * 2;
|
|
1444
|
+
// Dragging down looks further down, as CesiumJS's own tilt does.
|
|
1445
|
+
let pitch = -dy / Math.max(canvas.clientHeight, 1) * Math.PI;
|
|
1446
|
+
// Keeps the view from tipping past straight up or down, where it would flip over.
|
|
1447
|
+
const elevation = Math.asin(Math$1.clamp(Cartesian3.dot(camera.direction, up), -1, 1));
|
|
1448
|
+
const limit = Math.PI / 2 - ORBIT_POLE_MARGIN;
|
|
1449
|
+
pitch = Math$1.clamp(elevation + pitch, -limit, limit) - elevation;
|
|
1450
|
+
rotateAbout(camera, drag.target, up, heading);
|
|
1451
|
+
const right = Cartesian3.cross(camera.direction, up, new Cartesian3());
|
|
1452
|
+
if (Cartesian3.magnitude(right) > Math$1.EPSILON6) {
|
|
1453
|
+
Cartesian3.normalize(right, right);
|
|
1454
|
+
const before = Cartesian3.clone(camera.position);
|
|
1455
|
+
rotateAbout(camera, drag.target, right, pitch);
|
|
1456
|
+
// Orbiting does not swing a camera above the ground down through it; the tilt that would is undone.
|
|
1457
|
+
const moved = Cartesian3.subtract(camera.position, before, new Cartesian3());
|
|
1458
|
+
if (wouldSinkBelowGround(state, before, moved)) {
|
|
1459
|
+
rotateAbout(camera, drag.target, right, -pitch);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
levelCamera(camera, upAt(state, camera.position));
|
|
1463
|
+
}
|
|
1464
|
+
function rotateAbout(camera, pivot, axis, angle) {
|
|
1465
|
+
if (!angle) {
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
const rotation = Matrix3.fromQuaternion(Quaternion.fromAxisAngle(axis, angle));
|
|
1469
|
+
const offset = Cartesian3.subtract(camera.position, pivot, new Cartesian3());
|
|
1470
|
+
Matrix3.multiplyByVector(rotation, offset, offset);
|
|
1471
|
+
Cartesian3.add(pivot, offset, camera.position);
|
|
1472
|
+
Matrix3.multiplyByVector(rotation, camera.direction, camera.direction);
|
|
1473
|
+
Matrix3.multiplyByVector(rotation, camera.up, camera.up);
|
|
1474
|
+
Matrix3.multiplyByVector(rotation, camera.right, camera.right);
|
|
1475
|
+
}
|
|
1476
|
+
/*
|
|
1477
|
+
* Takes any roll out, so the horizon stays level however the camera has turned.
|
|
1478
|
+
*/
|
|
1479
|
+
function levelCamera(camera, up) {
|
|
1480
|
+
const direction = Cartesian3.normalize(camera.direction, camera.direction);
|
|
1481
|
+
const right = Cartesian3.cross(direction, up, new Cartesian3());
|
|
1482
|
+
if (Cartesian3.magnitude(right) < Math$1.EPSILON6) {
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
Cartesian3.normalize(right, camera.right);
|
|
1486
|
+
Cartesian3.cross(camera.right, direction, camera.up);
|
|
1487
|
+
Cartesian3.normalize(camera.up, camera.up);
|
|
1488
|
+
}
|
|
1489
|
+
function onWheel(state, e) {
|
|
1490
|
+
const viewer = state.viewer;
|
|
1491
|
+
if (viewer.isDestroyed() || !state.ours || !allows(state, EDrag.Zoom)) {
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
let notches = e.deltaMode === 1 ? e.deltaY / 3 : e.deltaMode === 2 ? e.deltaY : e.deltaY / 100;
|
|
1495
|
+
notches = Math$1.clamp(-notches, -3, 3);
|
|
1496
|
+
if (!notches) {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
const position = canvasPosition(viewer, e);
|
|
1500
|
+
const camera = viewer.camera;
|
|
1501
|
+
const target = pickTarget(state, position);
|
|
1502
|
+
const ray = camera.getPickRay(position);
|
|
1503
|
+
if (!target || !ray) {
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
const step = zoomStep(state, ray.direction, target, notches);
|
|
1507
|
+
Cartesian3.add(state.pendingZoom, step, state.pendingZoom);
|
|
1508
|
+
state.zoomPosition = Cartesian3.clone(camera.position);
|
|
1509
|
+
if (state.zoomFrame == null) {
|
|
1510
|
+
state.zoomFrame = requestAnimationFrame(() => easeZoom(state));
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
/*
|
|
1514
|
+
* Applies part of the outstanding wheel movement each frame, so a notch glides rather than jumps.
|
|
1515
|
+
*/
|
|
1516
|
+
function easeZoom(state) {
|
|
1517
|
+
state.zoomFrame = null;
|
|
1518
|
+
const viewer = state.viewer;
|
|
1519
|
+
if (viewer.isDestroyed() || !viewer[CESIUM_CAMERA_CONTROLS_KEY]) {
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
// A tool locking the camera mid glide (walkthrough, a camera lock) owns it from then on.
|
|
1523
|
+
if (!allows(state, EDrag.Zoom) ||
|
|
1524
|
+
!state.zoomPosition ||
|
|
1525
|
+
!Cartesian3.equalsEpsilon(viewer.camera.position, state.zoomPosition, 0, 1e-3)) {
|
|
1526
|
+
state.pendingZoom = new Cartesian3();
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
const remaining = Cartesian3.magnitude(state.pendingZoom);
|
|
1530
|
+
const share = remaining < 0.01 ? 1 : ZOOM_EASE;
|
|
1531
|
+
const step = Cartesian3.multiplyByScalar(state.pendingZoom, share, new Cartesian3());
|
|
1532
|
+
Cartesian3.subtract(state.pendingZoom, step, state.pendingZoom);
|
|
1533
|
+
Cartesian3.add(viewer.camera.position, step, viewer.camera.position);
|
|
1534
|
+
state.zoomPosition = Cartesian3.clone(viewer.camera.position);
|
|
1535
|
+
viewer.scene.requestRender();
|
|
1536
|
+
if (share < 1) {
|
|
1537
|
+
state.zoomFrame = requestAnimationFrame(() => easeZoom(state));
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
function moveAlong(state, direction, target, notches) {
|
|
1541
|
+
const step = zoomStep(state, direction, target, notches);
|
|
1542
|
+
Cartesian3.add(state.viewer.camera.position, step, state.viewer.camera.position);
|
|
1543
|
+
}
|
|
1544
|
+
/*
|
|
1545
|
+
* The move for some notches toward a target along a direction, a share of the distance with a floor so it never stalls.
|
|
1546
|
+
*/
|
|
1547
|
+
function zoomStep(state, direction, picked, notches) {
|
|
1548
|
+
const camera = state.viewer.camera;
|
|
1549
|
+
const target = picked.point;
|
|
1550
|
+
// Where the camera will be once the glide already under way ends, which this step continues from.
|
|
1551
|
+
const from = Cartesian3.add(camera.positionWC, state.pendingZoom, new Cartesian3());
|
|
1552
|
+
const distance = Math.max(Cartesian3.distance(from, target), MIN_ZOOM_DISTANCE);
|
|
1553
|
+
state.lastDistance = distance;
|
|
1554
|
+
let length = distance * ZOOM_SHARE * notches * zoomSpeedShare(state, picked);
|
|
1555
|
+
// A geospatial camera zooming out hands over to CesiumJS once it is high enough, so only model-space is capped.
|
|
1556
|
+
if (length < 0 && state.getModelSpaceFrame) {
|
|
1557
|
+
const origin = Matrix4.getTranslation(state.getModelSpaceFrame(), new Cartesian3());
|
|
1558
|
+
const range = Cartesian3.distance(from, origin);
|
|
1559
|
+
length = Math.max(length, range - MODEL_SPACE_MAX_RANGE);
|
|
1560
|
+
if (length >= 0) {
|
|
1561
|
+
return new Cartesian3();
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
const unit = Cartesian3.normalize(direction, new Cartesian3());
|
|
1565
|
+
// With the globe hidden there is no hand-over, so zooming out stops where the Earth is a dot.
|
|
1566
|
+
if (length < 0 && !state.getModelSpaceFrame && !globeShown(state)) {
|
|
1567
|
+
const rise = -Cartesian3.dot(unit, upAt(state, from));
|
|
1568
|
+
const headroom = HIDDEN_GLOBE_MAX_HEIGHT - heightOf(state, from);
|
|
1569
|
+
if (rise > 0) {
|
|
1570
|
+
length = Math.max(length, -Math.max(headroom, 0) / rise);
|
|
1571
|
+
}
|
|
1572
|
+
if (length >= 0) {
|
|
1573
|
+
return new Cartesian3();
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
const step = Cartesian3.multiplyByScalar(unit, length, new Cartesian3());
|
|
1577
|
+
return length > 0 ? resistDescent(state, from, step, picked, notches) : step;
|
|
1578
|
+
}
|
|
1579
|
+
/*
|
|
1580
|
+
* How fast to zoom toward a target: slower toward a guess, or while the terrain that would give a real one loads.
|
|
1581
|
+
*/
|
|
1582
|
+
function zoomSpeedShare(state, picked) {
|
|
1583
|
+
let share = 1;
|
|
1584
|
+
if (picked.source !== "pick") {
|
|
1585
|
+
share *= ZOOM_GUESS_SHARE;
|
|
1586
|
+
}
|
|
1587
|
+
const globe = state.viewer.scene.globe;
|
|
1588
|
+
if (!state.getModelSpaceFrame && globeShown(state) && globe.tilesLoaded === false) {
|
|
1589
|
+
share *= ZOOM_LOADING_SHARE;
|
|
1590
|
+
}
|
|
1591
|
+
return share;
|
|
1592
|
+
}
|
|
1593
|
+
/*
|
|
1594
|
+
* The ground a move comes down onto: the ground picked, else the terrain under where the move ends; null for none.
|
|
1595
|
+
*/
|
|
1596
|
+
function groundUnderMove(state, from, step, picked) {
|
|
1597
|
+
var _a, _b;
|
|
1598
|
+
if (state.getModelSpaceFrame || !hasGround(state)) {
|
|
1599
|
+
return null;
|
|
1600
|
+
}
|
|
1601
|
+
if (picked === null || picked === void 0 ? void 0 : picked.ground) {
|
|
1602
|
+
return { point: picked.point, up: upAt(state, picked.point) };
|
|
1603
|
+
}
|
|
1604
|
+
if (!globeShown(state)) {
|
|
1605
|
+
return null;
|
|
1606
|
+
}
|
|
1607
|
+
const ellipsoid = ellipsoidOf(state);
|
|
1608
|
+
const end = Cartesian3.add(from, step, new Cartesian3());
|
|
1609
|
+
const carto = ellipsoid.cartesianToCartographic(end);
|
|
1610
|
+
if (!carto) {
|
|
1611
|
+
return null;
|
|
1612
|
+
}
|
|
1613
|
+
const height = (_b = (_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : terrainHeightAt(state, ellipsoid.cartesianToCartographic(from))) !== null && _b !== void 0 ? _b : 0;
|
|
1614
|
+
const point = Cartesian3.fromRadians(carto.longitude, carto.latitude, height, ellipsoid);
|
|
1615
|
+
return { point, up: ellipsoid.geodeticSurfaceNormal(point, new Cartesian3()) };
|
|
1616
|
+
}
|
|
1617
|
+
/*
|
|
1618
|
+
* Whether a move takes a camera that is above the ground to within the stand-off of it or below.
|
|
1619
|
+
*/
|
|
1620
|
+
function wouldSinkBelowGround(state, from, step) {
|
|
1621
|
+
const ground = groundUnderMove(state, from, step, null);
|
|
1622
|
+
if (!ground) {
|
|
1623
|
+
return false;
|
|
1624
|
+
}
|
|
1625
|
+
const before = Cartesian3.dot(Cartesian3.subtract(from, ground.point, new Cartesian3()), ground.up);
|
|
1626
|
+
const after = before + Cartesian3.dot(step, ground.up);
|
|
1627
|
+
return before > 0 && after < Math.min(GROUND_STANDOFF, before);
|
|
1628
|
+
}
|
|
1629
|
+
/*
|
|
1630
|
+
* Slows a camera coming down from above as it nears the ground and stops it just above, until pushed on enough to
|
|
1631
|
+
* pass through; harder when nothing is known to be underground. A camera already below the ground moves freely.
|
|
1632
|
+
*/
|
|
1633
|
+
function resistDescent(state, from, step, picked, notches) {
|
|
1634
|
+
const ground = groundUnderMove(state, from, step, picked);
|
|
1635
|
+
const length = Cartesian3.magnitude(step);
|
|
1636
|
+
if (!ground || length === 0) {
|
|
1637
|
+
return step;
|
|
1638
|
+
}
|
|
1639
|
+
const above = Cartesian3.dot(Cartesian3.subtract(from, ground.point, new Cartesian3()), ground.up);
|
|
1640
|
+
const unit = Cartesian3.divideByScalar(step, length, new Cartesian3());
|
|
1641
|
+
const sink = -Cartesian3.dot(unit, ground.up);
|
|
1642
|
+
if (above <= 0 || sink <= 0) {
|
|
1643
|
+
return step;
|
|
1644
|
+
}
|
|
1645
|
+
let allowed = length;
|
|
1646
|
+
if (above < GROUND_APPROACH) {
|
|
1647
|
+
allowed *= Math.max(above / GROUND_APPROACH, GROUND_APPROACH_FLOOR);
|
|
1648
|
+
}
|
|
1649
|
+
const toStandOff = Math.max(above - GROUND_STANDOFF, 0) / sink;
|
|
1650
|
+
if (allowed <= toStandOff) {
|
|
1651
|
+
return Cartesian3.multiplyByScalar(unit, allowed, new Cartesian3());
|
|
1652
|
+
}
|
|
1653
|
+
// Held at the stand-off: each push counts, and enough close together go through.
|
|
1654
|
+
const now = Date.now();
|
|
1655
|
+
if (now - state.push.at > PUSH_WINDOW_MS) {
|
|
1656
|
+
state.push.notches = 0;
|
|
1657
|
+
}
|
|
1658
|
+
state.push.at = now;
|
|
1659
|
+
state.push.notches += Math.abs(notches);
|
|
1660
|
+
const needed = scanScene(state).undergroundData ? PUSH_NOTCHES_DATA_BELOW : PUSH_NOTCHES_NOTHING_BELOW;
|
|
1661
|
+
if (state.push.notches >= needed) {
|
|
1662
|
+
state.push.notches = 0;
|
|
1663
|
+
// A shallow push would land far along the ground to get under it, so it goes no further than a usual step.
|
|
1664
|
+
const through = Math.min((above + GROUND_BREAK_DEPTH) / sink, Math.max(length, (above + GROUND_BREAK_DEPTH) * 4));
|
|
1665
|
+
return Cartesian3.multiplyByScalar(unit, through, new Cartesian3());
|
|
1666
|
+
}
|
|
1667
|
+
return Cartesian3.multiplyByScalar(unit, toStandOff, new Cartesian3());
|
|
1668
|
+
}
|
|
1669
|
+
/*
|
|
1670
|
+
* What the scene holds that the camera cares about, rescanned at most every couple of seconds.
|
|
1671
|
+
*/
|
|
1672
|
+
function scanScene(state) {
|
|
1673
|
+
var _a, _b;
|
|
1674
|
+
const now = Date.now();
|
|
1675
|
+
if (state.scan && now - state.scan.at < SCENE_SCAN_MS) {
|
|
1676
|
+
return applyOverride(state, state.scan);
|
|
1677
|
+
}
|
|
1678
|
+
const scene = state.viewer.scene;
|
|
1679
|
+
const found = { at: now, undergroundData: false, groundTileset: false };
|
|
1680
|
+
// Seeing through the ground is turned on to look at what is under it.
|
|
1681
|
+
if ((_b = (_a = scene.globe) === null || _a === void 0 ? void 0 : _a.translucency) === null || _b === void 0 ? void 0 : _b.enabled) {
|
|
1682
|
+
found.undergroundData = true;
|
|
1683
|
+
}
|
|
1684
|
+
const visit = (primitive) => {
|
|
1685
|
+
if (!primitive || primitive.show === false || (primitive.isDestroyed && primitive.isDestroyed())) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
if (typeof primitive.length === "number" && typeof primitive.get === "function") {
|
|
1689
|
+
for (let i = 0; i < primitive.length; i++) {
|
|
1690
|
+
visit(primitive.get(i));
|
|
1691
|
+
}
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
if (primitive[GROUND_TILESET_KEY]) {
|
|
1695
|
+
found.groundTileset = true;
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
if (!found.undergroundData && reachesBelowGround(state, lowestPointOf(primitive))) {
|
|
1699
|
+
found.undergroundData = true;
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
visit(scene.primitives);
|
|
1703
|
+
if (!found.undergroundData) {
|
|
1704
|
+
found.undergroundData = entitiesBelowGround(state);
|
|
1705
|
+
}
|
|
1706
|
+
state.scan = found;
|
|
1707
|
+
return applyOverride(state, found);
|
|
1708
|
+
}
|
|
1709
|
+
function applyOverride(state, found) {
|
|
1710
|
+
return state.undergroundOverride == null ? found : { ...found, undergroundData: state.undergroundOverride };
|
|
1711
|
+
}
|
|
1712
|
+
/*
|
|
1713
|
+
* The lowest point of a tileset or model: its root box's lowest corner, or its bounding sphere's centre.
|
|
1714
|
+
*/
|
|
1715
|
+
function lowestPointOf(primitive) {
|
|
1716
|
+
var _a, _b, _c;
|
|
1717
|
+
const volume = (_a = primitive === null || primitive === void 0 ? void 0 : primitive.root) === null || _a === void 0 ? void 0 : _a.boundingVolume;
|
|
1718
|
+
if (volume) {
|
|
1719
|
+
const region = Number.isFinite(volume.minimumHeight) && volume.rectangle;
|
|
1720
|
+
if (region) {
|
|
1721
|
+
return Cartesian3.fromRadians(Rectangle.center(volume.rectangle).longitude, Rectangle.center(volume.rectangle).latitude, volume.minimumHeight);
|
|
1722
|
+
}
|
|
1723
|
+
const box = volume.boundingVolume;
|
|
1724
|
+
const corners = box instanceof OrientedBoundingBox && typeof OrientedBoundingBox.computeCorners === "function" ? OrientedBoundingBox.computeCorners(box) : null;
|
|
1725
|
+
if (corners === null || corners === void 0 ? void 0 : corners.length) {
|
|
1726
|
+
return lowestOf(corners);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
// A sphere's centre, as its radius reaches below the ground for anything standing on it.
|
|
1730
|
+
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;
|
|
1731
|
+
}
|
|
1732
|
+
function lowestOf(points) {
|
|
1733
|
+
var _a, _b;
|
|
1734
|
+
let lowest = null;
|
|
1735
|
+
let lowestHeight = Number.POSITIVE_INFINITY;
|
|
1736
|
+
for (const point of points) {
|
|
1737
|
+
const height = (_b = (_a = Cartographic.fromCartesian(point)) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
|
|
1738
|
+
if (height < lowestHeight) {
|
|
1739
|
+
lowestHeight = height;
|
|
1740
|
+
lowest = point;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
return lowest;
|
|
1744
|
+
}
|
|
1745
|
+
/*
|
|
1746
|
+
* Whether a point is clearly below the ground at its place: the terrain there, else sea level.
|
|
1747
|
+
*/
|
|
1748
|
+
function reachesBelowGround(state, point) {
|
|
1749
|
+
var _a;
|
|
1750
|
+
if (!point) {
|
|
1751
|
+
return false;
|
|
1752
|
+
}
|
|
1753
|
+
const carto = ellipsoidOf(state).cartesianToCartographic(point);
|
|
1754
|
+
if (!carto) {
|
|
1755
|
+
return false;
|
|
1756
|
+
}
|
|
1757
|
+
return carto.height < ((_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0) - UNDERGROUND_MARGIN;
|
|
1758
|
+
}
|
|
1759
|
+
/*
|
|
1760
|
+
* Whether any of the first entities sits clearly below the ground: a point, or a line's first or last vertex.
|
|
1761
|
+
*/
|
|
1762
|
+
function entitiesBelowGround(state) {
|
|
1763
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
1764
|
+
const viewer = state.viewer;
|
|
1765
|
+
const collections = [viewer.entities];
|
|
1766
|
+
const sources = viewer.dataSources;
|
|
1767
|
+
for (let i = 0; i < ((_a = sources === null || sources === void 0 ? void 0 : sources.length) !== null && _a !== void 0 ? _a : 0); i++) {
|
|
1768
|
+
collections.push((_b = sources.get(i)) === null || _b === void 0 ? void 0 : _b.entities);
|
|
1769
|
+
}
|
|
1770
|
+
const time = (_d = (_c = viewer.clock) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : JulianDate.now();
|
|
1771
|
+
let seen = 0;
|
|
1772
|
+
for (const collection of collections) {
|
|
1773
|
+
for (const entity of (_e = collection === null || collection === void 0 ? void 0 : collection.values) !== null && _e !== void 0 ? _e : []) {
|
|
1774
|
+
if (seen++ >= SCENE_SCAN_ENTITIES) {
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
|
+
if (!entity || entity.show === false) {
|
|
1778
|
+
continue;
|
|
1779
|
+
}
|
|
1780
|
+
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;
|
|
1781
|
+
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);
|
|
1782
|
+
if (reference === HeightReference.CLAMP_TO_GROUND) {
|
|
1783
|
+
continue;
|
|
1784
|
+
}
|
|
1785
|
+
const position = (_o = (_m = entity.position) === null || _m === void 0 ? void 0 : _m.getValue) === null || _o === void 0 ? void 0 : _o.call(_m, time);
|
|
1786
|
+
if (position) {
|
|
1787
|
+
const relative = reference === HeightReference.RELATIVE_TO_GROUND;
|
|
1788
|
+
const height = relative ? (_p = ellipsoidOf(state).cartesianToCartographic(position)) === null || _p === void 0 ? void 0 : _p.height : null;
|
|
1789
|
+
if (relative ? height < -UNDERGROUND_MARGIN : reachesBelowGround(state, position)) {
|
|
1790
|
+
return true;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
const line = entity.polyline;
|
|
1794
|
+
if (line && !((_r = (_q = line.clampToGround) === null || _q === void 0 ? void 0 : _q.getValue) === null || _r === void 0 ? void 0 : _r.call(_q, time))) {
|
|
1795
|
+
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 : [];
|
|
1796
|
+
if (positions.length && (reachesBelowGround(state, positions[0]) || reachesBelowGround(state, positions[positions.length - 1]))) {
|
|
1797
|
+
return true;
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
return false;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
910
1805
|
const CESIUM_INSPECTOR_KEY = "_nextspace_inspector";
|
|
911
1806
|
const CESIUM_TIMELINE_KEY = "_nextspace_timeline";
|
|
912
1807
|
const CESIUM_TIMELINE_LIVE_KEY = "_nextspace_timeline_live";
|
|
@@ -1384,6 +2279,13 @@ var ViewUtils;
|
|
|
1384
2279
|
return overriddenImageBasedLighting || null;
|
|
1385
2280
|
}
|
|
1386
2281
|
ViewUtils.GetDefaultImageBasedLighting = GetDefaultImageBasedLighting;
|
|
2282
|
+
/**
|
|
2283
|
+
* Shadow mode for the Entity graphics this library draws, following the scene's shadow switch.
|
|
2284
|
+
*/
|
|
2285
|
+
function GetEntityShadowMode(viewer) {
|
|
2286
|
+
return (viewer === null || viewer === void 0 ? void 0 : viewer.shadows) ? ShadowMode.ENABLED : ShadowMode.DISABLED;
|
|
2287
|
+
}
|
|
2288
|
+
ViewUtils.GetEntityShadowMode = GetEntityShadowMode;
|
|
1387
2289
|
function EngineShadesModelsDarker() {
|
|
1388
2290
|
return typeof DynamicEnvironmentMapManager !== "undefined";
|
|
1389
2291
|
}
|
|
@@ -1455,6 +2357,7 @@ var ViewUtils;
|
|
|
1455
2357
|
viewer[CESIUM_MODEL_SPACE_KEY] = modelSpace;
|
|
1456
2358
|
// Reload globe since we display it differently between the two modes.
|
|
1457
2359
|
SetGlobeDetails({ viewer });
|
|
2360
|
+
CameraControls.SetModelSpace(viewer, modelSpace ? () => GetModelSpaceFrame(viewer) : null);
|
|
1458
2361
|
}
|
|
1459
2362
|
ViewUtils.SetModelSpace = SetModelSpace;
|
|
1460
2363
|
function GetModelSpace(viewer) {
|
|
@@ -6177,7 +7080,7 @@ var EntitySimulation;
|
|
|
6177
7080
|
const byTime = new Map();
|
|
6178
7081
|
for (const set of this.sets.values()) {
|
|
6179
7082
|
for (const [ms, record] of set.records.get(entityId) || []) {
|
|
6180
|
-
if (attrKey && record.attrKey && record.attrKey
|
|
7083
|
+
if (attrKey && record.attrKey && !PathUtils.Equals(record.attrKey, attrKey)) {
|
|
6181
7084
|
continue;
|
|
6182
7085
|
}
|
|
6183
7086
|
const held = byTime.get(ms);
|
|
@@ -11982,6 +12885,28 @@ function getHighestZIndex(viewer, visual) {
|
|
|
11982
12885
|
return highest;
|
|
11983
12886
|
}
|
|
11984
12887
|
const MAX_SHOW_DEPTH = 10;
|
|
12888
|
+
// Entity graphics whose shadows follow the scene's shadow switch.
|
|
12889
|
+
const SHADOWED_GRAPHICS = ["model", "polygon", "polyline", "corridor"];
|
|
12890
|
+
/*
|
|
12891
|
+
* Points a registered Entity graphic, and the graphics drawn beside it, at the given shadow mode.
|
|
12892
|
+
*/
|
|
12893
|
+
function updateCEntityShadows(viewer, visual, mode, depth = 0) {
|
|
12894
|
+
if (!visual || depth > MAX_SHOW_DEPTH) {
|
|
12895
|
+
return;
|
|
12896
|
+
}
|
|
12897
|
+
for (const key of SHADOWED_GRAPHICS) {
|
|
12898
|
+
const graphic = visual[key];
|
|
12899
|
+
// Only graphics drawn with a mode; one left at Cesium's default was never meant to shadow.
|
|
12900
|
+
if ((graphic === null || graphic === void 0 ? void 0 : graphic.shadows) != null) {
|
|
12901
|
+
SetCPropIfChanged({ viewer, graphic, property: "shadows", value: mode });
|
|
12902
|
+
}
|
|
12903
|
+
}
|
|
12904
|
+
if (visual._siblingGraphics) {
|
|
12905
|
+
for (let i = 0; i < visual._siblingGraphics.length; i++) {
|
|
12906
|
+
updateCEntityShadows(viewer, visual._siblingGraphics[i], mode, depth + 1);
|
|
12907
|
+
}
|
|
12908
|
+
}
|
|
12909
|
+
}
|
|
11985
12910
|
function updateCEntityShow(viewer, visual, rego, show, ignoreParent, depth = 0) {
|
|
11986
12911
|
if (depth > MAX_SHOW_DEPTH) {
|
|
11987
12912
|
console.warn("updateCEntityShow(): Max show depth reached. EntityId = " + rego.entityId);
|
|
@@ -12318,7 +13243,7 @@ var VisualsRegister;
|
|
|
12318
13243
|
}
|
|
12319
13244
|
get OnLabelGroupsChanged() { return this.labelGroupsChanged; }
|
|
12320
13245
|
constructor(params) {
|
|
12321
|
-
var _a, _b;
|
|
13246
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12322
13247
|
this.id = ObjectUtils.UId();
|
|
12323
13248
|
this.disposed = false;
|
|
12324
13249
|
this.rego = {};
|
|
@@ -12368,6 +13293,7 @@ var VisualsRegister;
|
|
|
12368
13293
|
this.sourceOrderDirty = false;
|
|
12369
13294
|
// Stops following what is simulated, so labels can read it again when it changes.
|
|
12370
13295
|
this.simulationRemoval = null;
|
|
13296
|
+
this.shadowsRemoval = null;
|
|
12371
13297
|
this.labelGroupsChanged = new BruceEvent();
|
|
12372
13298
|
this.hoverRingState = {};
|
|
12373
13299
|
this.retiringHoverLabels = new Map();
|
|
@@ -12403,6 +13329,27 @@ var VisualsRegister;
|
|
|
12403
13329
|
register: this
|
|
12404
13330
|
});
|
|
12405
13331
|
this.simulationRemoval = (_b = (_a = EntitySimulation.Get(this.viewer)) === null || _a === void 0 ? void 0 : _a.OnChanged.Subscribe((change) => this.reloadLabels(change.entityIds))) !== null && _b !== void 0 ? _b : null;
|
|
13332
|
+
this.entityShadows = Boolean((_c = this.viewer) === null || _c === void 0 ? void 0 : _c.shadows);
|
|
13333
|
+
this.shadowsRemoval = (_g = (_f = (_e = (_d = this.viewer) === null || _d === void 0 ? void 0 : _d.scene) === null || _e === void 0 ? void 0 : _e.preUpdate) === null || _f === void 0 ? void 0 : _f.addEventListener(() => this.syncEntityShadows())) !== null && _g !== void 0 ? _g : null;
|
|
13334
|
+
}
|
|
13335
|
+
/*
|
|
13336
|
+
* Follows the scene's shadow switch on every registered Entity, whichever app or bookmark flipped it.
|
|
13337
|
+
*/
|
|
13338
|
+
syncEntityShadows() {
|
|
13339
|
+
const viewer = this.viewer;
|
|
13340
|
+
const enabled = Boolean(viewer === null || viewer === void 0 ? void 0 : viewer.shadows);
|
|
13341
|
+
if (enabled === this.entityShadows || this.disposed || !viewer || viewer.isDestroyed()) {
|
|
13342
|
+
return;
|
|
13343
|
+
}
|
|
13344
|
+
this.entityShadows = enabled;
|
|
13345
|
+
const mode = enabled ? ShadowMode.ENABLED : ShadowMode.DISABLED;
|
|
13346
|
+
for (const regos of Object.values(this.rego)) {
|
|
13347
|
+
for (const rego of regos) {
|
|
13348
|
+
if (rego.visual instanceof Entity) {
|
|
13349
|
+
updateCEntityShadows(viewer, rego.visual, mode);
|
|
13350
|
+
}
|
|
13351
|
+
}
|
|
13352
|
+
}
|
|
12406
13353
|
}
|
|
12407
13354
|
/*
|
|
12408
13355
|
* Tells labels to read their Entity again, since they keep what they read when drawn.
|
|
@@ -13331,9 +14278,11 @@ var VisualsRegister;
|
|
|
13331
14278
|
(_b = this.viewer.scene) === null || _b === void 0 ? void 0 : _b.requestRender();
|
|
13332
14279
|
}
|
|
13333
14280
|
Dispose() {
|
|
13334
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14281
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13335
14282
|
(_a = this.simulationRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
13336
14283
|
this.simulationRemoval = null;
|
|
14284
|
+
(_b = this.shadowsRemoval) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
14285
|
+
this.shadowsRemoval = null;
|
|
13337
14286
|
CesiumEntityStyler.SetDimming(this.viewer, this.id, false);
|
|
13338
14287
|
this.ClearLabelHover();
|
|
13339
14288
|
clearTimeout(this.hoverRingReset);
|
|
@@ -13343,14 +14292,14 @@ var VisualsRegister;
|
|
|
13343
14292
|
EntityLabel.Detatch({ label });
|
|
13344
14293
|
}
|
|
13345
14294
|
this.retiringHoverLabels.clear();
|
|
13346
|
-
(
|
|
14295
|
+
(_c = this.labelGroups) === null || _c === void 0 ? void 0 : _c.Dispose();
|
|
13347
14296
|
this.labelGroupsChanged.Clear();
|
|
13348
14297
|
for (const regos of Object.values(this.rego)) {
|
|
13349
14298
|
for (const rego of regos)
|
|
13350
14299
|
EntityLabel.Detatch({ rego, force: true });
|
|
13351
14300
|
}
|
|
13352
14301
|
EntityLabel.SetContainer(this.viewer);
|
|
13353
|
-
(
|
|
14302
|
+
(_d = this.cameraCullerDispose) === null || _d === void 0 ? void 0 : _d.call(this, {
|
|
13354
14303
|
uncull: false
|
|
13355
14304
|
});
|
|
13356
14305
|
this.cameraCullerDispose = null;
|
|
@@ -13367,7 +14316,7 @@ var VisualsRegister;
|
|
|
13367
14316
|
this.disposed = true;
|
|
13368
14317
|
for (const record of Array.from(this.menuItemSources.values())) {
|
|
13369
14318
|
try {
|
|
13370
|
-
(
|
|
14319
|
+
(_f = (_e = this.viewer) === null || _e === void 0 ? void 0 : _e.dataSources) === null || _f === void 0 ? void 0 : _f.remove(record.source, true);
|
|
13371
14320
|
}
|
|
13372
14321
|
catch (e) {
|
|
13373
14322
|
console.error(e);
|
|
@@ -13376,7 +14325,7 @@ var VisualsRegister;
|
|
|
13376
14325
|
this.menuItemSources.clear();
|
|
13377
14326
|
// Hand every tileset's show flag back to its owner, holding whatever the owner last asked for.
|
|
13378
14327
|
for (const rego of Array.from(this.tilesets.values())) {
|
|
13379
|
-
(
|
|
14328
|
+
(_g = rego.gate) === null || _g === void 0 ? void 0 : _g.Release();
|
|
13380
14329
|
}
|
|
13381
14330
|
this.tilesets.clear();
|
|
13382
14331
|
}
|
|
@@ -14100,8 +15049,11 @@ var VisualsRegister;
|
|
|
14100
15049
|
}
|
|
14101
15050
|
}
|
|
14102
15051
|
// Add the new visual to the register.
|
|
15052
|
+
// Tileset managers add the same rego again for each tile holding more of the Entity.
|
|
14103
15053
|
const entityRegos = (_a = this.rego[entityId]) !== null && _a !== void 0 ? _a : [];
|
|
14104
|
-
entityRegos.
|
|
15054
|
+
if (!entityRegos.includes(rego)) {
|
|
15055
|
+
entityRegos.push(rego);
|
|
15056
|
+
}
|
|
14105
15057
|
this.rego[entityId] = entityRegos;
|
|
14106
15058
|
this.indexMenuItemEntity(rego.menuItemId, entityId);
|
|
14107
15059
|
// Mark the visual as part of this register so selection works.
|
|
@@ -14535,6 +15487,28 @@ var VisualsRegister;
|
|
|
14535
15487
|
}
|
|
14536
15488
|
}
|
|
14537
15489
|
}
|
|
15490
|
+
/*
|
|
15491
|
+
* Hands a tile feature rego to a sibling feature from another tile when its own tile unloads.
|
|
15492
|
+
* An Entity split across tiles keeps drawing from those, so it must stay registered for them.
|
|
15493
|
+
*/
|
|
15494
|
+
promoteTileSibling(rego, removing) {
|
|
15495
|
+
var _a;
|
|
15496
|
+
const departing = rego.visual;
|
|
15497
|
+
if (!(departing instanceof Cesium3DTileFeature) || !((_a = departing._siblingGraphics) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
15498
|
+
return false;
|
|
15499
|
+
}
|
|
15500
|
+
const remaining = departing._siblingGraphics.filter(s => !removing.has(s));
|
|
15501
|
+
if (!remaining.length) {
|
|
15502
|
+
return false;
|
|
15503
|
+
}
|
|
15504
|
+
departing._siblingGraphics = undefined;
|
|
15505
|
+
unmarkEntity(departing, true);
|
|
15506
|
+
const promoted = remaining[0];
|
|
15507
|
+
promoted._siblingGraphics = remaining.slice(1);
|
|
15508
|
+
rego.visual = promoted;
|
|
15509
|
+
markEntity(this, rego, promoted, false);
|
|
15510
|
+
return true;
|
|
15511
|
+
}
|
|
14538
15512
|
/**
|
|
14539
15513
|
* Removes regos matching given visuals.
|
|
14540
15514
|
* This is used when we cannot unpack properties from the visual any longer to determine its ID.
|
|
@@ -14545,6 +15519,7 @@ var VisualsRegister;
|
|
|
14545
15519
|
var _a, _b, _c;
|
|
14546
15520
|
const { doRemove = true, requestRender = true, source, doUpdate, menuItemId } = params;
|
|
14547
15521
|
const removedEntityIds = new Set();
|
|
15522
|
+
const removing = new Set(params.visuals);
|
|
14548
15523
|
for (const visual of params.visuals) {
|
|
14549
15524
|
const visExt = visual;
|
|
14550
15525
|
const rego = (visExt === null || visExt === void 0 ? void 0 : visExt._register) === this ? visExt._rego : null;
|
|
@@ -14556,7 +15531,20 @@ var VisualsRegister;
|
|
|
14556
15531
|
if (!entityRegos) {
|
|
14557
15532
|
continue;
|
|
14558
15533
|
}
|
|
14559
|
-
if (rego.visual === visual) {
|
|
15534
|
+
if (rego.visual === visual && this.promoteTileSibling(rego, removing)) {
|
|
15535
|
+
if (doRemove != false) {
|
|
15536
|
+
removeEntity(this.viewer, visual);
|
|
15537
|
+
}
|
|
15538
|
+
// The label was placed against the departing feature, the refresh attaches it again.
|
|
15539
|
+
EntityLabel.Detatch({
|
|
15540
|
+
rego, force: true
|
|
15541
|
+
});
|
|
15542
|
+
this.queueUpdate({
|
|
15543
|
+
entityId: entityId,
|
|
15544
|
+
refresh: true
|
|
15545
|
+
});
|
|
15546
|
+
}
|
|
15547
|
+
else if (rego.visual === visual) {
|
|
14560
15548
|
EntityLabel.Detatch({
|
|
14561
15549
|
rego, force: true
|
|
14562
15550
|
});
|
|
@@ -16212,6 +17200,304 @@ class TilesetStyler {
|
|
|
16212
17200
|
}
|
|
16213
17201
|
}
|
|
16214
17202
|
|
|
17203
|
+
// viewer[VIEWER_WATCH_KEY] is true once the viewer's canvas reports context loss to DeviceProfile.
|
|
17204
|
+
const VIEWER_WATCH_KEY = "_bruceDeviceProfileWatch";
|
|
17205
|
+
// localStorage[DEMOTION_KEY] holds an IDemotion written after this browser lost a WebGL context.
|
|
17206
|
+
const DEMOTION_KEY = "bruce-cesium-device-demotion";
|
|
17207
|
+
// A lost context demotes for this long, so one driver reset does not cap a strong device forever.
|
|
17208
|
+
// Measured on the wall clock, not the viewer's: it spans sessions, and a scene clock can be historic.
|
|
17209
|
+
const DEMOTION_MS = 14 * 24 * 60 * 60 * 1000;
|
|
17210
|
+
// Each loss demotes one more tier, up to this many.
|
|
17211
|
+
const DEMOTION_MAX = 2;
|
|
17212
|
+
/*
|
|
17213
|
+
* Reads the demotion left by earlier context losses, ignoring an expired or unreadable one.
|
|
17214
|
+
*/
|
|
17215
|
+
function readDemotion(now) {
|
|
17216
|
+
try {
|
|
17217
|
+
const value = JSON.parse(window.localStorage.getItem(DEMOTION_KEY));
|
|
17218
|
+
if (value &&
|
|
17219
|
+
Number.isFinite(value.count) &&
|
|
17220
|
+
Number.isFinite(value.at) &&
|
|
17221
|
+
now - value.at < DEMOTION_MS) {
|
|
17222
|
+
return value;
|
|
17223
|
+
}
|
|
17224
|
+
}
|
|
17225
|
+
catch (e) {
|
|
17226
|
+
// Storage is blocked (private mode, sandboxed frame) or holds junk; treat as no demotion.
|
|
17227
|
+
}
|
|
17228
|
+
return null;
|
|
17229
|
+
}
|
|
17230
|
+
/*
|
|
17231
|
+
* Stores or clears the demotion, carrying on without it where storage is blocked.
|
|
17232
|
+
*/
|
|
17233
|
+
function writeDemotion(value) {
|
|
17234
|
+
try {
|
|
17235
|
+
if (value) {
|
|
17236
|
+
window.localStorage.setItem(DEMOTION_KEY, JSON.stringify(value));
|
|
17237
|
+
}
|
|
17238
|
+
else {
|
|
17239
|
+
window.localStorage.removeItem(DEMOTION_KEY);
|
|
17240
|
+
}
|
|
17241
|
+
}
|
|
17242
|
+
catch (e) {
|
|
17243
|
+
// Without storage the demotion lasts only for this page.
|
|
17244
|
+
}
|
|
17245
|
+
}
|
|
17246
|
+
/*
|
|
17247
|
+
* Reads the GPU name, preferring the unmasked one, which browsers that hide it simply do not offer.
|
|
17248
|
+
*/
|
|
17249
|
+
function readRenderer(gl) {
|
|
17250
|
+
try {
|
|
17251
|
+
const ext = gl.getExtension("WEBGL_debug_renderer_info");
|
|
17252
|
+
const name = ext ? gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) : gl.getParameter(gl.RENDERER);
|
|
17253
|
+
return typeof name === "string" && name ? name : undefined;
|
|
17254
|
+
}
|
|
17255
|
+
catch (e) {
|
|
17256
|
+
return undefined;
|
|
17257
|
+
}
|
|
17258
|
+
}
|
|
17259
|
+
/**
|
|
17260
|
+
* Picks how much the scene may hold in memory on this device, from a hardware guess and past sessions.
|
|
17261
|
+
*/
|
|
17262
|
+
var DeviceProfile;
|
|
17263
|
+
(function (DeviceProfile) {
|
|
17264
|
+
let ETier;
|
|
17265
|
+
(function (ETier) {
|
|
17266
|
+
ETier["Low"] = "LOW";
|
|
17267
|
+
ETier["Mid"] = "MID";
|
|
17268
|
+
ETier["High"] = "HIGH";
|
|
17269
|
+
})(ETier = DeviceProfile.ETier || (DeviceProfile.ETier = {}));
|
|
17270
|
+
DeviceProfile.BUDGETS = {
|
|
17271
|
+
[ETier.Low]: { tilesetMb: 384, splats: 1000000 },
|
|
17272
|
+
[ETier.Mid]: { tilesetMb: 1024, splats: 3000000 },
|
|
17273
|
+
[ETier.High]: { tilesetMb: 2048, splats: 6000000 }
|
|
17274
|
+
};
|
|
17275
|
+
const ORDER = [ETier.Low, ETier.Mid, ETier.High];
|
|
17276
|
+
/**
|
|
17277
|
+
* Raised after the override or a demotion changes the tier, so live budgets can be redistributed.
|
|
17278
|
+
*/
|
|
17279
|
+
DeviceProfile.Changed = new Event();
|
|
17280
|
+
let override = null;
|
|
17281
|
+
let detected = null;
|
|
17282
|
+
let logged = false;
|
|
17283
|
+
/*
|
|
17284
|
+
* Sorts a GPU name into a class. Order matters: Intel Arc is discrete, SwiftShader names any vendor.
|
|
17285
|
+
*/
|
|
17286
|
+
function ClassifyGpu(renderer) {
|
|
17287
|
+
const name = (renderer || "").toLowerCase();
|
|
17288
|
+
if (!name) {
|
|
17289
|
+
return "unknown";
|
|
17290
|
+
}
|
|
17291
|
+
if (/swiftshader|llvmpipe|softpipe|lavapipe|software|basic render/.test(name)) {
|
|
17292
|
+
return "software";
|
|
17293
|
+
}
|
|
17294
|
+
if (/mali|adreno|powervr|apple gpu|videocore|immortalis|xclipse|tegra/.test(name)) {
|
|
17295
|
+
return "mobile";
|
|
17296
|
+
}
|
|
17297
|
+
if (/apple m\d+ (pro|max|ultra)/.test(name)) {
|
|
17298
|
+
return "discrete";
|
|
17299
|
+
}
|
|
17300
|
+
if (/nvidia|geforce|quadro|rtx|radeon (rx|pro|r9|vii)|firepro|arc(\(tm\))? a\d/.test(name)) {
|
|
17301
|
+
return "discrete";
|
|
17302
|
+
}
|
|
17303
|
+
if (/intel|apple m\d|radeon(\(tm\))? graphics|vega \d/.test(name)) {
|
|
17304
|
+
return "integrated";
|
|
17305
|
+
}
|
|
17306
|
+
return "unknown";
|
|
17307
|
+
}
|
|
17308
|
+
DeviceProfile.ClassifyGpu = ClassifyGpu;
|
|
17309
|
+
/**
|
|
17310
|
+
* Guesses a tier from the hardware alone. Unknown hardware stays mid; only clear evidence moves it.
|
|
17311
|
+
*/
|
|
17312
|
+
function Classify(env) {
|
|
17313
|
+
const ua = (env.userAgent || "").toLowerCase();
|
|
17314
|
+
const mobile = /android|iphone|ipad|ipod|mobile/.test(ua) || (/macintosh/.test(ua) && env.maxTouchPoints > 1);
|
|
17315
|
+
const gpuClass = ClassifyGpu(env.gpuRenderer);
|
|
17316
|
+
const memory = env.deviceMemory;
|
|
17317
|
+
const reasons = [];
|
|
17318
|
+
let tier = ETier.Mid;
|
|
17319
|
+
if (gpuClass === "software") {
|
|
17320
|
+
reasons.push("software renderer");
|
|
17321
|
+
tier = ETier.Low;
|
|
17322
|
+
}
|
|
17323
|
+
if (mobile) {
|
|
17324
|
+
reasons.push("mobile device");
|
|
17325
|
+
tier = ETier.Low;
|
|
17326
|
+
}
|
|
17327
|
+
if (Number.isFinite(memory) && memory < 4) {
|
|
17328
|
+
reasons.push(`${memory} GB device memory`);
|
|
17329
|
+
tier = ETier.Low;
|
|
17330
|
+
}
|
|
17331
|
+
if (Number.isFinite(env.maxTextureSize) && env.maxTextureSize < 8192) {
|
|
17332
|
+
reasons.push(`max texture ${env.maxTextureSize}`);
|
|
17333
|
+
tier = ETier.Low;
|
|
17334
|
+
}
|
|
17335
|
+
if (tier === ETier.Mid && gpuClass === "discrete") {
|
|
17336
|
+
if (!Number.isFinite(memory) || memory >= 8) {
|
|
17337
|
+
reasons.push("discrete GPU");
|
|
17338
|
+
tier = ETier.High;
|
|
17339
|
+
}
|
|
17340
|
+
else {
|
|
17341
|
+
reasons.push(`discrete GPU held to mid by ${memory} GB device memory`);
|
|
17342
|
+
}
|
|
17343
|
+
}
|
|
17344
|
+
if (!reasons.length) {
|
|
17345
|
+
reasons.push(`${gpuClass} GPU`);
|
|
17346
|
+
}
|
|
17347
|
+
return { tier, gpuClass, mobile, reasons };
|
|
17348
|
+
}
|
|
17349
|
+
DeviceProfile.Classify = Classify;
|
|
17350
|
+
/*
|
|
17351
|
+
* Reads the browser environment, from the viewer's GL context when given rather than a spare one.
|
|
17352
|
+
*/
|
|
17353
|
+
function readEnvironment(viewer) {
|
|
17354
|
+
var _a, _b, _c;
|
|
17355
|
+
const nav = typeof navigator !== "undefined" ? navigator : {};
|
|
17356
|
+
const env = {
|
|
17357
|
+
userAgent: nav.userAgent,
|
|
17358
|
+
maxTouchPoints: nav.maxTouchPoints,
|
|
17359
|
+
deviceMemory: nav.deviceMemory,
|
|
17360
|
+
hardwareConcurrency: nav.hardwareConcurrency
|
|
17361
|
+
};
|
|
17362
|
+
let gl = (_b = (_a = viewer === null || viewer === void 0 ? void 0 : viewer.scene) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b._gl;
|
|
17363
|
+
let spare = false;
|
|
17364
|
+
if (!gl && typeof document !== "undefined") {
|
|
17365
|
+
try {
|
|
17366
|
+
gl = document.createElement("canvas").getContext("webgl");
|
|
17367
|
+
spare = Boolean(gl);
|
|
17368
|
+
}
|
|
17369
|
+
catch (e) {
|
|
17370
|
+
gl = null;
|
|
17371
|
+
}
|
|
17372
|
+
}
|
|
17373
|
+
// Detection must never stop a scene loading, so anything odd leaves the GPU unknown.
|
|
17374
|
+
if (gl &&
|
|
17375
|
+
typeof gl.getParameter === "function" &&
|
|
17376
|
+
typeof gl.getExtension === "function") {
|
|
17377
|
+
env.gpuRenderer = readRenderer(gl);
|
|
17378
|
+
try {
|
|
17379
|
+
env.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) || undefined;
|
|
17380
|
+
if (spare) {
|
|
17381
|
+
// Browsers cap live contexts per page; give this one back now rather than at GC.
|
|
17382
|
+
(_c = gl.getExtension("WEBGL_lose_context")) === null || _c === void 0 ? void 0 : _c.loseContext();
|
|
17383
|
+
}
|
|
17384
|
+
}
|
|
17385
|
+
catch (e) {
|
|
17386
|
+
// Leave it unknown.
|
|
17387
|
+
}
|
|
17388
|
+
}
|
|
17389
|
+
return env;
|
|
17390
|
+
}
|
|
17391
|
+
/**
|
|
17392
|
+
* Returns this device's profile, detecting it once per page. Pass the viewer to read its GL context.
|
|
17393
|
+
*/
|
|
17394
|
+
function Get(viewer) {
|
|
17395
|
+
var _a, _b;
|
|
17396
|
+
if (!detected) {
|
|
17397
|
+
const environment = readEnvironment(viewer);
|
|
17398
|
+
detected = { ...Classify(environment), environment };
|
|
17399
|
+
}
|
|
17400
|
+
const demotion = readDemotion(Date.now());
|
|
17401
|
+
const demoted = Math.min((_a = demotion === null || demotion === void 0 ? void 0 : demotion.count) !== null && _a !== void 0 ? _a : 0, DEMOTION_MAX);
|
|
17402
|
+
let tier = ORDER[Math.max(0, ORDER.indexOf(detected.tier) - demoted)];
|
|
17403
|
+
if (override) {
|
|
17404
|
+
tier = override;
|
|
17405
|
+
}
|
|
17406
|
+
const profile = {
|
|
17407
|
+
tier,
|
|
17408
|
+
detectedTier: detected.tier,
|
|
17409
|
+
gpuClass: detected.gpuClass,
|
|
17410
|
+
mobile: detected.mobile,
|
|
17411
|
+
demoted,
|
|
17412
|
+
overridden: Boolean(override),
|
|
17413
|
+
reasons: [...detected.reasons],
|
|
17414
|
+
environment: { ...detected.environment }
|
|
17415
|
+
};
|
|
17416
|
+
if (!logged) {
|
|
17417
|
+
logged = true;
|
|
17418
|
+
console.info(`[DeviceProfile] tier ${profile.tier} (${profile.reasons.join(", ")}` +
|
|
17419
|
+
`${demoted ? `, demoted ${demoted} after lost WebGL context` : ""}` +
|
|
17420
|
+
`${override ? ", overridden" : ""}). GPU: ${(_b = profile.environment.gpuRenderer) !== null && _b !== void 0 ? _b : "unknown"}.`);
|
|
17421
|
+
}
|
|
17422
|
+
return profile;
|
|
17423
|
+
}
|
|
17424
|
+
DeviceProfile.Get = Get;
|
|
17425
|
+
/**
|
|
17426
|
+
* Returns the memory budgets for this device's tier, or for a given tier.
|
|
17427
|
+
*/
|
|
17428
|
+
function GetBudget(tier) {
|
|
17429
|
+
return DeviceProfile.BUDGETS[tier !== null && tier !== void 0 ? tier : Get().tier];
|
|
17430
|
+
}
|
|
17431
|
+
DeviceProfile.GetBudget = GetBudget;
|
|
17432
|
+
/**
|
|
17433
|
+
* Forces a tier, for a user who knows better than the guess. Null returns to detection.
|
|
17434
|
+
*/
|
|
17435
|
+
function SetOverride(tier) {
|
|
17436
|
+
const next = tier && ORDER.includes(tier) ? tier : null;
|
|
17437
|
+
if (next === override) {
|
|
17438
|
+
return;
|
|
17439
|
+
}
|
|
17440
|
+
override = next;
|
|
17441
|
+
DeviceProfile.Changed.raiseEvent();
|
|
17442
|
+
}
|
|
17443
|
+
DeviceProfile.SetOverride = SetOverride;
|
|
17444
|
+
/**
|
|
17445
|
+
* Returns the forced tier, or null while detection decides.
|
|
17446
|
+
*/
|
|
17447
|
+
function GetOverride() {
|
|
17448
|
+
return override;
|
|
17449
|
+
}
|
|
17450
|
+
DeviceProfile.GetOverride = GetOverride;
|
|
17451
|
+
/**
|
|
17452
|
+
* Records that a WebGL context was lost, so this and later sessions start a tier lower.
|
|
17453
|
+
*/
|
|
17454
|
+
function RecordContextLost() {
|
|
17455
|
+
var _a, _b;
|
|
17456
|
+
const now = Date.now();
|
|
17457
|
+
const count = Math.min(((_b = (_a = readDemotion(now)) === null || _a === void 0 ? void 0 : _a.count) !== null && _b !== void 0 ? _b : 0) + 1, DEMOTION_MAX);
|
|
17458
|
+
writeDemotion({ count, at: now });
|
|
17459
|
+
console.warn(`[DeviceProfile] WebGL context lost; demoting the memory tier by ${count}.`);
|
|
17460
|
+
DeviceProfile.Changed.raiseEvent();
|
|
17461
|
+
}
|
|
17462
|
+
DeviceProfile.RecordContextLost = RecordContextLost;
|
|
17463
|
+
/**
|
|
17464
|
+
* Forgets earlier context losses, for a host that offers a reset.
|
|
17465
|
+
*/
|
|
17466
|
+
function ClearDemotion() {
|
|
17467
|
+
writeDemotion(null);
|
|
17468
|
+
DeviceProfile.Changed.raiseEvent();
|
|
17469
|
+
}
|
|
17470
|
+
DeviceProfile.ClearDemotion = ClearDemotion;
|
|
17471
|
+
/**
|
|
17472
|
+
* Reports the viewer's context losses. Safe to call repeatedly.
|
|
17473
|
+
*/
|
|
17474
|
+
function WatchViewer(viewer) {
|
|
17475
|
+
const canvas = viewer === null || viewer === void 0 ? void 0 : viewer.canvas;
|
|
17476
|
+
if (!canvas ||
|
|
17477
|
+
viewer[VIEWER_WATCH_KEY] ||
|
|
17478
|
+
typeof canvas.addEventListener !== "function") {
|
|
17479
|
+
return;
|
|
17480
|
+
}
|
|
17481
|
+
viewer[VIEWER_WATCH_KEY] = true;
|
|
17482
|
+
canvas.addEventListener("webglcontextlost", () => {
|
|
17483
|
+
// Ignore a loss caused by tearing the viewer down.
|
|
17484
|
+
if (!viewer.isDestroyed()) {
|
|
17485
|
+
RecordContextLost();
|
|
17486
|
+
}
|
|
17487
|
+
});
|
|
17488
|
+
}
|
|
17489
|
+
DeviceProfile.WatchViewer = WatchViewer;
|
|
17490
|
+
/**
|
|
17491
|
+
* Forgets the detected hardware and override, for tests.
|
|
17492
|
+
*/
|
|
17493
|
+
function Reset() {
|
|
17494
|
+
detected = null;
|
|
17495
|
+
override = null;
|
|
17496
|
+
logged = false;
|
|
17497
|
+
}
|
|
17498
|
+
DeviceProfile.Reset = Reset;
|
|
17499
|
+
})(DeviceProfile || (DeviceProfile = {}));
|
|
17500
|
+
|
|
16215
17501
|
/**
|
|
16216
17502
|
* Returns if a given tileset is alive and in the scene.
|
|
16217
17503
|
* @param viewer
|
|
@@ -16230,7 +17516,7 @@ function isAlive$2(viewer, cTileset) {
|
|
|
16230
17516
|
}
|
|
16231
17517
|
return viewer.scene.primitives.contains(cTileset);
|
|
16232
17518
|
}
|
|
16233
|
-
const VIEWER_WATCH_KEY = "bruce-viewer-watch";
|
|
17519
|
+
const VIEWER_WATCH_KEY$1 = "bruce-viewer-watch";
|
|
16234
17520
|
const WATCH_KEY = "bruce-tileset-watch";
|
|
16235
17521
|
const VIEWER_DATE_RANGE_WATCH_KEY = "bruce-viewer-date-range-watch";
|
|
16236
17522
|
const DATE_RANGE_WATCH_KEY = "bruce-tileset-date-range-watch";
|
|
@@ -16292,6 +17578,22 @@ function setDateRangeVisible(renderObject, visible) {
|
|
|
16292
17578
|
}
|
|
16293
17579
|
renderObject._bruceDateRangeVisible = visible;
|
|
16294
17580
|
}
|
|
17581
|
+
// A tileset may pass its cache share by this fraction before Cesium coarsens it to fit.
|
|
17582
|
+
const TILESET_OVERFLOW_RATIO = 0.25;
|
|
17583
|
+
/*
|
|
17584
|
+
* Returns the options capping a tileset's tile cache at the given MB, in the form the running Cesium reads.
|
|
17585
|
+
*/
|
|
17586
|
+
function getTilesetMemoryProps(mb) {
|
|
17587
|
+
const prototype = Cesium3DTileset.prototype;
|
|
17588
|
+
if ("cacheBytes" in prototype) {
|
|
17589
|
+
const props = { cacheBytes: Math.round(mb * 1024 * 1024) };
|
|
17590
|
+
if ("maximumCacheOverflowBytes" in prototype) {
|
|
17591
|
+
props.maximumCacheOverflowBytes = Math.round(mb * TILESET_OVERFLOW_RATIO * 1024 * 1024);
|
|
17592
|
+
}
|
|
17593
|
+
return props;
|
|
17594
|
+
}
|
|
17595
|
+
return { maximumMemoryUsage: mb };
|
|
17596
|
+
}
|
|
16295
17597
|
/**
|
|
16296
17598
|
* Creates and returns a tileset instance from a given url.
|
|
16297
17599
|
* This is made to handle the difference between old and new cesium versions.
|
|
@@ -16308,8 +17610,8 @@ async function createTileset(url, props, noMemoryLimit) {
|
|
|
16308
17610
|
};
|
|
16309
17611
|
Object.assign(defaultProps, ViewUtils.DefaultLightingProps());
|
|
16310
17612
|
if (noMemoryLimit != true) {
|
|
16311
|
-
//
|
|
16312
|
-
defaultProps.
|
|
17613
|
+
// The memory watcher narrows this to a share once the tileset joins it.
|
|
17614
|
+
Object.assign(defaultProps, getTilesetMemoryProps(TilesetRenderEngine.GetTilesetMemoryBudget()));
|
|
16313
17615
|
}
|
|
16314
17616
|
const C3DT = Cesium3DTileset;
|
|
16315
17617
|
if (C3DT.fromUrl) {
|
|
@@ -16861,10 +18163,23 @@ var TilesetRenderEngine;
|
|
|
16861
18163
|
}
|
|
16862
18164
|
TilesetRenderEngine.UnwatchDateRange = UnwatchDateRange;
|
|
16863
18165
|
/**
|
|
16864
|
-
*
|
|
16865
|
-
|
|
18166
|
+
* Total MB all tilesets may use, split evenly; null leaves it to the DeviceProfile tier.
|
|
18167
|
+
*/
|
|
18168
|
+
TilesetRenderEngine.MAX_TILESET_MEMORY = null;
|
|
18169
|
+
/**
|
|
18170
|
+
* Smallest MB share a tileset gets; small, since Cesium coarsens one that needs more.
|
|
18171
|
+
*/
|
|
18172
|
+
TilesetRenderEngine.MIN_TILESET_MEMORY = 32;
|
|
18173
|
+
/**
|
|
18174
|
+
* Returns the total MB all tilesets may use, from MAX_TILESET_MEMORY or else the device tier.
|
|
16866
18175
|
*/
|
|
16867
|
-
|
|
18176
|
+
function GetTilesetMemoryBudget() {
|
|
18177
|
+
if (Number.isFinite(TilesetRenderEngine.MAX_TILESET_MEMORY) && TilesetRenderEngine.MAX_TILESET_MEMORY > 0) {
|
|
18178
|
+
return TilesetRenderEngine.MAX_TILESET_MEMORY;
|
|
18179
|
+
}
|
|
18180
|
+
return DeviceProfile.GetBudget().tilesetMb;
|
|
18181
|
+
}
|
|
18182
|
+
TilesetRenderEngine.GetTilesetMemoryBudget = GetTilesetMemoryBudget;
|
|
16868
18183
|
/**
|
|
16869
18184
|
* Watches tileset date cutoffs and toggles their primitive visibility based on the viewer clock.
|
|
16870
18185
|
*/
|
|
@@ -16955,23 +18270,26 @@ var TilesetRenderEngine;
|
|
|
16955
18270
|
constructor(viewer) {
|
|
16956
18271
|
this.watched = [];
|
|
16957
18272
|
this.viewer = viewer;
|
|
18273
|
+
DeviceProfile.Get(viewer);
|
|
18274
|
+
DeviceProfile.WatchViewer(viewer);
|
|
18275
|
+
this.removeChanged = DeviceProfile.Changed.addEventListener(() => this.distributeMemory());
|
|
16958
18276
|
}
|
|
16959
18277
|
distributeMemory() {
|
|
16960
18278
|
this.clean();
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
const
|
|
16966
|
-
const totalPerTileset = Math.max(this.watched.length ? maxMemory / this.watched.length : maxMemory, minMemory);
|
|
18279
|
+
if (!this.watched.length) {
|
|
18280
|
+
return;
|
|
18281
|
+
}
|
|
18282
|
+
const share = Math.max(GetTilesetMemoryBudget() / this.watched.length, TilesetRenderEngine.MIN_TILESET_MEMORY);
|
|
18283
|
+
const props = getTilesetMemoryProps(share);
|
|
16967
18284
|
this.watched.forEach(x => {
|
|
16968
|
-
|
|
16969
|
-
// TODO: Check if it's needed then.
|
|
16970
|
-
x["maximumMemoryUsage"] = totalPerTileset;
|
|
18285
|
+
Object.assign(x, props);
|
|
16971
18286
|
});
|
|
16972
18287
|
}
|
|
16973
18288
|
destroy() {
|
|
18289
|
+
var _a;
|
|
16974
18290
|
this.watched = [];
|
|
18291
|
+
(_a = this.removeChanged) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
18292
|
+
this.removeChanged = null;
|
|
16975
18293
|
}
|
|
16976
18294
|
/**
|
|
16977
18295
|
* Remove all dead tilesets.
|
|
@@ -17020,10 +18338,10 @@ var TilesetRenderEngine;
|
|
|
17020
18338
|
if (!viewer || viewer.isDestroyed()) {
|
|
17021
18339
|
return null;
|
|
17022
18340
|
}
|
|
17023
|
-
if (!viewer[VIEWER_WATCH_KEY]) {
|
|
17024
|
-
viewer[VIEWER_WATCH_KEY] = new MemoryWatcher(viewer);
|
|
18341
|
+
if (!viewer[VIEWER_WATCH_KEY$1]) {
|
|
18342
|
+
viewer[VIEWER_WATCH_KEY$1] = new MemoryWatcher(viewer);
|
|
17025
18343
|
}
|
|
17026
|
-
return viewer[VIEWER_WATCH_KEY];
|
|
18344
|
+
return viewer[VIEWER_WATCH_KEY$1];
|
|
17027
18345
|
}
|
|
17028
18346
|
TilesetRenderEngine.GetMemoryWatcher = GetMemoryWatcher;
|
|
17029
18347
|
function GetDateRangeWatcher(viewer) {
|
|
@@ -28227,7 +29545,9 @@ var XGridsRenderEngine;
|
|
|
28227
29545
|
if (loadUrl.indexOf("?") !== -1) {
|
|
28228
29546
|
loadUrl = loadUrl.split("?")[0];
|
|
28229
29547
|
}
|
|
28230
|
-
|
|
29548
|
+
const profile = DeviceProfile.Get(viewer);
|
|
29549
|
+
DeviceProfile.WatchViewer(viewer);
|
|
29550
|
+
let maxSplats = DeviceProfile.GetBudget(profile.tier).splats;
|
|
28231
29551
|
/*
|
|
28232
29552
|
* Configures optional LOD capabilities once metadata or initial geometry is ready.
|
|
28233
29553
|
*/
|
|
@@ -28312,8 +29632,7 @@ var XGridsRenderEngine;
|
|
|
28312
29632
|
}
|
|
28313
29633
|
try {
|
|
28314
29634
|
const sdkBudget = typeof obj.getCurrentConfig === "function" ? (_d = obj.getCurrentConfig()) === null || _d === void 0 ? void 0 : _d.maxLoadSplatCount : undefined;
|
|
28315
|
-
|
|
28316
|
-
maxSplats = Number.isFinite(sdkBudget) && sdkBudget > 0 && sdkBudget <= 2000000 ? sdkBudget : 6000000;
|
|
29635
|
+
maxSplats = GetSplatBudget(sdkBudget, profile);
|
|
28317
29636
|
if (LCCRender.nextspaceMetadataReady === 1 &&
|
|
28318
29637
|
typeof obj.setNextspaceMetadataCallback === "function" &&
|
|
28319
29638
|
typeof obj.setMaxSplats === "function") {
|
|
@@ -28354,6 +29673,21 @@ var XGridsRenderEngine;
|
|
|
28354
29673
|
return obj;
|
|
28355
29674
|
}
|
|
28356
29675
|
XGridsRenderEngine.Render = Render;
|
|
29676
|
+
/*
|
|
29677
|
+
* The most splats a scan may load: the tier's, lowered by the SDK's GPU limit unless overridden.
|
|
29678
|
+
*/
|
|
29679
|
+
function GetSplatBudget(sdkBudget, profile) {
|
|
29680
|
+
const budget = DeviceProfile.GetBudget(profile.tier).splats;
|
|
29681
|
+
// Above 2M the SDK is reporting its flat default, not a limit it chose for this GPU.
|
|
29682
|
+
if (!profile.overridden &&
|
|
29683
|
+
Number.isFinite(sdkBudget) &&
|
|
29684
|
+
sdkBudget > 0 &&
|
|
29685
|
+
sdkBudget <= 2000000) {
|
|
29686
|
+
return Math.min(sdkBudget, budget);
|
|
29687
|
+
}
|
|
29688
|
+
return budget;
|
|
29689
|
+
}
|
|
29690
|
+
XGridsRenderEngine.GetSplatBudget = GetSplatBudget;
|
|
28357
29691
|
/*
|
|
28358
29692
|
* Detaches optional tuning before unloading the scan.
|
|
28359
29693
|
*/
|
|
@@ -29938,6 +31272,8 @@ var TilesetGooglePhotosRenderManager;
|
|
|
29938
31272
|
this.doDispose();
|
|
29939
31273
|
return;
|
|
29940
31274
|
}
|
|
31275
|
+
// Photorealistic tiles cover the Earth, so the camera treats them as the ground when the globe is hidden.
|
|
31276
|
+
CameraControls.SetGroundTileset(this.cTileset, true);
|
|
29941
31277
|
this.viewer.scene.primitives.add(this.cTileset);
|
|
29942
31278
|
this.applyColorMask();
|
|
29943
31279
|
this.viewer.scene.requestRender();
|
|
@@ -38815,6 +40151,1238 @@ var TileRenderEngine;
|
|
|
38815
40151
|
})(Terrain = TileRenderEngine.Terrain || (TileRenderEngine.Terrain = {}));
|
|
38816
40152
|
})(TileRenderEngine || (TileRenderEngine = {}));
|
|
38817
40153
|
|
|
40154
|
+
// Builds simple meshes into binary glTF in code. Nothing here imports Cesium, so it can move to bruce-models as is.
|
|
40155
|
+
const GLB_MAGIC = 0x46546C67;
|
|
40156
|
+
const GLB_CHUNK_JSON = 0x4E4F534A;
|
|
40157
|
+
const GLB_CHUNK_BIN = 0x004E4942;
|
|
40158
|
+
const GL_ARRAY_BUFFER = 34962;
|
|
40159
|
+
const GL_ELEMENT_ARRAY_BUFFER = 34963;
|
|
40160
|
+
const GL_UNSIGNED_SHORT = 5123;
|
|
40161
|
+
const GL_UNSIGNED_INT = 5125;
|
|
40162
|
+
const GL_FLOAT = 5126;
|
|
40163
|
+
const GL_TRIANGLES = 4;
|
|
40164
|
+
/**
|
|
40165
|
+
* Writes meshes as binary glTF (GLB), for models simple enough to describe in code rather than ship as files.
|
|
40166
|
+
*/
|
|
40167
|
+
var GltfGenerator;
|
|
40168
|
+
(function (GltfGenerator) {
|
|
40169
|
+
/**
|
|
40170
|
+
* Vertices and triangles collected by the shape functions, one material's worth.
|
|
40171
|
+
*/
|
|
40172
|
+
class Mesh {
|
|
40173
|
+
constructor() {
|
|
40174
|
+
this.positions = [];
|
|
40175
|
+
this.normals = [];
|
|
40176
|
+
this.indices = [];
|
|
40177
|
+
}
|
|
40178
|
+
AddVertex(position, normal) {
|
|
40179
|
+
this.positions.push(position[0], position[1], position[2]);
|
|
40180
|
+
this.normals.push(normal[0], normal[1], normal[2]);
|
|
40181
|
+
return this.positions.length / 3 - 1;
|
|
40182
|
+
}
|
|
40183
|
+
/**
|
|
40184
|
+
* Adds a triangle wound so its front faces along normal, whichever order the corners come in.
|
|
40185
|
+
* Per corner normals smooth it; without them every corner takes the face normal.
|
|
40186
|
+
*/
|
|
40187
|
+
AddTriangle(a, b, c, normal, corners) {
|
|
40188
|
+
var _a, _b, _c;
|
|
40189
|
+
const ia = this.AddVertex(a, (_a = corners === null || corners === void 0 ? void 0 : corners[0]) !== null && _a !== void 0 ? _a : normal);
|
|
40190
|
+
const ib = this.AddVertex(b, (_b = corners === null || corners === void 0 ? void 0 : corners[1]) !== null && _b !== void 0 ? _b : normal);
|
|
40191
|
+
const ic = this.AddVertex(c, (_c = corners === null || corners === void 0 ? void 0 : corners[2]) !== null && _c !== void 0 ? _c : normal);
|
|
40192
|
+
if (Dot(Cross(Sub(b, a), Sub(c, a)), normal) >= 0) {
|
|
40193
|
+
this.indices.push(ia, ib, ic);
|
|
40194
|
+
}
|
|
40195
|
+
else {
|
|
40196
|
+
this.indices.push(ia, ic, ib);
|
|
40197
|
+
}
|
|
40198
|
+
}
|
|
40199
|
+
/**
|
|
40200
|
+
* Joins three added vertices into a triangle facing along normal, so shapes can share corners.
|
|
40201
|
+
*/
|
|
40202
|
+
AddIndexedTriangle(ia, ib, ic, normal) {
|
|
40203
|
+
const at = (i) => [this.positions[i * 3], this.positions[i * 3 + 1], this.positions[i * 3 + 2]];
|
|
40204
|
+
const a = at(ia);
|
|
40205
|
+
if (Dot(Cross(Sub(at(ib), a), Sub(at(ic), a)), normal) >= 0) {
|
|
40206
|
+
this.indices.push(ia, ib, ic);
|
|
40207
|
+
}
|
|
40208
|
+
else {
|
|
40209
|
+
this.indices.push(ia, ic, ib);
|
|
40210
|
+
}
|
|
40211
|
+
}
|
|
40212
|
+
get VertexCount() {
|
|
40213
|
+
return this.positions.length / 3;
|
|
40214
|
+
}
|
|
40215
|
+
}
|
|
40216
|
+
GltfGenerator.Mesh = Mesh;
|
|
40217
|
+
function Add(a, b) {
|
|
40218
|
+
return [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
|
|
40219
|
+
}
|
|
40220
|
+
GltfGenerator.Add = Add;
|
|
40221
|
+
function Sub(a, b) {
|
|
40222
|
+
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
40223
|
+
}
|
|
40224
|
+
GltfGenerator.Sub = Sub;
|
|
40225
|
+
function Scale(a, s) {
|
|
40226
|
+
return [a[0] * s, a[1] * s, a[2] * s];
|
|
40227
|
+
}
|
|
40228
|
+
GltfGenerator.Scale = Scale;
|
|
40229
|
+
function Dot(a, b) {
|
|
40230
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
40231
|
+
}
|
|
40232
|
+
GltfGenerator.Dot = Dot;
|
|
40233
|
+
function Cross(a, b) {
|
|
40234
|
+
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
40235
|
+
}
|
|
40236
|
+
GltfGenerator.Cross = Cross;
|
|
40237
|
+
function Normalize(a) {
|
|
40238
|
+
const length = Math.hypot(a[0], a[1], a[2]);
|
|
40239
|
+
return length ? Scale(a, 1 / length) : [0, 0, 0];
|
|
40240
|
+
}
|
|
40241
|
+
GltfGenerator.Normalize = Normalize;
|
|
40242
|
+
/*
|
|
40243
|
+
* Two unit vectors at right angles to an axis and each other, the first along start where one is given.
|
|
40244
|
+
*/
|
|
40245
|
+
function perpendiculars(axis, start) {
|
|
40246
|
+
const n = Normalize(axis);
|
|
40247
|
+
let u = start ? Sub(start, Scale(n, Dot(start, n))) : null;
|
|
40248
|
+
if (!u || Math.hypot(u[0], u[1], u[2]) < 1e-9) {
|
|
40249
|
+
u = Math.abs(n[0]) < 0.9 ? Cross(n, [1, 0, 0]) : Cross(n, [0, 1, 0]);
|
|
40250
|
+
}
|
|
40251
|
+
u = Normalize(u);
|
|
40252
|
+
return [u, Cross(n, u)];
|
|
40253
|
+
}
|
|
40254
|
+
/*
|
|
40255
|
+
* The point on a circle around centre at a given turn, in the plane the two perpendiculars span.
|
|
40256
|
+
*/
|
|
40257
|
+
function onCircle(centre, u, v, radius, angle) {
|
|
40258
|
+
return Add(centre, Add(Scale(u, Math.cos(angle) * radius), Scale(v, Math.sin(angle) * radius)));
|
|
40259
|
+
}
|
|
40260
|
+
/**
|
|
40261
|
+
* Adds a flat disc facing along normal.
|
|
40262
|
+
*/
|
|
40263
|
+
function AddDisc(mesh, params) {
|
|
40264
|
+
const { centre, radius, sides } = params;
|
|
40265
|
+
const normal = Normalize(params.normal);
|
|
40266
|
+
const [u, v] = perpendiculars(normal, params.start);
|
|
40267
|
+
for (let i = 0; i < sides; i++) {
|
|
40268
|
+
const a = onCircle(centre, u, v, radius, i / sides * Math.PI * 2);
|
|
40269
|
+
const b = onCircle(centre, u, v, radius, (i + 1) / sides * Math.PI * 2);
|
|
40270
|
+
mesh.AddTriangle(centre, a, b, normal);
|
|
40271
|
+
}
|
|
40272
|
+
}
|
|
40273
|
+
GltfGenerator.AddDisc = AddDisc;
|
|
40274
|
+
/**
|
|
40275
|
+
* Adds a smooth sided cylinder between two points, closed at the start by default.
|
|
40276
|
+
*/
|
|
40277
|
+
function AddCylinder(mesh, params) {
|
|
40278
|
+
const { start, end, radius, sides } = params;
|
|
40279
|
+
const axis = Normalize(Sub(end, start));
|
|
40280
|
+
const [u, v] = perpendiculars(axis);
|
|
40281
|
+
for (let i = 0; i < sides; i++) {
|
|
40282
|
+
const angleA = i / sides * Math.PI * 2;
|
|
40283
|
+
const angleB = (i + 1) / sides * Math.PI * 2;
|
|
40284
|
+
const outA = onCircle([0, 0, 0], u, v, 1, angleA);
|
|
40285
|
+
const outB = onCircle([0, 0, 0], u, v, 1, angleB);
|
|
40286
|
+
const a0 = onCircle(start, u, v, radius, angleA);
|
|
40287
|
+
const b0 = onCircle(start, u, v, radius, angleB);
|
|
40288
|
+
const a1 = onCircle(end, u, v, radius, angleA);
|
|
40289
|
+
const b1 = onCircle(end, u, v, radius, angleB);
|
|
40290
|
+
const face = Normalize(Add(outA, outB));
|
|
40291
|
+
mesh.AddTriangle(a0, b0, b1, face, [outA, outB, outB]);
|
|
40292
|
+
mesh.AddTriangle(a0, b1, a1, face, [outA, outB, outA]);
|
|
40293
|
+
}
|
|
40294
|
+
if (params.capStart != false) {
|
|
40295
|
+
AddDisc(mesh, { centre: start, normal: Scale(axis, -1), radius, sides });
|
|
40296
|
+
}
|
|
40297
|
+
if (params.capEnd) {
|
|
40298
|
+
AddDisc(mesh, { centre: end, normal: axis, radius, sides });
|
|
40299
|
+
}
|
|
40300
|
+
}
|
|
40301
|
+
GltfGenerator.AddCylinder = AddCylinder;
|
|
40302
|
+
/**
|
|
40303
|
+
* Adds a cone from a base circle to a tip, closed at the base by default.
|
|
40304
|
+
*/
|
|
40305
|
+
function AddCone(mesh, params) {
|
|
40306
|
+
const { base, tip, radius, sides } = params;
|
|
40307
|
+
const toTip = Sub(tip, base);
|
|
40308
|
+
const height = Math.hypot(toTip[0], toTip[1], toTip[2]);
|
|
40309
|
+
const axis = Normalize(toTip);
|
|
40310
|
+
const [u, v] = perpendiculars(axis, params.start);
|
|
40311
|
+
// A side normal leans toward the tip by the slope of the side.
|
|
40312
|
+
const sideNormal = (angle) => Normalize(Add(Scale(onCircle([0, 0, 0], u, v, 1, angle), height), Scale(axis, radius)));
|
|
40313
|
+
for (let i = 0; i < sides; i++) {
|
|
40314
|
+
const angleA = i / sides * Math.PI * 2;
|
|
40315
|
+
const angleB = (i + 1) / sides * Math.PI * 2;
|
|
40316
|
+
const a = onCircle(base, u, v, radius, angleA);
|
|
40317
|
+
const b = onCircle(base, u, v, radius, angleB);
|
|
40318
|
+
const face = sideNormal((angleA + angleB) / 2);
|
|
40319
|
+
mesh.AddTriangle(a, b, tip, face, params.faceted ? undefined : [sideNormal(angleA), sideNormal(angleB), face]);
|
|
40320
|
+
}
|
|
40321
|
+
if (params.cap != false) {
|
|
40322
|
+
AddDisc(mesh, { centre: base, normal: Scale(axis, -1), radius, sides, start: params.start });
|
|
40323
|
+
}
|
|
40324
|
+
}
|
|
40325
|
+
GltfGenerator.AddCone = AddCone;
|
|
40326
|
+
/**
|
|
40327
|
+
* Adds a smooth ring of tube around an axis through centre.
|
|
40328
|
+
*/
|
|
40329
|
+
function AddTorus(mesh, params) {
|
|
40330
|
+
const { centre, radius, tube, segments, sides } = params;
|
|
40331
|
+
const axis = Normalize(params.axis);
|
|
40332
|
+
const [u, v] = perpendiculars(axis);
|
|
40333
|
+
// A grid of shared corners, wrapping round both ways.
|
|
40334
|
+
const first = mesh.VertexCount;
|
|
40335
|
+
for (let i = 0; i < segments; i++) {
|
|
40336
|
+
const out = onCircle([0, 0, 0], u, v, 1, i / segments * Math.PI * 2);
|
|
40337
|
+
for (let j = 0; j < sides; j++) {
|
|
40338
|
+
const turn = j / sides * Math.PI * 2;
|
|
40339
|
+
const normal = Add(Scale(out, Math.cos(turn)), Scale(axis, Math.sin(turn)));
|
|
40340
|
+
mesh.AddVertex(Add(Add(centre, Scale(out, radius)), Scale(normal, tube)), normal);
|
|
40341
|
+
}
|
|
40342
|
+
}
|
|
40343
|
+
const at = (i, j) => first + (i % segments) * sides + (j % sides);
|
|
40344
|
+
const normalAt = (i) => [mesh.normals[i * 3], mesh.normals[i * 3 + 1], mesh.normals[i * 3 + 2]];
|
|
40345
|
+
for (let i = 0; i < segments; i++) {
|
|
40346
|
+
for (let j = 0; j < sides; j++) {
|
|
40347
|
+
const quad = [at(i, j), at(i + 1, j), at(i + 1, j + 1), at(i, j + 1)];
|
|
40348
|
+
const normal = Normalize(Add(normalAt(quad[0]), normalAt(quad[2])));
|
|
40349
|
+
mesh.AddIndexedTriangle(quad[0], quad[1], quad[2], normal);
|
|
40350
|
+
mesh.AddIndexedTriangle(quad[0], quad[2], quad[3], normal);
|
|
40351
|
+
}
|
|
40352
|
+
}
|
|
40353
|
+
}
|
|
40354
|
+
GltfGenerator.AddTorus = AddTorus;
|
|
40355
|
+
/**
|
|
40356
|
+
* Adds a flat convex outline, given in a plane's own across and up coordinates, facing along normal.
|
|
40357
|
+
*/
|
|
40358
|
+
function AddConvexOutline(mesh, params) {
|
|
40359
|
+
const { points, origin, across, up } = params;
|
|
40360
|
+
const normal = Normalize(params.normal);
|
|
40361
|
+
const at = ([x, y]) => Add(origin, Add(Scale(across, x), Scale(up, y)));
|
|
40362
|
+
for (let i = 1; i < points.length - 1; i++) {
|
|
40363
|
+
mesh.AddTriangle(at(points[0]), at(points[i]), at(points[i + 1]), normal);
|
|
40364
|
+
}
|
|
40365
|
+
}
|
|
40366
|
+
GltfGenerator.AddConvexOutline = AddConvexOutline;
|
|
40367
|
+
function align4(length) {
|
|
40368
|
+
return Math.ceil(length / 4) * 4;
|
|
40369
|
+
}
|
|
40370
|
+
function bounds(positions) {
|
|
40371
|
+
const min = [Infinity, Infinity, Infinity];
|
|
40372
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
40373
|
+
for (let i = 0; i < positions.length; i++) {
|
|
40374
|
+
const k = i % 3;
|
|
40375
|
+
min[k] = Math.min(min[k], positions[i]);
|
|
40376
|
+
max[k] = Math.max(max[k], positions[i]);
|
|
40377
|
+
}
|
|
40378
|
+
return { min, max };
|
|
40379
|
+
}
|
|
40380
|
+
/**
|
|
40381
|
+
* Packs a mesh into GLB bytes, under a chain of node matrices (outermost first) when given.
|
|
40382
|
+
*/
|
|
40383
|
+
function ToGlb(params) {
|
|
40384
|
+
var _a, _b, _c;
|
|
40385
|
+
const { mesh, material } = params;
|
|
40386
|
+
const count = mesh.VertexCount;
|
|
40387
|
+
const wide = count > 0xFFFF;
|
|
40388
|
+
const IndexArray = wide ? Uint32Array : Uint16Array;
|
|
40389
|
+
const indexLength = mesh.indices.length * IndexArray.BYTES_PER_ELEMENT;
|
|
40390
|
+
const indexBytes = align4(indexLength);
|
|
40391
|
+
const vertexBytes = count * 12;
|
|
40392
|
+
const bin = new ArrayBuffer(indexBytes + vertexBytes * 2);
|
|
40393
|
+
new IndexArray(bin, 0, mesh.indices.length).set(mesh.indices);
|
|
40394
|
+
new Float32Array(bin, indexBytes, count * 3).set(mesh.positions);
|
|
40395
|
+
new Float32Array(bin, indexBytes + vertexBytes, count * 3).set(mesh.normals);
|
|
40396
|
+
// The mesh node is last, each matrix node holding the next.
|
|
40397
|
+
const matrices = (_a = params.matrices) !== null && _a !== void 0 ? _a : [];
|
|
40398
|
+
const nodes = matrices.map((matrix, i) => ({ matrix, children: [i + 1] }));
|
|
40399
|
+
nodes.push({ mesh: 0 });
|
|
40400
|
+
const json = {
|
|
40401
|
+
asset: { version: "2.0", generator: "bruce-cesium GltfGenerator" },
|
|
40402
|
+
scene: 0,
|
|
40403
|
+
scenes: [{ nodes: [0] }],
|
|
40404
|
+
nodes,
|
|
40405
|
+
meshes: [{ primitives: [{ attributes: { POSITION: 1, NORMAL: 2 }, indices: 0, material: 0, mode: GL_TRIANGLES }] }],
|
|
40406
|
+
materials: [{
|
|
40407
|
+
pbrMetallicRoughness: {
|
|
40408
|
+
baseColorFactor: material.color,
|
|
40409
|
+
metallicFactor: (_b = material.metallic) !== null && _b !== void 0 ? _b : 0,
|
|
40410
|
+
roughnessFactor: (_c = material.roughness) !== null && _c !== void 0 ? _c : 1
|
|
40411
|
+
},
|
|
40412
|
+
doubleSided: Boolean(material.doubleSided)
|
|
40413
|
+
}],
|
|
40414
|
+
buffers: [{ byteLength: bin.byteLength }],
|
|
40415
|
+
bufferViews: [
|
|
40416
|
+
{ buffer: 0, byteOffset: 0, byteLength: indexLength, target: GL_ELEMENT_ARRAY_BUFFER },
|
|
40417
|
+
{ buffer: 0, byteOffset: indexBytes, byteLength: vertexBytes, target: GL_ARRAY_BUFFER },
|
|
40418
|
+
{ buffer: 0, byteOffset: indexBytes + vertexBytes, byteLength: vertexBytes, target: GL_ARRAY_BUFFER }
|
|
40419
|
+
],
|
|
40420
|
+
accessors: [
|
|
40421
|
+
{ bufferView: 0, componentType: wide ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, count: mesh.indices.length, type: "SCALAR" },
|
|
40422
|
+
{ bufferView: 1, componentType: GL_FLOAT, count, type: "VEC3", ...bounds(mesh.positions) },
|
|
40423
|
+
{ bufferView: 2, componentType: GL_FLOAT, count, type: "VEC3" }
|
|
40424
|
+
]
|
|
40425
|
+
};
|
|
40426
|
+
let text = JSON.stringify(json);
|
|
40427
|
+
text += " ".repeat(align4(text.length) - text.length);
|
|
40428
|
+
const jsonBytes = new TextEncoder().encode(text);
|
|
40429
|
+
const glb = new Uint8Array(20 + jsonBytes.length + 8 + bin.byteLength);
|
|
40430
|
+
const view = new DataView(glb.buffer);
|
|
40431
|
+
view.setUint32(0, GLB_MAGIC, true);
|
|
40432
|
+
view.setUint32(4, 2, true);
|
|
40433
|
+
view.setUint32(8, glb.length, true);
|
|
40434
|
+
view.setUint32(12, jsonBytes.length, true);
|
|
40435
|
+
view.setUint32(16, GLB_CHUNK_JSON, true);
|
|
40436
|
+
glb.set(jsonBytes, 20);
|
|
40437
|
+
const binStart = 20 + jsonBytes.length;
|
|
40438
|
+
view.setUint32(binStart, bin.byteLength, true);
|
|
40439
|
+
view.setUint32(binStart + 4, GLB_CHUNK_BIN, true);
|
|
40440
|
+
glb.set(new Uint8Array(bin), binStart + 8);
|
|
40441
|
+
return glb;
|
|
40442
|
+
}
|
|
40443
|
+
GltfGenerator.ToGlb = ToGlb;
|
|
40444
|
+
/**
|
|
40445
|
+
* Packs a mesh into a GLB data URI, which loads as a model url with nothing to fetch.
|
|
40446
|
+
*/
|
|
40447
|
+
function ToDataUri(params) {
|
|
40448
|
+
const glb = ToGlb(params);
|
|
40449
|
+
let binary = "";
|
|
40450
|
+
for (let i = 0; i < glb.length; i += 0x8000) {
|
|
40451
|
+
binary += String.fromCharCode.apply(null, glb.subarray(i, i + 0x8000));
|
|
40452
|
+
}
|
|
40453
|
+
return "data:model/gltf-binary;base64," + btoa(binary);
|
|
40454
|
+
}
|
|
40455
|
+
GltfGenerator.ToDataUri = ToDataUri;
|
|
40456
|
+
})(GltfGenerator || (GltfGenerator = {}));
|
|
40457
|
+
|
|
40458
|
+
// Sides on an arrow's shaft and cone.
|
|
40459
|
+
const ARROW_SIDES = 16;
|
|
40460
|
+
const SHAFT_RADIUS = 2.4;
|
|
40461
|
+
const SHAFT_LENGTH = 265;
|
|
40462
|
+
const CONE_RADIUS = 10;
|
|
40463
|
+
const CONE_BASE = 264.6;
|
|
40464
|
+
const CONE_TIP = 306.3;
|
|
40465
|
+
const RING_RADIUS = 210;
|
|
40466
|
+
const RING_TUBE = 1;
|
|
40467
|
+
const RING_SEGMENTS = 60;
|
|
40468
|
+
const RING_SIDES = 10;
|
|
40469
|
+
// The ring's two arrowheads sit either side of its 45 degree mark, each pointing back toward it.
|
|
40470
|
+
const RING_MARK_ANGLES = [137.64, -47.64];
|
|
40471
|
+
const RING_MARK_LENGTH = 5.82;
|
|
40472
|
+
const RING_MARK_CENTRE = 209.8;
|
|
40473
|
+
const RING_MARK_RADIUS = 8.5;
|
|
40474
|
+
const RING_MARK_SIDES = 8;
|
|
40475
|
+
// Turns the original models' Y up node into the Z up frame the pieces were drawn in.
|
|
40476
|
+
const ROOT_MATRIX = [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1];
|
|
40477
|
+
// Points a piece drawn along +Z down another axis, as the original models' mesh nodes did.
|
|
40478
|
+
const TO_X_MATRIX = [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1];
|
|
40479
|
+
const TO_Y_ARROW_MATRIX = [0, 0, -1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1];
|
|
40480
|
+
const TO_Y_RING_MATRIX = [1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1];
|
|
40481
|
+
const RED = { color: [1, 0, 0, 1] };
|
|
40482
|
+
const GREEN = { color: [0.2196, 0.5216, 0.1647, 1] };
|
|
40483
|
+
const BLUE = { color: [0.1608, 0.3843, 0.698, 1] };
|
|
40484
|
+
const LETTER_X = {
|
|
40485
|
+
across: [0, 1, 0],
|
|
40486
|
+
facing: [-1, 0, 0],
|
|
40487
|
+
strokes: [
|
|
40488
|
+
[[16.4, 318.6], [16.4, 324.2], [-19.4, 349.8], [-19.4, 343.9]],
|
|
40489
|
+
[[-19.4, 316.9], [-19.4, 322.6], [16.4, 348.8], [16.4, 343.6]]
|
|
40490
|
+
]
|
|
40491
|
+
};
|
|
40492
|
+
const LETTER_Y = {
|
|
40493
|
+
across: [0, 1, 0],
|
|
40494
|
+
facing: [-1, 0, 0],
|
|
40495
|
+
strokes: [
|
|
40496
|
+
[[-1.9, 320.1], [2.8, 320.1], [2.8, 337.7], [-1.9, 337.7]],
|
|
40497
|
+
[[-1.9, 335.3], [2.8, 335.3], [-10.7, 355.9], [-16.2, 355.9]],
|
|
40498
|
+
[[-1.9, 335.3], [2.8, 335.3], [16.6, 355.9], [10.9, 355.9]]
|
|
40499
|
+
]
|
|
40500
|
+
};
|
|
40501
|
+
const LETTER_Z = {
|
|
40502
|
+
across: [1, 0, 0],
|
|
40503
|
+
facing: [0, -1, 0],
|
|
40504
|
+
strokes: [
|
|
40505
|
+
[[-14.6, 319], [13.7, 319], [13.7, 323.3], [-14.6, 323.3]],
|
|
40506
|
+
[[-14.6, 323.3], [-9.1, 323.3], [13.1, 350.6], [7.5, 350.6]],
|
|
40507
|
+
[[-12.5, 350.6], [13.1, 350.6], [13.1, 354.8], [-12.5, 354.8]]
|
|
40508
|
+
]
|
|
40509
|
+
};
|
|
40510
|
+
/*
|
|
40511
|
+
* An axis arrow along +Z: shaft, cone and the axis letter past the tip.
|
|
40512
|
+
*/
|
|
40513
|
+
function arrowMesh(letter) {
|
|
40514
|
+
const mesh = new GltfGenerator.Mesh();
|
|
40515
|
+
GltfGenerator.AddCylinder(mesh, { start: [0, 0, 0], end: [0, 0, SHAFT_LENGTH], radius: SHAFT_RADIUS, sides: ARROW_SIDES });
|
|
40516
|
+
GltfGenerator.AddCone(mesh, { base: [0, 0, CONE_BASE], tip: [0, 0, CONE_TIP], radius: CONE_RADIUS, sides: ARROW_SIDES });
|
|
40517
|
+
for (const stroke of letter.strokes) {
|
|
40518
|
+
GltfGenerator.AddConvexOutline(mesh, { points: stroke, origin: [0, 0, 0], across: letter.across, up: [0, 0, 1], normal: letter.facing });
|
|
40519
|
+
}
|
|
40520
|
+
return mesh;
|
|
40521
|
+
}
|
|
40522
|
+
function onRing(degrees, radius) {
|
|
40523
|
+
const angle = degrees * Math.PI / 180;
|
|
40524
|
+
return [Math.cos(angle) * radius, Math.sin(angle) * radius, 0];
|
|
40525
|
+
}
|
|
40526
|
+
/*
|
|
40527
|
+
* A rotation ring about +Z with its two arrowheads.
|
|
40528
|
+
*/
|
|
40529
|
+
function ringMesh() {
|
|
40530
|
+
const mesh = new GltfGenerator.Mesh();
|
|
40531
|
+
GltfGenerator.AddTorus(mesh, {
|
|
40532
|
+
centre: [0, 0, 0],
|
|
40533
|
+
axis: [0, 0, 1],
|
|
40534
|
+
radius: RING_RADIUS,
|
|
40535
|
+
tube: RING_TUBE,
|
|
40536
|
+
segments: RING_SEGMENTS,
|
|
40537
|
+
sides: RING_SIDES
|
|
40538
|
+
});
|
|
40539
|
+
for (const degrees of RING_MARK_ANGLES) {
|
|
40540
|
+
const toward = degrees > 45 ? -RING_MARK_LENGTH : RING_MARK_LENGTH;
|
|
40541
|
+
GltfGenerator.AddCone(mesh, {
|
|
40542
|
+
base: onRing(degrees, RING_MARK_CENTRE),
|
|
40543
|
+
tip: onRing(degrees + toward, RING_MARK_CENTRE),
|
|
40544
|
+
radius: RING_MARK_RADIUS,
|
|
40545
|
+
sides: RING_MARK_SIDES,
|
|
40546
|
+
faceted: true,
|
|
40547
|
+
// A rim corner points at the ring's centre, as the original arrowheads' did.
|
|
40548
|
+
start: onRing(degrees, 1)
|
|
40549
|
+
});
|
|
40550
|
+
}
|
|
40551
|
+
return mesh;
|
|
40552
|
+
}
|
|
40553
|
+
/**
|
|
40554
|
+
* The transform gizmo's pieces as GLB data URIs, built on first use so there are no model files to host.
|
|
40555
|
+
* Sizes, colours and frames match the models they replaced (Navigator's public/res/gizmo), scales included.
|
|
40556
|
+
*/
|
|
40557
|
+
var GltfGizmo;
|
|
40558
|
+
(function (GltfGizmo) {
|
|
40559
|
+
let EPiece;
|
|
40560
|
+
(function (EPiece) {
|
|
40561
|
+
EPiece["X"] = "x";
|
|
40562
|
+
EPiece["Y"] = "y";
|
|
40563
|
+
EPiece["Z"] = "z";
|
|
40564
|
+
EPiece["XRotation"] = "x-rot";
|
|
40565
|
+
EPiece["YRotation"] = "y-rot";
|
|
40566
|
+
EPiece["ZRotation"] = "z-rot";
|
|
40567
|
+
})(EPiece = GltfGizmo.EPiece || (GltfGizmo.EPiece = {}));
|
|
40568
|
+
const BUILDERS = {
|
|
40569
|
+
[EPiece.X]: () => GltfGenerator.ToDataUri({ mesh: arrowMesh(LETTER_X), material: RED, matrices: [ROOT_MATRIX, TO_X_MATRIX] }),
|
|
40570
|
+
[EPiece.Y]: () => GltfGenerator.ToDataUri({ mesh: arrowMesh(LETTER_Y), material: GREEN, matrices: [ROOT_MATRIX, TO_Y_ARROW_MATRIX] }),
|
|
40571
|
+
[EPiece.Z]: () => GltfGenerator.ToDataUri({ mesh: arrowMesh(LETTER_Z), material: BLUE, matrices: [ROOT_MATRIX] }),
|
|
40572
|
+
[EPiece.XRotation]: () => GltfGenerator.ToDataUri({ mesh: ringMesh(), material: RED, matrices: [ROOT_MATRIX, TO_X_MATRIX] }),
|
|
40573
|
+
[EPiece.YRotation]: () => GltfGenerator.ToDataUri({ mesh: ringMesh(), material: GREEN, matrices: [ROOT_MATRIX, TO_Y_RING_MATRIX] }),
|
|
40574
|
+
[EPiece.ZRotation]: () => GltfGenerator.ToDataUri({ mesh: ringMesh(), material: BLUE, matrices: [ROOT_MATRIX] })
|
|
40575
|
+
};
|
|
40576
|
+
// Built pieces, so every gizmo shares one string per piece and CesiumJS's model cache sees the same url.
|
|
40577
|
+
const built = {};
|
|
40578
|
+
/**
|
|
40579
|
+
* Returns a piece's model as a data URI, to pass wherever a model url is taken.
|
|
40580
|
+
*/
|
|
40581
|
+
function GetUri(piece) {
|
|
40582
|
+
if (!built[piece]) {
|
|
40583
|
+
built[piece] = BUILDERS[piece]();
|
|
40584
|
+
}
|
|
40585
|
+
return built[piece];
|
|
40586
|
+
}
|
|
40587
|
+
GltfGizmo.GetUri = GetUri;
|
|
40588
|
+
})(GltfGizmo || (GltfGizmo = {}));
|
|
40589
|
+
|
|
40590
|
+
// viewer[CLASS_INSTANCE_KEY] will point at an instance of MapGridHandler.
|
|
40591
|
+
const CLASS_INSTANCE_KEY = "nextspace-navigator-grid-handler";
|
|
40592
|
+
// viewer[UPDATE_MARKER_KEY] will point at a number that is incremented every time the grid is updated.
|
|
40593
|
+
// This is used to determine if the grid is still valid or if it needs to be redrawn.
|
|
40594
|
+
const UPDATE_MARKER_KEY = "nextspace-marker-grid";
|
|
40595
|
+
// viewer[LAST_SETTINGS_KEY] will point at the last settings used for the grid.
|
|
40596
|
+
const LAST_SETTINGS_KEY = "nextspace-navigator-last-settings-grid";
|
|
40597
|
+
/*
|
|
40598
|
+
* The point a distance in metres along a heading in degrees from another, over a spherical earth.
|
|
40599
|
+
*/
|
|
40600
|
+
function offsetPoint$1(point, distance, heading) {
|
|
40601
|
+
// Radius of earth.
|
|
40602
|
+
const radius = 6371e3;
|
|
40603
|
+
const δ = distance / radius;
|
|
40604
|
+
const θ = Math$1.toRadians(heading);
|
|
40605
|
+
const φ1 = Math$1.toRadians(point.latitude);
|
|
40606
|
+
const λ1 = Math$1.toRadians(point.longitude);
|
|
40607
|
+
const sinφ2 = Math.sin(φ1) * Math.cos(δ) + Math.cos(φ1) * Math.sin(δ) * Math.cos(θ);
|
|
40608
|
+
const φ2 = Math.asin(sinφ2);
|
|
40609
|
+
const y = Math.sin(θ) * Math.sin(δ) * Math.cos(φ1);
|
|
40610
|
+
const x = Math.cos(δ) - Math.sin(φ1) * sinφ2;
|
|
40611
|
+
const λ2 = λ1 + Math.atan2(y, x);
|
|
40612
|
+
return {
|
|
40613
|
+
altitude: point.altitude,
|
|
40614
|
+
latitude: Math$1.toDegrees(φ2),
|
|
40615
|
+
longitude: Math$1.toDegrees(λ2)
|
|
40616
|
+
};
|
|
40617
|
+
}
|
|
40618
|
+
/**
|
|
40619
|
+
* Handler for drawing a grid of lines on the map with a specified spacing.
|
|
40620
|
+
* Initially this grid is for model-space viewing which means we start at 0,0 lat/lon and have it expand from there.
|
|
40621
|
+
* However, it should be a general-use tool for drawing a grid anywhere.
|
|
40622
|
+
*
|
|
40623
|
+
* It reacts to camera changes and draws the grid within view with padding.
|
|
40624
|
+
* This helps avoid performance issues around drawing too many lines.
|
|
40625
|
+
*/
|
|
40626
|
+
class MapGridHandler {
|
|
40627
|
+
constructor(viewer, spacingInMeters = 100, modelSpace = false) {
|
|
40628
|
+
this.gridCenterGizmoPieces = [];
|
|
40629
|
+
this.maxCacheSize = 1000;
|
|
40630
|
+
// === Thresholds for grid stability.
|
|
40631
|
+
// As a fraction of current grid extent.
|
|
40632
|
+
this.CAMERA_MOVE_THRESHOLD = 0.5;
|
|
40633
|
+
// 40% change in camera height triggers redraw.
|
|
40634
|
+
this.HEIGHT_CHANGE_THRESHOLD = 0.4;
|
|
40635
|
+
// 40% change in grid extent triggers redraw.
|
|
40636
|
+
this.GRID_EXTENT_CHANGE_THRESHOLD = 0.4;
|
|
40637
|
+
// 5km - distance that triggers origin reset.
|
|
40638
|
+
this.EXTREME_DISTANCE_THRESHOLD = 5000;
|
|
40639
|
+
// Grid limits to prevent drawing too many lines.
|
|
40640
|
+
this.MAX_LINES = 500;
|
|
40641
|
+
// 50% padding around visible area.
|
|
40642
|
+
this.VIEW_PADDING_FACTOR = 0.5;
|
|
40643
|
+
// Minimum pixels between grid lines to show them.
|
|
40644
|
+
this.MIN_GRID_PIXEL_SIZE = 20;
|
|
40645
|
+
// Base ratio - will be adjusted dynamically based on spacing size and camera height.
|
|
40646
|
+
this.BASE_MAX_VISIBILITY_RATIO = 30;
|
|
40647
|
+
// Height to spacing ratio.
|
|
40648
|
+
this.HEIGHT_TO_SPACING_RATIO = 100;
|
|
40649
|
+
// === Label settings
|
|
40650
|
+
// Label every nth intersection.
|
|
40651
|
+
this.LABEL_INTERVAL = 2;
|
|
40652
|
+
// Maximum number of labels to show.
|
|
40653
|
+
this.MAX_LABELS = 100;
|
|
40654
|
+
// Spacing levels to use for adaptive spacing.
|
|
40655
|
+
this.SPACING_LEVELS = [
|
|
40656
|
+
1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 300, 400, 500, 1000, 2000, 2500, 5000, 10000, 20000, 25000, 50000, 100000
|
|
40657
|
+
];
|
|
40658
|
+
// Minimum zoom distance to prevent precision issues.
|
|
40659
|
+
this.MINIMUM_ZOOM_DISTANCE = 40;
|
|
40660
|
+
// Base spacing to use for adaptive spacing.
|
|
40661
|
+
this.BASE_SPACING = 1;
|
|
40662
|
+
// Maximum number of attempts to find a suitable spacing.
|
|
40663
|
+
this.MAX_ADAPTIVE_ATTEMPTS = 5;
|
|
40664
|
+
this.viewer = viewer;
|
|
40665
|
+
this.spacingInMeters = spacingInMeters;
|
|
40666
|
+
this.isUpdating = false;
|
|
40667
|
+
this.modelSpace = modelSpace;
|
|
40668
|
+
this.lastCameraPosition = null;
|
|
40669
|
+
this.fixedGridOrigin = null;
|
|
40670
|
+
this.lastGridExtent = 0;
|
|
40671
|
+
this.offsetCache = new Map();
|
|
40672
|
+
this.gridPrimitives = new PrimitiveCollection();
|
|
40673
|
+
this.viewer.scene.primitives.add(this.gridPrimitives);
|
|
40674
|
+
this.currentMarker = viewer[UPDATE_MARKER_KEY] || 1;
|
|
40675
|
+
const isMac = typeof navigator !== "undefined" && (navigator.platform.toUpperCase().indexOf("MAC") !== -1 ||
|
|
40676
|
+
navigator.userAgent.toUpperCase().indexOf("MAC") !== -1);
|
|
40677
|
+
if (modelSpace && isMac) {
|
|
40678
|
+
console.log("[MAC-FIX] Applying camera distance limits for Mac");
|
|
40679
|
+
viewer.scene.screenSpaceCameraController.minimumZoomDistance = this.MINIMUM_ZOOM_DISTANCE;
|
|
40680
|
+
}
|
|
40681
|
+
const manager = ViewerUtils.GetManager({
|
|
40682
|
+
viewer: this.viewer,
|
|
40683
|
+
createIfMissing: false
|
|
40684
|
+
});
|
|
40685
|
+
if (manager) {
|
|
40686
|
+
this.cameraChangeRemoval = manager.Monitor.Updated().Subscribe(() => {
|
|
40687
|
+
this.onCameraChanged();
|
|
40688
|
+
});
|
|
40689
|
+
}
|
|
40690
|
+
// Initial grid draw.
|
|
40691
|
+
this.onCameraChanged();
|
|
40692
|
+
}
|
|
40693
|
+
Update(spacingInMeters, modelSpace) {
|
|
40694
|
+
this.currentMarker = this.viewer[UPDATE_MARKER_KEY] || 1;
|
|
40695
|
+
let needsUpdate = false;
|
|
40696
|
+
if (this.spacingInMeters !== spacingInMeters) {
|
|
40697
|
+
this.spacingInMeters = spacingInMeters;
|
|
40698
|
+
needsUpdate = true;
|
|
40699
|
+
}
|
|
40700
|
+
if (modelSpace !== undefined && this.modelSpace !== modelSpace) {
|
|
40701
|
+
this.modelSpace = modelSpace;
|
|
40702
|
+
needsUpdate = true;
|
|
40703
|
+
}
|
|
40704
|
+
if (needsUpdate) {
|
|
40705
|
+
this.clearGrid();
|
|
40706
|
+
// When spacing or model space changes, clear the cached origin to force recalculation
|
|
40707
|
+
// This ensures grid alignment at the new spacing.
|
|
40708
|
+
this.fixedGridOrigin = null;
|
|
40709
|
+
this.offsetCache.clear();
|
|
40710
|
+
this.onCameraChanged();
|
|
40711
|
+
}
|
|
40712
|
+
}
|
|
40713
|
+
Dispose() {
|
|
40714
|
+
this.clearGrid();
|
|
40715
|
+
this.clearGizmoPieces();
|
|
40716
|
+
if (this.cameraChangeRemoval) {
|
|
40717
|
+
this.cameraChangeRemoval();
|
|
40718
|
+
this.cameraChangeRemoval = null;
|
|
40719
|
+
}
|
|
40720
|
+
if (this.gridPrimitives) {
|
|
40721
|
+
this.viewer.scene.primitives.remove(this.gridPrimitives);
|
|
40722
|
+
this.gridPrimitives = null;
|
|
40723
|
+
}
|
|
40724
|
+
if (this.viewer) {
|
|
40725
|
+
this.viewer = null;
|
|
40726
|
+
}
|
|
40727
|
+
this.offsetCache.clear();
|
|
40728
|
+
this.fixedGridOrigin = null;
|
|
40729
|
+
}
|
|
40730
|
+
clearGrid() {
|
|
40731
|
+
if (this.gridPrimitives) {
|
|
40732
|
+
this.gridPrimitives.removeAll();
|
|
40733
|
+
this.gridLines = null;
|
|
40734
|
+
this.gridLabels = null;
|
|
40735
|
+
}
|
|
40736
|
+
}
|
|
40737
|
+
calculateAdaptiveSpacing(cameraHeight, baseSpacing) {
|
|
40738
|
+
// Define spacing levels that look good (powers of 2, 5, and 10)
|
|
40739
|
+
const spacingLevels = this.SPACING_LEVELS;
|
|
40740
|
+
// Ensure base spacing is at least 1m
|
|
40741
|
+
const adjustedBaseSpacing = Math.max(this.BASE_SPACING, baseSpacing);
|
|
40742
|
+
// For very close cameras, use much smaller spacing regardless of base
|
|
40743
|
+
if (cameraHeight < 10) {
|
|
40744
|
+
// Find the smallest reasonable spacing for this height
|
|
40745
|
+
// Rule: spacing should be roughly 1/20th to 1/50th of camera height, but at least 1m
|
|
40746
|
+
const targetSpacing = Math.max(this.BASE_SPACING, cameraHeight / 30);
|
|
40747
|
+
// Find the closest spacing level to our target
|
|
40748
|
+
let bestSpacing = this.BASE_SPACING; // Start with minimum
|
|
40749
|
+
let bestDifference = Math.abs(1 - targetSpacing);
|
|
40750
|
+
for (const spacing of spacingLevels) {
|
|
40751
|
+
if (spacing >= this.BASE_SPACING) { // Only consider valid spacings
|
|
40752
|
+
const difference = Math.abs(spacing - targetSpacing);
|
|
40753
|
+
if (difference < bestDifference) {
|
|
40754
|
+
bestSpacing = spacing;
|
|
40755
|
+
bestDifference = difference;
|
|
40756
|
+
}
|
|
40757
|
+
}
|
|
40758
|
+
}
|
|
40759
|
+
return bestSpacing;
|
|
40760
|
+
}
|
|
40761
|
+
// For medium distances (10m - 200m), scale more gradually
|
|
40762
|
+
if (cameraHeight < 200) {
|
|
40763
|
+
const targetSpacing = cameraHeight / 10; // More conservative scaling// Find closest spacing level, but prefer going up from base spacing
|
|
40764
|
+
let bestSpacing = adjustedBaseSpacing;
|
|
40765
|
+
let bestDifference = Math.abs(adjustedBaseSpacing - targetSpacing);
|
|
40766
|
+
for (const spacing of spacingLevels) {
|
|
40767
|
+
if (spacing >= Math.min(adjustedBaseSpacing, targetSpacing)) {
|
|
40768
|
+
const difference = Math.abs(spacing - targetSpacing);
|
|
40769
|
+
if (difference < bestDifference) {
|
|
40770
|
+
bestSpacing = spacing;
|
|
40771
|
+
bestDifference = difference;
|
|
40772
|
+
}
|
|
40773
|
+
}
|
|
40774
|
+
}
|
|
40775
|
+
return bestSpacing;
|
|
40776
|
+
}
|
|
40777
|
+
// For far distances (100m+), scale up aggressively
|
|
40778
|
+
const targetSpacing = cameraHeight / 20;
|
|
40779
|
+
// Find the spacing level that's closest to target but not smaller than base
|
|
40780
|
+
let bestSpacing = adjustedBaseSpacing;
|
|
40781
|
+
let bestDifference = Math.abs(adjustedBaseSpacing - targetSpacing);
|
|
40782
|
+
for (const spacing of spacingLevels) {
|
|
40783
|
+
if (spacing >= adjustedBaseSpacing) {
|
|
40784
|
+
const difference = Math.abs(spacing - targetSpacing);
|
|
40785
|
+
if (difference < bestDifference) {
|
|
40786
|
+
bestSpacing = spacing;
|
|
40787
|
+
bestDifference = difference;
|
|
40788
|
+
}
|
|
40789
|
+
}
|
|
40790
|
+
}
|
|
40791
|
+
return bestSpacing;
|
|
40792
|
+
}
|
|
40793
|
+
/*
|
|
40794
|
+
* The point model-space treats as 0,0,0: the UCS in UCS placement, otherwise 0,0 lat/lon at sea level.
|
|
40795
|
+
*/
|
|
40796
|
+
modelSpaceOrigin() {
|
|
40797
|
+
const origin = ViewUtils.IsModelSpaceUcs(this.viewer) ? ViewUtils.GetModelSpaceOrigin(this.viewer) : null;
|
|
40798
|
+
return origin !== null && origin !== void 0 ? origin : { latitude: 0, longitude: 0, altitude: 0 };
|
|
40799
|
+
}
|
|
40800
|
+
/*
|
|
40801
|
+
* The origin as a scene position, where the axis gizmo sits.
|
|
40802
|
+
*/
|
|
40803
|
+
modelSpaceOriginPos3d() {
|
|
40804
|
+
const origin = this.modelSpaceOrigin();
|
|
40805
|
+
return Cartesian3.fromDegrees(origin.longitude, origin.latitude, origin.altitude);
|
|
40806
|
+
}
|
|
40807
|
+
drawGizmoPieces() {
|
|
40808
|
+
if (this.gridCenterGizmoPieces.length) {
|
|
40809
|
+
return;
|
|
40810
|
+
}
|
|
40811
|
+
// X.
|
|
40812
|
+
{
|
|
40813
|
+
const pos3d = this.modelSpaceOriginPos3d();
|
|
40814
|
+
const scale = new CallbackProperty(() => Cartesian3.distance(this.viewer.camera.position, pos3d) * 0.0002, false);
|
|
40815
|
+
const orientation = Transforms.headingPitchRollQuaternion(pos3d, new HeadingPitchRoll(Math$1.toRadians(90), 0, 0));
|
|
40816
|
+
const entity = this.viewer.entities.add(new Entity({
|
|
40817
|
+
model: {
|
|
40818
|
+
uri: GltfGizmo.GetUri(GltfGizmo.EPiece.X),
|
|
40819
|
+
heightReference: HeightReference.NONE,
|
|
40820
|
+
shadows: ShadowMode.DISABLED,
|
|
40821
|
+
distanceDisplayCondition: new DistanceDisplayCondition(0, Number.MAX_VALUE),
|
|
40822
|
+
scale
|
|
40823
|
+
},
|
|
40824
|
+
position: pos3d,
|
|
40825
|
+
orientation: new ConstantProperty(orientation)
|
|
40826
|
+
}));
|
|
40827
|
+
this.gridCenterGizmoPieces.push(entity);
|
|
40828
|
+
}
|
|
40829
|
+
// Y.
|
|
40830
|
+
{
|
|
40831
|
+
const pos3d = this.modelSpaceOriginPos3d();
|
|
40832
|
+
const scale = new CallbackProperty(() => Cartesian3.distance(this.viewer.camera.position, pos3d) * 0.0002, false);
|
|
40833
|
+
const orientation = Transforms.headingPitchRollQuaternion(pos3d, new HeadingPitchRoll(Math$1.toRadians(90), 0, 0));
|
|
40834
|
+
const entity = this.viewer.entities.add(new Entity({
|
|
40835
|
+
model: {
|
|
40836
|
+
uri: GltfGizmo.GetUri(GltfGizmo.EPiece.Y),
|
|
40837
|
+
heightReference: HeightReference.NONE,
|
|
40838
|
+
shadows: ShadowMode.DISABLED,
|
|
40839
|
+
distanceDisplayCondition: new DistanceDisplayCondition(0, Number.MAX_VALUE),
|
|
40840
|
+
scale
|
|
40841
|
+
},
|
|
40842
|
+
position: pos3d,
|
|
40843
|
+
orientation: new ConstantProperty(orientation)
|
|
40844
|
+
}));
|
|
40845
|
+
this.gridCenterGizmoPieces.push(entity);
|
|
40846
|
+
}
|
|
40847
|
+
// Z.
|
|
40848
|
+
{
|
|
40849
|
+
const pos3d = this.modelSpaceOriginPos3d();
|
|
40850
|
+
const scale = new CallbackProperty(() => Cartesian3.distance(this.viewer.camera.position, pos3d) * 0.0002, false);
|
|
40851
|
+
const orientation = Transforms.headingPitchRollQuaternion(pos3d, new HeadingPitchRoll(Math$1.toRadians(90), 0, 0));
|
|
40852
|
+
const entity = this.viewer.entities.add(new Entity({
|
|
40853
|
+
model: {
|
|
40854
|
+
uri: GltfGizmo.GetUri(GltfGizmo.EPiece.Z),
|
|
40855
|
+
heightReference: HeightReference.NONE,
|
|
40856
|
+
shadows: ShadowMode.DISABLED,
|
|
40857
|
+
distanceDisplayCondition: new DistanceDisplayCondition(0, Number.MAX_VALUE),
|
|
40858
|
+
scale
|
|
40859
|
+
},
|
|
40860
|
+
position: pos3d,
|
|
40861
|
+
orientation: new ConstantProperty(orientation)
|
|
40862
|
+
}));
|
|
40863
|
+
this.gridCenterGizmoPieces.push(entity);
|
|
40864
|
+
}
|
|
40865
|
+
}
|
|
40866
|
+
clearGizmoPieces() {
|
|
40867
|
+
for (const piece of this.gridCenterGizmoPieces) {
|
|
40868
|
+
if (piece && this.viewer.entities.contains(piece)) {
|
|
40869
|
+
this.viewer.entities.remove(piece);
|
|
40870
|
+
}
|
|
40871
|
+
}
|
|
40872
|
+
this.gridCenterGizmoPieces = [];
|
|
40873
|
+
}
|
|
40874
|
+
onCameraChanged() {
|
|
40875
|
+
if (this.isUpdating) {
|
|
40876
|
+
return;
|
|
40877
|
+
}
|
|
40878
|
+
else if (this.currentMarker !== this.viewer[UPDATE_MARKER_KEY]) {
|
|
40879
|
+
return;
|
|
40880
|
+
}
|
|
40881
|
+
this.isUpdating = true;
|
|
40882
|
+
// Small delay to avoid excessive updates during camera movement.
|
|
40883
|
+
setTimeout(() => {
|
|
40884
|
+
if (this.currentMarker !== this.viewer[UPDATE_MARKER_KEY]) {
|
|
40885
|
+
this.isUpdating = false;
|
|
40886
|
+
return;
|
|
40887
|
+
}
|
|
40888
|
+
try {
|
|
40889
|
+
// The grid goes first, since it notices when the origin has moved and the gizmo has to follow.
|
|
40890
|
+
this.updateGrid();
|
|
40891
|
+
if (this.modelSpace) {
|
|
40892
|
+
this.drawGizmoPieces();
|
|
40893
|
+
}
|
|
40894
|
+
else {
|
|
40895
|
+
this.clearGizmoPieces();
|
|
40896
|
+
}
|
|
40897
|
+
}
|
|
40898
|
+
catch (e) {
|
|
40899
|
+
console.error(e);
|
|
40900
|
+
}
|
|
40901
|
+
finally {
|
|
40902
|
+
this.isUpdating = false;
|
|
40903
|
+
}
|
|
40904
|
+
}, 100);
|
|
40905
|
+
}
|
|
40906
|
+
cachedOffsetPoint(point, distance, heading) {
|
|
40907
|
+
const key = `${point.latitude.toFixed(8)},${point.longitude.toFixed(8)},${distance.toFixed(1)},${heading}`;
|
|
40908
|
+
if (this.offsetCache.has(key)) {
|
|
40909
|
+
return this.offsetCache.get(key);
|
|
40910
|
+
}
|
|
40911
|
+
const result = offsetPoint$1(point, distance, heading);
|
|
40912
|
+
this.offsetCache.set(key, result);
|
|
40913
|
+
if (this.offsetCache.size > this.maxCacheSize) {
|
|
40914
|
+
const keys = Array.from(this.offsetCache.keys());
|
|
40915
|
+
for (let i = 0; i < 100; i++) {
|
|
40916
|
+
this.offsetCache.delete(keys[i]);
|
|
40917
|
+
}
|
|
40918
|
+
}
|
|
40919
|
+
return result;
|
|
40920
|
+
}
|
|
40921
|
+
/**
|
|
40922
|
+
* Calculates a dynamic visibility ratio based on spacing size.
|
|
40923
|
+
* For small grid spacings, we can show the grid from farther away.
|
|
40924
|
+
* For large grid spacings, we need to hide it sooner to prevent performance issues.
|
|
40925
|
+
*/
|
|
40926
|
+
getMaxVisibilityRatio() {
|
|
40927
|
+
if (this.spacingInMeters <= 10) {
|
|
40928
|
+
return this.BASE_MAX_VISIBILITY_RATIO;
|
|
40929
|
+
}
|
|
40930
|
+
if (this.spacingInMeters <= 100) {
|
|
40931
|
+
const factor = 1 - ((this.spacingInMeters - 10) / 90);
|
|
40932
|
+
return this.BASE_MAX_VISIBILITY_RATIO * (0.5 + (factor * 0.5));
|
|
40933
|
+
}
|
|
40934
|
+
const largeGridFactor = Math.min(1, 100 / this.spacingInMeters);
|
|
40935
|
+
return this.BASE_MAX_VISIBILITY_RATIO * 0.5 * largeGridFactor;
|
|
40936
|
+
}
|
|
40937
|
+
updateGrid() {
|
|
40938
|
+
const cameraPosition = this.viewer.camera.position;
|
|
40939
|
+
const cameraCartographic = Cartographic.fromCartesian(cameraPosition);
|
|
40940
|
+
const cameraHeight = cameraCartographic.height;
|
|
40941
|
+
let adaptiveSpacing = this.calculateAdaptiveSpacing(cameraHeight, this.spacingInMeters);
|
|
40942
|
+
// Calculate visible area.
|
|
40943
|
+
const visibleArea = this.calculateVisibleArea();
|
|
40944
|
+
if (!visibleArea) {
|
|
40945
|
+
return;
|
|
40946
|
+
}
|
|
40947
|
+
let densityCheckPassed = false;
|
|
40948
|
+
let attempts = 0;
|
|
40949
|
+
while (!densityCheckPassed && attempts < this.MAX_ADAPTIVE_ATTEMPTS) {
|
|
40950
|
+
if (this.isGridDensityAcceptable(visibleArea, cameraHeight, adaptiveSpacing)) {
|
|
40951
|
+
densityCheckPassed = true;
|
|
40952
|
+
}
|
|
40953
|
+
else {
|
|
40954
|
+
adaptiveSpacing *= 2;
|
|
40955
|
+
attempts++;
|
|
40956
|
+
}
|
|
40957
|
+
}
|
|
40958
|
+
// The origin follows the UCS of what is shown, so the grid moves with it when that changes.
|
|
40959
|
+
if (this.modelSpace && this.fixedGridOrigin && !Carto.IsEqual(this.fixedGridOrigin, this.modelSpaceOrigin())) {
|
|
40960
|
+
this.fixedGridOrigin = null;
|
|
40961
|
+
this.lastCameraPosition = null;
|
|
40962
|
+
this.clearGizmoPieces();
|
|
40963
|
+
}
|
|
40964
|
+
// Calculate grid origin if we don't have one yet.
|
|
40965
|
+
if (!this.fixedGridOrigin) {
|
|
40966
|
+
if (this.modelSpace) {
|
|
40967
|
+
this.fixedGridOrigin = this.modelSpaceOrigin();
|
|
40968
|
+
}
|
|
40969
|
+
else {
|
|
40970
|
+
const centerCartographic = Cartographic.fromCartesian(visibleArea.centerCartesian);
|
|
40971
|
+
const centerPoint = {
|
|
40972
|
+
latitude: Math$1.toDegrees(centerCartographic.latitude),
|
|
40973
|
+
longitude: Math$1.toDegrees(centerCartographic.longitude),
|
|
40974
|
+
altitude: 0
|
|
40975
|
+
};
|
|
40976
|
+
// Simple attempt at snapping to the grid, should do something smarter.
|
|
40977
|
+
this.fixedGridOrigin = {
|
|
40978
|
+
latitude: Math.round(centerPoint.latitude * 100000) / 100000,
|
|
40979
|
+
longitude: Math.round(centerPoint.longitude * 100000) / 100000,
|
|
40980
|
+
altitude: 0
|
|
40981
|
+
};
|
|
40982
|
+
}
|
|
40983
|
+
}
|
|
40984
|
+
// Calculate appropriate grid extent based on camera height.
|
|
40985
|
+
// For larger grid spacings, we use a tighter extent to prevent performance issues.
|
|
40986
|
+
const scaledExtentFactor = Math.max(0.5, Math.min(3, 3 - Math.log10(Math.max(1, adaptiveSpacing)) * 0.5));
|
|
40987
|
+
const visibilityRadius = Math.min(cameraHeight * scaledExtentFactor, Infinity);
|
|
40988
|
+
// Check if we should redraw the grid.
|
|
40989
|
+
const shouldRedraw = this.shouldRedrawGrid(cameraPosition, cameraHeight, visibilityRadius, adaptiveSpacing);
|
|
40990
|
+
if (!shouldRedraw) {
|
|
40991
|
+
return;
|
|
40992
|
+
}
|
|
40993
|
+
// Remember current settings for next comparison.
|
|
40994
|
+
this.lastCameraHeight = cameraHeight;
|
|
40995
|
+
this.lastCameraPosition = cameraPosition.clone();
|
|
40996
|
+
this.lastGridExtent = visibilityRadius;
|
|
40997
|
+
// Clear existing grid and create a new one.
|
|
40998
|
+
this.clearGrid();
|
|
40999
|
+
this.gridLines = new PolylineCollection();
|
|
41000
|
+
this.gridLabels = new LabelCollection({
|
|
41001
|
+
scene: this.viewer.scene
|
|
41002
|
+
});
|
|
41003
|
+
this.gridPrimitives.add(this.gridLines);
|
|
41004
|
+
this.gridPrimitives.add(this.gridLabels);
|
|
41005
|
+
// Generate grid lines and labels using our fixed origin.
|
|
41006
|
+
this.generateGridLines(this.fixedGridOrigin, visibilityRadius, adaptiveSpacing);
|
|
41007
|
+
}
|
|
41008
|
+
shouldRedrawGrid(cameraPosition, cameraHeight, gridExtent, currentSpacing) {
|
|
41009
|
+
// check if the spacing has changed
|
|
41010
|
+
if (this.lastUsedSpacing && this.lastUsedSpacing !== currentSpacing) {
|
|
41011
|
+
return true;
|
|
41012
|
+
}
|
|
41013
|
+
// Always draw if we don't have a grid yet.
|
|
41014
|
+
if (!this.gridLines || !this.lastCameraPosition || !this.fixedGridOrigin) {
|
|
41015
|
+
return true;
|
|
41016
|
+
}
|
|
41017
|
+
// Check for significant height change.
|
|
41018
|
+
const heightRatio = cameraHeight / this.lastCameraHeight;
|
|
41019
|
+
if (heightRatio > (1 + this.HEIGHT_CHANGE_THRESHOLD) ||
|
|
41020
|
+
heightRatio < (1 - this.HEIGHT_CHANGE_THRESHOLD)) {
|
|
41021
|
+
return true;
|
|
41022
|
+
}
|
|
41023
|
+
// Check for significant position change relative to current grid extent.
|
|
41024
|
+
const distance = Cartesian3.distance(cameraPosition, this.lastCameraPosition);
|
|
41025
|
+
const moveThreshold = gridExtent * this.CAMERA_MOVE_THRESHOLD;
|
|
41026
|
+
if (distance > moveThreshold) {
|
|
41027
|
+
return true;
|
|
41028
|
+
}
|
|
41029
|
+
// Check for significant grid extent change.
|
|
41030
|
+
const extentRatio = gridExtent / this.lastGridExtent;
|
|
41031
|
+
if (extentRatio > (1 + this.GRID_EXTENT_CHANGE_THRESHOLD) ||
|
|
41032
|
+
extentRatio < (1 - this.GRID_EXTENT_CHANGE_THRESHOLD)) {
|
|
41033
|
+
return true;
|
|
41034
|
+
}
|
|
41035
|
+
// No significant changes, keep current grid.
|
|
41036
|
+
return false;
|
|
41037
|
+
}
|
|
41038
|
+
isGridDensityAcceptable(visibleArea, cameraHeight, spacingToCheck = this.spacingInMeters) {
|
|
41039
|
+
const lonRange = visibleArea.eastLon - visibleArea.westLon;
|
|
41040
|
+
const latRange = visibleArea.northLat - visibleArea.southLat;
|
|
41041
|
+
// Convert to approximate meters at center
|
|
41042
|
+
const centerCartographic = Cartographic.fromCartesian(visibleArea.centerCartesian);
|
|
41043
|
+
const metersPerDegreeLon = 111319.9 * Math.cos(centerCartographic.latitude);
|
|
41044
|
+
const canvas = this.viewer.scene.canvas;
|
|
41045
|
+
const spacingInDegrees = spacingToCheck / metersPerDegreeLon;
|
|
41046
|
+
const canvasWidth = canvas.clientWidth;
|
|
41047
|
+
const pixelsPerDegree = canvasWidth / lonRange;
|
|
41048
|
+
const pixelsBetweenGridLines = pixelsPerDegree * spacingInDegrees;
|
|
41049
|
+
const minPixelSize = 1;
|
|
41050
|
+
return pixelsBetweenGridLines >= minPixelSize;
|
|
41051
|
+
}
|
|
41052
|
+
calculateVisibleArea() {
|
|
41053
|
+
const scene = this.viewer.scene;
|
|
41054
|
+
const camera = scene.camera;
|
|
41055
|
+
const globe = scene.globe;
|
|
41056
|
+
// Get the corners of the view frustum
|
|
41057
|
+
const canvas = scene.canvas;
|
|
41058
|
+
const corners = [
|
|
41059
|
+
new Cartesian2(0, 0),
|
|
41060
|
+
new Cartesian2(canvas.clientWidth, 0),
|
|
41061
|
+
new Cartesian2(0, canvas.clientHeight),
|
|
41062
|
+
new Cartesian2(canvas.clientWidth, canvas.clientHeight),
|
|
41063
|
+
new Cartesian2(canvas.clientWidth / 2, canvas.clientHeight / 2) // Center
|
|
41064
|
+
];
|
|
41065
|
+
// Project corners to the globe
|
|
41066
|
+
const cartographicCorners = [];
|
|
41067
|
+
for (const corner of corners) {
|
|
41068
|
+
const ray = camera.getPickRay(corner);
|
|
41069
|
+
if (!ray) {
|
|
41070
|
+
continue;
|
|
41071
|
+
}
|
|
41072
|
+
const position = globe.pick(ray, scene);
|
|
41073
|
+
if (!position) {
|
|
41074
|
+
continue;
|
|
41075
|
+
}
|
|
41076
|
+
cartographicCorners.push(Cartographic.fromCartesian(position));
|
|
41077
|
+
}
|
|
41078
|
+
if (cartographicCorners.length === 0) {
|
|
41079
|
+
return null;
|
|
41080
|
+
}
|
|
41081
|
+
// Find the bounding rectangle
|
|
41082
|
+
let westLon = Number.POSITIVE_INFINITY;
|
|
41083
|
+
let eastLon = Number.NEGATIVE_INFINITY;
|
|
41084
|
+
let southLat = Number.POSITIVE_INFINITY;
|
|
41085
|
+
let northLat = Number.NEGATIVE_INFINITY;
|
|
41086
|
+
for (const corner of cartographicCorners) {
|
|
41087
|
+
westLon = Math.min(westLon, corner.longitude);
|
|
41088
|
+
eastLon = Math.max(eastLon, corner.longitude);
|
|
41089
|
+
southLat = Math.min(southLat, corner.latitude);
|
|
41090
|
+
northLat = Math.max(northLat, corner.latitude);
|
|
41091
|
+
}
|
|
41092
|
+
// Add some padding around the visible area
|
|
41093
|
+
const lonPadding = (eastLon - westLon) * this.VIEW_PADDING_FACTOR;
|
|
41094
|
+
const latPadding = (northLat - southLat) * this.VIEW_PADDING_FACTOR;
|
|
41095
|
+
westLon -= lonPadding;
|
|
41096
|
+
eastLon += lonPadding;
|
|
41097
|
+
southLat -= latPadding;
|
|
41098
|
+
northLat += latPadding;
|
|
41099
|
+
// Get center position for reference
|
|
41100
|
+
const centerCartographic = new Cartographic((westLon + eastLon) / 2, (southLat + northLat) / 2);
|
|
41101
|
+
const centerCartesian = Cartesian3.fromRadians(centerCartographic.longitude, centerCartographic.latitude, 0);
|
|
41102
|
+
return {
|
|
41103
|
+
westLon: Math$1.toDegrees(westLon),
|
|
41104
|
+
eastLon: Math$1.toDegrees(eastLon),
|
|
41105
|
+
southLat: Math$1.toDegrees(southLat),
|
|
41106
|
+
northLat: Math$1.toDegrees(northLat),
|
|
41107
|
+
centerCartesian: centerCartesian
|
|
41108
|
+
};
|
|
41109
|
+
}
|
|
41110
|
+
generateGridLines(originPoint, visibilityRadius, actualSpacing = this.spacingInMeters) {
|
|
41111
|
+
// Number of grid cells in each direction (add 1 for edge lines).
|
|
41112
|
+
const gridCellCount = Math.ceil(visibilityRadius / actualSpacing) + 1;
|
|
41113
|
+
const maxCells = Math.min(gridCellCount, Math.floor(this.MAX_LINES / 2));
|
|
41114
|
+
// Calculate interval to skip lines for density control.
|
|
41115
|
+
const spacingFactor = actualSpacing / 100;
|
|
41116
|
+
const heightFactor = this.lastCameraHeight / 500;
|
|
41117
|
+
let lineSkipInterval = Math.floor(spacingFactor * heightFactor);
|
|
41118
|
+
lineSkipInterval = Math.min(Math.max(lineSkipInterval, 1), 10); // Clamp between 1 and 10
|
|
41119
|
+
const intersections = [];
|
|
41120
|
+
// Generate north-south grid lines (longitude lines)
|
|
41121
|
+
for (let i = -maxCells; i <= maxCells; i++) {
|
|
41122
|
+
if (i % lineSkipInterval !== 0) {
|
|
41123
|
+
continue;
|
|
41124
|
+
}
|
|
41125
|
+
const positions = [];
|
|
41126
|
+
// Create a vertical line at this longitude offset.
|
|
41127
|
+
// East heading for longitude.
|
|
41128
|
+
const startPoint = this.cachedOffsetPoint(originPoint, i * actualSpacing, 90);
|
|
41129
|
+
// Draw the line from south to north
|
|
41130
|
+
for (let j = -maxCells; j <= maxCells; j++) {
|
|
41131
|
+
if (j % lineSkipInterval !== 0) {
|
|
41132
|
+
continue;
|
|
41133
|
+
}
|
|
41134
|
+
// North heading for latitude.
|
|
41135
|
+
const linePoint = this.cachedOffsetPoint(startPoint, j * actualSpacing, 0);
|
|
41136
|
+
const position = Cartesian3.fromDegrees(linePoint.longitude, linePoint.latitude, linePoint.altitude);
|
|
41137
|
+
positions.push(position);
|
|
41138
|
+
intersections.push({
|
|
41139
|
+
position: position,
|
|
41140
|
+
i: i,
|
|
41141
|
+
j: j
|
|
41142
|
+
});
|
|
41143
|
+
}
|
|
41144
|
+
if (positions.length >= 2) {
|
|
41145
|
+
// Check if this is the primary Y axis (i=0) in model space
|
|
41146
|
+
const isPrimaryYAxis = this.modelSpace && i === 0;
|
|
41147
|
+
this.addGridLine(positions, isPrimaryYAxis ? "y" : null);
|
|
41148
|
+
}
|
|
41149
|
+
}
|
|
41150
|
+
// Generate east-west grid lines (latitude lines).
|
|
41151
|
+
for (let j = -maxCells; j <= maxCells; j++) {
|
|
41152
|
+
if (j % lineSkipInterval !== 0) {
|
|
41153
|
+
continue;
|
|
41154
|
+
}
|
|
41155
|
+
const positions = [];
|
|
41156
|
+
// Create a horizontal line at this latitude offset
|
|
41157
|
+
// North heading for latitude.
|
|
41158
|
+
const startPoint = this.cachedOffsetPoint(originPoint, j * actualSpacing, 0);
|
|
41159
|
+
// Draw the line from west to east.
|
|
41160
|
+
for (let i = -maxCells; i <= maxCells; i++) {
|
|
41161
|
+
if (i % lineSkipInterval !== 0) {
|
|
41162
|
+
continue;
|
|
41163
|
+
}
|
|
41164
|
+
// East heading for longitude.
|
|
41165
|
+
const linePoint = this.cachedOffsetPoint(startPoint, i * actualSpacing, 90);
|
|
41166
|
+
const position = Cartesian3.fromDegrees(linePoint.longitude, linePoint.latitude, linePoint.altitude);
|
|
41167
|
+
positions.push(position);
|
|
41168
|
+
}
|
|
41169
|
+
if (positions.length >= 2) {
|
|
41170
|
+
// Check if this is the primary X axis (j=0) in model space
|
|
41171
|
+
const isPrimaryXAxis = this.modelSpace && j === 0;
|
|
41172
|
+
this.addGridLine(positions, isPrimaryXAxis ? "x" : null);
|
|
41173
|
+
}
|
|
41174
|
+
}
|
|
41175
|
+
this.addGridLabels(intersections, actualSpacing);
|
|
41176
|
+
}
|
|
41177
|
+
addGridLabels(intersections, actualSpacing) {
|
|
41178
|
+
if (!this.gridLabels) {
|
|
41179
|
+
return;
|
|
41180
|
+
}
|
|
41181
|
+
// Determine label interval based on number of intersections.
|
|
41182
|
+
// Use higher interval for more intersections to prevent crowding.
|
|
41183
|
+
const totalIntersections = intersections.length;
|
|
41184
|
+
let labelInterval = this.LABEL_INTERVAL;
|
|
41185
|
+
if (totalIntersections > 1000) {
|
|
41186
|
+
labelInterval = 5;
|
|
41187
|
+
}
|
|
41188
|
+
else if (totalIntersections > 500) {
|
|
41189
|
+
labelInterval = 3;
|
|
41190
|
+
}
|
|
41191
|
+
let labelCount = 0;
|
|
41192
|
+
// Filter intersections to only those at the labelInterval.
|
|
41193
|
+
const labelPoints = intersections.filter(point => {
|
|
41194
|
+
// Always label the origin (0,0).
|
|
41195
|
+
if (point.i === 0 && point.j === 0) {
|
|
41196
|
+
return true;
|
|
41197
|
+
}
|
|
41198
|
+
return (point.i % labelInterval === 0 && point.j % labelInterval === 0);
|
|
41199
|
+
});
|
|
41200
|
+
// Sort points by distance from origin.
|
|
41201
|
+
labelPoints.sort((a, b) => {
|
|
41202
|
+
const distA = Math.abs(a.i) + Math.abs(a.j);
|
|
41203
|
+
const distB = Math.abs(b.i) + Math.abs(b.j);
|
|
41204
|
+
return distA - distB;
|
|
41205
|
+
});
|
|
41206
|
+
// Add labels, prioritizing those closest to the origin.
|
|
41207
|
+
for (const point of labelPoints) {
|
|
41208
|
+
if (labelCount >= this.MAX_LABELS) {
|
|
41209
|
+
// Limit reached.
|
|
41210
|
+
break;
|
|
41211
|
+
}
|
|
41212
|
+
let labelText;
|
|
41213
|
+
// Model space coordinates (meters from origin).
|
|
41214
|
+
if (this.modelSpace) {
|
|
41215
|
+
const xMeters = point.i * actualSpacing;
|
|
41216
|
+
const yMeters = point.j * actualSpacing;
|
|
41217
|
+
if (point.i === 0 && point.j === 0) {
|
|
41218
|
+
labelText = "0,0,0";
|
|
41219
|
+
}
|
|
41220
|
+
else {
|
|
41221
|
+
labelText = `${xMeters},${yMeters}`;
|
|
41222
|
+
}
|
|
41223
|
+
}
|
|
41224
|
+
// Geographic coordinates (degrees).
|
|
41225
|
+
else {
|
|
41226
|
+
const cartographic = Cartographic.fromCartesian(point.position);
|
|
41227
|
+
const latitude = Math$1.toDegrees(cartographic.latitude);
|
|
41228
|
+
const longitude = Math$1.toDegrees(cartographic.longitude);
|
|
41229
|
+
const latFormatted = latitude.toFixed(5);
|
|
41230
|
+
const lonFormatted = longitude.toFixed(5);
|
|
41231
|
+
labelText = `${latFormatted}, ${lonFormatted}`;
|
|
41232
|
+
}
|
|
41233
|
+
this.gridLabels.add({
|
|
41234
|
+
position: point.position,
|
|
41235
|
+
text: labelText,
|
|
41236
|
+
font: this.modelSpace && point.i === 0 && point.j === 0 ? "20px sans-serif" : "14px sans-serif",
|
|
41237
|
+
fillColor: this.modelSpace && point.i === 0 && point.j === 0 ? Color.WHITE : Color.WHITE.withAlpha(0.5),
|
|
41238
|
+
style: LabelStyle.FILL,
|
|
41239
|
+
horizontalOrigin: HorizontalOrigin.CENTER,
|
|
41240
|
+
verticalOrigin: VerticalOrigin.TOP,
|
|
41241
|
+
pixelOffset: new Cartesian2(0, 10),
|
|
41242
|
+
// Fade out with distance.
|
|
41243
|
+
translucencyByDistance: new NearFarScalar(1000, 1.0, 15000, 0.4)
|
|
41244
|
+
});
|
|
41245
|
+
labelCount++;
|
|
41246
|
+
}
|
|
41247
|
+
}
|
|
41248
|
+
addGridLine(positions, primaryAxis = null) {
|
|
41249
|
+
if (!this.gridLines || positions.length < 2) {
|
|
41250
|
+
return;
|
|
41251
|
+
}
|
|
41252
|
+
let lineColor;
|
|
41253
|
+
let lineWidth = 1.0;
|
|
41254
|
+
let lineAlpha = 0.2;
|
|
41255
|
+
// Red for X axis.
|
|
41256
|
+
if (primaryAxis === "x") {
|
|
41257
|
+
lineColor = Color.RED;
|
|
41258
|
+
lineAlpha = 0.5;
|
|
41259
|
+
lineWidth = 1.5;
|
|
41260
|
+
}
|
|
41261
|
+
// Green for Y axis.
|
|
41262
|
+
else if (primaryAxis === "y") {
|
|
41263
|
+
lineColor = Color.GREEN;
|
|
41264
|
+
lineAlpha = 0.5;
|
|
41265
|
+
lineWidth = 1.5;
|
|
41266
|
+
}
|
|
41267
|
+
// Default gray for regular grid lines.
|
|
41268
|
+
else {
|
|
41269
|
+
lineColor = Color.LIGHTGRAY;
|
|
41270
|
+
}
|
|
41271
|
+
this.gridLines.add({
|
|
41272
|
+
positions: positions,
|
|
41273
|
+
width: lineWidth,
|
|
41274
|
+
material: Material.fromType("Color", {
|
|
41275
|
+
color: lineColor.withAlpha(lineAlpha)
|
|
41276
|
+
})
|
|
41277
|
+
});
|
|
41278
|
+
}
|
|
41279
|
+
}
|
|
41280
|
+
// Grid square size used when settings name none, in metres.
|
|
41281
|
+
const DEFAULT_SPACING = 50;
|
|
41282
|
+
var CesiumMapGrid;
|
|
41283
|
+
(function (CesiumMapGrid) {
|
|
41284
|
+
function GetCurrentSpacing(viewer) {
|
|
41285
|
+
if (!viewer || viewer.isDestroyed()) {
|
|
41286
|
+
return 0;
|
|
41287
|
+
}
|
|
41288
|
+
const handler = viewer[CLASS_INSTANCE_KEY];
|
|
41289
|
+
return handler ? handler.getCurrentSpacing() : 0;
|
|
41290
|
+
}
|
|
41291
|
+
CesiumMapGrid.GetCurrentSpacing = GetCurrentSpacing;
|
|
41292
|
+
function Remove(viewer) {
|
|
41293
|
+
if (!viewer || viewer.isDestroyed()) {
|
|
41294
|
+
return;
|
|
41295
|
+
}
|
|
41296
|
+
else if (!viewer[LAST_SETTINGS_KEY]) {
|
|
41297
|
+
return;
|
|
41298
|
+
}
|
|
41299
|
+
if (!viewer[UPDATE_MARKER_KEY]) {
|
|
41300
|
+
viewer[UPDATE_MARKER_KEY] = 1;
|
|
41301
|
+
}
|
|
41302
|
+
else {
|
|
41303
|
+
viewer[UPDATE_MARKER_KEY]++;
|
|
41304
|
+
}
|
|
41305
|
+
// Dispose of the handler.
|
|
41306
|
+
if (viewer[CLASS_INSTANCE_KEY]) {
|
|
41307
|
+
viewer[CLASS_INSTANCE_KEY].Dispose();
|
|
41308
|
+
viewer[CLASS_INSTANCE_KEY] = null;
|
|
41309
|
+
}
|
|
41310
|
+
viewer[LAST_SETTINGS_KEY] = {
|
|
41311
|
+
...viewer[LAST_SETTINGS_KEY],
|
|
41312
|
+
enabled: false
|
|
41313
|
+
};
|
|
41314
|
+
}
|
|
41315
|
+
CesiumMapGrid.Remove = Remove;
|
|
41316
|
+
function Draw(viewer, spacingInMeters, modelSpace = true) {
|
|
41317
|
+
if (!viewer || viewer.isDestroyed()) {
|
|
41318
|
+
return;
|
|
41319
|
+
}
|
|
41320
|
+
let settings = viewer[LAST_SETTINGS_KEY];
|
|
41321
|
+
if (settings) {
|
|
41322
|
+
// See if the settings are the same as the last time.
|
|
41323
|
+
if (settings.spacing === spacingInMeters &&
|
|
41324
|
+
settings.modelSpace === modelSpace &&
|
|
41325
|
+
settings.enabled) {
|
|
41326
|
+
return;
|
|
41327
|
+
}
|
|
41328
|
+
}
|
|
41329
|
+
if (!viewer[UPDATE_MARKER_KEY]) {
|
|
41330
|
+
viewer[UPDATE_MARKER_KEY] = 1;
|
|
41331
|
+
}
|
|
41332
|
+
else {
|
|
41333
|
+
viewer[UPDATE_MARKER_KEY]++;
|
|
41334
|
+
}
|
|
41335
|
+
settings = {
|
|
41336
|
+
...settings,
|
|
41337
|
+
enabled: true,
|
|
41338
|
+
spacing: spacingInMeters,
|
|
41339
|
+
modelSpace: modelSpace
|
|
41340
|
+
};
|
|
41341
|
+
viewer[LAST_SETTINGS_KEY] = settings;
|
|
41342
|
+
// Create or update the handler.
|
|
41343
|
+
if (viewer[CLASS_INSTANCE_KEY]) {
|
|
41344
|
+
viewer[CLASS_INSTANCE_KEY].Update(spacingInMeters, modelSpace);
|
|
41345
|
+
}
|
|
41346
|
+
else {
|
|
41347
|
+
viewer[CLASS_INSTANCE_KEY] = new MapGridHandler(viewer, spacingInMeters, modelSpace);
|
|
41348
|
+
}
|
|
41349
|
+
}
|
|
41350
|
+
CesiumMapGrid.Draw = Draw;
|
|
41351
|
+
/**
|
|
41352
|
+
* Draws a bookmark's grid, or removes the grid when it has none; only model-space draws one.
|
|
41353
|
+
*/
|
|
41354
|
+
function Apply(viewer, grid, modelSpace) {
|
|
41355
|
+
if ((grid === null || grid === void 0 ? void 0 : grid.enabled) && modelSpace) {
|
|
41356
|
+
Draw(viewer, Number(grid.spacing) || DEFAULT_SPACING, modelSpace);
|
|
41357
|
+
}
|
|
41358
|
+
else {
|
|
41359
|
+
Remove(viewer);
|
|
41360
|
+
}
|
|
41361
|
+
}
|
|
41362
|
+
CesiumMapGrid.Apply = Apply;
|
|
41363
|
+
function GetIsEnabled(viewer) {
|
|
41364
|
+
if (!viewer || viewer.isDestroyed()) {
|
|
41365
|
+
return false;
|
|
41366
|
+
}
|
|
41367
|
+
const settings = viewer[LAST_SETTINGS_KEY];
|
|
41368
|
+
if (settings) {
|
|
41369
|
+
return Boolean(settings.enabled);
|
|
41370
|
+
}
|
|
41371
|
+
return false;
|
|
41372
|
+
}
|
|
41373
|
+
CesiumMapGrid.GetIsEnabled = GetIsEnabled;
|
|
41374
|
+
/**
|
|
41375
|
+
* Returns the last applied grid settings.
|
|
41376
|
+
*/
|
|
41377
|
+
function GetSettings(viewer) {
|
|
41378
|
+
if (!viewer || viewer.isDestroyed()) {
|
|
41379
|
+
return null;
|
|
41380
|
+
}
|
|
41381
|
+
return viewer[LAST_SETTINGS_KEY];
|
|
41382
|
+
}
|
|
41383
|
+
CesiumMapGrid.GetSettings = GetSettings;
|
|
41384
|
+
})(CesiumMapGrid || (CesiumMapGrid = {}));
|
|
41385
|
+
|
|
38818
41386
|
// TODO: Move these to the data model.
|
|
38819
41387
|
const MIN_SHADOW_SIZE = 2048;
|
|
38820
41388
|
const MAX_SHADOW_SIZE = 32768;
|
|
@@ -39006,7 +41574,7 @@ async function renderLegacyNavigator(iteration, params, bookmark, view) {
|
|
|
39006
41574
|
* @param view
|
|
39007
41575
|
*/
|
|
39008
41576
|
async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
39009
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
41577
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
|
|
39010
41578
|
const viewer = params.manager.Viewer;
|
|
39011
41579
|
const scene = viewer.scene;
|
|
39012
41580
|
// Ion requests go through the server-side proxy (set up during viewer init or here as fallback).
|
|
@@ -39231,15 +41799,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39231
41799
|
scene.globe.translucency.frontFaceAlphaByDistance.farValue = 1;
|
|
39232
41800
|
}
|
|
39233
41801
|
scene.globe.translucency.frontFaceAlphaByDistance.nearValue = EnsureNumber(globeAlpha, 1);
|
|
39234
|
-
|
|
39235
|
-
if (shadows == null) {
|
|
39236
|
-
shadows = (_u = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _u === void 0 ? void 0 : _u.shadows;
|
|
39237
|
-
}
|
|
39238
|
-
if (shadows == null) {
|
|
39239
|
-
shadows = {
|
|
39240
|
-
enabled: false
|
|
39241
|
-
};
|
|
39242
|
-
}
|
|
41802
|
+
const shadows = ViewRenderEngine.ResolveShadows(bSettings, defaults === null || defaults === void 0 ? void 0 : defaults.settings, contentType);
|
|
39243
41803
|
viewer.shadows = Boolean(shadows.enabled);
|
|
39244
41804
|
viewer.shadowMap.enabled = Boolean(shadows.enabled);
|
|
39245
41805
|
let size = EnsureNumber(shadows.pixelSize);
|
|
@@ -39252,9 +41812,11 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39252
41812
|
viewer.shadowMap.size = size;
|
|
39253
41813
|
viewer.shadowMap.softShadows = Boolean(shadows.soften);
|
|
39254
41814
|
viewer.shadowMap.darkness = EnsureNumber(shadows.darkness, 0.3);
|
|
41815
|
+
// Drawn after the model-space origin is resolved above, since the grid starts from it.
|
|
41816
|
+
CesiumMapGrid.Apply(viewer, (_u = bSettings.grid) !== null && _u !== void 0 ? _u : (_v = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _v === void 0 ? void 0 : _v.grid, contentType == ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE);
|
|
39255
41817
|
let ambientOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.ambientOcclusion;
|
|
39256
41818
|
if (ambientOcclusion == null) {
|
|
39257
|
-
ambientOcclusion = (
|
|
41819
|
+
ambientOcclusion = (_w = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _w === void 0 ? void 0 : _w.ambientOcclusion;
|
|
39258
41820
|
}
|
|
39259
41821
|
if (ambientOcclusion == null) {
|
|
39260
41822
|
ambientOcclusion = {
|
|
@@ -39277,7 +41839,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39277
41839
|
}
|
|
39278
41840
|
let lighting = bSettings === null || bSettings === void 0 ? void 0 : bSettings.lighting;
|
|
39279
41841
|
if (lighting == null) {
|
|
39280
|
-
lighting = (
|
|
41842
|
+
lighting = (_x = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _x === void 0 ? void 0 : _x.lighting;
|
|
39281
41843
|
}
|
|
39282
41844
|
if (lighting == null) {
|
|
39283
41845
|
lighting = {
|
|
@@ -39295,7 +41857,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39295
41857
|
ViewUtils.ApplyDefaultBrightness(viewer, EnsureNumber(lighting.brightnessShift, DEFAULT_BRIGHTNESS_SHIFT));
|
|
39296
41858
|
let quality = bSettings === null || bSettings === void 0 ? void 0 : bSettings.quality;
|
|
39297
41859
|
if (quality == null) {
|
|
39298
|
-
quality = (
|
|
41860
|
+
quality = (_y = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _y === void 0 ? void 0 : _y.quality;
|
|
39299
41861
|
}
|
|
39300
41862
|
if (quality == null) {
|
|
39301
41863
|
quality = {
|
|
@@ -39306,11 +41868,11 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39306
41868
|
fxaa.enabled = Boolean(quality.fxaa);
|
|
39307
41869
|
let dateTime = bSettings === null || bSettings === void 0 ? void 0 : bSettings.dateTime;
|
|
39308
41870
|
if (dateTime == null) {
|
|
39309
|
-
dateTime = (
|
|
41871
|
+
dateTime = (_z = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _z === void 0 ? void 0 : _z.dateTime;
|
|
39310
41872
|
}
|
|
39311
41873
|
let timeline = bSettings === null || bSettings === void 0 ? void 0 : bSettings.timeline;
|
|
39312
41874
|
if (timeline == null) {
|
|
39313
|
-
timeline = (
|
|
41875
|
+
timeline = (_0 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _0 === void 0 ? void 0 : _0.timeline;
|
|
39314
41876
|
}
|
|
39315
41877
|
if (timeline == null) {
|
|
39316
41878
|
timeline = {
|
|
@@ -39334,7 +41896,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39334
41896
|
// Newer version that has states per Entity ID + Menu Item ID.
|
|
39335
41897
|
let states = bSettings === null || bSettings === void 0 ? void 0 : bSettings.states;
|
|
39336
41898
|
if (states == null) {
|
|
39337
|
-
states = (
|
|
41899
|
+
states = (_1 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _1 === void 0 ? void 0 : _1.states;
|
|
39338
41900
|
}
|
|
39339
41901
|
if (states != null) {
|
|
39340
41902
|
params.manager.VisualsRegister.OverrideStates(states);
|
|
@@ -39343,7 +41905,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39343
41905
|
else {
|
|
39344
41906
|
let selectedIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.selectedEntityIds;
|
|
39345
41907
|
if (selectedIds == null) {
|
|
39346
|
-
selectedIds = (
|
|
41908
|
+
selectedIds = (_2 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _2 === void 0 ? void 0 : _2.selectedEntityIds;
|
|
39347
41909
|
}
|
|
39348
41910
|
if (selectedIds != null) {
|
|
39349
41911
|
params.manager.VisualsRegister.ClearSelected();
|
|
@@ -39357,7 +41919,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39357
41919
|
params.manager.VisualsRegister.ClearHidden();
|
|
39358
41920
|
let hiddenIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.hiddenEntityIds;
|
|
39359
41921
|
if (hiddenIds == null) {
|
|
39360
|
-
hiddenIds = (
|
|
41922
|
+
hiddenIds = (_3 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _3 === void 0 ? void 0 : _3.hiddenEntityIds;
|
|
39361
41923
|
}
|
|
39362
41924
|
if (hiddenIds != null) {
|
|
39363
41925
|
params.manager.VisualsRegister.SetHidden({
|
|
@@ -39369,7 +41931,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39369
41931
|
params.manager.VisualsRegister.ClearIsolated();
|
|
39370
41932
|
let isolatedIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.isolatedEntityIds;
|
|
39371
41933
|
if (isolatedIds == null) {
|
|
39372
|
-
isolatedIds = (
|
|
41934
|
+
isolatedIds = (_4 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _4 === void 0 ? void 0 : _4.isolatedEntityIds;
|
|
39373
41935
|
}
|
|
39374
41936
|
if (isolatedIds != null) {
|
|
39375
41937
|
params.manager.VisualsRegister.SetIsolated({
|
|
@@ -39380,7 +41942,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39380
41942
|
}
|
|
39381
41943
|
let labelledIds = bSettings === null || bSettings === void 0 ? void 0 : bSettings.labelledEntityIds;
|
|
39382
41944
|
if (labelledIds == null) {
|
|
39383
|
-
labelledIds = (
|
|
41945
|
+
labelledIds = (_5 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _5 === void 0 ? void 0 : _5.labelledEntityIds;
|
|
39384
41946
|
}
|
|
39385
41947
|
if (!(labelledIds === null || labelledIds === void 0 ? void 0 : labelledIds.length)) {
|
|
39386
41948
|
params.manager.VisualsRegister.ClearLabelled({
|
|
@@ -39404,7 +41966,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39404
41966
|
params.manager.VisualsRegister.ClearOpacity();
|
|
39405
41967
|
let entityOpacityMap = bSettings === null || bSettings === void 0 ? void 0 : bSettings.entityOpacityMap;
|
|
39406
41968
|
if (entityOpacityMap == null) {
|
|
39407
|
-
entityOpacityMap = (
|
|
41969
|
+
entityOpacityMap = (_6 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _6 === void 0 ? void 0 : _6.entityOpacityMap;
|
|
39408
41970
|
}
|
|
39409
41971
|
if (entityOpacityMap != null) {
|
|
39410
41972
|
for (const entityId in entityOpacityMap) {
|
|
@@ -39419,7 +41981,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39419
41981
|
}
|
|
39420
41982
|
}
|
|
39421
41983
|
}
|
|
39422
|
-
let imagery = (bSettings === null || bSettings === void 0 ? void 0 : bSettings.imagery) != null ? bSettings.imagery : (
|
|
41984
|
+
let imagery = (bSettings === null || bSettings === void 0 ? void 0 : bSettings.imagery) != null ? bSettings.imagery : (_7 = defaults.settings) === null || _7 === void 0 ? void 0 : _7.imagery;
|
|
39423
41985
|
if (imagery == null) {
|
|
39424
41986
|
// TODO: Need global default.
|
|
39425
41987
|
imagery = [
|
|
@@ -39489,7 +42051,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39489
42051
|
// Otherwise we cause a flicker of rendered graphics.
|
|
39490
42052
|
// Maybe TODO to such a function for menu item manager.
|
|
39491
42053
|
const curEnabled = params.manager.GetEnabledItemIds();
|
|
39492
|
-
const newItemIds = (
|
|
42054
|
+
const newItemIds = (_8 = bSettings === null || bSettings === void 0 ? void 0 : bSettings.menuItemIds) !== null && _8 !== void 0 ? _8 : [];
|
|
39493
42055
|
for (const id of curEnabled) {
|
|
39494
42056
|
let shouldRemove;
|
|
39495
42057
|
if (id == RELATION_MENU_ITEM_ID) {
|
|
@@ -39563,7 +42125,7 @@ async function renderNavigator(iteration, params, bookmark, view, getters) {
|
|
|
39563
42125
|
}
|
|
39564
42126
|
let gOcclusion = bSettings === null || bSettings === void 0 ? void 0 : bSettings.groundOcclusion;
|
|
39565
42127
|
if (gOcclusion == null) {
|
|
39566
|
-
gOcclusion = (
|
|
42128
|
+
gOcclusion = (_9 = defaults === null || defaults === void 0 ? void 0 : defaults.settings) === null || _9 === void 0 ? void 0 : _9.groundOcclusion;
|
|
39567
42129
|
}
|
|
39568
42130
|
if (gOcclusion == null) {
|
|
39569
42131
|
// TODO: Need global default.
|
|
@@ -39581,6 +42143,17 @@ var ViewRenderEngine;
|
|
|
39581
42143
|
ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE,
|
|
39582
42144
|
ProjectViewBookmark.EContentType.WEB_3D_SPLIT_PLUGIN
|
|
39583
42145
|
];
|
|
42146
|
+
/**
|
|
42147
|
+
* A bookmark's own shadows, else the view's defaults unless it is model-space, which reads brighter without.
|
|
42148
|
+
*/
|
|
42149
|
+
function ResolveShadows(bSettings, defaults, contentType) {
|
|
42150
|
+
let shadows = bSettings === null || bSettings === void 0 ? void 0 : bSettings.shadows;
|
|
42151
|
+
if (shadows == null && contentType != ProjectViewBookmark.EContentType.WEB_3D_MODEL_SPACE) {
|
|
42152
|
+
shadows = defaults === null || defaults === void 0 ? void 0 : defaults.shadows;
|
|
42153
|
+
}
|
|
42154
|
+
return shadows !== null && shadows !== void 0 ? shadows : { enabled: false };
|
|
42155
|
+
}
|
|
42156
|
+
ViewRenderEngine.ResolveShadows = ResolveShadows;
|
|
39584
42157
|
/**
|
|
39585
42158
|
* Returns where a model-space bookmark's camera goes, measured from the origin in effect.
|
|
39586
42159
|
* @param viewer
|
|
@@ -44312,7 +46885,7 @@ const HOLD_ACTIVATION_TIME_MS = 350;
|
|
|
44312
46885
|
const HOLD_LOADER_DELAY_MS = 150;
|
|
44313
46886
|
const CONTINUOUS_ANIMATION_SPEED = 0.02 / 3;
|
|
44314
46887
|
const ZOOM_DISTANCE = 0.85;
|
|
44315
|
-
const MIN_ZOOM_DISTANCE = 0.3;
|
|
46888
|
+
const MIN_ZOOM_DISTANCE$1 = 0.3;
|
|
44316
46889
|
const NEAR_NADIR_PITCH = -Math.PI / 2 + 0.05;
|
|
44317
46890
|
const MIN_ORBIT_OFFSET_METERS = 5;
|
|
44318
46891
|
// Caps how far a pivot may be from the camera relative to the camera's own altitude.
|
|
@@ -44518,7 +47091,7 @@ function DoZoom(params) {
|
|
|
44518
47091
|
const mag = (ZOOM_DISTANCE * 0.5) / Math.max(1, 4 - Math.log10(height));
|
|
44519
47092
|
const zoom = zoomIn ? 1 - mag : 1 + mag;
|
|
44520
47093
|
const offset = Cartesian3.multiplyByScalar(Cartesian3.subtract(p, ground, new Cartesian3()), zoom, new Cartesian3());
|
|
44521
|
-
if (zoomIn && Cartesian3.magnitude(offset) <= MIN_ZOOM_DISTANCE) {
|
|
47094
|
+
if (zoomIn && Cartesian3.magnitude(offset) <= MIN_ZOOM_DISTANCE$1) {
|
|
44522
47095
|
return Promise.resolve(null);
|
|
44523
47096
|
}
|
|
44524
47097
|
const to = Cartesian3.add(ground, offset, new Cartesian3());
|
|
@@ -44742,7 +47315,7 @@ function StartContinuousZoom(params) {
|
|
|
44742
47315
|
const mag = (ZOOM_DISTANCE * 0.5) / Math.max(1, 4 - Math.log10(height));
|
|
44743
47316
|
const zoom = zoomIn ? 1 - mag * 0.03 : 1 + mag * 0.03;
|
|
44744
47317
|
const offset = Cartesian3.multiplyByScalar(Cartesian3.subtract(p, ground, new Cartesian3()), zoom, new Cartesian3());
|
|
44745
|
-
if (zoomIn && Cartesian3.magnitude(offset) <= MIN_ZOOM_DISTANCE) {
|
|
47318
|
+
if (zoomIn && Cartesian3.magnitude(offset) <= MIN_ZOOM_DISTANCE$1) {
|
|
44746
47319
|
active = false;
|
|
44747
47320
|
return;
|
|
44748
47321
|
}
|
|
@@ -45552,7 +48125,7 @@ var ViewerUtils;
|
|
|
45552
48125
|
* @param viewer
|
|
45553
48126
|
*/
|
|
45554
48127
|
function InitViewer(params) {
|
|
45555
|
-
const { viewer, destroyWidgets, styleContainer, nextspaceWidgets, widgetParams } = params;
|
|
48128
|
+
const { viewer, destroyWidgets, styleContainer, nextspaceWidgets, widgetParams, cameraControls } = params;
|
|
45556
48129
|
const data = { widgets: {} };
|
|
45557
48130
|
if (destroyWidgets != false) {
|
|
45558
48131
|
try {
|
|
@@ -45579,6 +48152,12 @@ var ViewerUtils;
|
|
|
45579
48152
|
// Newer cesium is much dimmer by default so we shift brightness a bit.
|
|
45580
48153
|
ViewUtils.ApplyDefaultBrightness(viewer);
|
|
45581
48154
|
backgroundRendering(viewer);
|
|
48155
|
+
if (cameraControls != false) {
|
|
48156
|
+
CameraControls.Attach(viewer);
|
|
48157
|
+
if (ViewUtils.GetModelSpace(viewer)) {
|
|
48158
|
+
CameraControls.SetModelSpace(viewer, () => ViewUtils.GetModelSpaceFrame(viewer));
|
|
48159
|
+
}
|
|
48160
|
+
}
|
|
45582
48161
|
// Capturing the destroy call to destroy all widgets.
|
|
45583
48162
|
const olDestroy = viewer.destroy;
|
|
45584
48163
|
viewer.destroy = () => {
|
|
@@ -45587,6 +48166,7 @@ var ViewerUtils;
|
|
|
45587
48166
|
}
|
|
45588
48167
|
try {
|
|
45589
48168
|
ViewerUtils.DisposeNextspaceWidgets(viewer);
|
|
48169
|
+
CameraControls.Detach(viewer);
|
|
45590
48170
|
}
|
|
45591
48171
|
// We don't want the actual destroy to fail.
|
|
45592
48172
|
catch (e) {
|
|
@@ -49731,7 +52311,7 @@ var EntityRenderEngineModel3d;
|
|
|
49731
52311
|
...ViewUtils.DefaultLightingProps(),
|
|
49732
52312
|
heightReference: heightRef,
|
|
49733
52313
|
scale: new CallbackProperty(() => scale * styleScale, true),
|
|
49734
|
-
shadows:
|
|
52314
|
+
shadows: ViewUtils.GetEntityShadowMode(params.viewer),
|
|
49735
52315
|
colorBlendAmount: blendAmount,
|
|
49736
52316
|
colorBlendMode: blendMode,
|
|
49737
52317
|
color: new CallbackProperty(() => {
|
|
@@ -49766,7 +52346,7 @@ var EntityRenderEngineModel3d;
|
|
|
49766
52346
|
cEntity.model.uri = new ConstantProperty(params.lodUrl);
|
|
49767
52347
|
}
|
|
49768
52348
|
cEntity.model.heightReference = new ConstantProperty(heightRef);
|
|
49769
|
-
cEntity.model.shadows = new ConstantProperty(
|
|
52349
|
+
cEntity.model.shadows = new ConstantProperty(ViewUtils.GetEntityShadowMode(params.viewer));
|
|
49770
52350
|
cEntity.model.colorBlendAmount = new ConstantProperty(blendAmount);
|
|
49771
52351
|
cEntity.model.colorBlendMode = new ConstantProperty(blendMode);
|
|
49772
52352
|
cEntity.model.distanceDisplayCondition = new ConstantProperty(EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
@@ -50608,7 +53188,7 @@ var EntityRenderEnginePolyline;
|
|
|
50608
53188
|
zIndex: getZIndex(style, entity, params.tags),
|
|
50609
53189
|
distanceDisplayCondition: EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
50610
53190
|
cornerType: CornerType.MITERED,
|
|
50611
|
-
shadows:
|
|
53191
|
+
shadows: ViewUtils.GetEntityShadowMode(params.viewer),
|
|
50612
53192
|
fill: true
|
|
50613
53193
|
} : null,
|
|
50614
53194
|
position: EntityUtils.GetPos({
|
|
@@ -55074,7 +57654,7 @@ var EntityRenderEnginePolygon;
|
|
|
55074
57654
|
fill: !drawsDisplacedSurface,
|
|
55075
57655
|
extrudedHeight: extrusion.value,
|
|
55076
57656
|
extrudedHeightReference: extrusion.exHeightRef,
|
|
55077
|
-
shadows:
|
|
57657
|
+
shadows: ViewUtils.GetEntityShadowMode(params.viewer),
|
|
55078
57658
|
heightReference: heightRef,
|
|
55079
57659
|
classificationType: classification,
|
|
55080
57660
|
perPositionHeight: heightRef == HeightReference.CLAMP_TO_GROUND ? false : true,
|
|
@@ -55154,7 +57734,7 @@ var EntityRenderEnginePolygon;
|
|
|
55154
57734
|
viewer: params.viewer,
|
|
55155
57735
|
graphic: cEntity.polygon,
|
|
55156
57736
|
property: "shadows",
|
|
55157
|
-
value:
|
|
57737
|
+
value: ViewUtils.GetEntityShadowMode(params.viewer)
|
|
55158
57738
|
});
|
|
55159
57739
|
SetCPropIfChanged({
|
|
55160
57740
|
viewer: params.viewer,
|
|
@@ -55289,7 +57869,7 @@ var EntityRenderEnginePolygon;
|
|
|
55289
57869
|
cornerType: CornerType.MITERED,
|
|
55290
57870
|
classificationType: classification,
|
|
55291
57871
|
distanceDisplayCondition: EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width, false, size),
|
|
55292
|
-
shadows:
|
|
57872
|
+
shadows: ViewUtils.GetEntityShadowMode(params.viewer)
|
|
55293
57873
|
} : null,
|
|
55294
57874
|
show: true
|
|
55295
57875
|
});
|
|
@@ -55412,7 +57992,7 @@ var EntityRenderEnginePolygon;
|
|
|
55412
57992
|
cornerType: CornerType.MITERED,
|
|
55413
57993
|
classificationType: classification,
|
|
55414
57994
|
distanceDisplayCondition: EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance, width, false, size),
|
|
55415
|
-
shadows:
|
|
57995
|
+
shadows: ViewUtils.GetEntityShadowMode(params.viewer),
|
|
55416
57996
|
} : null,
|
|
55417
57997
|
show: true
|
|
55418
57998
|
});
|
|
@@ -57748,7 +60328,7 @@ var StyleUtils;
|
|
|
57748
60328
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
57749
60329
|
})(StyleUtils || (StyleUtils = {}));
|
|
57750
60330
|
|
|
57751
|
-
const VERSION = "7.7.
|
|
60331
|
+
const VERSION = "7.7.9";
|
|
57752
60332
|
/**
|
|
57753
60333
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
57754
60334
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|
|
@@ -57765,5 +60345,5 @@ const getENVIRONMENT = () => {
|
|
|
57765
60345
|
return ENVIRONMENT;
|
|
57766
60346
|
};
|
|
57767
60347
|
|
|
57768
|
-
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, CesiumViewMonitor, 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 };
|
|
60348
|
+
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, 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 };
|
|
57769
60349
|
//# sourceMappingURL=bruce-cesium.es5.js.map
|