bruce-cesium 7.9.1 → 7.9.3

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 (55) hide show
  1. package/dist/bruce-cesium.es5.js +941 -143
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +939 -140
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +1 -1
  6. package/dist/lib/internal/cesium-patch-pick-splat.js +127 -0
  7. package/dist/lib/internal/cesium-patch-pick-splat.js.map +1 -0
  8. package/dist/lib/internal/cesium-patch-pick-through-ground.js +155 -0
  9. package/dist/lib/internal/cesium-patch-pick-through-ground.js.map +1 -0
  10. package/dist/lib/internal/cesium-patch-splat-order.js +73 -0
  11. package/dist/lib/internal/cesium-patch-splat-order.js.map +1 -0
  12. package/dist/lib/rendering/displaced-surface-primitive.js +17 -0
  13. package/dist/lib/rendering/displaced-surface-primitive.js.map +1 -1
  14. package/dist/lib/rendering/entity-render-engine-model3d.js +10 -10
  15. package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -1
  16. package/dist/lib/rendering/entity-render-engine-point.js +6 -6
  17. package/dist/lib/rendering/entity-render-engine-point.js.map +1 -1
  18. package/dist/lib/rendering/entity-render-engine-polygon.js +30 -12
  19. package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
  20. package/dist/lib/rendering/entity-render-engine-polyline.js +4 -4
  21. package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -1
  22. package/dist/lib/rendering/menu-item-manager.js +16 -2
  23. package/dist/lib/rendering/menu-item-manager.js.map +1 -1
  24. package/dist/lib/rendering/menu-item-style-overlay.js +51 -11
  25. package/dist/lib/rendering/menu-item-style-overlay.js.map +1 -1
  26. package/dist/lib/rendering/menu-item-styles.js +9 -1
  27. package/dist/lib/rendering/menu-item-styles.js.map +1 -1
  28. package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js +1 -1
  29. package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js.map +1 -1
  30. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +1 -1
  31. package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
  32. package/dist/lib/rendering/tileset-styler.js +14 -9
  33. package/dist/lib/rendering/tileset-styler.js.map +1 -1
  34. package/dist/lib/rendering/visuals-register.js +74 -6
  35. package/dist/lib/rendering/visuals-register.js.map +1 -1
  36. package/dist/lib/rendering/xgrids-render-engine.js +3 -0
  37. package/dist/lib/rendering/xgrids-render-engine.js.map +1 -1
  38. package/dist/lib/utils/drawing-utils.js +241 -75
  39. package/dist/lib/utils/drawing-utils.js.map +1 -1
  40. package/dist/lib/viewer/camera-controls.js +134 -1
  41. package/dist/lib/viewer/camera-controls.js.map +1 -1
  42. package/dist/lib/viewer/viewer-utils.js +6 -0
  43. package/dist/lib/viewer/viewer-utils.js.map +1 -1
  44. package/dist/types/bruce-cesium.d.ts +1 -1
  45. package/dist/types/internal/cesium-patch-pick-splat.d.ts +8 -0
  46. package/dist/types/internal/cesium-patch-pick-through-ground.d.ts +7 -0
  47. package/dist/types/internal/cesium-patch-splat-order.d.ts +2 -0
  48. package/dist/types/rendering/displaced-surface-primitive.d.ts +6 -2
  49. package/dist/types/rendering/menu-item-manager.d.ts +1 -0
  50. package/dist/types/rendering/menu-item-style-overlay.d.ts +22 -4
  51. package/dist/types/rendering/tileset-styler.d.ts +1 -0
  52. package/dist/types/rendering/visuals-register.d.ts +11 -0
  53. package/dist/types/utils/drawing-utils.d.ts +7 -1
  54. package/dist/types/viewer/camera-controls.d.ts +4 -0
  55. 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, 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, ConstantPositionProperty, DistanceDisplayCondition, ClassificationType, ArcType, CornerType, ColorBlendMode, Model, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, HorizontalOrigin, VerticalOrigin, NearFarScalar, Matrix3, KmlDataSource, FeatureDetection, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, OrthographicFrustum, EasingFunction, 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, PrimitiveCollection, ShadowMode, PolylineCollection, LabelCollection, LabelStyle, Material, CustomDataSource, GeometryInstance, Event, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, ScreenSpaceEventHandler, ScreenSpaceEventType, CameraEventType, Plane, OrientedBoundingBox, 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, Geometry as Geometry$1, EntityLod, UrlUtils, Bounds, ClientFileValueMap, Color as Color$1, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, Api, EntityRelation, BruceApi, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, 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, ColorBlendMode, Model, ClassificationType, ArcType, CornerType, HorizontalOrigin, VerticalOrigin, 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, SceneMode, IntersectionTests, Ray, SceneTransforms, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, HeadingPitchRange, Ion, Cesium3DTileStyle, IonResource, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileColorBlendMode, OrthographicFrustum, EasingFunction, Intersect, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CesiumInspector, defined, ClockRange, ShadowMode, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, GeometryInstance, Event, CustomDataSource, 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, ZoomControl, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Geometry as Geometry$1, Api, ProjectView, ProjectViewBookmark, Assembly, EntityCoords, ClientFileValueMap, Color as Color$1, Bounds, EntityRelation, BruceApi, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, 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.
@@ -110,6 +110,406 @@ var MeasureUtils;
110
110
  MeasureUtils.MeasurePolygon = MeasurePolygon;
111
111
  })(MeasureUtils || (MeasureUtils = {}));
112
112
 
