bruce-cesium 7.9.2 → 7.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/bruce-cesium.es5.js +451 -92
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +450 -89
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +1 -1
  6. package/dist/lib/rendering/displaced-surface-primitive.js +17 -0
  7. package/dist/lib/rendering/displaced-surface-primitive.js.map +1 -1
  8. package/dist/lib/rendering/entity-render-engine-model3d.js +10 -10
  9. package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -1
  10. package/dist/lib/rendering/entity-render-engine-point.js +6 -6
  11. package/dist/lib/rendering/entity-render-engine-point.js.map +1 -1
  12. package/dist/lib/rendering/entity-render-engine-polygon.js +30 -12
  13. package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
  14. package/dist/lib/rendering/entity-render-engine-polyline.js +4 -4
  15. package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -1
  16. package/dist/lib/rendering/menu-item-manager.js +16 -2
  17. package/dist/lib/rendering/menu-item-manager.js.map +1 -1
  18. package/dist/lib/rendering/menu-item-style-overlay.js +51 -11
  19. package/dist/lib/rendering/menu-item-style-overlay.js.map +1 -1
  20. package/dist/lib/rendering/menu-item-styles.js +9 -1
  21. package/dist/lib/rendering/menu-item-styles.js.map +1 -1
  22. package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js +1 -1
  23. package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js.map +1 -1
  24. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +1 -1
  25. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
  26. package/dist/lib/rendering/tileset-styler.js +14 -9
  27. package/dist/lib/rendering/tileset-styler.js.map +1 -1
  28. package/dist/lib/rendering/visuals-register.js +36 -5
  29. package/dist/lib/rendering/visuals-register.js.map +1 -1
  30. package/dist/lib/viewer/camera-controls.js +255 -27
  31. package/dist/lib/viewer/camera-controls.js.map +1 -1
  32. package/dist/types/bruce-cesium.d.ts +1 -1
  33. package/dist/types/rendering/displaced-surface-primitive.d.ts +6 -2
  34. package/dist/types/rendering/menu-item-manager.d.ts +1 -0
  35. package/dist/types/rendering/menu-item-style-overlay.d.ts +22 -4
  36. package/dist/types/rendering/tileset-styler.d.ts +1 -0
  37. package/dist/types/rendering/visuals-register.d.ts +11 -0
  38. package/dist/types/viewer/camera-controls.d.ts +11 -0
  39. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import * as Cesium from 'cesium';
2
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, HeightReference, Matrix4, ConstantPositionProperty, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ClassificationType, ColorBlendMode, Model, ShaderSource, Ellipsoid, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, ArcType, CornerType, SceneMode, IntersectionTests, Ray, SceneTransforms, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, Cesium3DTileset, WebGLConstants, Intersect, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, ShadowMode, CustomDataSource, GeometryInstance, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, CesiumInspector, defined, ClockRange, DynamicEnvironmentMapManager, 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, Api, EntityLod, UrlUtils, Geometry as Geometry$1, ProjectView, ProjectViewBookmark, ZoomControl, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, BruceApi, EntityRelation, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, ClassificationType, ArcType, CornerType, ShaderSource, Ellipsoid, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, HorizontalOrigin, VerticalOrigin, SceneMode, IntersectionTests, Ray, SceneTransforms, ColorBlendMode, Model, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, IonResource, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, FeatureDetection, Cesium3DTileset, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PrimitiveCollection, ShadowMode, PolylineCollection, LabelCollection, LabelStyle, Material, CustomDataSource, Event, CesiumInspector, defined, ClockRange, DynamicEnvironmentMapManager, ScreenSpaceEventHandler, ScreenSpaceEventType, CameraEventType, Plane, OrientedBoundingBox, GeometryInstance, 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, ZoomControl, AccountConcept, RecordChangeFeed, Geometry as Geometry$1, Api, ProjectView, ProjectViewBookmark, EntityLod, UrlUtils, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, BruceApi, EntityRelation, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, ProjectViewBookmarkGroup, EntityAttachment, EntityAttribute, MathUtils } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -1367,6 +1367,11 @@ const PUSH_NOTCHES_DATA_BELOW = 3;
1367
1367
  const PUSH_NOTCHES_NOTHING_BELOW = 10;
1368
1368
  // Pushes further apart than this start counting again.
1369
1369
  const PUSH_WINDOW_MS = 1200;
1370
+ // How long after a zoom newly loaded terrain may lift the camera, and how much longer while loading.
1371
+ const SURFACE_HOLD_MS = 4000;
1372
+ const SURFACE_LOADING_MS = 30000;
1373
+ // No visible ground lies lower; a stand-in tileset below this is a coarse tile cutting under the curve.
1374
+ const GROUND_FLOOR = -500;
1370
1375
  // How far below the ground something must reach to count as data underground, in metres.
1371
1376
  const UNDERGROUND_MARGIN = 3;
1372
1377
  // How long a scan of the scene for underground data and stand-in ground is trusted, in milliseconds.
@@ -1416,6 +1421,7 @@ var CameraControls;
1416
1421
  push: { notches: 0, at: 0 },
1417
1422
  scan: null,
1418
1423
  undergroundOverride: null,
1424
+ surface: { above: false, through: false, until: 0, at: null },
1419
1425
  saved: {
1420
1426
  rotateEventTypes: controller.rotateEventTypes,
1421
1427
  zoomEventTypes: controller.zoomEventTypes,
@@ -1440,7 +1446,10 @@ var CameraControls;
1440
1446
  listen(window, "pointerup", (e) => onPointerUp(state, e));
1441
1447
  listen(window, "pointercancel", (e) => onPointerUp(state, e));
1442
1448
  listen(canvas, "wheel", (e) => onWheel(state, e), { passive: true });
1443
- state.removals.push(scene.preUpdate.addEventListener(() => syncController(state)));
1449
+ state.removals.push(scene.preUpdate.addEventListener(() => {
1450
+ syncController(state);
1451
+ keepAboveGround(state);
1452
+ }));
1444
1453
  syncController(state);
1445
1454
  scene.requestRender();
1446
1455
  }
@@ -1592,6 +1601,38 @@ function terrainHeightAt(state, carto) {
1592
1601
  const height = globe.getHeight(carto);
1593
1602
  return Number.isFinite(height) ? height : undefined;
1594
1603
  }