113
+ /*
114
+ * Makes pickPosition return an opaque primitive drawn through the ground, not the ground above it, with occlusion off.
115
+ */
116
+ const PICK_THROUGH_GROUND_PATCH_KEY = "_nextspacePickThroughGroundPatch";
117
+ // What the patch saw of the pick depth copy, read by GetPickDepthKind.
118
+ const PICK_DEPTH_KIND_KEY = "_nextspacePickDepthKind";
119
+ // From CesiumJS 1.118 the pick depth copy merges the globe's depth in; only that shader names this variable.
120
+ const MERGE_MARK = "globeDepthPacked";
121
+ // Before 1.118 the copy is a plain repack of the scene depth.
122
+ const LEGACY_MARK = "czm_packDepth(texture";
123
+ /*
124
+ * The merge CesiumJS uses, except that a scene depth farther than the globe is kept unless it is the depth plane.
125
+ */
126
+ const PICK_THROUGH_GROUND_FS = `uniform highp sampler2D colorTexture;
127
+ uniform vec4 u_nextspaceDepthPlane;
128
+ uniform vec2 u_nextspaceFlags;
129
+ in vec2 v_textureCoordinates;
130
+ vec3 nextspaceEye(float depth)
131
+ {
132
+ vec2 uv = (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw;
133
+ if (u_nextspaceFlags.y > 0.5) {
134
+ float fromCamera = pow(2.0, depth * czm_log2FarDepthFromNearPlusOne) - 1.0 + czm_currentFrustum.x;
135
+ vec4 q = czm_inverseProjection * vec4(2.0 * uv - 1.0, 0.0, 1.0);
136
+ vec3 d = q.xyz / q.w;
137
+ return d * (fromCamera / -d.z);
138
+ }
139
+ vec4 e = czm_windowToEyeCoordinates(vec4(gl_FragCoord.xy, depth, 1.0));
140
+ return e.xyz / e.w;
141
+ }
142
+ void main()
143
+ {
144
+ vec4 globeDepthPacked = texture(czm_globeDepthTexture, v_textureCoordinates);
145
+ float globeDepth = czm_unpackDepth(globeDepthPacked);
146
+ float depth = texture(colorTexture, v_textureCoordinates).r;
147
+ bool sceneDepth = depth > 0.0 && depth < 1.0;
148
+ bool keepScene = globeDepth <= 0.0 || globeDepth >= 1.0 || depth < globeDepth && sceneDepth;
149
+ if (!keepScene && sceneDepth && u_nextspaceFlags.x > 0.5) {
150
+ vec3 p = nextspaceEye(depth);
151
+ keepScene = abs(dot(u_nextspaceDepthPlane.xyz, p) + u_nextspaceDepthPlane.w) > max(0.5, 0.002 * length(p));
152
+ }
153
+ out_FragColor = keepScene ? czm_packDepth(depth) : globeDepthPacked;
154
+ }
155
+ `;
156
+ /*
157
+ * The depth plane CesiumJS draws once the globe's depth is cleared, as a unit-normal plane in world coordinates.
158
+ */
159
+ function GetDepthPlaneWorld(cameraPosition, radii, offset, result) {
160
+ // Mirrors DepthPlane's computeDepthQuad: the plane through the limb, in the ellipsoid's scaled space.
161
+ const rx = radii.x + offset;
162
+ const ry = radii.y + offset;
163
+ const rz = radii.z + offset;
164
+ const qx = cameraPosition.x / rx;
165
+ const qy = cameraPosition.y / ry;
166
+ const qz = cameraPosition.z / rz;
167
+ const qm = Math.sqrt(qx * qx + qy * qy + qz * qz);
168
+ const nx = qx / qm / rx;
169
+ const ny = qy / qm / ry;
170
+ const nz = qz / qm / rz;
171
+ const nm = Math.sqrt(nx * nx + ny * ny + nz * nz);
172
+ return Cartesian4.fromElements(nx / nm, ny / nm, nz / nm, -(1 / qm) / nm, result);
173
+ }
174
+ /*
175
+ * Moves a world plane into eye coordinates, keeping its normal unit length so distances stay in metres.
176
+ */
177
+ function GetPlaneEye(planeWorld, inverseView, result) {
178
+ const transposed = Matrix4.transpose(inverseView, new Matrix4());
179
+ Matrix4.multiplyByVector(transposed, planeWorld, result);
180
+ const m = Math.sqrt(result.x * result.x + result.y * result.y + result.z * result.z);
181
+ return Cartesian4.divideByScalar(result, m, result);
182
+ }
183
+ /*
184
+ * What the viewer's pick depth holds, as far as the patch has seen.
185
+ */
186
+ function GetPickDepthKind(viewer) {
187
+ var _a, _b, _c;
188
+ return (_c = (_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[PICK_DEPTH_KIND_KEY]) !== null && _c !== void 0 ? _c : "unknown";
189
+ }
190
+ /*
191
+ * Patches the viewer's pick depth copy so a primitive seen through the ground picks itself.
192
+ */
193
+ function InstallPickThroughGroundPatch(viewer) {
194
+ var _a, _b, _c;
195
+ const scene = viewer === null || viewer === void 0 ? void 0 : viewer.scene;
196
+ const context = scene === null || scene === void 0 ? void 0 : scene.context;
197
+ if (!context || typeof context.createViewportQuadCommand !== "function") {
198
+ return false;
199
+ }
200
+ if (context[PICK_THROUGH_GROUND_PATCH_KEY]) {
201
+ return true;
202
+ }
203
+ const plane = new Cartesian4();
204
+ const planeWorld = new Cartesian4();
205
+ const flags = new Cartesian2();
206
+ const updatePlane = () => {
207
+ var _a, _b, _c, _d;
208
+ const env = scene._environmentState;
209
+ const camera = scene.camera;
210
+ const on = Boolean((env === null || env === void 0 ? void 0 : env.clearGlobeDepth) &&
211
+ (env === null || env === void 0 ? void 0 : env.useDepthPlane) &&
212
+ ((_a = camera === null || camera === void 0 ? void 0 : camera.frustum) === null || _a === void 0 ? void 0 : _a.fov) != null &&
213
+ scene.mode === SceneMode.SCENE3D &&
214
+ scene.globe);
215
+ flags.x = on ? 1 : 0;
216
+ flags.y = ((_b = scene.frameState) === null || _b === void 0 ? void 0 : _b.useLogDepth) ? 1 : 0;
217
+ if (on) {
218
+ const offset = (_d = (_c = scene._depthPlane) === null || _c === void 0 ? void 0 : _c._ellipsoidOffset) !== null && _d !== void 0 ? _d : 0;
219
+ GetDepthPlaneWorld(camera.positionWC, scene.globe.ellipsoid.radii, offset, planeWorld);
220
+ GetPlaneEye(planeWorld, camera.inverseViewMatrix, plane);
221
+ }
222
+ };
223
+ const original = context.createViewportQuadCommand;
224
+ context.createViewportQuadCommand = function (fragmentShaderSource, overrides) {
225
+ try {
226
+ if (typeof fragmentShaderSource === "string" && (overrides === null || overrides === void 0 ? void 0 : overrides.uniformMap)) {
227
+ if (fragmentShaderSource.includes(MERGE_MARK) && overrides.uniformMap.colorTexture) {
228
+ context[PICK_DEPTH_KIND_KEY] = "merged";
229
+ overrides.uniformMap.u_nextspaceDepthPlane = () => {
230
+ updatePlane();
231
+ return plane;
232
+ };
233
+ overrides.uniformMap.u_nextspaceFlags = () => flags;
234
+ fragmentShaderSource = PICK_THROUGH_GROUND_FS;
235
+ context[PICK_DEPTH_KIND_KEY] = "through-ground";
236
+ }
237
+ else if (fragmentShaderSource.includes(LEGACY_MARK) && overrides.uniformMap.u_texture) {
238
+ context[PICK_DEPTH_KIND_KEY] = "legacy";
239
+ }
240
+ }
241
+ }
242
+ catch (e) {
243
+ console.error("Failed to patch the pick depth merge.", e);
244
+ }
245
+ return original.call(this, fragmentShaderSource, overrides);
246
+ };
247
+ // A pick depth made before this point rebuilds its copy on the next frame.
248
+ for (const view of [scene.view, scene.defaultView]) {
249
+ for (const pickDepth of (_a = view === null || view === void 0 ? void 0 : view.pickDepths) !== null && _a !== void 0 ? _a : []) {
250
+ if (pickDepth === null || pickDepth === void 0 ? void 0 : pickDepth._copyDepthCommand) {
251
+ (_c = (_b = pickDepth._copyDepthCommand.shaderProgram) === null || _b === void 0 ? void 0 : _b.destroy) === null || _c === void 0 ? void 0 : _c.call(_b);
252
+ pickDepth._copyDepthCommand = undefined;
253
+ }
254
+ }
255
+ }
256
+ context[PICK_THROUGH_GROUND_PATCH_KEY] = true;
257
+ return true;
258
+ }
259
+
260
+ /*
261
+ * Makes XGrids splats pick only where they are visibly drawn, not across their faint halos.
262
+ */
263
+ const PICK_SPLAT_PATCH_KEY = "_nextspacePickSplatPatch";
264
+ // The XGrids SDK compiles its splat shaders with this define.
265
+ const SPLAT_DEFINE = "LccShader";
266
+ // CesiumJS's derived pick shader keeps every fragment with any alpha at all.
267
+ const ANY_ALPHA = /(out_FragColor|out_FragData_0|gl_FragColor)\.a == 0\.0/;
268
+ /*
269
+ * The least opacity a splat fragment needs to be picked; tuned against the SDK's own raycast on real scans.
270
+ */
271
+ const SPLAT_PICK_MIN_ALPHA = 0.25;
272
+ /*
273
+ * Raises the alpha a derived splat "pick" shader needs before it keeps a fragment, returning whether it did.
274
+ */
275
+ function FixSplatPick(keyword, options) {
276
+ const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
277
+ const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
278
+ const sources = fragment === null || fragment === void 0 ? void 0 : fragment.sources;
279
+ if (keyword !== "pick" ||
280
+ !Array.isArray(defines) ||
281
+ !Array.isArray(sources) ||
282
+ !defines.includes(SPLAT_DEFINE) ||
283
+ !sources.some(x => typeof x === "string" && ANY_ALPHA.test(x))) {
284
+ return false;
285
+ }
286
+ fragment.sources = sources.map(x => typeof x === "string" ? x.replace(ANY_ALPHA, `$1.a < ${SPLAT_PICK_MIN_ALPHA.toFixed(3)}`) : x);
287
+ return true;
288
+ }
289
+ /*
290
+ * Whether a pick result is an XGrids splat mesh rather than a Cesium primitive or Entity.
291
+ */
292
+ function IsSplatPick(picked) {
293
+ var _a;
294
+ return Boolean(picked &&
295
+ typeof picked.id === "string" &&
296
+ typeof ((_a = picked.primitive) === null || _a === void 0 ? void 0 : _a.splatCount) === "number");
297
+ }
298
+ /*
299
+ * Patches a viewer's shader cache so splat pick shaders drop their near-transparent fragments.
300
+ */
301
+ function InstallPickSplatPatch(viewer) {
302
+ var _a, _b;
303
+ const cache = (_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.shaderCache;
304
+ if (!cache || typeof cache.createDerivedShaderProgram !== "function") {
305
+ return false;
306
+ }
307
+ if (cache[PICK_SPLAT_PATCH_KEY]) {
308
+ return true;
309
+ }
310
+ const original = cache.createDerivedShaderProgram;
311
+ cache.createDerivedShaderProgram = function (shaderProgram, keyword, options) {
312
+ try {
313
+ FixSplatPick(keyword, options);
314
+ }
315
+ catch (e) {
316
+ console.error("Failed to fix a splat pick shader.", e);
317
+ }
318
+ return original.call(this, shaderProgram, keyword, options);
319
+ };
320
+ cache[PICK_SPLAT_PATCH_KEY] = true;
321
+ return true;
322
+ }
323
+ // The XGrids render objects drawn on a viewer, so picking only looks for splats when there are some.
324
+ const SPLATS_KEY = "_nextspaceSplats";
325
+ /*
326
+ * Records that a splat render object is drawn on, or removed from, a viewer.
327
+ */
328
+ function TrackSplats(viewer, renderObject, drawn) {
329
+ var _a;
330
+ if (!viewer || !renderObject) {
331
+ return;
332
+ }
333
+ const set = (_a = viewer[SPLATS_KEY]) !== null && _a !== void 0 ? _a : (viewer[SPLATS_KEY] = new Set());
334
+ if (drawn) {
335
+ set.add(renderObject);
336
+ }
337
+ else {
338
+ set.delete(renderObject);
339
+ }
340
+ }
341
+ /*
342
+ * Whether any XGrids splats are drawn on a viewer.
343
+ */
344
+ function HasSplats(viewer) {
345
+ var _a;
346
+ return Boolean((_a = viewer === null || viewer === void 0 ? void 0 : viewer[SPLATS_KEY]) === null || _a === void 0 ? void 0 : _a.size);
347
+ }
348
+ /*
349
+ * Whether pick results for splats follow what is visibly drawn, so a splat can be trusted to hide what is behind it.
350
+ */
351
+ function IsSplatPickVisible(viewer) {
352
+ var _a, _b, _c;
353
+ return Boolean((_c = (_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.shaderCache) === null || _c === void 0 ? void 0 : _c[PICK_SPLAT_PATCH_KEY]);
354
+ }
355
+ /*
356
+ * Whether the SDK raycasts splats as opacity-weighted ellipsoids (usePrecisionRaycast) rather than points.
357
+ */
358
+ function IsSplatRaycastPrecise(viewer) {
359
+ var _a, _b;
360
+ const set = viewer === null || viewer === void 0 ? void 0 : viewer[SPLATS_KEY];
361
+ if (!(set === null || set === void 0 ? void 0 : set.size)) {
362
+ return false;
363
+ }
364
+ for (const object of Array.from(set)) {
365
+ try {
366
+ if ((_b = (_a = object === null || object === void 0 ? void 0 : object.getCurrentConfig) === null || _a === void 0 ? void 0 : _a.call(object)) === null || _b === void 0 ? void 0 : _b.usePrecisionRaycast) {
367
+ return true;
368
+ }
369
+ }
370
+ catch (e) {
371
+ // A disposed scan has no config; the others still answer.
372
+ }
373
+ }
374
+ return false;
375
+ }
376
+
377
+ const ACCURATE_PICK_KEY = "_nextspaceAccuratePick";
378
+ // A repeat pick at the same pixel within this long, with the camera still, returns the last result.
379
+ const ACCURATE_PICK_CACHE_MS = 3000;
380
+ // Beyond this a splat raycast gives up; matches what Navigator always asked the SDK for.
381
+ const SPLAT_MAX_DISTANCE = 1000;
382
+ // A point raycast this thin still finds a splat a pixel covers at close range without catching ones beside it.
383
+ const SPLAT_MIN_RADIUS = 0.005;
384
+ // A precise raycast only uses the radius to shortlist splats before testing their ellipsoids.
385
+ const SPLAT_PRECISE_SHORTLIST = 0.5;
386
+ /*
387
+ * Whether a cached accurate pick still answers: the same pixel, a still camera and recent enough.
388
+ */
389
+ function isCacheValid(cache, camera, cursor, pickOnly) {
390
+ if (cache.pickOnly !== pickOnly || performance.now() - cache.time > ACCURATE_PICK_CACHE_MS) {
391
+ return false;
392
+ }
393
+ // Same pixel only; a neighbour's answer steps a pointer-following cursor and corrupts normals read from picks.
394
+ if (Cartesian2.distanceSquared(cursor, cache.cursor) >= 0.25) {
395
+ return false;
396
+ }
397
+ const p = camera.positionWC;
398
+ const q = cache.cameraPosition;
399
+ if (Math.abs(p.x - q.x) > 2 || Math.abs(p.y - q.y) > 2 || Math.abs(p.z - q.z) > 2) {
400
+ return false;
401
+ }
402
+ const cos = Cartesian3.dot(camera.directionWC, cache.cameraDirection) /
403
+ (Cartesian3.magnitude(camera.directionWC) * Cartesian3.magnitude(cache.cameraDirection));
404
+ if (Math.acos(Math.min(1, cos)) > Math$1.toRadians(5)) {
405
+ return false;
406
+ }
407
+ const width = camera.frustum instanceof OrthographicFrustum ? camera.frustum.width : null;
408
+ return width === cache.frustumWidth || (width != null && cache.frustumWidth != null && Math.abs(width - cache.frustumWidth) < 1e-6);
409
+ }
410
+ /*
411
+ * Whether pickPosition is right over the ground with occlusion off: CesiumJS 1.118+, unknown before a first frame.
412
+ */
413
+ function isPickPositionFixed(viewer) {
414
+ const kind = GetPickDepthKind(viewer);
415
+ return kind === "through-ground" || kind === "merged";
416
+ }
417
+ /*
418
+ * Whether the terrain provider can answer a globe pick yet.
419
+ */
420
+ function isTerrainReady(viewer) {
421
+ return Boolean(viewer.terrainProvider && viewer.terrainProvider["ready"] != false);
422
+ }
423
+ /*
424
+ * The size of one screen pixel at a distance from the camera, in metres.
425
+ */
426
+ function pixelSizeAt(scene, distance) {
427
+ const height = scene.canvas.clientHeight;
428
+ const frustum = scene.camera.frustum;
429
+ if (frustum instanceof OrthographicFrustum) {
430
+ return frustum.width / Math.max(1, scene.canvas.clientWidth);
431
+ }
432
+ const fovy = frustum === null || frustum === void 0 ? void 0 : frustum.fovy;
433
+ if (!height || !fovy) {
434
+ return 0;
435
+ }
436
+ return 2 * distance * Math.tan(fovy / 2) / height;
437
+ }
438
+ /*
439
+ * Whether a pick result is something pickOnly positions land on: a tileset, a model or an Entity with a model.
440
+ */
441
+ function isPositionObject(object) {
442
+ const entity = (object === null || object === void 0 ? void 0 : object.id) instanceof Entity ? object.id : null;
443
+ return Boolean(object instanceof Cesium3DTileFeature ||
444
+ object instanceof Cesium3DTileset ||
445
+ (object === null || object === void 0 ? void 0 : object.primitive) instanceof Cesium3DTileset ||
446
+ (object === null || object === void 0 ? void 0 : object.primitive) instanceof Model ||
447
+ (entity === null || entity === void 0 ? void 0 : entity.model));
448
+ }
449
+ /*
450
+ * The front-most pickOnly object under a cursor, skipping ignored ones; drillPick only when there are any to skip.
451
+ */
452
+ function pickObject(scene, cursor, ignored) {
453
+ if (!(ignored === null || ignored === void 0 ? void 0 : ignored.length)) {
454
+ return isPositionObject(scene.pick(cursor, 1, 1));
455
+ }
456
+ const objects = scene.drillPick(cursor, ignored.length + 1, 3, 3);
457
+ for (const object of objects) {
458
+ const owner = (object === null || object === void 0 ? void 0 : object.id) instanceof Entity ? object.id : object;
459
+ if (ignored.includes(owner) || ignored.includes(object)) {
460
+ continue;
461
+ }
462
+ return isPositionObject(object);
463
+ }
464
+ return false;
465
+ }
466
+ /*
467
+ * Workarounds for CesiumJS before 1.118, whose pickPosition hit the depth plane over the ground (cesium#4368).
468
+ */
469
+ function legacyPick(viewer, cursor, pixel, pickOnly, ignored) {
470
+ var _a, _b, _c, _d, _e;
471
+ const scene = viewer.scene;
472
+ let pos3d = null;
473
+ if (!pickOnly && ((_a = scene.globe) === null || _a === void 0 ? void 0 : _a.depthTestAgainstTerrain)) {
474
+ pos3d = (_b = scene.pickPosition(pixel)) !== null && _b !== void 0 ? _b : null;
475
+ }
476
+ else {
477
+ if (!pickOnly) {
478
+ pos3d = (_c = scene.pickPosition(pixel)) !== null && _c !== void 0 ? _c : null;
479
+ }
480
+ if (pos3d) {
481
+ const carto = Cartographic.fromCartesian(pos3d);
482
+ if (!carto || carto.height < 0) {
483
+ pos3d = null;
484
+ }
485
+ }
486
+ if (!pos3d) {
487
+ if (scene.pickPositionSupported && pickObject(scene, cursor, ignored)) {
488
+ pos3d = (_d = scene.pickPosition(pixel)) !== null && _d !== void 0 ? _d : null;
489
+ }
490
+ if (!pickOnly && !pos3d && scene.globe && isTerrainReady(viewer)) {
491
+ const ray = scene.camera.getPickRay(cursor);
492
+ pos3d = ray ? ((_e = scene.globe.pick(ray, scene)) !== null && _e !== void 0 ? _e : null) : null;
493
+ }
494
+ }
495
+ }
496
+ // A tileset the depth missed can still be found by rendering along the ray.
497
+ if (!pos3d && scene.mode === SceneMode.SCENE3D && typeof scene.pickFromRay === "function") {
498
+ const picked = scene.pick(cursor, 1, 1);
499
+ if (picked instanceof Cesium3DTileFeature || (picked === null || picked === void 0 ? void 0 : picked.primitive) instanceof Cesium3DTileset) {
500
+ try {
501
+ const hit = scene.pickFromRay(scene.camera.getPickRay(cursor), []);
502
+ if ((hit === null || hit === void 0 ? void 0 : hit.position) && Cartes.ValidateCartes3(hit.position)) {
503
+ pos3d = hit.position;
504
+ }
505
+ }
506
+ catch (e) {
507
+ console.error(e);
508
+ }
509
+ }
510
+ }
511
+ return pos3d;
512
+ }
113
513
  const [C3] = [Cartesian3];
114
514
  function getT(t, alpha, p0, p1) {
115
515
  const d = C3.subtract(p1, p0, new C3);
@@ -441,91 +841,119 @@ var DrawingUtils;
441
841
  return pos3d;
442
842
  }
443
843
  DrawingUtils.EnsurePosHeight = EnsurePosHeight;
844
+ /*
845
+ * The splat surface under a screen position when a splat is front-most there, raycast no further than behind.
846
+ */
847
+ function GetSplatPosition(params) {
848
+ const { viewer, cursor, behind } = params;
849
+ if (!HasSplats(viewer) || typeof LCCRender === "undefined") {
850
+ return null;
851
+ }
852
+ const scene = viewer.scene;
853
+ if (!IsSplatPick(scene.pick(cursor, 1, 1))) {
854
+ return null;
855
+ }
856
+ const ray = scene.camera.getPickRay(cursor);
857
+ if (!ray) {
858
+ return null;
859
+ }
860
+ const maxDistance = behind ? Cartesian3.distance(ray.origin, behind) : SPLAT_MAX_DISTANCE;
861
+ const precise = IsSplatRaycastPrecise(viewer);
862
+ // A point raycast is a cylinder, so make it a pixel wide where it ends; nearer it is wider than a pixel.
863
+ const radius = precise ? SPLAT_PRECISE_SHORTLIST : Math.max(SPLAT_MIN_RADIUS, pixelSizeAt(scene, Math.min(maxDistance, SPLAT_MAX_DISTANCE)));
864
+ let hit = null;
865
+ try {
866
+ if (typeof LCCRender.raycastFromOrigin === "function") {
867
+ const query = {
868
+ origin: { x: ray.origin.x, y: ray.origin.y, z: ray.origin.z },
869
+ direction: { x: ray.direction.x, y: ray.direction.y, z: ray.direction.z },
870
+ maxDistance,
871
+ radius
872
+ };
873
+ if (precise) {
874
+ query.opacityThreshold = SPLAT_PICK_MIN_ALPHA;
875
+ }
876
+ hit = LCCRender.raycastFromOrigin(query);
877
+ }
878
+ else if (typeof LCCRender.raycast === "function") {
879
+ hit = LCCRender.raycast({ evt: cursor, maxDistance, radius });
880
+ }
881
+ }
882
+ catch (e) {
883
+ console.error("Failed to raycast splats.", e);
884
+ return null;
885
+ }
886
+ if (!hit || !isFinite(hit.x) || !isFinite(hit.y) || !isFinite(hit.z)) {
887
+ return null;
888
+ }
889
+ return new Cartesian3(hit.x, hit.y, hit.z);
890
+ }
891
+ DrawingUtils.GetSplatPosition = GetSplatPosition;
892
+ /*
893
+ * Moves a window position to its drawing-buffer pixel's centre, where pickPosition reads the depth.
894
+ */
895
+ function PixelCentre(scene, cursor) {
896
+ const xScale = scene.drawingBufferWidth / scene.canvas.clientWidth;
897
+ const yScale = scene.drawingBufferHeight / scene.canvas.clientHeight;
898
+ if (!isFinite(xScale) || !isFinite(yScale) || !xScale || !yScale) {
899
+ return new Cartesian2(cursor.x, cursor.y);
900
+ }
901
+ return new Cartesian2((Math.floor(cursor.x * xScale) + 0.5) / xScale, (Math.floor(cursor.y * yScale) + 0.5) / yScale);
902
+ }
903
+ DrawingUtils.PixelCentre = PixelCentre;
444
904
  /**
445
905
  * Returns an accurate 3d position from a given screen position.
446
906
  * @param viewer
447
907
  * @param cursor
448
908
  * @returns
449
909
  */
450
- DrawingUtils.GetAccuratePosition = (() => {
451
- let cachedPick = null;
452
- let cacheTimestamp = null;
453
- let cachedCameraState = null;
454
- let cachedPickOnlyState = null;
455
- return (viewer, cursor, pickOnly = false, ignoredPickOnly) => {
456
- const scene = viewer.scene;
457
- const camera = scene.camera;
458
- // Check if we can use cached position.
459
- if (cachedPick && cacheTimestamp && cachedPickOnlyState === pickOnly) {
460
- const timeElapsed = Date.now() - cacheTimestamp;
461
- const isWithinCacheDuration = timeElapsed < 3000; // 3 seconds
462
- const isNearPreviousPick = Cartesian2.distanceSquared(cursor, cachedPick.cursor) < 9; // 3 pixels
463
- const directionDot = Cartesian3.dot(camera.directionWC, cachedCameraState.direction);
464
- const directionLengths = Cartesian3.magnitude(camera.directionWC) * Cartesian3.magnitude(cachedCameraState.direction);
465
- const angle = Math.acos(directionDot / directionLengths);
466
- const hasCameraMoved = Math.abs(camera.positionWC.x - cachedCameraState.position.x) > 2 || // 2 meters
467
- Math.abs(camera.positionWC.y - cachedCameraState.position.y) > 2 ||
468
- angle > Math$1.toRadians(5); // 5 degrees
469
- if (isWithinCacheDuration && isNearPreviousPick && !hasCameraMoved) {
470
- return cachedPick.position;
471
- }
472
- }
473
- // Actual picking logic
474
- // https://community.cesium.com/t/scene-pick-returning-point-inside-the-globe/18940/9
475
- let pos3d = null;
476
- // Means we can accurately pick right now.
477
- if (!pickOnly && scene.globe.depthTestAgainstTerrain) {
478
- pos3d = scene.pickPosition(cursor);
479
- }
480
- // Means we cannot guarantee an accurate pick.
481
- // We want to prioritize pick-position when we can, so we'll try use it and if the result is sus then we'll use some fallbacks.
482
- else {
483
- if (!pickOnly) {
484
- pos3d = scene.pickPosition(cursor);
485
- }
486
- if (defined(pos3d)) {
487
- const carto = Cartographic.fromCartesian(pos3d);
488
- if (!defined(carto) || carto.height < 0) {
489
- pos3d = null;
490
- }
491
- }
492
- if (!defined(pos3d)) {
493
- pos3d = null;
494
- const ray = scene.camera.getPickRay(cursor);
495
- if (scene.pickPositionSupported) {
496
- const pickedObjects = scene.drillPick(cursor, !(ignoredPickOnly === null || ignoredPickOnly === void 0 ? void 0 : ignoredPickOnly.length) ? 1 : ignoredPickOnly.length + 1, 3, 3);
497
- for (let i = 0; i < pickedObjects.length; i++) {
498
- let object = pickedObjects[i];
499
- object = (object && object.id && object.id instanceof Entity ? object.id : object);
500
- if (object &&
501
- (!ignoredPickOnly || !ignoredPickOnly.includes(object)) &&
502
- (object instanceof Cesium3DTileFeature ||
503
- object instanceof Cesium3DTileset ||
504
- (object instanceof Entity && object.model))) {
505
- pos3d = scene.pickPosition(cursor);
506
- break;
507
- }
508
- }
509
- }
510
- if (!pickOnly && !defined(pos3d)) {
511
- pos3d = scene.globe.pick(ray, scene);
512
- }
513
- }
910
+ function GetAccuratePosition(viewer, cursor, pickOnly = false, ignoredPickOnly) {
911
+ var _a, _b, _c, _d;
912
+ const scene = viewer === null || viewer === void 0 ? void 0 : viewer.scene;
913
+ // A hidden viewer's canvas has no size, and picking it throws from a frustum of NaN.
914
+ if (!scene || !((_a = scene.canvas) === null || _a === void 0 ? void 0 : _a.clientWidth) || !((_b = scene.canvas) === null || _b === void 0 ? void 0 : _b.clientHeight)) {
915
+ return null;
916
+ }
917
+ const camera = scene.camera;
918
+ const canCache = !(ignoredPickOnly === null || ignoredPickOnly === void 0 ? void 0 : ignoredPickOnly.length);
919
+ const cache = viewer[ACCURATE_PICK_KEY];
920
+ if (canCache && cache && isCacheValid(cache, camera, cursor, pickOnly)) {
921
+ return cache.position;
922
+ }
923
+ const pixel = PixelCentre(scene, cursor);
924
+ let pos3d = null;
925
+ if (!isPickPositionFixed(viewer)) {
926
+ pos3d = legacyPick(viewer, cursor, pixel, pickOnly, ignoredPickOnly);
927
+ }
928
+ else if (pickOnly) {
929
+ if (pickObject(scene, cursor, ignoredPickOnly)) {
930
+ pos3d = (_c = scene.pickPosition(pixel)) !== null && _c !== void 0 ? _c : null;
931
+ }
932
+ }
933
+ else {
934
+ // The pick depth holds the globe here too, so no depth means no ground drawn; a globe pick only costs.
935
+ pos3d = (_d = scene.pickPosition(pixel)) !== null && _d !== void 0 ? _d : null;
936
+ }
937
+ if (!pickOnly) {
938
+ const splat = GetSplatPosition({ viewer, cursor, behind: pos3d !== null && pos3d !== void 0 ? pos3d : undefined });
939
+ if (splat) {
940
+ pos3d = splat;
514
941
  }
515
- // Update cache.
516
- cachedPick = {
942
+ }
943
+ if (canCache) {
944
+ viewer[ACCURATE_PICK_KEY] = {
517
945
  position: pos3d,
518
- cursor: cursor.clone()
946
+ cursor: cursor.clone(),
947
+ pickOnly,
948
+ time: performance.now(),
949
+ cameraPosition: camera.positionWC.clone(),
950
+ cameraDirection: camera.directionWC.clone(),
951
+ frustumWidth: camera.frustum instanceof OrthographicFrustum ? camera.frustum.width : null
519
952
  };
520
- cacheTimestamp = Date.now();
521
- cachedCameraState = {
522
- position: camera.positionWC.clone(),
523
- direction: camera.directionWC.clone()
524
- };
525
- cachedPickOnlyState = pickOnly;
526
- return pos3d;
527
- };
528
- })();
953
+ }
954
+ return pos3d;
955
+ }
956
+ DrawingUtils.GetAccuratePosition = GetAccuratePosition;
529
957
  /**
530
958
  * Smooths a given set of points.
531
959
  * @param points
@@ -1218,6 +1646,126 @@ function plausibleDistance(state) {
1218
1646
  const horizon = Math.sqrt(2 * ellipsoidOf(state).maximumRadius * Math.max(height, 0));
1219
1647
  return Math.max(PLAUSIBLE_PICK_FLOOR, height * 10, horizon * 1.5);
1220
1648
  }
1649
+ // Window radii, in drawing buffer pixels, searched for the surface around a gap between point cloud points.
1650
+ const GAP_RADII = [2, 4, 8, 12];
1651
+ // A pick this many times farther than the surface around it, plus the slack in metres, looked through a gap.
1652
+ const GAP_FARTHER = 1.5;
1653
+ const GAP_SLACK = 0.5;
1654
+ // Directions around the centre, and how many must hold nearer pixels for the centre to be surrounded.
1655
+ const GAP_SECTORS = 8;
1656
+ const GAP_SECTORS_NEAR = 6;
1657
+ const PACKED_DEPTH = new Cartesian4(1, 1 / 255, 1 / 65025, 1 / 16581375);
1658
+ /*
1659
+ * Distances along the view axis drawn around a window position, rows bottom-up, Infinity where nothing is drawn.
1660
+ */
1661
+ function readDepthDistances(scene, position, radius) {
1662
+ var _a, _b, _c, _d, _e;
1663
+ const view = (_a = scene._view) !== null && _a !== void 0 ? _a : scene.view;
1664
+ const frustums = view === null || view === void 0 ? void 0 : view.frustumCommandsList;
1665
+ if (!(frustums === null || frustums === void 0 ? void 0 : frustums.length) ||
1666
+ typeof ((_b = scene._picking) === null || _b === void 0 ? void 0 : _b.getPickDepth) !== "function" ||
1667
+ typeof ((_c = scene.context) === null || _c === void 0 ? void 0 : _c.readPixels) !== "function") {
1668
+ return null;
1669
+ }
1670
+ const bufferX = position.x * scene.drawingBufferWidth / scene.canvas.clientWidth;
1671
+ const bufferY = position.y * scene.drawingBufferHeight / scene.canvas.clientHeight;
1672
+ if (!Number.isFinite(bufferX) || !Number.isFinite(bufferY)) {
1673
+ return null;
1674
+ }
1675
+ const x = Math.floor(bufferX) - radius;
1676
+ // The same row pickPosition reads for this position, so a pixel found here is the one it then returns.
1677
+ const y = Math.floor(scene.drawingBufferHeight - bufferY) - radius;
1678
+ const width = 2 * radius + 1;
1679
+ const logDepth = Boolean((_d = scene.frameState) === null || _d === void 0 ? void 0 : _d.useLogDepth);
1680
+ const distances = new Float64Array(width * width).fill(Infinity);
1681
+ // Farthest frustum first, so a nearer frustum's depth overwrites it.
1682
+ for (let f = frustums.length - 1; f >= 0; f--) {
1683
+ const framebuffer = (_e = scene._picking.getPickDepth(scene, f)) === null || _e === void 0 ? void 0 : _e.framebuffer;
1684
+ if (!framebuffer) {
1685
+ continue;
1686
+ }
1687
+ const near = frustums[f].near;
1688
+ const far = frustums[f].far;
1689
+ const pixels = scene.context.readPixels({ x, y, width, height: width, framebuffer });
1690
+ for (let i = 0; i < distances.length; i++) {
1691
+ const o = 4 * i;
1692
+ const packed = pixels[o] * PACKED_DEPTH.x + pixels[o + 1] * PACKED_DEPTH.y +
1693
+ pixels[o + 2] * PACKED_DEPTH.z + pixels[o + 3] * PACKED_DEPTH.w;
1694
+ const depth = packed / 255;
1695
+ if (depth > 0 && depth < 1) {
1696
+ // Undoes CesiumJS's logarithmic depth, or the perspective projection's depth when that is off.
1697
+ distances[i] = logDepth ?
1698
+ Math.pow(2, depth * Math.log2(far - near + 1)) - 1 + near :
1699
+ 2 * near * far / ((far + near) - (2 * depth - 1) * (far - near));
1700
+ }
1701
+ }
1702
+ }
1703
+ return distances;
1704
+ }
1705
+ /*
1706
+ * Offsets of the surface pixel around the centre for each radius where clearly nearer pixels surround it.
1707
+ */
1708
+ function FindGapSurfaces(distances, radius) {
1709
+ const width = 2 * radius + 1;
1710
+ const centre = distances[radius * width + radius];
1711
+ const found = [];
1712
+ for (const r of GAP_RADII) {
1713
+ if (r > radius) {
1714
+ break;
1715
+ }
1716
+ const near = [];
1717
+ const sectors = new Set();
1718
+ for (let dy = -r; dy <= r; dy++) {
1719
+ for (let dx = -r; dx <= r; dx++) {
1720
+ const distance = distances[(radius + dy) * width + (radius + dx)];
1721
+ // Nearer by the same margin that later decides the centre looked through a gap.
1722
+ if ((dx || dy) && distance * GAP_FARTHER + GAP_SLACK < centre) {
1723
+ near.push([distance, dx, dy]);
1724
+ const turn = (Math.atan2(dy, dx) + Math.PI) / (2 * Math.PI);
1725
+ sectors.add(Math.floor(turn * GAP_SECTORS) % GAP_SECTORS);
1726
+ }
1727
+ }
1728
+ }
1729
+ // An object's silhouette covers half the directions at most; points around a gap cover nearly all of them.
1730
+ if (sectors.size >= GAP_SECTORS_NEAR) {
1731
+ near.sort((a, b) => a[0] - b[0]);
1732
+ // The middle of the near pixels by distance stands for the surface, past stray points in front of it.
1733
+ const surface = near[Math.floor(near.length / 2)];
1734
+ found.push({ dx: surface[1], dy: surface[2] });
1735
+ }
1736
+ }
1737
+ return found;
1738
+ }
1739
+ /*
1740
+ * The point cloud surface around a pick that looked through a gap between its points, or null when it did not.
1741
+ */
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
+ }
1751
+ if (!distances) {
1752
+ return null;
1753
+ }
1754
+ const eye = scene.camera.positionWC;
1755
+ const pickedDistance = picked ? Cartesian3.distance(eye, picked) : Infinity;
1756
+ const xScale = scene.canvas.clientWidth / scene.drawingBufferWidth;
1757
+ const yScale = scene.canvas.clientHeight / scene.drawingBufferHeight;
1758
+ for (const { dx, dy } of FindGapSurfaces(distances, radius)) {
1759
+ // Buffer rows run bottom-up, window rows top-down.
1760
+ const surface = scene.pickPosition(new Cartesian2(position.x + dx * xScale, position.y - dy * yScale));
1761
+ if (!surface) {
1762
+ continue;
1763
+ }
1764
+ const distance = Cartesian3.distance(eye, surface);
1765
+ return pickedDistance > distance * GAP_FARTHER + GAP_SLACK ? surface : null;
1766
+ }
1767
+ return null;
1768
+ }
1221
1769
  /*
1222
1770
  * The point under a screen position: what is drawn there, else the ground plane, else a point at the last distance.
1223
1771
  */
@@ -1238,7 +1786,18 @@ function pickTarget(state, position) {
1238
1786
  picked = null;
1239
1787
  }
1240
1788
  }
1789
+ // Splats write no depth, so without this the camera turns and zooms about whatever is behind them.
1790
+ const ahead = isAhead(camera, picked) ? picked : undefined;
1791
+ const splat = DrawingUtils.GetSplatPosition({ viewer, cursor: position, behind: ahead });
1792
+ if (splat) {
1793
+ return { point: splat, source: "pick", ground: false };
1794
+ }
1241
1795
  const plausible = plausibleDistance(state);
1796
+ // 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;
1798
+ if (isAhead(camera, surface) && Cartesian3.distance(surface, camera.positionWC) < plausible) {
1799
+ return { point: surface, source: "pick", ground: false };
1800
+ }
1242
1801
  if (isAhead(camera, picked) && Cartesian3.distance(picked, camera.positionWC) < plausible) {
1243
1802
  return { point: picked, source: "pick", ground: isGroundPick(state, position) };
1244
1803
  }
@@ -13522,6 +14081,25 @@ var VisualRegisterCuller;
13522
14081
  VisualRegisterCuller.MarkShouldRecheck = MarkShouldRecheck;
13523
14082
  })(VisualRegisterCuller || (VisualRegisterCuller = {}));