1604
+ /*
1605
+ * The ground's height at a place: the loaded terrain, or the tileset standing in for a hidden globe.
1606
+ */
1607
+ function groundHeightAt(state, carto) {
1608
+ var _a;
1609
+ if (globeShown(state)) {
1610
+ return terrainHeightAt(state, carto);
1611
+ }
1612
+ const tileset = scanScene(state).ground;
1613
+ if (!carto || !tileset || ((_a = tileset.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(tileset)) || typeof tileset.getHeight !== "function") {
1614
+ return undefined;
1615
+ }
1616
+ try {
1617
+ // Only tiles drawn this frame answer, which near the camera are the finest loaded.
1618
+ const height = tileset.getHeight(carto, state.viewer.scene);
1619
+ return Number.isFinite(height) && height > GROUND_FLOOR ? height : undefined;
1620
+ }
1621
+ catch (e) {
1622
+ return undefined;
1623
+ }
1624
+ }
1625
+ /*
1626
+ * Whether the ground is still loading: the globe's tiles, or the stand-in tileset's.
1627
+ */
1628
+ function groundLoading(state) {
1629
+ var _a;
1630
+ if (globeShown(state)) {
1631
+ return state.viewer.scene.globe.tilesLoaded === false;
1632
+ }
1633
+ const tileset = scanScene(state).ground;
1634
+ return Boolean(tileset && !((_a = tileset.isDestroyed) === null || _a === void 0 ? void 0 : _a.call(tileset)) && tileset.tilesLoaded === false);
1635
+ }
1595
1636
  function ellipsoidOf(state) {
1596
1637
  var _a, _b;
1597
1638
  return (_b = (_a = state.viewer.scene.globe) === null || _a === void 0 ? void 0 : _a.ellipsoid) !== null && _b !== void 0 ? _b : Ellipsoid.WGS84;
@@ -1629,8 +1670,8 @@ function groundPlane(state) {
1629
1670
  if (!carto) {
1630
1671
  return null;
1631
1672
  }
1632
- // Level with the terrain under the camera, not sea level, so a guess over high ground is not far too deep.
1633
- const surface = Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0, ellipsoid);
1673
+ // Level with the ground under the camera, not sea level, so a guess over high ground is not far too deep.
1674
+ const surface = Cartesian3.fromRadians(carto.longitude, carto.latitude, (_a = groundHeightAt(state, carto)) !== null && _a !== void 0 ? _a : 0, ellipsoid);
1634
1675
  return Plane.fromPointNormal(surface, ellipsoid.geodeticSurfaceNormal(surface, new Cartesian3()));
1635
1676
  }
1636
1677
  /*
@@ -1654,6 +1695,15 @@ const GAP_SLACK = 0.5;
1654
1695
  // Directions around the centre, and how many must hold nearer pixels for the centre to be surrounded.
1655
1696
  const GAP_SECTORS = 8;
1656
1697
  const GAP_SECTORS_NEAR = 6;
1698
+ // How far around the cursor, in CSS pixels, nearer parts limit a zoom, and the most buffer pixels read.
1699
+ const CLEARANCE_RADIUS_PX = 24;
1700
+ const CLEARANCE_RADIUS_MAX = 64;
1701
+ // The share of that window that must be nearer, so a stray pixel or a thin cable does not slow the zoom.
1702
+ const CLEARANCE_SHARE = 0.05;
1703
+ // A pixel at least this share of the level ground's distance on its ray is ground, and never limits.
1704
+ const CLEARANCE_GROUND = 0.9;
1705
+ // A pan or orbit grabbing this many times farther than the reach grabs at the reach instead.
1706
+ const CLEARANCE_GRAB = 2;
1657
1707
  const PACKED_DEPTH = new Cartesian4(1, 1 / 255, 1 / 65025, 1 / 16581375);
1658
1708
  /*
1659
1709
  * Distances along the view axis drawn around a window position, rows bottom-up, Infinity where nothing is drawn.
@@ -1702,6 +1752,21 @@ function readDepthDistances(scene, position, radius) {
1702
1752
  }
1703
1753
  return distances;
1704
1754
  }
1755
+ /*
1756
+ * The depth window around a position for the gap search and the reach, or null when unreadable.
1757
+ */
1758
+ function readWindow(scene, position) {
1759
+ const scale = scene.drawingBufferWidth / scene.canvas.clientWidth;
1760
+ const clearance = Math.min(Math.round(CLEARANCE_RADIUS_PX * (Number.isFinite(scale) ? scale : 1)), CLEARANCE_RADIUS_MAX);
1761
+ const radius = Math.max(GAP_RADII[GAP_RADII.length - 1], clearance);
1762
+ try {
1763
+ const distances = readDepthDistances(scene, position, radius);
1764
+ return distances ? { distances, radius } : null;
1765
+ }
1766
+ catch (e) {
1767
+ return null;
1768
+ }
1769
+ }
1705
1770
  /*
1706
1771
  * Offsets of the surface pixel around the centre for each radius where clearly nearer pixels surround it.
1707
1772
  */
@@ -1739,15 +1804,7 @@ function FindGapSurfaces(distances, radius) {
1739
1804
  /*
1740
1805
  * The point cloud surface around a pick that looked through a gap between its points, or null when it did not.
1741
1806
  */
1742
- function fillGap(scene, position, picked) {
1743
- const radius = GAP_RADII[GAP_RADII.length - 1];
1744
- let distances = null;
1745
- try {
1746
- distances = readDepthDistances(scene, position, radius);
1747
- }
1748
- catch (e) {
1749
- return null;
1750
- }
1807
+ function fillGap(scene, position, picked, distances, radius) {
1751
1808
  if (!distances) {
1752
1809
  return null;
1753
1810
  }
@@ -1767,9 +1824,80 @@ function fillGap(scene, position, picked) {
1767
1824
  return null;
1768
1825
  }
1769
1826
  /*
1770
- * The point under a screen position: what is drawn there, else the ground plane, else a point at the last distance.
1827
+ * The view-axis distance within which a share of the window around the cursor is drawn, ground aside.
1828
+ */
1829
+ function NearClearance(distances, radius, groundAt) {
1830
+ const width = 2 * radius + 1;
1831
+ const near = [];
1832
+ for (let dy = -radius; dy <= radius; dy++) {
1833
+ for (let dx = -radius; dx <= radius; dx++) {
1834
+ const distance = distances[(radius + dy) * width + (radius + dx)];
1835
+ if (!Number.isFinite(distance)) {
1836
+ continue;
1837
+ }
1838
+ const ground = groundAt ? groundAt(dx, dy) : Infinity;
1839
+ if (!(ground > 0 && distance >= ground * CLEARANCE_GROUND)) {
1840
+ near.push(distance);
1841
+ }
1842
+ }
1843
+ }
1844
+ const needed = Math.max(1, Math.ceil(width * width * CLEARANCE_SHARE));
1845
+ if (near.length < needed) {
1846
+ return Infinity;
1847
+ }
1848
+ near.sort((a, b) => a - b);
1849
+ return near[needed - 1];
1850
+ }
1851
+ /*
1852
+ * The level ground's view-axis distance through each window pixel, or null when there is no ground.
1853
+ */
1854
+ function groundDistances(state, position) {
1855
+ const scene = state.viewer.scene;
1856
+ const camera = scene.camera;
1857
+ const frustum = camera.frustum;
1858
+ if (!(state.getModelSpaceFrame || hasGround(state)) ||
1859
+ typeof (frustum === null || frustum === void 0 ? void 0 : frustum.getPixelDimensions) !== "function") {
1860
+ return null;
1861
+ }
1862
+ const plane = groundPlane(state);
1863
+ if (!plane) {
1864
+ return null;
1865
+ }
1866
+ const width = scene.drawingBufferWidth;
1867
+ const height = scene.drawingBufferHeight;
1868
+ // The size of one buffer pixel one metre ahead, which turns a pixel offset into a ray direction.
1869
+ const pixel = frustum.getPixelDimensions(width, height, 1, 1, new Cartesian2());
1870
+ const above = Plane.getPointDistance(plane, camera.positionWC);
1871
+ const normal = plane.normal;
1872
+ const along = Cartesian3.dot(camera.directionWC, normal);
1873
+ const right = Cartesian3.dot(camera.rightWC, normal);
1874
+ const up = Cartesian3.dot(camera.upWC, normal);
1875
+ // The cursor's offset from the centre in buffer pixels, rows bottom-up as the window's are.
1876
+ const x = Math.floor(position.x * width / scene.canvas.clientWidth) + 0.5 - width / 2;
1877
+ const y = height / 2 - Math.floor(position.y * height / scene.canvas.clientHeight) - 0.5;
1878
+ return (dx, dy) => {
1879
+ const rate = along + (x + dx) * pixel.x * right + (y + dy) * pixel.y * up;
1880
+ return rate < 0 ? -above / rate : Infinity;
1881
+ };
1882
+ }
1883
+ /*
1884
+ * The point under a screen position, and how far a zoom toward it may go before passing parts beside it.
1771
1885
  */
1772
1886
  function pickTarget(state, position) {
1887
+ const scene = state.viewer.scene;
1888
+ // Read before anything else picks, while the depth still holds the frame on screen.
1889
+ const depths = scene.pickPositionSupported ? readWindow(scene, position) : null;
1890
+ const target = pickPoint(state, position, depths);
1891
+ if (target && depths) {
1892
+ target.reach = NearClearance(depths.distances, depths.radius, groundDistances(state, position));
1893
+ target.reachFrom = Cartesian3.clone(state.viewer.camera.positionWC);
1894
+ }
1895
+ return target;
1896
+ }
1897
+ /*
1898
+ * The point under a screen position: what is drawn there, else the ground plane, else a point at the last distance.
1899
+ */
1900
+ function pickPoint(state, position, depths) {
1773
1901
  const viewer = state.viewer;
1774
1902
  const scene = viewer.scene;
1775
1903
  const camera = viewer.camera;
@@ -1794,12 +1922,16 @@ function pickTarget(state, position) {
1794
1922
  }
1795
1923
  const plausible = plausibleDistance(state);
1796
1924
  // A click between point cloud points sees the background; turning or zooming about that throws the camera far off.
1797
- const surface = scene.pickPositionSupported ? fillGap(scene, position, ahead !== null && ahead !== void 0 ? ahead : null) : null;
1925
+ const surface = depths ? fillGap(scene, position, ahead !== null && ahead !== void 0 ? ahead : null, depths.distances, depths.radius) : null;
1798
1926
  if (isAhead(camera, surface) && Cartesian3.distance(surface, camera.positionWC) < plausible) {
1799
1927
  return { point: surface, source: "pick", ground: false };
1800
1928
  }
1801
1929
  if (isAhead(camera, picked) && Cartesian3.distance(picked, camera.positionWC) < plausible) {
1802
- return { point: picked, source: "pick", ground: isGroundPick(state, position) };
1930
+ const ground = isGroundPick(state, position);
1931
+ // Right after a jump a stand-in tileset's coarse tiles cut far under the curve; use sea level.
1932
+ if (!ground || globeShown(state) || heightOf(state, picked) > GROUND_FLOOR) {
1933
+ return { point: picked, source: "pick", ground };
1934
+ }
1803
1935
  }
1804
1936
  const ground = groundPlane(state);
1805
1937
  const onGround = ground ? IntersectionTests.rayPlane(ray, ground) : null;
@@ -1901,8 +2033,8 @@ function onPointerDown(state, e) {
1901
2033
  if (!picked) {
1902
2034
  return;
1903
2035
  }
1904
- const target = picked.point;
1905
2036
  const camera = viewer.camera;
2037
+ const target = kind === EDrag.Zoom ? picked.point : GrabPoint(camera, position, picked);
1906
2038
  const distance = Cartesian3.distance(camera.positionWC, target);
1907
2039
  state.lastDistance = Math.max(distance, MIN_ZOOM_DISTANCE);
1908
2040
  const drag = { kind, pointerId: e.pointerId, last: position, target, up: upAt(state, target), distance, picked };
@@ -1910,10 +2042,28 @@ function onPointerDown(state, e) {
1910
2042
  drag.plane = panPlane(camera, target, drag.up);
1911
2043
  }
1912
2044
  else if (kind === EDrag.Zoom) {
2045
+ holdSurface(state);
1913
2046
  drag.direction = Cartesian3.normalize(Cartesian3.subtract(target, camera.positionWC, new Cartesian3()), new Cartesian3());
1914
2047
  }
1915
2048
  state.drag = drag;
1916
2049
  }
2050
+ /*
2051
+ * Where a pan or orbit takes hold: the pick, or beside the cursor when it looked far past parts there.
2052
+ */
2053
+ function GrabPoint(camera, position, picked) {
2054
+ const reach = picked.reach;
2055
+ const ray = camera.getPickRay(position);
2056
+ if (!ray || reach == null || !Number.isFinite(reach)) {
2057
+ return picked.point;
2058
+ }
2059
+ const facing = Cartesian3.dot(ray.direction, camera.directionWC);
2060
+ const depth = Cartesian3.dot(Cartesian3.subtract(picked.point, camera.positionWC, new Cartesian3()), camera.directionWC);
2061
+ if (facing <= 0 || depth <= reach * CLEARANCE_GRAB) {
2062
+ return picked.point;
2063
+ }
2064
+ // The reach is along the view axis, so the ray goes a little further to the same depth.
2065
+ return Ray.getPoint(ray, Math.max(reach, MIN_ZOOM_DISTANCE) / facing);
2066
+ }
1917
2067
  /*
1918
2068
  * A level plane through the grabbed point, or one facing the camera when the level one is seen edge on.
1919
2069
  */
@@ -2062,6 +2212,7 @@ function onWheel(state, e) {
2062
2212
  if (!target || !ray) {
2063
2213
  return;
2064
2214
  }
2215
+ holdSurface(state);
2065
2216
  const step = zoomStep(state, ray.direction, target, notches);
2066
2217
  Cartesian3.add(state.pendingZoom, step, state.pendingZoom);
2067
2218
  state.zoomPosition = Cartesian3.clone(camera.position);
@@ -2090,6 +2241,8 @@ function easeZoom(state) {
2090
2241
  const step = Cartesian3.multiplyByScalar(state.pendingZoom, share, new Cartesian3());
2091
2242
  Cartesian3.subtract(state.pendingZoom, step, state.pendingZoom);
2092
2243
  Cartesian3.add(viewer.camera.position, step, viewer.camera.position);
2244
+ zoomMoved(state);
2245
+ keepAboveGround(state);
2093
2246
  state.zoomPosition = Cartesian3.clone(viewer.camera.position);
2094
2247
  viewer.scene.requestRender();
2095
2248
  if (share < 1) {
@@ -2099,6 +2252,7 @@ function easeZoom(state) {
2099
2252
  function moveAlong(state, direction, target, notches) {
2100
2253
  const step = zoomStep(state, direction, target, notches);
2101
2254
  Cartesian3.add(state.viewer.camera.position, step, state.viewer.camera.position);
2255
+ zoomMoved(state);
2102
2256
  }
2103
2257
  /*
2104
2258
  * The move for some notches toward a target along a direction, a share of the distance with a floor so it never stalls.
@@ -2108,7 +2262,14 @@ function zoomStep(state, direction, picked, notches) {
2108
2262
  const target = picked.point;
2109
2263
  // Where the camera will be once the glide already under way ends, which this step continues from.
2110
2264
  const from = Cartesian3.add(camera.positionWC, state.pendingZoom, new Cartesian3());
2111
- const distance = Math.max(Cartesian3.distance(from, target), MIN_ZOOM_DISTANCE);
2265
+ const unit = Cartesian3.normalize(direction, new Cartesian3());
2266
+ let distance = Cartesian3.distance(from, target);
2267
+ // Between parts of a model, each step goes as far as it would on the nearest part around the cursor.
2268
+ if (picked.reach != null && picked.reachFrom) {
2269
+ const travelled = Cartesian3.dot(Cartesian3.subtract(from, picked.reachFrom, new Cartesian3()), unit);
2270
+ distance = Math.min(distance, picked.reach - travelled);
2271
+ }
2272
+ distance = Math.max(distance, MIN_ZOOM_DISTANCE);
2112
2273
  state.lastDistance = distance;
2113
2274
  let length = distance * ZOOM_SHARE * notches * zoomSpeedShare(state, picked);
2114
2275
  // A geospatial camera zooming out hands over to CesiumJS once it is high enough, so only model-space is capped.
@@ -2120,7 +2281,6 @@ function zoomStep(state, direction, picked, notches) {
2120
2281
  return new Cartesian3();
2121
2282
  }
2122
2283
  }
2123
- const unit = Cartesian3.normalize(direction, new Cartesian3());
2124
2284
  // With the globe hidden there is no hand-over, so zooming out stops where the Earth is a dot.
2125
2285
  if (length < 0 && !state.getModelSpaceFrame && !globeShown(state)) {
2126
2286
  const rise = -Cartesian3.dot(unit, upAt(state, from));
@@ -2136,15 +2296,14 @@ function zoomStep(state, direction, picked, notches) {
2136
2296
  return length > 0 ? resistDescent(state, from, step, picked, notches) : step;
2137
2297
  }
2138
2298
  /*
2139
- * How fast to zoom toward a target: slower toward a guess, or while the terrain that would give a real one loads.
2299
+ * How fast to zoom toward a target: slower toward a guess, or while the ground that would give a real one loads.
2140
2300
  */
2141
2301
  function zoomSpeedShare(state, picked) {
2142
2302
  let share = 1;
2143
2303
  if (picked.source !== "pick") {
2144
2304
  share *= ZOOM_GUESS_SHARE;
2145
2305
  }
2146
- const globe = state.viewer.scene.globe;
2147
- if (!state.getModelSpaceFrame && globeShown(state) && globe.tilesLoaded === false) {
2306
+ if (!state.getModelSpaceFrame && groundLoading(state)) {
2148
2307
  share *= ZOOM_LOADING_SHARE;
2149
2308
  }
2150
2309
  return share;
@@ -2160,16 +2319,17 @@ function groundUnderMove(state, from, step, picked) {
2160
2319
  if (picked === null || picked === void 0 ? void 0 : picked.ground) {
2161
2320
  return { point: picked.point, up: upAt(state, picked.point) };
2162
2321
  }
2163
- if (!globeShown(state)) {
2164
- return null;
2165
- }
2166
2322
  const ellipsoid = ellipsoidOf(state);
2167
2323
  const end = Cartesian3.add(from, step, new Cartesian3());
2168
2324
  const carto = ellipsoid.cartesianToCartographic(end);
2169
2325
  if (!carto) {
2170
2326
  return null;
2171
2327
  }
2172
- const height = (_b = (_a = terrainHeightAt(state, carto)) !== null && _a !== void 0 ? _a : terrainHeightAt(state, ellipsoid.cartesianToCartographic(from))) !== null && _b !== void 0 ? _b : 0;
2328
+ // Unloaded terrain counts as sea level; an unknown stand-in tileset counts as nothing.
2329
+ const height = (_b = (_a = groundHeightAt(state, carto)) !== null && _a !== void 0 ? _a : groundHeightAt(state, ellipsoid.cartesianToCartographic(from))) !== null && _b !== void 0 ? _b : (globeShown(state) ? 0 : null);
2330
+ if (height == null) {
2331
+ return null;
2332
+ }
2173
2333
  const point = Cartesian3.fromRadians(carto.longitude, carto.latitude, height, ellipsoid);
2174
2334
  return { point, up: ellipsoid.geodeticSurfaceNormal(point, new Cartesian3()) };
2175
2335
  }
@@ -2219,12 +2379,77 @@ function resistDescent(state, from, step, picked, notches) {
2219
2379
  const needed = scanScene(state).undergroundData ? PUSH_NOTCHES_DATA_BELOW : PUSH_NOTCHES_NOTHING_BELOW;
2220
2380
  if (state.push.notches >= needed) {
2221
2381
  state.push.notches = 0;
2382
+ state.surface = { above: false, through: true, until: now + SURFACE_HOLD_MS, at: null };
2222
2383
  // A shallow push would land far along the ground to get under it, so it goes no further than a usual step.
2223
2384
  const through = Math.min((above + GROUND_BREAK_DEPTH) / sink, Math.max(length, (above + GROUND_BREAK_DEPTH) * 4));
2224
2385
  return Cartesian3.multiplyByScalar(unit, through, new Cartesian3());
2225
2386
  }
2226
2387
  return Cartesian3.multiplyByScalar(unit, toStandOff, new Cartesian3());
2227
2388
  }
2389
+ /*
2390
+ * The camera's height above the loaded ground under it, or undefined without ground or in model-space.
2391
+ */
2392
+ function heightAboveGround(state) {
2393
+ if (state.getModelSpaceFrame || !hasGround(state)) {
2394
+ return undefined;
2395
+ }
2396
+ const carto = ellipsoidOf(state).cartesianToCartographic(state.viewer.camera.positionWC);
2397
+ const ground = carto ? groundHeightAt(state, carto) : undefined;
2398
+ return ground == null ? undefined : carto.height - ground;
2399
+ }
2400
+ /*
2401
+ * Notes whether the camera is above the ground as a zoom begins, unless it is being pushed through it.
2402
+ */
2403
+ function holdSurface(state) {
2404
+ var _a;
2405
+ const now = Date.now();
2406
+ if (state.surface.through && now < state.surface.until) {
2407
+ return;
2408
+ }
2409
+ const at = Cartesian3.clone(state.viewer.camera.positionWC);
2410
+ // Ground not loaded yet counts as sea level, as it does for a descent.
2411
+ const above = (_a = heightAboveGround(state)) !== null && _a !== void 0 ? _a : (hasGround(state) && !state.getModelSpaceFrame ? heightOf(state, at) : undefined);
2412
+ state.surface = { above: above != null && above > 0, through: false, until: now + SURFACE_HOLD_MS, at };
2413
+ }
2414
+ /*
2415
+ * Lifts a camera a zoom kept above the ground back over finer ground that loads in higher.
2416
+ */
2417
+ function keepAboveGround(state) {
2418
+ const surface = state.surface;
2419
+ const now = Date.now();
2420
+ if (!surface.above || !state.ours || now > surface.until + SURFACE_LOADING_MS) {
2421
+ return;
2422
+ }
2423
+ // Ground that has finished loading does not move under a still camera.
2424
+ if (now > surface.until && !groundLoading(state)) {
2425
+ return;
2426
+ }
2427
+ const camera = state.viewer.camera;
2428
+ // A bookmark, fly-to or pan moved it since, which may mean to go below the ground.
2429
+ if (!surface.at || !Cartesian3.equalsEpsilon(camera.positionWC, surface.at, 0, 1e-3)) {
2430
+ surface.above = false;
2431
+ return;
2432
+ }
2433
+ const above = heightAboveGround(state);
2434
+ if (above == null || above >= GROUND_STANDOFF / 2) {
2435
+ return;
2436
+ }
2437
+ const ellipsoid = ellipsoidOf(state);
2438
+ const carto = ellipsoid.cartesianToCartographic(camera.positionWC);
2439
+ Cartesian3.fromRadians(carto.longitude, carto.latitude, carto.height - above + GROUND_STANDOFF, ellipsoid, camera.position);
2440
+ // What is left of the glide would take it straight back down.
2441
+ state.pendingZoom = new Cartesian3();
2442
+ surface.at = Cartesian3.clone(camera.position);
2443
+ state.viewer.scene.requestRender();
2444
+ }
2445
+ /*
2446
+ * Notes where a zoom just put the camera, so the ground hold can tell its moves from others.
2447
+ */
2448
+ function zoomMoved(state) {
2449
+ if (state.surface.at) {
2450
+ Cartesian3.clone(state.viewer.camera.positionWC, state.surface.at);
2451
+ }
2452
+ }
2228
2453
  /*
2229
2454
  * What the scene holds that the camera cares about, rescanned at most every couple of seconds.
2230
2455
  */
@@ -2235,7 +2460,7 @@ function scanScene(state) {
2235
2460
  return applyOverride(state, state.scan);
2236
2461
  }
2237
2462
  const scene = state.viewer.scene;
2238
- const found = { at: now, undergroundData: false, groundTileset: false };
2463
+ const found = { at: now, undergroundData: false, groundTileset: false, ground: null };
2239
2464
  // Seeing through the ground is turned on to look at what is under it.
2240
2465
  if ((_b = (_a = scene.globe) === null || _a === void 0 ? void 0 : _a.translucency) === null || _b === void 0 ? void 0 : _b.enabled) {
2241
2466
  found.undergroundData = true;
@@ -2252,6 +2477,7 @@ function scanScene(state) {
2252
2477
  }
2253
2478
  if (primitive[GROUND_TILESET_KEY]) {
2254
2479
  found.groundTileset = true;
2480
+ found.ground = primitive;
2255
2481
  return;
2256
2482
  }
2257
2483
  if (!found.undergroundData && reachesBelowGround(state, lowestPointOf(primitive))) {
@@ -14309,7 +14535,7 @@ function updateEntityShow(viewer, rego, show) {
14309
14535
  }
14310
14536
  }
14311
14537
  function updateEntity(viewer, entityId, register, refresh, cache = {}) {
14312
- var _a, _b, _c;
14538
+ var _a, _b, _c, _d;
14313
14539
  if (!entityId) {
14314
14540
  // What are we doing?
14315
14541
  return;
@@ -14396,7 +14622,8 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
14396
14622
  }
14397
14623
  }
14398
14624
  if (refresh === true || (refresh !== false && (refresh === null || refresh === void 0 ? void 0 : refresh.opacity))) {
14399
- let effectiveOpacity = state.opacity;
14625
+ // An Entity's own opacity wins over the one its menu item's bookmark style asks for.
14626
+ let effectiveOpacity = (_b = state.opacity) !== null && _b !== void 0 ? _b : register.GetMenuItemOpacity(rego.menuItemId);
14400
14627
  if ((effectiveOpacity == null || effectiveOpacity == 1) && !state.isolated && visible) {
14401
14628
  if (cache.isolationOpacity === undefined) {
14402
14629
  cache.isolationOpacity = register.GetIsolationOpacity();
@@ -14427,14 +14654,14 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
14427
14654
  EntityLabel.Attach({
14428
14655
  rego,
14429
14656
  viewer,
14430
- api: (_b = register.ApiGetters) === null || _b === void 0 ? void 0 : _b.GetBruceApi(),
14657
+ api: (_c = register.ApiGetters) === null || _c === void 0 ? void 0 : _c.GetBruceApi(),
14431
14658
  visualRegister: register,
14432
14659
  options: labelGroup ? labelGroup.options : register.GetLabelDefaults(),
14433
14660
  groupId: labelGroup === null || labelGroup === void 0 ? void 0 : labelGroup.groupId,
14434
14661
  persistent: true
14435
14662
  });
14436
14663
  }
14437
- else if (!visible || ((_c = EntityLabel.GetLabel({ rego })) === null || _c === void 0 ? void 0 : _c.Persistent)) {
14664
+ else if (!visible || ((_d = EntityLabel.GetLabel({ rego })) === null || _d === void 0 ? void 0 : _d.Persistent)) {
14438
14665
  EntityLabel.Detatch({
14439
14666
  rego, force: true
14440
14667
  });
@@ -14604,6 +14831,8 @@ var VisualsRegister;
14604
14831
  // When no Menu Item ID is set, then the second key is a blank string.
14605
14832
  // If an Entity ID state is set without a Menu Item ID, then it acts as a default for all Menu Items.
14606
14833
  this.states = {};
14834
+ // Opacity a whole menu item is drawn at, from its bookmark style; never a saved state.
14835
+ this.menuItemOpacities = new Map();
14607
14836
  // Queue of Entity updates to process in batches to avoid overloading the render loop.
14608
14837
  this.updateQueue = [];
14609
14838
  // Mirrors updateQueue for O(1) "already queued" checks.
@@ -15588,7 +15817,7 @@ var VisualsRegister;
15588
15817
  return;
15589
15818
  }
15590
15819
  this.dimmingDirty = false;
15591
- const dimming = Object.values(this.states).some(states => Object.values(states).some(state => state.isolated || (state.opacity != null && state.opacity < 1)));
15820
+ const dimming = Object.values(this.states).some(states => Object.values(states).some(state => state.isolated || (state.opacity != null && state.opacity < 1))) || this.menuItemOpacities.size > 0;
15592
15821
  if (!CesiumEntityStyler.SetDimming(this.viewer, this.id, dimming)) {
15593
15822
  return;
15594
15823
  }
@@ -17174,6 +17403,34 @@ var VisualsRegister;
17174
17403
  }
17175
17404
  return (totalOpacity && totalTicks) ? (totalOpacity / totalTicks) : totalOpacity != null && typeof totalOpacity == "number" ? totalOpacity : 1;
17176
17405
  }
17406
+ /**
17407
+ * Draws every Entity of a menu item at this opacity unless it has its own; null puts them back.
17408
+ * It is not a visual state, so a Bookmark save does not store it per Entity.
17409
+ */
17410
+ SetMenuItemOpacity(params) {
17411
+ var _a, _b, _c;
17412
+ const { menuItemId, opacity } = params;
17413
+ const wanted = typeof opacity === "number" && opacity >= 0 && opacity < 1 ? opacity : null;
17414
+ if (((_a = this.menuItemOpacities.get(menuItemId)) !== null && _a !== void 0 ? _a : null) === wanted) {
17415
+ return;
17416
+ }
17417
+ if (wanted == null) {
17418
+ this.menuItemOpacities.delete(menuItemId);
17419
+ }
17420
+ else {
17421
+ this.menuItemOpacities.set(menuItemId, wanted);
17422
+ }
17423
+ this.dimmingDirty = true;
17424
+ const entityIds = new Set(this.GetRegos({ menuItemId }).map(rego => rego.entityId).filter(Boolean));
17425
+ entityIds.forEach(entityId => this.queueUpdate({ entityId, refresh: { opacity: true } }));
17426
+ if (params.requestRender !== false) {
17427
+ (_c = (_b = this.viewer) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.requestRender();
17428
+ }
17429
+ }
17430
+ GetMenuItemOpacity(menuItemId) {
17431
+ var _a;
17432
+ return menuItemId ? ((_a = this.menuItemOpacities.get(menuItemId)) !== null && _a !== void 0 ? _a : null) : null;
17433
+ }
17177
17434
  ClearOpacity(params) {
17178
17435
  const clearedIds = new Set();
17179
17436
  this.ForEachState((state) => {
@@ -17545,18 +17802,57 @@ var MenuItemStyleOverlay;
17545
17802
  MenuItem.EType.EntitiesLoaded,
17546
17803
  MenuItem.EType.DataLab
17547
17804
  ];
17805
+ // The row every Entities render manager draws an item with when it names none.
17806
+ const DEFAULT_ZOOM_ROW = {
17807
+ MinZoom: 0,
17808
+ MaxZoom: 200000,
17809
+ DisplayType: ZoomControl.EDisplayType.Model3D,
17810
+ LODCategoryID: "glb",
17811
+ LODLevel: 0,
17812
+ StyleID: 0
17813
+ };
17814
+ // Instructions an overlay carries that are not style fields, so a merge never copies them onto a style.
17815
+ const INSTRUCTION_KEYS = ["types", "expandSources", "opacity"];
17548
17816
  /**
17549
- * Returns the base style with each field the overlay sets laid over it.
17817
+ * Returns the base style with each field the overlay sets laid over it, then its style for the Entity Type when given.
17550
17818
  */
17551
- function Merge(base, overlay) {
17552
- var _a, _b;
17819
+ function Merge(base, overlay, entityTypeId) {
17820
+ var _a;
17553
17821
  if (!overlay) {
17554
17822
  return base;
17555
17823
  }
17556
- const merged = { ...(base !== null && base !== void 0 ? base : {}) };
17824
+ const merged = layFields({ ...(base !== null && base !== void 0 ? base : {}) }, overlay);
17825
+ const typed = entityTypeId ? (_a = overlay.types) === null || _a === void 0 ? void 0 : _a[entityTypeId] : null;
17826
+ return typed ? layFields(merged, typed) : merged;
17827
+ }
17828
+ MenuItemStyleOverlay.Merge = Merge;
17829
+ /**
17830
+ * Returns whether an overlay paints a model fill, for the layer or for any Entity Type in it.
17831
+ */
17832
+ function SetsModelFill(overlay) {
17833
+ var _a;
17834
+ if (!overlay) {
17835
+ return false;
17836
+ }
17837
+ const types = Object.values((_a = overlay.types) !== null && _a !== void 0 ? _a : {});
17838
+ return [overlay, ...types].some(style => { var _a; return isSet((_a = style === null || style === void 0 ? void 0 : style.modelStyle) === null || _a === void 0 ? void 0 : _a.fillColor); });
17839
+ }
17840
+ MenuItemStyleOverlay.SetsModelFill = SetsModelFill;
17841
+ /**
17842
+ * Returns whether an overlay asks for attributes read from the Entities' sources.
17843
+ */
17844
+ function ExpandsSources(overlay) {
17845
+ return Boolean(overlay === null || overlay === void 0 ? void 0 : overlay.expandSources);
17846
+ }
17847
+ MenuItemStyleOverlay.ExpandsSources = ExpandsSources;
17848
+ /*
17849
+ * Lays each style field an overlay sets onto a copy already taken, leaving its instructions behind.
17850
+ */
17851
+ function layFields(merged, overlay) {
17852
+ var _a, _b;
17557
17853
  for (const key of Object.keys(overlay)) {
17558
17854
  const value = overlay[key];
17559
- if (!isSet(value)) {
17855
+ if (INSTRUCTION_KEYS.includes(key) || !isSet(value)) {
17560
17856
  continue;
17561
17857
  }
17562
17858
  if (isPlainObject(value)) {
@@ -17572,12 +17868,11 @@ var MenuItemStyleOverlay;
17572
17868
  }
17573
17869
  return merged;
17574
17870
  }
17575
- MenuItemStyleOverlay.Merge = Merge;
17576
17871
  /**
17577
- * Returns the overlay a zoom control row carries laid over the style it resolved.
17872
+ * Returns the overlay a zoom control row carries laid over the style it resolved, for an Entity of the given type.
17578
17873
  */
17579
- function ApplyRow(style, row) {
17580
- return Merge(style, row === null || row === void 0 ? void 0 : row.StyleOverlay);
17874
+ function ApplyRow(style, row, entityTypeId) {
17875
+ return Merge(style, row === null || row === void 0 ? void 0 : row.StyleOverlay, entityTypeId);
17581
17876
  }
17582
17877
  MenuItemStyleOverlay.ApplyRow = ApplyRow;
17583
17878
  /**
@@ -17616,7 +17911,7 @@ var MenuItemStyleOverlay;
17616
17911
  * Returns a copy carrying the overlay, or the item itself when it cannot take one and carries none.
17617
17912
  */
17618
17913
  function With(item, overlay) {
17619
- var _a;
17914
+ var _a, _b;
17620
17915
  const target = Supports(item) ? overlay : null;
17621
17916
  if (!target && !Get(item)) {
17622
17917
  return item;
@@ -17632,9 +17927,11 @@ var MenuItemStyleOverlay;
17632
17927
  return next;
17633
17928
  }
17634
17929
  const zItem = item;
17930
+ // An item with no rows is drawn on the render managers' own default row, which has to carry the overlay too.
17931
+ const rows = ((_a = zItem.CameraZoomSettings) === null || _a === void 0 ? void 0 : _a.length) || !target ? ((_b = zItem.CameraZoomSettings) !== null && _b !== void 0 ? _b : []) : [{ ...DEFAULT_ZOOM_ROW }];
17635
17932
  return {
17636
17933
  ...zItem,
17637
- CameraZoomSettings: ((_a = zItem.CameraZoomSettings) !== null && _a !== void 0 ? _a : []).map(row => {
17934
+ CameraZoomSettings: rows.map(row => {
17638
17935
  const next = { ...row };
17639
17936
  if (target) {
17640
17937
  next.StyleOverlay = target;
@@ -17836,6 +18133,8 @@ class TilesetStyler {
17836
18133
  this.scenario = 0;
17837
18134
  // Indicates that we should expand the sources of the Entity.
17838
18135
  this.expandSources = false;
18136
+ // What the item itself asks for, which an overlay reading sourced attributes can only add to.
18137
+ this.ownExpandSources = false;
17839
18138
  // Indicates that we are retrieving historic records.
17840
18139
  // This means that the current scene's time is included in the request.
17841
18140
  this.historic = false;
@@ -17901,8 +18200,9 @@ class TilesetStyler {
17901
18200
  this.applyStyles = Boolean(applyStyles);
17902
18201
  }
17903
18202
  if (expandSources != null) {
17904
- this.expandSources = expandSources;
18203
+ this.ownExpandSources = expandSources;
17905
18204
  }
18205
+ this.expandSources = this.ownExpandSources || MenuItemStyleOverlay.ExpandsSources(this.styleOverlay);
17906
18206
  if (fallbackStyleId != null) {
17907
18207
  this.fallbackStyleId = fallbackStyleId;
17908
18208
  }
@@ -18039,11 +18339,13 @@ class TilesetStyler {
18039
18339
  this.historic = params.historic;
18040
18340
  }
18041
18341
  if (params.expandSources != null) {
18042
- if (this.expandSources != params.expandSources) {
18043
- this.shouldUpdateRegoStates = true;
18044
- }
18045
- this.expandSources = params.expandSources;
18342
+ this.ownExpandSources = params.expandSources;
18343
+ }
18344
+ const expandSources = this.ownExpandSources || MenuItemStyleOverlay.ExpandsSources(this.styleOverlay);
18345
+ if (this.expandSources != expandSources) {
18346
+ this.shouldUpdateRegoStates = true;
18046
18347
  }
18348
+ this.expandSources = expandSources;
18047
18349
  // Reload styles.
18048
18350
  if (this.loaded) {
18049
18351
  this.styledEntityIds.clear();
@@ -18118,12 +18420,12 @@ class TilesetStyler {
18118
18420
  * Replaces the tileset's own colours while an overlay sets a model fill, so features show exactly what it maps to.
18119
18421
  */
18120
18422
  applyOverlayBlend() {
18121
- var _a, _b, _c, _d;
18423
+ var _a, _b;
18122
18424
  if (!this.cTileset || ((_b = (_a = this.cTileset).isDestroyed) === null || _b === void 0 ? void 0 : _b.call(_a))) {
18123
18425
  return;
18124
18426
  }
18125
- const fill = (_d = (_c = this.styleOverlay) === null || _c === void 0 ? void 0 : _c.modelStyle) === null || _d === void 0 ? void 0 : _d.fillColor;
18126
- const colours = Array.isArray(fill) ? fill.length > 0 : fill != null;
18427
+ // A fill for one Entity Type replaces too, as does a hide, which is a fully transparent fill.
18428
+ const colours = MenuItemStyleOverlay.SetsModelFill(this.styleOverlay);
18127
18429
  if (colours && this.blendBeforeOverlay == null) {
18128
18430
  this.blendBeforeOverlay = this.cTileset.colorBlendMode;
18129
18431
  this.cTileset.colorBlendMode = Cesium3DTileColorBlendMode.REPLACE;
@@ -18599,7 +18901,7 @@ class TilesetStyler {
18599
18901
  style = (_b = this.fallbackStyle) === null || _b === void 0 ? void 0 : _b.Settings;
18600
18902
  styleId = this.fallbackStyleId != null ? Number(this.fallbackStyleId) : null;
18601
18903
  }
18602
- style = MenuItemStyleOverlay.Merge(style, this.styleOverlay);
18904
+ style = MenuItemStyleOverlay.Merge(style, this.styleOverlay, entityTypeId);
18603
18905
  if (!style || !((_c = style === null || style === void 0 ? void 0 : style.modelStyle) === null || _c === void 0 ? void 0 : _c.customize)) {
18604
18906
  return { settings: null, styleId: null };
18605
18907
  }
@@ -23021,7 +23323,7 @@ var EntitiesRenderManager;
23021
23323
  console.error(e);
23022
23324
  }
23023
23325
  }
23024
- style = MenuItemStyleOverlay.ApplyRow(style, zoomItem);
23326
+ style = MenuItemStyleOverlay.ApplyRow(style, zoomItem, entityTypeId);
23025
23327
  const pStyle = (_g = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _g !== void 0 ? _g : {};
23026
23328
  const lStyle = (_h = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _h !== void 0 ? _h : {};
23027
23329
  const polygonsClamped = ((_j = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _j === void 0 ? void 0 : _j.id) == null ? true : ((_k = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _k === void 0 ? void 0 : _k.id) == 0;
@@ -24128,7 +24430,7 @@ var EntitiesLoadedRenderManager;
24128
24430
  if (!style) {
24129
24431
  style = zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.Style;
24130
24432
  }
24131
- style = MenuItemStyleOverlay.ApplyRow(style, zoomItem);
24433
+ style = MenuItemStyleOverlay.ApplyRow(style, zoomItem, entityTypeId);
24132
24434
  const pStyle = (_h = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _h !== void 0 ? _h : {};
24133
24435
  const lStyle = (_j = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _j !== void 0 ? _j : {};
24134
24436
  const polygonsClamped = ((_k = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _k === void 0 ? void 0 : _k.id) == null ? true : ((_l = pStyle === null || pStyle === void 0 ? void 0 : pStyle.altitudeOption) === null || _l === void 0 ? void 0 : _l.id) == 0;
@@ -35642,7 +35944,15 @@ var MenuItemStyles;
35642
35944
  if (laid == null) {
35643
35945
  return next;
35644
35946
  }
35645
- return MenuItemStyleOverlay.WithItemStyle(next, itemStyle);
35947
+ // These two only run a Styler with Apply Styles on, and a bookmark that lays colours on one needs them drawn; opacity alone does not.
35948
+ const inline = MenuItemStyleOverlay.GetItemStyle(alternation);
35949
+ const drawsStyle = inline
35950
+ ? Object.keys(inline).some(key => key !== "opacity" && key !== "expandSources")
35951
+ : MenuItemStyleOverlay.GetItemStyleId(alternation) != null;
35952
+ const styled = drawsStyle && (next.Type === MenuItem.EType.ArbTileset || next.Type === MenuItem.EType.EntityTileset) && !next.ApplyStyles
35953
+ ? { ...next, ApplyStyles: true }
35954
+ : next;
35955
+ return MenuItemStyleOverlay.WithItemStyle(styled, itemStyle);
35646
35956
  }
35647
35957
  MenuItemStyles.ApplyAlternation = ApplyAlternation;
35648
35958
  /**
@@ -36397,6 +36707,7 @@ var MenuItemManager;
36397
36707
  }
36398
36708
  }
36399
36709
  if (rItem.renderManager && !((_g = rItem.renderManager) === null || _g === void 0 ? void 0 : _g.Disposed)) {
36710
+ this.syncItemOpacity(rItem);
36400
36711
  (_h = this.onUpdate) === null || _h === void 0 ? void 0 : _h.Trigger({ isEnabling: true, itemId: rItem.id });
36401
36712
  }
36402
36713
  return rItem.id;
@@ -36407,7 +36718,7 @@ var MenuItemManager;
36407
36718
  * @param params
36408
36719
  */
36409
36720
  RemoveItemById(params) {
36410
- var _a, _b;
36721
+ var _a, _b, _c;
36411
36722
  let { menuItemId: id, recursive, allowHandoff } = params;
36412
36723
  if (this.viewer.isDestroyed()) {
36413
36724
  return;
@@ -36442,8 +36753,9 @@ var MenuItemManager;
36442
36753
  }
36443
36754
  this.ClearSeriesSegments(item.id);
36444
36755
  }
36756
+ (_b = this.visualsRegister) === null || _b === void 0 ? void 0 : _b.SetMenuItemOpacity({ menuItemId: item.id, opacity: null, requestRender: false });
36445
36757
  this.items = this.items.filter(x => x.id !== id);
36446
- (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: false, itemId: item.id });
36758
+ (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: false, itemId: item.id });
36447
36759
  }
36448
36760
  }
36449
36761
  /**
@@ -36482,6 +36794,7 @@ var MenuItemManager;
36482
36794
  const next = MenuItemStyleOverlay.With(chosen, this.getEffectiveOverlay(chosen, this.styleOverlay));
36483
36795
  rItem.renderManager.SwapStyle(next);
36484
36796
  rItem.item = next;
36797
+ this.syncItemOpacity(rItem);
36485
36798
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
36486
36799
  return true;
36487
36800
  }
@@ -36521,9 +36834,18 @@ var MenuItemManager;
36521
36834
  }
36522
36835
  rItem.renderManager.SwapStyle(next);
36523
36836
  rItem.item = next;
36837
+ this.syncItemOpacity(rItem);
36524
36838
  (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: true, itemId: rItem.id });
36525
36839
  }
36526
36840
  }
36841
+ /*
36842
+ * Draws an item at the opacity its bookmark style asks for, or opaque again once none is asked.
36843
+ */
36844
+ syncItemOpacity(rItem) {
36845
+ var _a, _b;
36846
+ const wanted = (_a = MenuItemStyleOverlay.GetItemStyle(rItem.item)) === null || _a === void 0 ? void 0 : _a.opacity;
36847
+ (_b = this.visualsRegister) === null || _b === void 0 ? void 0 : _b.SetMenuItemOpacity({ menuItemId: rItem.id, opacity: typeof wanted === "number" ? wanted : null });
36848
+ }
36527
36849
  /**
36528
36850
  * Lays an inline style or any Style record on one enabled item under the scene-wide one; neither clears it.
36529
36851
  */
@@ -36547,6 +36869,7 @@ var MenuItemManager;
36547
36869
  const next = MenuItemStyleOverlay.With(styled, this.getEffectiveOverlay(styled, this.styleOverlay));
36548
36870
  rItem.renderManager.SwapStyle(next);
36549
36871
  rItem.item = next;
36872
+ this.syncItemOpacity(rItem);
36550
36873
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
36551
36874
  return true;
36552
36875
  }
@@ -36596,6 +36919,7 @@ var MenuItemManager;
36596
36919
  const next = MenuItemStyleOverlay.With(rItem.item, effective);
36597
36920
  rItem.renderManager.SwapStyle(next);
36598
36921
  rItem.item = next;
36922
+ this.syncItemOpacity(rItem);
36599
36923
  (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: true, itemId: rItem.id });
36600
36924
  }
36601
36925
  }
@@ -53446,7 +53770,7 @@ var EntityRenderEnginePoint;
53446
53770
  * @returns
53447
53771
  */
53448
53772
  async function RenderGroup(params) {
53449
- var _a, _b, _c, _d, _e;
53773
+ var _a, _b, _c, _d, _e, _f;
53450
53774
  const api = params.apiGetter.getApi();
53451
53775
  const cEntities = new Map();
53452
53776
  // Gathering tags in case styling needs it.
@@ -53478,7 +53802,7 @@ var EntityRenderEnginePoint;
53478
53802
  const entity = params.entities[i];
53479
53803
  const zoomItem = params.zoomItems[entity.Bruce.ID];
53480
53804
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$1(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
53481
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
53805
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
53482
53806
  // Pass through tags that may be needed for styling.
53483
53807
  const tagIds = entity.Bruce["Layer.ID"];
53484
53808
  const tags = [];
@@ -53490,11 +53814,11 @@ var EntityRenderEnginePoint;
53490
53814
  }
53491
53815
  }
53492
53816
  }
53493
- const pStyle = (_b = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _b !== void 0 ? _b : {};
53817
+ const pStyle = (_c = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _c !== void 0 ? _c : {};
53494
53818
  let rego = null;
53495
53819
  // Only used for historic tracks right now.
53496
53820
  // So won't bother getting it if we don't have historic data.
53497
- if ((_c = params.entitiesHistoric) === null || _c === void 0 ? void 0 : _c[entity.Bruce.ID]) {
53821
+ if ((_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID]) {
53498
53822
  rego = params.visualRegister.GetRego({
53499
53823
  entityId: entity.Bruce.ID,
53500
53824
  menuItemId: params.menuItemId
@@ -53509,8 +53833,8 @@ var EntityRenderEnginePoint;
53509
53833
  apiGetter: params.apiGetter,
53510
53834
  maxDistance: zoomItem.MaxZoom,
53511
53835
  minDistance: zoomItem.MinZoom,
53512
- rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID),
53513
- entityHistoric: (_e = params.entitiesHistoric) === null || _e === void 0 ? void 0 : _e[entity.Bruce.ID],
53836
+ rendered: (_e = params.rendered) === null || _e === void 0 ? void 0 : _e.get(entity.Bruce.ID),
53837
+ entityHistoric: (_f = params.entitiesHistoric) === null || _f === void 0 ? void 0 : _f[entity.Bruce.ID],
53514
53838
  entityHistoricDrawTrack: params.entityHistoricDrawTrack,
53515
53839
  fullStyle: style,
53516
53840
  rego: rego
@@ -54340,7 +54664,7 @@ var EntityRenderEngineModel3d;
54340
54664
  * @returns
54341
54665
  */
54342
54666
  async function RenderGroup(params) {
54343
- var _a, _b, _c, _d, _e, _f, _g, _h;
54667
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
54344
54668
  const api = params.apiGetter.getApi();
54345
54669
  await api.Loading;
54346
54670
  const cEntities = new Map();
@@ -54378,7 +54702,7 @@ var EntityRenderEngineModel3d;
54378
54702
  const entity = params.entities[i];
54379
54703
  const zoomItem = params.zoomItems[entity.Bruce.ID];
54380
54704
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$2(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
54381
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
54705
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
54382
54706
  // Pass through tags that may be needed for styling.
54383
54707
  const tagIds = entity.Bruce["Layer.ID"];
54384
54708
  const tags = [];
@@ -54390,7 +54714,7 @@ var EntityRenderEngineModel3d;
54390
54714
  }
54391
54715
  }
54392
54716
  }
54393
- const mStyle = (_b = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _b !== void 0 ? _b : {};
54717
+ const mStyle = (_c = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _c !== void 0 ? _c : {};
54394
54718
  let group = mStyle.lodGroup ? Calculator.GetString(mStyle.lodGroup, entity, tags) : null;
54395
54719
  if (!group) {
54396
54720
  group = "DEFAULT";
@@ -54417,8 +54741,8 @@ var EntityRenderEngineModel3d;
54417
54741
  for (let i = 0; i < params.entities.length; i++) {
54418
54742
  const entity = params.entities[i];
54419
54743
  const zoomItem = params.zoomItems[entity.Bruce.ID];
54420
- const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_c = (await getStyle$2(api, entity, zoomItem.StyleID))) === null || _c === void 0 ? void 0 : _c.Settings : zoomItem.Style;
54421
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
54744
+ const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_d = (await getStyle$2(api, entity, zoomItem.StyleID))) === null || _d === void 0 ? void 0 : _d.Settings : zoomItem.Style;
54745
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e["EntityType.ID"]);
54422
54746
  const lod = lodData.find(x => x.entityId == entity.Bruce.ID);
54423
54747
  if (!(lod === null || lod === void 0 ? void 0 : lod.clientFileId)) {
54424
54748
  continue;
@@ -54437,21 +54761,21 @@ var EntityRenderEngineModel3d;
54437
54761
  let rego = null;
54438
54762
  // Only used for historic tracks right now.
54439
54763
  // So won't bother getting it if we don't have historic data.
54440
- if ((_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID]) {
54764
+ if ((_f = params.entitiesHistoric) === null || _f === void 0 ? void 0 : _f[entity.Bruce.ID]) {
54441
54765
  rego = params.visualRegister.GetRego({
54442
54766
  entityId: entity.Bruce.ID,
54443
54767
  menuItemId: params.menuItemId
54444
54768
  });
54445
54769
  }
54446
- const mStyle = (_e = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _e !== void 0 ? _e : {};
54770
+ const mStyle = (_g = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _g !== void 0 ? _g : {};
54447
54771
  const cEntity = Render({
54448
- rendered: (_f = params.rendered) === null || _f === void 0 ? void 0 : _f.get(entity.Bruce.ID),
54772
+ rendered: (_h = params.rendered) === null || _h === void 0 ? void 0 : _h.get(entity.Bruce.ID),
54449
54773
  entity: entity,
54450
- entityHistoric: (_g = params.entitiesHistoric) === null || _g === void 0 ? void 0 : _g[entity.Bruce.ID],
54774
+ entityHistoric: (_j = params.entitiesHistoric) === null || _j === void 0 ? void 0 : _j[entity.Bruce.ID],
54451
54775
  style: mStyle,
54452
54776
  tags: tags,
54453
54777
  viewer: params.viewer,
54454
- lodUrl: (_h = lod.url) !== null && _h !== void 0 ? _h : ClientFile.GetUrl({
54778
+ lodUrl: (_k = lod.url) !== null && _k !== void 0 ? _k : ClientFile.GetUrl({
54455
54779
  api,
54456
54780
  fileId: lod.clientFileId,
54457
54781
  viaCdn: true
@@ -54958,7 +55282,7 @@ var EntityRenderEnginePolyline;
54958
55282
  * @returns
54959
55283
  */
54960
55284
  async function RenderGroup(params) {
54961
- var _a, _b, _c;
55285
+ var _a, _b, _c, _d;
54962
55286
  const api = params.apiGetter.getApi();
54963
55287
  const cEntities = new Map();
54964
55288
  // Gathering tags in case styling needs it.
@@ -54990,7 +55314,7 @@ var EntityRenderEnginePolyline;
54990
55314
  const entity = params.entities[i];
54991
55315
  const zoomItem = params.zoomItems[entity.Bruce.ID];
54992
55316
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$3(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
54993
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
55317
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
54994
55318
  // Pass through tags that may be needed for styling.
54995
55319
  const tagIds = entity.Bruce["Layer.ID"];
54996
55320
  const tags = [];
@@ -55002,7 +55326,7 @@ var EntityRenderEnginePolyline;
55002
55326
  }
55003
55327
  }
55004
55328
  }
55005
- const lStyle = (_b = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _b !== void 0 ? _b : {};
55329
+ const lStyle = (_c = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _c !== void 0 ? _c : {};
55006
55330
  const cEntity = Render({
55007
55331
  entity: entity,
55008
55332
  style: lStyle,
@@ -55010,7 +55334,7 @@ var EntityRenderEnginePolyline;
55010
55334
  viewer: params.viewer,
55011
55335
  maxDistance: zoomItem.MaxZoom,
55012
55336
  minDistance: zoomItem.MinZoom,
55013
- rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID)
55337
+ rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID)
55014
55338
  });
55015
55339
  if (cEntity) {
55016
55340
  const name = await getName$2(api, entity, params.offline);
@@ -58339,6 +58663,23 @@ void main() {
58339
58663
  GetPlacementKey() {
58340
58664
  return [this.groundPixels ? 1 : 0, this.baseHeight, this.exaggeration, this.followGround ? 1 : 0].join("|");
58341
58665
  }
58666
+ /**
58667
+ * Repaints the sheet with new colours, keeping its geometry and the frames it is reading.
58668
+ */
58669
+ SetRamp(rampStops, lowColor, highColor) {
58670
+ const pixels = RampLookup(rampStops || null, lowColor || DEFAULT_LOW_COLOR, highColor || DEFAULT_HIGH_COLOR);
58671
+ // A re-render with the same colours keeps the texture it already has.
58672
+ if (this.rampPixels && pixels.length === this.rampPixels.length && pixels.every((value, i) => value === this.rampPixels[i])) {
58673
+ return;
58674
+ }
58675
+ this.rampPixels = pixels;
58676
+ this.maskFillValue = firstOpaqueStop(this.rampPixels);
58677
+ // Rebuilt from the new pixels on the next frame.
58678
+ if (this.rampTexture) {
58679
+ this.rampTexture.destroy();
58680
+ this.rampTexture = null;
58681
+ }
58682
+ }
58342
58683
  /**
58343
58684
  * The ramp the sheet is painted with, as 256 RGBA steps across the value range.
58344
58685
  */
@@ -59091,6 +59432,8 @@ const TEXTURE_FRAME_SERIES_ANIMATOR_KEY = "TextureFrameSeriesAnimator.Animator";
59091
59432
  const EXTRUSION_ANIMATOR_KEY = "TextureFrameSeriesAnimator.ExtrusionAnimator";
59092
59433
  const TEXTURE_VALUE_LABELS_KEY = "TextureValueLabels.Overlay";
59093
59434
  const DISPLACED_SURFACE_KEY = "DisplacedSurfacePrimitive.Surface";
59435
+ // Whether the surface's animator was built hiding the baseline, which it cannot change afterwards.
59436
+ const EXTRUSION_BASELINE_KEY = "TextureFrameSeriesAnimator.ExtrusionBaseline";
59094
59437
  var EntityRenderEnginePolygon;
59095
59438
  (function (EntityRenderEnginePolygon) {
59096
59439
  /**
@@ -59646,7 +59989,7 @@ var EntityRenderEnginePolygon;
59646
59989
  }
59647
59990
  EntityRenderEnginePolygon.Render = Render;
59648
59991
  async function RenderGroup(params) {
59649
- var _a, _b, _c, _d;
59992
+ var _a, _b, _c, _d, _e;
59650
59993
  const api = params.apiGetter.getApi();
59651
59994
  const cEntities = new Map();
59652
59995
  // Gathering tags in case styling needs it.
@@ -59678,7 +60021,7 @@ var EntityRenderEnginePolygon;
59678
60021
  const entity = params.entities[i];
59679
60022
  const zoomItem = params.zoomItems[entity.Bruce.ID];
59680
60023
  const ownStyle = (!params.offline && zoomItem.StyleID != -1) ? (_a = (await getStyle$4(api, entity, zoomItem.StyleID))) === null || _a === void 0 ? void 0 : _a.Settings : zoomItem.Style;
59681
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
60024
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
59682
60025
  // Pass through tags that may be needed for styling.
59683
60026
  const tagIds = entity.Bruce["Layer.ID"];
59684
60027
  const tags = [];
@@ -59690,7 +60033,7 @@ var EntityRenderEnginePolygon;
59690
60033
  }
59691
60034
  }
59692
60035
  }
59693
- const pStyle = (_b = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _b !== void 0 ? _b : {};
60036
+ const pStyle = (_c = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _c !== void 0 ? _c : {};
59694
60037
  let cEntity = null;
59695
60038
  try {
59696
60039
  cEntity = await Render({
@@ -59704,14 +60047,14 @@ var EntityRenderEnginePolygon;
59704
60047
  // Temporarily disabling re-using graphics for polygons as they have some bugs, and
59705
60048
  // they don't support any animation yet.
59706
60049
  // rendered: null
59707
- rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID),
60050
+ rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID),
59708
60051
  menuItemId: params.menuItemId,
59709
60052
  visualRegister: params.visualRegister,
59710
60053
  onSeriesDiscovered: params.onSeriesDiscovered
59711
60054
  });
59712
60055
  }
59713
60056
  catch (e) {
59714
- console.error(`Polygon.RenderGroup: failed to render entity ${((_d = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _d === void 0 ? void 0 : _d.ID) || "<NONE>"}:`, e);
60057
+ console.error(`Polygon.RenderGroup: failed to render entity ${((_e = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _e === void 0 ? void 0 : _e.ID) || "<NONE>"}:`, e);
59715
60058
  }
59716
60059
  if (cEntity) {
59717
60060
  const name = await getName$3(api, entity, params.offline);
@@ -59923,10 +60266,15 @@ function syncDisplacedSurface(params) {
59923
60266
  const placement = surfacePlacement(entity, heightRef, extrusionArchive && TextureFrameSeriesAnimator.IsDatumHeight(extrusionArchive.metadata));
59924
60267
  // Whether the surface follows terrain is baked into its ground sampling, so a change there has
59925
60268
  // to rebuild rather than update in place.
59926
- if (reusable && existingSurface.GetFollowsGround() === placement.followGround) {
60269
+ // The baseline mask is read by the animator as it is built, so a change there rebuilds too.
60270
+ const baselineKept = cEntity[EXTRUSION_BASELINE_KEY] === Boolean(style.maskTextureBaseline);
60271
+ if (reusable && baselineKept && existingSurface.GetFollowsGround() === placement.followGround) {
59927
60272
  existingSurface.SetBaseHeight(placement.baseHeight);
59928
60273
  existingSurface.SetExaggeration(exaggerationFor(style));
59929
60274
  existingSurface.SetWater(waterFor(style));
60275
+ // A restyle that only recolours, such as a bookmark's own ramp, repaints in place.
60276
+ const ramp = surfaceRamp(style.textureColorMask, extrusionArchive.metadata);
60277
+ existingSurface.SetRamp(ramp.rampStops, ramp.lowColor, ramp.highColor);
59930
60278
  return;
59931
60279
  }
59932
60280
  disposeDisplacedSurface(cEntity, viewer);
@@ -59953,7 +60301,8 @@ function syncDisplacedSurface(params) {
59953
60301
  maskBaseline: style.maskTextureBaseline
59954
60302
  });
59955
60303
  cEntity[EXTRUSION_ANIMATOR_KEY] = animator;
59956
- const mask = style.textureColorMask;
60304
+ cEntity[EXTRUSION_BASELINE_KEY] = Boolean(style.maskTextureBaseline);
60305
+ const ramp = surfaceRamp(style.textureColorMask, extrusionArchive.metadata);
59957
60306
  const surface = new DisplacedSurfacePrimitive.Surface({
59958
60307
  extent,
59959
60308
  // The grid has to be walked the way the raster was sampled, or the surface skews across the extent.
@@ -59967,18 +60316,28 @@ function syncDisplacedSurface(params) {
59967
60316
  packedValue: TextureFrameSeriesAnimator.IsPackedValue(extrusionArchive.metadata),
59968
60317
  exaggeration: exaggerationFor(style),
59969
60318
  water: waterFor(style),
60319
+ lowColor: ramp.lowColor,
60320
+ highColor: ramp.highColor,
60321
+ rampStops: ramp.rampStops
60322
+ });
60323
+ surface.BindAnimator(animator);
60324
+ viewer.scene.primitives.add(surface);
60325
+ cEntity[DISPLACED_SURFACE_KEY] = surface;
60326
+ }
60327
+ /*
60328
+ * The colours a displaced surface paints with, from the style's mask.
60329
+ */
60330
+ function surfaceRamp(mask, metadata) {
60331
+ return {
59970
60332
  lowColor: mask ? Color$1.ColorFromStr(mask.minColor) : null,
59971
60333
  highColor: mask ? Color$1.ColorFromStr(mask.maxColor) : null,
59972
60334
  // Normalised the same way the animator normalises them, so the surface and the flat drape
59973
60335
  // agree about which values the style hides.
59974
60336
  rampStops: ((mask && mask.points) || []).map((stop) => ({
59975
- position: TextureFrameSeriesAnimator.NormalisePosition(extrusionArchive.metadata, stop.position),
60337
+ position: TextureFrameSeriesAnimator.NormalisePosition(metadata, stop.position),
59976
60338
  color: Color$1.ColorFromStr(stop.color)
59977
60339
  })).filter((stop) => Boolean(stop.color))
59978
- });
59979
- surface.BindAnimator(animator);
59980
- viewer.scene.primitives.add(surface);
59981
- cEntity[DISPLACED_SURFACE_KEY] = surface;
60340
+ };
59982
60341
  }
59983
60342
  /**
59984
60343
  * Turns the polygon's altitude option into the two things the displaced surface needs:
@@ -61961,7 +62320,7 @@ var StyleUtils;
61961
62320
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
61962
62321
  })(StyleUtils || (StyleUtils = {}));
61963
62322
 
61964
- const VERSION = "7.9.2";
62323
+ const VERSION = "7.9.4";
61965
62324
  /**
61966
62325
  * Updates the environment instance used by bruce-cesium to one specified.
61967
62326
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -61978,5 +62337,5 @@ const getENVIRONMENT = () => {
61978
62337
  return ENVIRONMENT;
61979
62338
  };
61980
62339
 
61981
- export { VERSION, setENVIRONMENT, getENVIRONMENT, ClusterItems, PointClustering, PointClusterSize, CesiumAnimatedInOut, DisplacedSurfacePrimitive, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, extractMetadataFromFileUrl, EntityRenderEnginePolygon, EntityRenderEnginePolyline, TextureFrameSeriesAnimator, TextureValueLabels, MenuItemCreator, MenuItemManager, MenuItemStyles, MenuItemStyleOverlay, CesiumParabola, EntityLabel, EntityLabelGroup, LiveCursor, SharedGetters, EntitySimulation, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, createTileset, TilesetRenderEngine, ViewRenderEngine, VisualRegisterCuller, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, CESIUM_MODEL_SPACE_POSITIONING_KEY, DEFAULT_LIVE_PADDING_SECONDS, DEFAULT_BRIGHTNESS_SHIFT, DEFAULT_LIGHT_INTENSITY, LIGHTING_SETTINGS_VERSION, LIGHT_INTENSITY_COMPENSATION, MAX_COMPENSATED_LIGHT_INTENSITY, ViewUtils, CesiumMapGrid, GltfGenerator, GltfGizmo, DeviceProfile, CesiumViewMonitor, CameraControls, FindGapSurfaces, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, WidgetLeftPanelTabDashboard, EMenuItemState, WidgetLeftPanelTabMenuItems, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, ECursor, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, CreateTabIconSvg, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
62340
+ export { VERSION, setENVIRONMENT, getENVIRONMENT, ClusterItems, PointClustering, PointClusterSize, CesiumAnimatedInOut, DisplacedSurfacePrimitive, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, extractMetadataFromFileUrl, EntityRenderEnginePolygon, EntityRenderEnginePolyline, TextureFrameSeriesAnimator, TextureValueLabels, MenuItemCreator, MenuItemManager, MenuItemStyles, MenuItemStyleOverlay, CesiumParabola, EntityLabel, EntityLabelGroup, LiveCursor, SharedGetters, EntitySimulation, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, createTileset, TilesetRenderEngine, ViewRenderEngine, VisualRegisterCuller, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, CESIUM_MODEL_SPACE_POSITIONING_KEY, DEFAULT_LIVE_PADDING_SECONDS, DEFAULT_BRIGHTNESS_SHIFT, DEFAULT_LIGHT_INTENSITY, LIGHTING_SETTINGS_VERSION, LIGHT_INTENSITY_COMPENSATION, MAX_COMPENSATED_LIGHT_INTENSITY, ViewUtils, CesiumMapGrid, GltfGenerator, GltfGizmo, DeviceProfile, CesiumViewMonitor, CameraControls, FindGapSurfaces, NearClearance, GrabPoint, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, WidgetLeftPanelTabDashboard, EMenuItemState, WidgetLeftPanelTabMenuItems, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, ECursor, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, CreateTabIconSvg, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
61982
62341
  //# sourceMappingURL=bruce-cesium.es5.js.map