13524
14083
 
14084
+ // A splat this close in front of a visual still lets it be picked, so scans laid over models do not steal clicks.
14085
+ const SPLAT_HIDES_MIN = 0.25;
14086
+ const SPLAT_HIDES_RATIO = 0.01;
14087
+ /*
14088
+ * Whether a drilled splat's visible surface lies clearly in front of what the depth shows at the cursor.
14089
+ */
14090
+ function isSplatInFront(viewer, cursor, behind) {
14091
+ // The drill found a splat somewhere in its area; this asks again at the cursor's own pixel.
14092
+ const hit = DrawingUtils.GetSplatPosition({ viewer, cursor });
14093
+ if (!hit) {
14094
+ return false;
14095
+ }
14096
+ if (!behind) {
14097
+ return true;
14098
+ }
14099
+ const eye = viewer.scene.camera.positionWC;
14100
+ const visual = Cartesian3.distance(eye, behind);
14101
+ return Cartesian3.distance(eye, hit) < visual - Math.max(SPLAT_HIDES_MIN, visual * SPLAT_HIDES_RATIO);
14102
+ }
13525
14103
  function isTilesetFeatureAlive(visual) {
13526
14104
  var _a, _b;
13527
14105
  const cTileset = visual === null || visual === void 0 ? void 0 : visual.tileset;
@@ -13731,7 +14309,7 @@ function updateEntityShow(viewer, rego, show) {
13731
14309
  }
13732
14310
  }
13733
14311
  function updateEntity(viewer, entityId, register, refresh, cache = {}) {
13734
- var _a, _b, _c;
14312
+ var _a, _b, _c, _d;
13735
14313
  if (!entityId) {
13736
14314
  // What are we doing?
13737
14315
  return;
@@ -13818,7 +14396,8 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
13818
14396
  }
13819
14397
  }
13820
14398
  if (refresh === true || (refresh !== false && (refresh === null || refresh === void 0 ? void 0 : refresh.opacity))) {
13821
- let effectiveOpacity = state.opacity;
14399
+ // An Entity's own opacity wins over the one its menu item's bookmark style asks for.
14400
+ let effectiveOpacity = (_b = state.opacity) !== null && _b !== void 0 ? _b : register.GetMenuItemOpacity(rego.menuItemId);
13822
14401
  if ((effectiveOpacity == null || effectiveOpacity == 1) && !state.isolated && visible) {
13823
14402
  if (cache.isolationOpacity === undefined) {
13824
14403
  cache.isolationOpacity = register.GetIsolationOpacity();
@@ -13849,14 +14428,14 @@ function updateEntity(viewer, entityId, register, refresh, cache = {}) {
13849
14428
  EntityLabel.Attach({
13850
14429
  rego,
13851
14430
  viewer,
13852
- api: (_b = register.ApiGetters) === null || _b === void 0 ? void 0 : _b.GetBruceApi(),
14431
+ api: (_c = register.ApiGetters) === null || _c === void 0 ? void 0 : _c.GetBruceApi(),
13853
14432
  visualRegister: register,
13854
14433
  options: labelGroup ? labelGroup.options : register.GetLabelDefaults(),
13855
14434
  groupId: labelGroup === null || labelGroup === void 0 ? void 0 : labelGroup.groupId,
13856
14435
  persistent: true
13857
14436
  });
13858
14437
  }
13859
- else if (!visible || ((_c = EntityLabel.GetLabel({ rego })) === null || _c === void 0 ? void 0 : _c.Persistent)) {
14438
+ else if (!visible || ((_d = EntityLabel.GetLabel({ rego })) === null || _d === void 0 ? void 0 : _d.Persistent)) {
13860
14439
  EntityLabel.Detatch({
13861
14440
  rego, force: true
13862
14441
  });
@@ -14026,6 +14605,8 @@ var VisualsRegister;
14026
14605
  // When no Menu Item ID is set, then the second key is a blank string.
14027
14606
  // If an Entity ID state is set without a Menu Item ID, then it acts as a default for all Menu Items.
14028
14607
  this.states = {};
14608
+ // Opacity a whole menu item is drawn at, from its bookmark style; never a saved state.
14609
+ this.menuItemOpacities = new Map();
14029
14610
  // Queue of Entity updates to process in batches to avoid overloading the render loop.
14030
14611
  this.updateQueue = [];
14031
14612
  // Mirrors updateQueue for O(1) "already queued" checks.
@@ -15010,7 +15591,7 @@ var VisualsRegister;
15010
15591
  return;
15011
15592
  }
15012
15593
  this.dimmingDirty = false;
15013
- const dimming = Object.values(this.states).some(states => Object.values(states).some(state => state.isolated || (state.opacity != null && state.opacity < 1)));
15594
+ 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;
15014
15595
  if (!CesiumEntityStyler.SetDimming(this.viewer, this.id, dimming)) {
15015
15596
  return;
15016
15597
  }
@@ -16360,9 +16941,25 @@ var VisualsRegister;
16360
16941
  const width = Math.ceil(EnsureNumber(params.width, 5));
16361
16942
  const height = Math.ceil(EnsureNumber(params.height, 5));
16362
16943
  const pickLimit = Math.ceil(EnsureNumber(params.pickLimit, 5));
16363
- const picked = this.viewer.scene.drillPick(new Cartesian2(cursor.x, cursor.y), pickLimit, width, height);
16944
+ const scene = this.viewer.scene;
16945
+ const position = new Cartesian2(cursor.x, cursor.y);
16946
+ // Splats are only trusted to hide what is behind them once their pick follows what is visibly drawn.
16947
+ const splatsHide = HasSplats(this.viewer) && IsSplatPickVisible(this.viewer);
16948
+ // Read before drillPick, which leaves pickPosition reading its own pick pass.
16949
+ const behind = splatsHide ? scene.pickPosition(DrawingUtils.PixelCentre(scene, position)) : null;
16950
+ let splatChecked = false;
16951
+ const picked = scene.drillPick(position, pickLimit, width, height);
16364
16952
  for (let i = 0; i < picked.length; i++) {
16365
16953
  const object = picked[i];
16954
+ if (splatsHide && IsSplatPick(object)) {
16955
+ if (!found.length && !splatChecked) {
16956
+ splatChecked = true;
16957
+ if (isSplatInFront(this.viewer, position, behind)) {
16958
+ break;
16959
+ }
16960
+ }
16961
+ continue;
16962
+ }
16366
16963
  const entity = (object && object.id && object.id instanceof Entity ? object.id : object);
16367
16964
  const visual = entity;
16368
16965
  if (((_a = visual === null || visual === void 0 ? void 0 : visual._register) === null || _a === void 0 ? void 0 : _a.Id) == this.id) {
@@ -16580,6 +17177,34 @@ var VisualsRegister;
16580
17177
  }
16581
17178
  return (totalOpacity && totalTicks) ? (totalOpacity / totalTicks) : totalOpacity != null && typeof totalOpacity == "number" ? totalOpacity : 1;
16582
17179
  }
17180
+ /**
17181
+ * Draws every Entity of a menu item at this opacity unless it has its own; null puts them back.
17182
+ * It is not a visual state, so a Bookmark save does not store it per Entity.
17183
+ */
17184
+ SetMenuItemOpacity(params) {
17185
+ var _a, _b, _c;
17186
+ const { menuItemId, opacity } = params;
17187
+ const wanted = typeof opacity === "number" && opacity >= 0 && opacity < 1 ? opacity : null;
17188
+ if (((_a = this.menuItemOpacities.get(menuItemId)) !== null && _a !== void 0 ? _a : null) === wanted) {
17189
+ return;
17190
+ }
17191
+ if (wanted == null) {
17192
+ this.menuItemOpacities.delete(menuItemId);
17193
+ }
17194
+ else {
17195
+ this.menuItemOpacities.set(menuItemId, wanted);
17196
+ }
17197
+ this.dimmingDirty = true;
17198
+ const entityIds = new Set(this.GetRegos({ menuItemId }).map(rego => rego.entityId).filter(Boolean));
17199
+ entityIds.forEach(entityId => this.queueUpdate({ entityId, refresh: { opacity: true } }));
17200
+ if (params.requestRender !== false) {
17201
+ (_c = (_b = this.viewer) === null || _b === void 0 ? void 0 : _b.scene) === null || _c === void 0 ? void 0 : _c.requestRender();
17202
+ }
17203
+ }
17204
+ GetMenuItemOpacity(menuItemId) {
17205
+ var _a;
17206
+ return menuItemId ? ((_a = this.menuItemOpacities.get(menuItemId)) !== null && _a !== void 0 ? _a : null) : null;
17207
+ }
16583
17208
  ClearOpacity(params) {
16584
17209
  const clearedIds = new Set();
16585
17210
  this.ForEachState((state) => {
@@ -16951,18 +17576,57 @@ var MenuItemStyleOverlay;
16951
17576
  MenuItem.EType.EntitiesLoaded,
16952
17577
  MenuItem.EType.DataLab
16953
17578
  ];
17579
+ // The row every Entities render manager draws an item with when it names none.
17580
+ const DEFAULT_ZOOM_ROW = {
17581
+ MinZoom: 0,
17582
+ MaxZoom: 200000,
17583
+ DisplayType: ZoomControl.EDisplayType.Model3D,
17584
+ LODCategoryID: "glb",
17585
+ LODLevel: 0,
17586
+ StyleID: 0
17587
+ };
17588
+ // Instructions an overlay carries that are not style fields, so a merge never copies them onto a style.
17589
+ const INSTRUCTION_KEYS = ["types", "expandSources", "opacity"];
16954
17590
  /**
16955
- * Returns the base style with each field the overlay sets laid over it.
17591
+ * Returns the base style with each field the overlay sets laid over it, then its style for the Entity Type when given.
16956
17592
  */
16957
- function Merge(base, overlay) {
16958
- var _a, _b;
17593
+ function Merge(base, overlay, entityTypeId) {
17594
+ var _a;
16959
17595
  if (!overlay) {
16960
17596
  return base;
16961
17597
  }
16962
- const merged = { ...(base !== null && base !== void 0 ? base : {}) };
17598
+ const merged = layFields({ ...(base !== null && base !== void 0 ? base : {}) }, overlay);
17599
+ const typed = entityTypeId ? (_a = overlay.types) === null || _a === void 0 ? void 0 : _a[entityTypeId] : null;
17600
+ return typed ? layFields(merged, typed) : merged;
17601
+ }
17602
+ MenuItemStyleOverlay.Merge = Merge;
17603
+ /**
17604
+ * Returns whether an overlay paints a model fill, for the layer or for any Entity Type in it.
17605
+ */
17606
+ function SetsModelFill(overlay) {
17607
+ var _a;
17608
+ if (!overlay) {
17609
+ return false;
17610
+ }
17611
+ const types = Object.values((_a = overlay.types) !== null && _a !== void 0 ? _a : {});
17612
+ 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); });
17613
+ }
17614
+ MenuItemStyleOverlay.SetsModelFill = SetsModelFill;
17615
+ /**
17616
+ * Returns whether an overlay asks for attributes read from the Entities' sources.
17617
+ */
17618
+ function ExpandsSources(overlay) {
17619
+ return Boolean(overlay === null || overlay === void 0 ? void 0 : overlay.expandSources);
17620
+ }
17621
+ MenuItemStyleOverlay.ExpandsSources = ExpandsSources;
17622
+ /*
17623
+ * Lays each style field an overlay sets onto a copy already taken, leaving its instructions behind.
17624
+ */
17625
+ function layFields(merged, overlay) {
17626
+ var _a, _b;
16963
17627
  for (const key of Object.keys(overlay)) {
16964
17628
  const value = overlay[key];
16965
- if (!isSet(value)) {
17629
+ if (INSTRUCTION_KEYS.includes(key) || !isSet(value)) {
16966
17630
  continue;
16967
17631
  }
16968
17632
  if (isPlainObject(value)) {
@@ -16978,12 +17642,11 @@ var MenuItemStyleOverlay;
16978
17642
  }
16979
17643
  return merged;
16980
17644
  }
16981
- MenuItemStyleOverlay.Merge = Merge;
16982
17645
  /**
16983
- * Returns the overlay a zoom control row carries laid over the style it resolved.
17646
+ * Returns the overlay a zoom control row carries laid over the style it resolved, for an Entity of the given type.
16984
17647
  */
16985
- function ApplyRow(style, row) {
16986
- return Merge(style, row === null || row === void 0 ? void 0 : row.StyleOverlay);
17648
+ function ApplyRow(style, row, entityTypeId) {
17649
+ return Merge(style, row === null || row === void 0 ? void 0 : row.StyleOverlay, entityTypeId);
16987
17650
  }
16988
17651
  MenuItemStyleOverlay.ApplyRow = ApplyRow;
16989
17652
  /**
@@ -17022,7 +17685,7 @@ var MenuItemStyleOverlay;
17022
17685
  * Returns a copy carrying the overlay, or the item itself when it cannot take one and carries none.
17023
17686
  */
17024
17687
  function With(item, overlay) {
17025
- var _a;
17688
+ var _a, _b;
17026
17689
  const target = Supports(item) ? overlay : null;
17027
17690
  if (!target && !Get(item)) {
17028
17691
  return item;
@@ -17038,9 +17701,11 @@ var MenuItemStyleOverlay;
17038
17701
  return next;
17039
17702
  }
17040
17703
  const zItem = item;
17704
+ // An item with no rows is drawn on the render managers' own default row, which has to carry the overlay too.
17705
+ 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 }];
17041
17706
  return {
17042
17707
  ...zItem,
17043
- CameraZoomSettings: ((_a = zItem.CameraZoomSettings) !== null && _a !== void 0 ? _a : []).map(row => {
17708
+ CameraZoomSettings: rows.map(row => {
17044
17709
  const next = { ...row };
17045
17710
  if (target) {
17046
17711
  next.StyleOverlay = target;
@@ -17242,6 +17907,8 @@ class TilesetStyler {
17242
17907
  this.scenario = 0;
17243
17908
  // Indicates that we should expand the sources of the Entity.
17244
17909
  this.expandSources = false;
17910
+ // What the item itself asks for, which an overlay reading sourced attributes can only add to.
17911
+ this.ownExpandSources = false;
17245
17912
  // Indicates that we are retrieving historic records.
17246
17913
  // This means that the current scene's time is included in the request.
17247
17914
  this.historic = false;
@@ -17307,8 +17974,9 @@ class TilesetStyler {
17307
17974
  this.applyStyles = Boolean(applyStyles);
17308
17975
  }
17309
17976
  if (expandSources != null) {
17310
- this.expandSources = expandSources;
17977
+ this.ownExpandSources = expandSources;
17311
17978
  }
17979
+ this.expandSources = this.ownExpandSources || MenuItemStyleOverlay.ExpandsSources(this.styleOverlay);
17312
17980
  if (fallbackStyleId != null) {
17313
17981
  this.fallbackStyleId = fallbackStyleId;
17314
17982
  }
@@ -17445,11 +18113,13 @@ class TilesetStyler {
17445
18113
  this.historic = params.historic;
17446
18114
  }
17447
18115
  if (params.expandSources != null) {
17448
- if (this.expandSources != params.expandSources) {
17449
- this.shouldUpdateRegoStates = true;
17450
- }
17451
- this.expandSources = params.expandSources;
18116
+ this.ownExpandSources = params.expandSources;
17452
18117
  }
18118
+ const expandSources = this.ownExpandSources || MenuItemStyleOverlay.ExpandsSources(this.styleOverlay);
18119
+ if (this.expandSources != expandSources) {
18120
+ this.shouldUpdateRegoStates = true;
18121
+ }
18122
+ this.expandSources = expandSources;
17453
18123
  // Reload styles.
17454
18124
  if (this.loaded) {
17455
18125
  this.styledEntityIds.clear();
@@ -17524,12 +18194,12 @@ class TilesetStyler {
17524
18194
  * Replaces the tileset's own colours while an overlay sets a model fill, so features show exactly what it maps to.
17525
18195
  */
17526
18196
  applyOverlayBlend() {
17527
- var _a, _b, _c, _d;
18197
+ var _a, _b;
17528
18198
  if (!this.cTileset || ((_b = (_a = this.cTileset).isDestroyed) === null || _b === void 0 ? void 0 : _b.call(_a))) {
17529
18199
  return;
17530
18200
  }
17531
- const fill = (_d = (_c = this.styleOverlay) === null || _c === void 0 ? void 0 : _c.modelStyle) === null || _d === void 0 ? void 0 : _d.fillColor;
17532
- const colours = Array.isArray(fill) ? fill.length > 0 : fill != null;
18201
+ // A fill for one Entity Type replaces too, as does a hide, which is a fully transparent fill.
18202
+ const colours = MenuItemStyleOverlay.SetsModelFill(this.styleOverlay);
17533
18203
  if (colours && this.blendBeforeOverlay == null) {
17534
18204
  this.blendBeforeOverlay = this.cTileset.colorBlendMode;
17535
18205
  this.cTileset.colorBlendMode = Cesium3DTileColorBlendMode.REPLACE;
@@ -18005,7 +18675,7 @@ class TilesetStyler {
18005
18675
  style = (_b = this.fallbackStyle) === null || _b === void 0 ? void 0 : _b.Settings;
18006
18676
  styleId = this.fallbackStyleId != null ? Number(this.fallbackStyleId) : null;
18007
18677
  }
18008
- style = MenuItemStyleOverlay.Merge(style, this.styleOverlay);
18678
+ style = MenuItemStyleOverlay.Merge(style, this.styleOverlay, entityTypeId);
18009
18679
  if (!style || !((_c = style === null || style === void 0 ? void 0 : style.modelStyle) === null || _c === void 0 ? void 0 : _c.customize)) {
18010
18680
  return { settings: null, styleId: null };
18011
18681
  }
@@ -22427,7 +23097,7 @@ var EntitiesRenderManager;
22427
23097
  console.error(e);
22428
23098
  }
22429
23099
  }
22430
- style = MenuItemStyleOverlay.ApplyRow(style, zoomItem);
23100
+ style = MenuItemStyleOverlay.ApplyRow(style, zoomItem, entityTypeId);
22431
23101
  const pStyle = (_g = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _g !== void 0 ? _g : {};
22432
23102
  const lStyle = (_h = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _h !== void 0 ? _h : {};
22433
23103
  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;
@@ -23534,7 +24204,7 @@ var EntitiesLoadedRenderManager;
23534
24204
  if (!style) {
23535
24205
  style = zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.Style;
23536
24206
  }
23537
- style = MenuItemStyleOverlay.ApplyRow(style, zoomItem);
24207
+ style = MenuItemStyleOverlay.ApplyRow(style, zoomItem, entityTypeId);
23538
24208
  const pStyle = (_h = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _h !== void 0 ? _h : {};
23539
24209
  const lStyle = (_j = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _j !== void 0 ? _j : {};
23540
24210
  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;
@@ -30512,6 +31182,7 @@ var XGridsRenderEngine;
30512
31182
  if (typeof obj.setLodAutoLevelUp === "function") {
30513
31183
  obj.setLodAutoLevelUp(true);
30514
31184
  }
31185
+ TrackSplats(viewer, obj, true);
30515
31186
  return obj;
30516
31187
  }
30517
31188
  XGridsRenderEngine.Render = Render;
@@ -30546,6 +31217,7 @@ var XGridsRenderEngine;
30546
31217
  console.warn("[XGridsRenderEngine] Remove() LCCRender library not available.");
30547
31218
  return;
30548
31219
  }
31220
+ TrackSplats(viewer, renderObject, false);
30549
31221
  LCCRender.unload(renderObject);
30550
31222
  }
30551
31223
  XGridsRenderEngine.Remove = Remove;
@@ -35046,7 +35718,15 @@ var MenuItemStyles;
35046
35718
  if (laid == null) {
35047
35719
  return next;
35048
35720
  }
35049
- return MenuItemStyleOverlay.WithItemStyle(next, itemStyle);
35721
+ // 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.
35722
+ const inline = MenuItemStyleOverlay.GetItemStyle(alternation);
35723
+ const drawsStyle = inline
35724
+ ? Object.keys(inline).some(key => key !== "opacity" && key !== "expandSources")
35725
+ : MenuItemStyleOverlay.GetItemStyleId(alternation) != null;
35726
+ const styled = drawsStyle && (next.Type === MenuItem.EType.ArbTileset || next.Type === MenuItem.EType.EntityTileset) && !next.ApplyStyles
35727
+ ? { ...next, ApplyStyles: true }
35728
+ : next;
35729
+ return MenuItemStyleOverlay.WithItemStyle(styled, itemStyle);
35050
35730
  }
35051
35731
  MenuItemStyles.ApplyAlternation = ApplyAlternation;
35052
35732
  /**
@@ -35801,6 +36481,7 @@ var MenuItemManager;
35801
36481
  }
35802
36482
  }
35803
36483
  if (rItem.renderManager && !((_g = rItem.renderManager) === null || _g === void 0 ? void 0 : _g.Disposed)) {
36484
+ this.syncItemOpacity(rItem);
35804
36485
  (_h = this.onUpdate) === null || _h === void 0 ? void 0 : _h.Trigger({ isEnabling: true, itemId: rItem.id });
35805
36486
  }
35806
36487
  return rItem.id;
@@ -35811,7 +36492,7 @@ var MenuItemManager;
35811
36492
  * @param params
35812
36493
  */
35813
36494
  RemoveItemById(params) {
35814
- var _a, _b;
36495
+ var _a, _b, _c;
35815
36496
  let { menuItemId: id, recursive, allowHandoff } = params;
35816
36497
  if (this.viewer.isDestroyed()) {
35817
36498
  return;
@@ -35846,8 +36527,9 @@ var MenuItemManager;
35846
36527
  }
35847
36528
  this.ClearSeriesSegments(item.id);
35848
36529
  }
36530
+ (_b = this.visualsRegister) === null || _b === void 0 ? void 0 : _b.SetMenuItemOpacity({ menuItemId: item.id, opacity: null, requestRender: false });
35849
36531
  this.items = this.items.filter(x => x.id !== id);
35850
- (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: false, itemId: item.id });
36532
+ (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: false, itemId: item.id });
35851
36533
  }
35852
36534
  }
35853
36535
  /**
@@ -35886,6 +36568,7 @@ var MenuItemManager;
35886
36568
  const next = MenuItemStyleOverlay.With(chosen, this.getEffectiveOverlay(chosen, this.styleOverlay));
35887
36569
  rItem.renderManager.SwapStyle(next);
35888
36570
  rItem.item = next;
36571
+ this.syncItemOpacity(rItem);
35889
36572
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
35890
36573
  return true;
35891
36574
  }
@@ -35925,9 +36608,18 @@ var MenuItemManager;
35925
36608
  }
35926
36609
  rItem.renderManager.SwapStyle(next);
35927
36610
  rItem.item = next;
36611
+ this.syncItemOpacity(rItem);
35928
36612
  (_c = this.onUpdate) === null || _c === void 0 ? void 0 : _c.Trigger({ isEnabling: true, itemId: rItem.id });
35929
36613
  }
35930
36614
  }
36615
+ /*
36616
+ * Draws an item at the opacity its bookmark style asks for, or opaque again once none is asked.
36617
+ */
36618
+ syncItemOpacity(rItem) {
36619
+ var _a, _b;
36620
+ const wanted = (_a = MenuItemStyleOverlay.GetItemStyle(rItem.item)) === null || _a === void 0 ? void 0 : _a.opacity;
36621
+ (_b = this.visualsRegister) === null || _b === void 0 ? void 0 : _b.SetMenuItemOpacity({ menuItemId: rItem.id, opacity: typeof wanted === "number" ? wanted : null });
36622
+ }
35931
36623
  /**
35932
36624
  * Lays an inline style or any Style record on one enabled item under the scene-wide one; neither clears it.
35933
36625
  */
@@ -35951,6 +36643,7 @@ var MenuItemManager;
35951
36643
  const next = MenuItemStyleOverlay.With(styled, this.getEffectiveOverlay(styled, this.styleOverlay));
35952
36644
  rItem.renderManager.SwapStyle(next);
35953
36645
  rItem.item = next;
36646
+ this.syncItemOpacity(rItem);
35954
36647
  (_a = this.onUpdate) === null || _a === void 0 ? void 0 : _a.Trigger({ isEnabling: true, itemId: rItem.id });
35955
36648
  return true;
35956
36649
  }
@@ -36000,6 +36693,7 @@ var MenuItemManager;
36000
36693
  const next = MenuItemStyleOverlay.With(rItem.item, effective);
36001
36694
  rItem.renderManager.SwapStyle(next);
36002
36695
  rItem.item = next;
36696
+ this.syncItemOpacity(rItem);
36003
36697
  (_b = this.onUpdate) === null || _b === void 0 ? void 0 : _b.Trigger({ isEnabling: true, itemId: rItem.id });
36004
36698
  }
36005
36699
  }
@@ -49008,6 +49702,72 @@ function InstallPickGroundPatch(viewer) {
49008
49702
  return true;
49009
49703
  }
49010
49704
 
49705
+ /*
49706
+ * Draws XGrids splats after the opaque meshes, so a mesh drawn later cannot paint over nearer splats.
49707
+ */
49708
+ const SPLAT_ORDER_PATCH_KEY = "_nextspaceSplatOrderPatch";
49709
+ /*
49710
+ * Whether a command is one of the XGrids SDK's splat draws.
49711
+ */
49712
+ function isSplatCommand(command) {
49713
+ var _a;
49714
+ return typeof ((_a = command === null || command === void 0 ? void 0 : command.owner) === null || _a === void 0 ? void 0 : _a.splatCount) === "number";
49715
+ }
49716
+ /*
49717
+ * Moves splat draws to the end of the opaque pass, keeping everything else in order, and returns how many moved.
49718
+ */
49719
+ function OrderSplatCommands(list, opaquePass) {
49720
+ const splats = [];
49721
+ let kept = 0;
49722
+ for (let i = 0; i < list.length; i++) {
49723
+ const command = list[i];
49724
+ if (isSplatCommand(command)) {
49725
+ splats.push(command);
49726
+ }
49727
+ else {
49728
+ list[kept++] = command;
49729
+ }
49730
+ }
49731
+ if (!splats.length) {
49732
+ return 0;
49733
+ }
49734
+ list.length = kept;
49735
+ for (const command of splats) {
49736
+ command.pass = opaquePass;
49737
+ list.push(command);
49738
+ }
49739
+ return splats.length;
49740
+ }
49741
+ /*
49742
+ * Patches a viewer's primitive update so splat draws come after its opaque meshes.
49743
+ */
49744
+ function InstallSplatOrderPatch(viewer) {
49745
+ var _a, _b;
49746
+ const primitives = (_a = viewer === null || viewer === void 0 ? void 0 : viewer.scene) === null || _a === void 0 ? void 0 : _a.primitives;
49747
+ const opaquePass = (_b = Pass) === null || _b === void 0 ? void 0 : _b.OPAQUE;
49748
+ if (!primitives || typeof primitives.update !== "function" || typeof opaquePass !== "number") {
49749
+ return false;
49750
+ }
49751
+ if (primitives[SPLAT_ORDER_PATCH_KEY]) {
49752
+ return true;
49753
+ }
49754
+ const original = primitives.update;
49755
+ primitives.update = function (frameState) {
49756
+ original.call(this, frameState);
49757
+ if (!HasSplats(viewer)) {
49758
+ return;
49759
+ }
49760
+ try {
49761
+ OrderSplatCommands(frameState.commandList, opaquePass);
49762
+ }
49763
+ catch (e) {
49764
+ console.error("Failed to order splat draws.", e);
49765
+ }
49766
+ };
49767
+ primitives[SPLAT_ORDER_PATCH_KEY] = true;
49768
+ return true;
49769
+ }
49770
+
49011
49771
  const CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
49012
49772
  const CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
49013
49773
  const BACKGROUND_RENDERING_KEY = "_backgroundRendering";
@@ -49095,6 +49855,9 @@ var ViewerUtils;
49095
49855
  backgroundRendering(viewer);
49096
49856
  InstallPickLightingPatch(viewer);
49097
49857
  InstallPickGroundPatch(viewer);
49858
+ InstallPickSplatPatch(viewer);
49859
+ InstallPickThroughGroundPatch(viewer);
49860
+ InstallSplatOrderPatch(viewer);
49098
49861
  if (cameraControls != false) {
49099
49862
  CameraControls.Attach(viewer);
49100
49863
  if (ViewUtils.GetModelSpace(viewer)) {
@@ -52781,7 +53544,7 @@ var EntityRenderEnginePoint;
52781
53544
  * @returns
52782
53545
  */
52783
53546
  async function RenderGroup(params) {
52784
- var _a, _b, _c, _d, _e;
53547
+ var _a, _b, _c, _d, _e, _f;
52785
53548
  const api = params.apiGetter.getApi();
52786
53549
  const cEntities = new Map();
52787
53550
  // Gathering tags in case styling needs it.
@@ -52813,7 +53576,7 @@ var EntityRenderEnginePoint;
52813
53576
  const entity = params.entities[i];
52814
53577
  const zoomItem = params.zoomItems[entity.Bruce.ID];
52815
53578
  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;
52816
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
53579
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
52817
53580
  // Pass through tags that may be needed for styling.
52818
53581
  const tagIds = entity.Bruce["Layer.ID"];
52819
53582
  const tags = [];
@@ -52825,11 +53588,11 @@ var EntityRenderEnginePoint;
52825
53588
  }
52826
53589
  }
52827
53590
  }
52828
- const pStyle = (_b = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _b !== void 0 ? _b : {};
53591
+ const pStyle = (_c = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _c !== void 0 ? _c : {};
52829
53592
  let rego = null;
52830
53593
  // Only used for historic tracks right now.
52831
53594
  // So won't bother getting it if we don't have historic data.
52832
- if ((_c = params.entitiesHistoric) === null || _c === void 0 ? void 0 : _c[entity.Bruce.ID]) {
53595
+ if ((_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID]) {
52833
53596
  rego = params.visualRegister.GetRego({
52834
53597
  entityId: entity.Bruce.ID,
52835
53598
  menuItemId: params.menuItemId
@@ -52844,8 +53607,8 @@ var EntityRenderEnginePoint;
52844
53607
  apiGetter: params.apiGetter,
52845
53608
  maxDistance: zoomItem.MaxZoom,
52846
53609
  minDistance: zoomItem.MinZoom,
52847
- rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID),
52848
- entityHistoric: (_e = params.entitiesHistoric) === null || _e === void 0 ? void 0 : _e[entity.Bruce.ID],
53610
+ rendered: (_e = params.rendered) === null || _e === void 0 ? void 0 : _e.get(entity.Bruce.ID),
53611
+ entityHistoric: (_f = params.entitiesHistoric) === null || _f === void 0 ? void 0 : _f[entity.Bruce.ID],
52849
53612
  entityHistoricDrawTrack: params.entityHistoricDrawTrack,
52850
53613
  fullStyle: style,
52851
53614
  rego: rego
@@ -53675,7 +54438,7 @@ var EntityRenderEngineModel3d;
53675
54438
  * @returns
53676
54439
  */
53677
54440
  async function RenderGroup(params) {
53678
- var _a, _b, _c, _d, _e, _f, _g, _h;
54441
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
53679
54442
  const api = params.apiGetter.getApi();
53680
54443
  await api.Loading;
53681
54444
  const cEntities = new Map();
@@ -53713,7 +54476,7 @@ var EntityRenderEngineModel3d;
53713
54476
  const entity = params.entities[i];
53714
54477
  const zoomItem = params.zoomItems[entity.Bruce.ID];
53715
54478
  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;
53716
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
54479
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
53717
54480
  // Pass through tags that may be needed for styling.
53718
54481
  const tagIds = entity.Bruce["Layer.ID"];
53719
54482
  const tags = [];
@@ -53725,7 +54488,7 @@ var EntityRenderEngineModel3d;
53725
54488
  }
53726
54489
  }
53727
54490
  }
53728
- const mStyle = (_b = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _b !== void 0 ? _b : {};
54491
+ const mStyle = (_c = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _c !== void 0 ? _c : {};
53729
54492
  let group = mStyle.lodGroup ? Calculator.GetString(mStyle.lodGroup, entity, tags) : null;
53730
54493
  if (!group) {
53731
54494
  group = "DEFAULT";
@@ -53752,8 +54515,8 @@ var EntityRenderEngineModel3d;
53752
54515
  for (let i = 0; i < params.entities.length; i++) {
53753
54516
  const entity = params.entities[i];
53754
54517
  const zoomItem = params.zoomItems[entity.Bruce.ID];
53755
- 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;
53756
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
54518
+ 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;
54519
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_e = entity.Bruce) === null || _e === void 0 ? void 0 : _e["EntityType.ID"]);
53757
54520
  const lod = lodData.find(x => x.entityId == entity.Bruce.ID);
53758
54521
  if (!(lod === null || lod === void 0 ? void 0 : lod.clientFileId)) {
53759
54522
  continue;
@@ -53772,21 +54535,21 @@ var EntityRenderEngineModel3d;
53772
54535
  let rego = null;
53773
54536
  // Only used for historic tracks right now.
53774
54537
  // So won't bother getting it if we don't have historic data.
53775
- if ((_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID]) {
54538
+ if ((_f = params.entitiesHistoric) === null || _f === void 0 ? void 0 : _f[entity.Bruce.ID]) {
53776
54539
  rego = params.visualRegister.GetRego({
53777
54540
  entityId: entity.Bruce.ID,
53778
54541
  menuItemId: params.menuItemId
53779
54542
  });
53780
54543
  }
53781
- const mStyle = (_e = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _e !== void 0 ? _e : {};
54544
+ const mStyle = (_g = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _g !== void 0 ? _g : {};
53782
54545
  const cEntity = Render({
53783
- rendered: (_f = params.rendered) === null || _f === void 0 ? void 0 : _f.get(entity.Bruce.ID),
54546
+ rendered: (_h = params.rendered) === null || _h === void 0 ? void 0 : _h.get(entity.Bruce.ID),
53784
54547
  entity: entity,
53785
- entityHistoric: (_g = params.entitiesHistoric) === null || _g === void 0 ? void 0 : _g[entity.Bruce.ID],
54548
+ entityHistoric: (_j = params.entitiesHistoric) === null || _j === void 0 ? void 0 : _j[entity.Bruce.ID],
53786
54549
  style: mStyle,
53787
54550
  tags: tags,
53788
54551
  viewer: params.viewer,
53789
- lodUrl: (_h = lod.url) !== null && _h !== void 0 ? _h : ClientFile.GetUrl({
54552
+ lodUrl: (_k = lod.url) !== null && _k !== void 0 ? _k : ClientFile.GetUrl({
53790
54553
  api,
53791
54554
  fileId: lod.clientFileId,
53792
54555
  viaCdn: true
@@ -54293,7 +55056,7 @@ var EntityRenderEnginePolyline;
54293
55056
  * @returns
54294
55057
  */
54295
55058
  async function RenderGroup(params) {
54296
- var _a, _b, _c;
55059
+ var _a, _b, _c, _d;
54297
55060
  const api = params.apiGetter.getApi();
54298
55061
  const cEntities = new Map();
54299
55062
  // Gathering tags in case styling needs it.
@@ -54325,7 +55088,7 @@ var EntityRenderEnginePolyline;
54325
55088
  const entity = params.entities[i];
54326
55089
  const zoomItem = params.zoomItems[entity.Bruce.ID];
54327
55090
  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;
54328
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
55091
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
54329
55092
  // Pass through tags that may be needed for styling.
54330
55093
  const tagIds = entity.Bruce["Layer.ID"];
54331
55094
  const tags = [];
@@ -54337,7 +55100,7 @@ var EntityRenderEnginePolyline;
54337
55100
  }
54338
55101
  }
54339
55102
  }
54340
- const lStyle = (_b = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _b !== void 0 ? _b : {};
55103
+ const lStyle = (_c = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _c !== void 0 ? _c : {};
54341
55104
  const cEntity = Render({
54342
55105
  entity: entity,
54343
55106
  style: lStyle,
@@ -54345,7 +55108,7 @@ var EntityRenderEnginePolyline;
54345
55108
  viewer: params.viewer,
54346
55109
  maxDistance: zoomItem.MaxZoom,
54347
55110
  minDistance: zoomItem.MinZoom,
54348
- rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID)
55111
+ rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID)
54349
55112
  });
54350
55113
  if (cEntity) {
54351
55114
  const name = await getName$2(api, entity, params.offline);
@@ -57674,6 +58437,23 @@ void main() {
57674
58437
  GetPlacementKey() {
57675
58438
  return [this.groundPixels ? 1 : 0, this.baseHeight, this.exaggeration, this.followGround ? 1 : 0].join("|");
57676
58439
  }
58440
+ /**
58441
+ * Repaints the sheet with new colours, keeping its geometry and the frames it is reading.
58442
+ */
58443
+ SetRamp(rampStops, lowColor, highColor) {
58444
+ const pixels = RampLookup(rampStops || null, lowColor || DEFAULT_LOW_COLOR, highColor || DEFAULT_HIGH_COLOR);
58445
+ // A re-render with the same colours keeps the texture it already has.
58446
+ if (this.rampPixels && pixels.length === this.rampPixels.length && pixels.every((value, i) => value === this.rampPixels[i])) {
58447
+ return;
58448
+ }
58449
+ this.rampPixels = pixels;
58450
+ this.maskFillValue = firstOpaqueStop(this.rampPixels);
58451
+ // Rebuilt from the new pixels on the next frame.
58452
+ if (this.rampTexture) {
58453
+ this.rampTexture.destroy();
58454
+ this.rampTexture = null;
58455
+ }
58456
+ }
57677
58457
  /**
57678
58458
  * The ramp the sheet is painted with, as 256 RGBA steps across the value range.
57679
58459
  */
@@ -58426,6 +59206,8 @@ const TEXTURE_FRAME_SERIES_ANIMATOR_KEY = "TextureFrameSeriesAnimator.Animator";
58426
59206
  const EXTRUSION_ANIMATOR_KEY = "TextureFrameSeriesAnimator.ExtrusionAnimator";
58427
59207
  const TEXTURE_VALUE_LABELS_KEY = "TextureValueLabels.Overlay";
58428
59208
  const DISPLACED_SURFACE_KEY = "DisplacedSurfacePrimitive.Surface";
59209
+ // Whether the surface's animator was built hiding the baseline, which it cannot change afterwards.
59210
+ const EXTRUSION_BASELINE_KEY = "TextureFrameSeriesAnimator.ExtrusionBaseline";
58429
59211
  var EntityRenderEnginePolygon;
58430
59212
  (function (EntityRenderEnginePolygon) {
58431
59213
  /**
@@ -58981,7 +59763,7 @@ var EntityRenderEnginePolygon;
58981
59763
  }
58982
59764
  EntityRenderEnginePolygon.Render = Render;
58983
59765
  async function RenderGroup(params) {
58984
- var _a, _b, _c, _d;
59766
+ var _a, _b, _c, _d, _e;
58985
59767
  const api = params.apiGetter.getApi();
58986
59768
  const cEntities = new Map();
58987
59769
  // Gathering tags in case styling needs it.
@@ -59013,7 +59795,7 @@ var EntityRenderEnginePolygon;
59013
59795
  const entity = params.entities[i];
59014
59796
  const zoomItem = params.zoomItems[entity.Bruce.ID];
59015
59797
  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;
59016
- const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem);
59798
+ const style = MenuItemStyleOverlay.ApplyRow(ownStyle, zoomItem, (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b["EntityType.ID"]);
59017
59799
  // Pass through tags that may be needed for styling.
59018
59800
  const tagIds = entity.Bruce["Layer.ID"];
59019
59801
  const tags = [];
@@ -59025,7 +59807,7 @@ var EntityRenderEnginePolygon;
59025
59807
  }
59026
59808
  }
59027
59809
  }
59028
- const pStyle = (_b = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _b !== void 0 ? _b : {};
59810
+ const pStyle = (_c = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _c !== void 0 ? _c : {};
59029
59811
  let cEntity = null;
59030
59812
  try {
59031
59813
  cEntity = await Render({
@@ -59039,14 +59821,14 @@ var EntityRenderEnginePolygon;
59039
59821
  // Temporarily disabling re-using graphics for polygons as they have some bugs, and
59040
59822
  // they don't support any animation yet.
59041
59823
  // rendered: null
59042
- rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID),
59824
+ rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID),
59043
59825
  menuItemId: params.menuItemId,
59044
59826
  visualRegister: params.visualRegister,
59045
59827
  onSeriesDiscovered: params.onSeriesDiscovered
59046
59828
  });
59047
59829
  }
59048
59830
  catch (e) {
59049
- 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);
59831
+ 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);
59050
59832
  }
59051
59833
  if (cEntity) {
59052
59834
  const name = await getName$3(api, entity, params.offline);
@@ -59258,10 +60040,15 @@ function syncDisplacedSurface(params) {
59258
60040
  const placement = surfacePlacement(entity, heightRef, extrusionArchive && TextureFrameSeriesAnimator.IsDatumHeight(extrusionArchive.metadata));
59259
60041
  // Whether the surface follows terrain is baked into its ground sampling, so a change there has
59260
60042
  // to rebuild rather than update in place.
59261
- if (reusable && existingSurface.GetFollowsGround() === placement.followGround) {
60043
+ // The baseline mask is read by the animator as it is built, so a change there rebuilds too.
60044
+ const baselineKept = cEntity[EXTRUSION_BASELINE_KEY] === Boolean(style.maskTextureBaseline);
60045
+ if (reusable && baselineKept && existingSurface.GetFollowsGround() === placement.followGround) {
59262
60046
  existingSurface.SetBaseHeight(placement.baseHeight);
59263
60047
  existingSurface.SetExaggeration(exaggerationFor(style));
59264
60048
  existingSurface.SetWater(waterFor(style));
60049
+ // A restyle that only recolours, such as a bookmark's own ramp, repaints in place.
60050
+ const ramp = surfaceRamp(style.textureColorMask, extrusionArchive.metadata);
60051
+ existingSurface.SetRamp(ramp.rampStops, ramp.lowColor, ramp.highColor);
59265
60052
  return;
59266
60053
  }
59267
60054
  disposeDisplacedSurface(cEntity, viewer);
@@ -59288,7 +60075,8 @@ function syncDisplacedSurface(params) {
59288
60075
  maskBaseline: style.maskTextureBaseline
59289
60076
  });
59290
60077
  cEntity[EXTRUSION_ANIMATOR_KEY] = animator;
59291
- const mask = style.textureColorMask;
60078
+ cEntity[EXTRUSION_BASELINE_KEY] = Boolean(style.maskTextureBaseline);
60079
+ const ramp = surfaceRamp(style.textureColorMask, extrusionArchive.metadata);
59292
60080
  const surface = new DisplacedSurfacePrimitive.Surface({
59293
60081
  extent,
59294
60082
  // The grid has to be walked the way the raster was sampled, or the surface skews across the extent.
@@ -59302,18 +60090,28 @@ function syncDisplacedSurface(params) {
59302
60090
  packedValue: TextureFrameSeriesAnimator.IsPackedValue(extrusionArchive.metadata),
59303
60091
  exaggeration: exaggerationFor(style),
59304
60092
  water: waterFor(style),
60093
+ lowColor: ramp.lowColor,
60094
+ highColor: ramp.highColor,
60095
+ rampStops: ramp.rampStops
60096
+ });
60097
+ surface.BindAnimator(animator);
60098
+ viewer.scene.primitives.add(surface);
60099
+ cEntity[DISPLACED_SURFACE_KEY] = surface;
60100
+ }
60101
+ /*
60102
+ * The colours a displaced surface paints with, from the style's mask.
60103
+ */
60104
+ function surfaceRamp(mask, metadata) {
60105
+ return {
59305
60106
  lowColor: mask ? Color$1.ColorFromStr(mask.minColor) : null,
59306
60107
  highColor: mask ? Color$1.ColorFromStr(mask.maxColor) : null,
59307
60108
  // Normalised the same way the animator normalises them, so the surface and the flat drape
59308
60109
  // agree about which values the style hides.
59309
60110
  rampStops: ((mask && mask.points) || []).map((stop) => ({
59310
- position: TextureFrameSeriesAnimator.NormalisePosition(extrusionArchive.metadata, stop.position),
60111
+ position: TextureFrameSeriesAnimator.NormalisePosition(metadata, stop.position),
59311
60112
  color: Color$1.ColorFromStr(stop.color)
59312
60113
  })).filter((stop) => Boolean(stop.color))
59313
- });
59314
- surface.BindAnimator(animator);
59315
- viewer.scene.primitives.add(surface);
59316
- cEntity[DISPLACED_SURFACE_KEY] = surface;
60114
+ };
59317
60115
  }
59318
60116
  /**
59319
60117
  * Turns the polygon's altitude option into the two things the displaced surface needs:
@@ -61296,7 +62094,7 @@ var StyleUtils;
61296
62094
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
61297
62095
  })(StyleUtils || (StyleUtils = {}));
61298
62096
 
61299
- const VERSION = "7.9.1";
62097
+ const VERSION = "7.9.3";
61300
62098
  /**
61301
62099
  * Updates the environment instance used by bruce-cesium to one specified.
61302
62100
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -61313,5 +62111,5 @@ const getENVIRONMENT = () => {
61313
62111
  return ENVIRONMENT;
61314
62112
  };
61315
62113
 
61316
- 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 };
62114
+ export { VERSION, setENVIRONMENT, getENVIRONMENT, ClusterItems, PointClustering, PointClusterSize, CesiumAnimatedInOut, DisplacedSurfacePrimitive, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, extractMetadataFromFileUrl, EntityRenderEnginePolygon, EntityRenderEnginePolyline, TextureFrameSeriesAnimator, TextureValueLabels, MenuItemCreator, MenuItemManager, MenuItemStyles, MenuItemStyleOverlay, CesiumParabola, EntityLabel, EntityLabelGroup, LiveCursor, SharedGetters, EntitySimulation, DataSourceStaticKmlManager, DataLabRenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, AssemblyRenderManager, GoogleSearchRenderManager, RelationsRenderManager, RenderManager, TilesetArbRenderManager, TilesetCadRenderManager, TilesetEntitiesRenderManager, TilesetGooglePhotosRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TileRenderEngine, createTileset, TilesetRenderEngine, ViewRenderEngine, VisualRegisterCuller, VisualsRegister, XGridsRenderEngine, CesiumEntityStyler, DrawingUtils, EntityUtils, MeasureUtils, StyleUtils, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, CESIUM_TIMELINE_LIVE_KEY, CESIUM_TIMELINE_LIVE_PADDING_KEY, CESIUM_TIMELINE_INTERVAL_KEY, CESIUM_MODEL_SPACE_KEY, CESIUM_MODEL_SPACE_POSITIONING_KEY, DEFAULT_LIVE_PADDING_SECONDS, DEFAULT_BRIGHTNESS_SHIFT, DEFAULT_LIGHT_INTENSITY, LIGHTING_SETTINGS_VERSION, LIGHT_INTENSITY_COMPENSATION, MAX_COMPENSATED_LIGHT_INTENSITY, ViewUtils, CesiumMapGrid, GltfGenerator, GltfGizmo, DeviceProfile, CesiumViewMonitor, CameraControls, FindGapSurfaces, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, WidgetLeftPanelTabDashboard, EMenuItemState, WidgetLeftPanelTabMenuItems, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, ECursor, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, CreateTabIconSvg, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
61317
62115
  //# sourceMappingURL=bruce-cesium.es5.js.map