bruce-cesium 7.8.7 → 7.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/bruce-cesium.es5.js +124 -13
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +122 -11
  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-ground.js +56 -0
  7. package/dist/lib/internal/cesium-patch-pick-ground.js.map +1 -0
  8. package/dist/lib/internal/cesium-patch-pick-lighting.js +51 -0
  9. package/dist/lib/internal/cesium-patch-pick-lighting.js.map +1 -0
  10. package/dist/lib/rendering/menu-item-creator.js +2 -1
  11. package/dist/lib/rendering/menu-item-creator.js.map +1 -1
  12. package/dist/lib/rendering/menu-item-manager.js +2 -1
  13. package/dist/lib/rendering/menu-item-manager.js.map +1 -1
  14. package/dist/lib/rendering/render-managers/common/entity-label-group.js +3 -2
  15. package/dist/lib/rendering/render-managers/common/entity-label-group.js.map +1 -1
  16. package/dist/lib/rendering/render-managers/common/entity-label.js +1 -1
  17. package/dist/lib/rendering/render-managers/common/entity-label.js.map +1 -1
  18. package/dist/lib/rendering/render-managers/tilesets/tileset-entities-render-manager.js +4 -2
  19. package/dist/lib/rendering/render-managers/tilesets/tileset-entities-render-manager.js.map +1 -1
  20. package/dist/lib/rendering/tileset-render-engine.js +7 -0
  21. package/dist/lib/rendering/tileset-render-engine.js.map +1 -1
  22. package/dist/lib/rendering/visuals-register.js +3 -3
  23. package/dist/lib/rendering/visuals-register.js.map +1 -1
  24. package/dist/lib/viewer/viewer-utils.js +4 -0
  25. package/dist/lib/viewer/viewer-utils.js.map +1 -1
  26. package/dist/types/bruce-cesium.d.ts +1 -1
  27. package/dist/types/internal/cesium-patch-pick-ground.d.ts +8 -0
  28. package/dist/types/internal/cesium-patch-pick-lighting.d.ts +8 -0
  29. package/dist/types/rendering/render-managers/common/entity-label-group.d.ts +3 -0
  30. package/dist/types/rendering/tileset-render-engine.d.ts +2 -0
  31. package/dist/types/rendering/visuals-register.d.ts +1 -1
  32. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import * as Cesium from 'cesium';
2
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, 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, ClassificationType, ArcType, CornerType, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, ColorBlendMode, Model, HorizontalOrigin, VerticalOrigin, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, KmlDataSource, Matrix3, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, IonResource, Cesium3DTileset, Intersect, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, WebGLConstants, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ShadowMode, CustomDataSource, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, GeometryInstance, Event, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, Geometry as Geometry$1, Bounds, ClientFileValueMap, Color as Color$1, EntityLod, UrlUtils, Api, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, BruceApi, EntityRelation, 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, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, Cartesian3, Model, ClassificationType, 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, ArcType, CornerType, JulianDate, Quaternion, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, FeatureDetection, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, Intersect, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, WebGLConstants, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CesiumInspector, ClockRange, ShadowMode, DynamicEnvironmentMapManager, GeometryInstance, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, CustomDataSource, Event, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, LRUCache, Carto, ProjectViewTile, EntityHistoricData, BruceEvent, DelayQueue, Entity as Entity$1, EntityTag, PathUtils, ClientFile, ENVIRONMENT, EntityAttachmentType, EntityRelationType, EntityType, Tileset, Calculator, DataLab, Style, ObjectUtils, MenuItem, AccountConcept, RecordChangeFeed, EntityLod, UrlUtils, Geometry as Geometry$1, Api, Bounds, ClientFileValueMap, Color as Color$1, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, EntityRelation, BruceApi, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, ProjectViewBookmarkGroup, EntityAttachment, EntityAttribute, MathUtils } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -9683,7 +9683,7 @@ var EntityLabel;
9683
9683
  const places = clickEntityIds.filter(id => { var _a, _b; return (_b = (_a = this.visualRegister.GetLabelGroupFor(id)) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.placeId; });
9684
9684
  if (places.length) {
9685
9685
  const keys = event;
9686
- this.visualRegister.ClickLabelPlaces(places, Boolean(keys.ctrlKey || keys.metaKey || keys.shiftKey));
9686
+ this.visualRegister.ClickLabelPlaces(places, Boolean(keys.ctrlKey || keys.metaKey || keys.shiftKey), clickEntityIds.length > 1);
9687
9687
  }
9688
9688
  const entityIds = clickEntityIds.filter(id => !places.includes(id));
9689
9689
  if (!entityIds.length) {
@@ -11260,7 +11260,8 @@ var EntityLabelGroup;
11260
11260
  latitude: place.latitude,
11261
11261
  altitude: place.altitude,
11262
11262
  look: place.look,
11263
- selected: place.selected || undefined
11263
+ selected: place.selected || undefined,
11264
+ interactive: place.interactive || undefined
11264
11265
  }));
11265
11266
  }
11266
11267
  EntityLabelGroup.FromPlaces = FromPlaces;
@@ -11813,7 +11814,7 @@ var EntityLabelGroup;
11813
11814
  }
11814
11815
  if (item.placeId) {
11815
11816
  // Clickable only when the app asks, and reported then, as there is no Entity to select.
11816
- options.selectOnClick = this.placesInteractive;
11817
+ options.selectOnClick = this.placesInteractive || Boolean(item.interactive);
11817
11818
  options.highlightColor = item.selected ? PLACE_SELECTED_COLOR : undefined;
11818
11819
  const look = item.look;
11819
11820
  if ((look === null || look === void 0 ? void 0 : look.iconUrl) || (look === null || look === void 0 ? void 0 : look.iconClass)) {
@@ -16830,13 +16831,13 @@ var VisualsRegister;
16830
16831
  this.labelGroups.SetPlacesInteractive(on);
16831
16832
  }
16832
16833
  /*
16833
- * Called by a label clicked while places are interactive, with the place keys it stands for.
16834
+ * Called by a clicked label that stands for places, with their keys and whether it was a cluster.
16834
16835
  */
16835
- ClickLabelPlaces(keys, additive) {
16836
+ ClickLabelPlaces(keys, additive, cluster = keys.length > 1) {
16836
16837
  const places = keys.map(key => { var _a, _b, _c; return ({ groupId: (_a = this.GetLabelGroupFor(key)) === null || _a === void 0 ? void 0 : _a.groupId, placeId: (_c = (_b = this.GetLabelGroupFor(key)) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.placeId }); })
16837
16838
  .filter(place => place.groupId && place.placeId);
16838
16839
  if (places.length) {
16839
- this.labelPlaceClicked.Trigger({ places, additive });
16840
+ this.labelPlaceClicked.Trigger({ places, additive, cluster });
16840
16841
  }
16841
16842
  }
16842
16843
  /*
@@ -18655,11 +18656,16 @@ var TilesetRenderEngine;
18655
18656
  cTilesetExt._bruceModelSpace = Boolean(params.modelSpace);
18656
18657
  }
18657
18658
  TilesetRenderEngine.ApplyPosition = ApplyPosition;
18659
+ // Eye dome lighting strength that keeps depth readable as soft grey edges, tuned on a coloured scan in November 2026.
18660
+ TilesetRenderEngine.POINT_OUTLINE_STRENGTH = 0.02;
18658
18661
  function ApplySettings(params) {
18659
18662
  const { cTileset, settings } = params;
18660
18663
  cTileset.maximumScreenSpaceError = EnsureNumber(settings.maxScreenSpaceError, 5);
18661
18664
  cTileset.pointCloudShading.attenuation = Boolean(settings.attenuation);
18662
18665
  cTileset.pointCloudShading.maximumAttenuation = EnsureNumber(settings.maximumAttenuation, 4);
18666
+ // Cesium's eye dome lighting is the point outline, at its default strength of 1 they render black.
18667
+ cTileset.pointCloudShading.eyeDomeLighting = settings.pointOutlines !== false;
18668
+ cTileset.pointCloudShading.eyeDomeLightingStrength = TilesetRenderEngine.POINT_OUTLINE_STRENGTH;
18663
18669
  if (settings.colorMask) {
18664
18670
  cTileset.style = new Cesium3DTileStyle({
18665
18671
  color: settings.colorMask
@@ -18789,6 +18795,7 @@ var TilesetRenderEngine;
18789
18795
  settings: {
18790
18796
  attenuation: settings.attenuation,
18791
18797
  maximumAttenuation: settings.attenuationMax,
18798
+ pointOutlines: settings.pointOutlines,
18792
18799
  maxScreenSpaceError: settings.maximumScreenSpaceError
18793
18800
  }
18794
18801
  });
@@ -18905,6 +18912,7 @@ var TilesetRenderEngine;
18905
18912
  attenuation: visual.attenuation != false,
18906
18913
  colorMask: visual.colorMask,
18907
18914
  maximumAttenuation: visual.attenuationMax,
18915
+ pointOutlines: visual.pointOutlines,
18908
18916
  maxScreenSpaceError: visual.maximumScreenSpaceError
18909
18917
  }
18910
18918
  });
@@ -29527,7 +29535,8 @@ var TilesetEntitiesRenderManager;
29527
29535
  cTileset: this.cTileset,
29528
29536
  settings: {
29529
29537
  attenuation: attenuation,
29530
- maximumAttenuation: attenuationMax
29538
+ maximumAttenuation: attenuationMax,
29539
+ pointOutlines: this.item.pointOutlines
29531
29540
  }
29532
29541
  });
29533
29542
  });
@@ -29898,7 +29907,8 @@ var TilesetEntitiesRenderManager;
29898
29907
  cTileset: this.cTileset,
29899
29908
  settings: {
29900
29909
  attenuation: attenuation,
29901
- maximumAttenuation: attenuationMax
29910
+ maximumAttenuation: attenuationMax,
29911
+ pointOutlines: this.item.pointOutlines
29902
29912
  }
29903
29913
  });
29904
29914
  this.viewer.scene.requestRender();
@@ -36123,7 +36133,8 @@ var MenuItemManager;
36123
36133
  Type: item.Type,
36124
36134
  BruceEntity: { SelectedExpandLayers: (_a = eItem.BruceEntity) === null || _a === void 0 ? void 0 : _a.SelectedExpandLayers },
36125
36135
  attenuation: tItem.attenuation,
36126
- attenuationMax: tItem.attenuationMax
36136
+ attenuationMax: tItem.attenuationMax,
36137
+ pointOutlines: tItem.pointOutlines
36127
36138
  }));
36128
36139
  this.authoredAlternations.set(item, authored);
36129
36140
  }
@@ -39591,10 +39602,11 @@ var MenuItemCreator;
39591
39602
  const tItem = item;
39592
39603
  const authored = manager.GetAuthoredAlternation(item);
39593
39604
  const tItemAlt = alternations[item.id];
39594
- const hasAttenuation = (tItemAlt === null || tItemAlt === void 0 ? void 0 : tItemAlt.attenuation) !== undefined || (tItemAlt === null || tItemAlt === void 0 ? void 0 : tItemAlt.attenuationMax) !== undefined;
39605
+ const hasAttenuation = (tItemAlt === null || tItemAlt === void 0 ? void 0 : tItemAlt.attenuation) !== undefined || (tItemAlt === null || tItemAlt === void 0 ? void 0 : tItemAlt.attenuationMax) !== undefined || (tItemAlt === null || tItemAlt === void 0 ? void 0 : tItemAlt.pointOutlines) !== undefined;
39595
39606
  const source = hasAttenuation ? tItemAlt : authored;
39596
39607
  tItem.attenuation = source.attenuation;
39597
39608
  tItem.attenuationMax = source.attenuationMax;
39609
+ tItem.pointOutlines = source.pointOutlines;
39598
39610
  }
39599
39611
  (_d = item.Children) === null || _d === void 0 ? void 0 : _d.forEach(alternateItems);
39600
39612
  };
@@ -48874,6 +48886,103 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
48874
48886
  }
48875
48887
  }
48876
48888
 
48889
+ /*
48890
+ * Keeps glTF and 3D Tiles pickable where a GPU shader compiler mangles CesiumJS's lit pick shaders.
48891
+ */
48892
+ const PICK_LIGHTING_PATCH_KEY = "_nextspacePickLightingPatch";
48893
+ // Added by CesiumJS's ImageBasedLightingPipelineStage; every use in its shaders sits behind an #ifdef.
48894
+ const IBL_DEFINE = "USE_IBL_LIGHTING";
48895
+ /**
48896
+ * Removes image based lighting from a derived "pick" shader's fragment options, returning whether it did.
48897
+ */
48898
+ function StripPickLighting(keyword, options) {
48899
+ const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
48900
+ const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
48901
+ if (keyword !== "pick" ||
48902
+ !Array.isArray(defines) ||
48903
+ !defines.includes(IBL_DEFINE)) {
48904
+ return false;
48905
+ }
48906
+ fragment.defines = defines.filter(x => x !== IBL_DEFINE);
48907
+ return true;
48908
+ }
48909
+ /**
48910
+ * Compiles a viewer's pick shaders unlit, since NVIDIA via ANGLE (Edge 155, CesiumJS 1.120) drops every lit pick.
48911
+ */
48912
+ function InstallPickLightingPatch(viewer) {
48913
+ var _a, _b;
48914
+ 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;
48915
+ if (!cache || typeof cache.createDerivedShaderProgram !== "function") {
48916
+ return false;
48917
+ }
48918
+ if (cache[PICK_LIGHTING_PATCH_KEY]) {
48919
+ return true;
48920
+ }
48921
+ const original = cache.createDerivedShaderProgram;
48922
+ cache.createDerivedShaderProgram = function (shaderProgram, keyword, options) {
48923
+ try {
48924
+ StripPickLighting(keyword, options);
48925
+ }
48926
+ catch (e) {
48927
+ console.error("Failed to strip lighting from a pick shader.", e);
48928
+ }
48929
+ return original.call(this, shaderProgram, keyword, options);
48930
+ };
48931
+ cache[PICK_LIGHTING_PATCH_KEY] = true;
48932
+ return true;
48933
+ }
48934
+
48935
+ /*
48936
+ * Makes a click on a ground clamped polygon pick that polygon rather than another one batched with it.
48937
+ */
48938
+ const PICK_GROUND_PATCH_KEY = "_nextspacePickGroundPatch";
48939
+ // Before CesiumJS 1.135 this keeps any pick fragment over the globe, so far batched polygons win the pick.
48940
+ const BROKEN_CULL = "uv.y <= 1.0 || logDepthOrDepth != 0.0)";
48941
+ // The same test the render path uses: the ground under the pixel lies within this polygon's extents.
48942
+ const FIXED_CULL = "uv.y <= 1.0 && logDepthOrDepth != 0.0)";
48943
+ /**
48944
+ * Corrects the extents cull in a ground primitive pick shader's fragment options, returning whether it did.
48945
+ */
48946
+ function FixPickGround(options) {
48947
+ const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
48948
+ const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
48949
+ const sources = fragment === null || fragment === void 0 ? void 0 : fragment.sources;
48950
+ if (!Array.isArray(defines) ||
48951
+ !Array.isArray(sources) ||
48952
+ !defines.includes("PICK") ||
48953
+ !defines.includes("CULL_FRAGMENTS") ||
48954
+ !sources.some(x => typeof x === "string" && x.includes(BROKEN_CULL))) {
48955
+ return false;
48956
+ }
48957
+ fragment.sources = sources.map(x => typeof x === "string" ? x.replace(BROKEN_CULL, FIXED_CULL) : x);
48958
+ return true;
48959
+ }
48960
+ /**
48961
+ * Patches a viewer's shader cache so batched ground clamped polygons pick only where they cover the ground.
48962
+ */
48963
+ function InstallPickGroundPatch(viewer) {
48964
+ var _a, _b;
48965
+ 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;
48966
+ if (!cache || typeof cache.getShaderProgram !== "function") {
48967
+ return false;
48968
+ }
48969
+ if (cache[PICK_GROUND_PATCH_KEY]) {
48970
+ return true;
48971
+ }
48972
+ const original = cache.getShaderProgram;
48973
+ cache.getShaderProgram = function (options) {
48974
+ try {
48975
+ FixPickGround(options);
48976
+ }
48977
+ catch (e) {
48978
+ console.error("Failed to fix a ground pick shader.", e);
48979
+ }
48980
+ return original.call(this, options);
48981
+ };
48982
+ cache[PICK_GROUND_PATCH_KEY] = true;
48983
+ return true;
48984
+ }
48985
+
48877
48986
  const CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
48878
48987
  const CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
48879
48988
  const BACKGROUND_RENDERING_KEY = "_backgroundRendering";
@@ -48959,6 +49068,8 @@ var ViewerUtils;
48959
49068
  // Newer cesium is much dimmer by default so we shift brightness a bit.
48960
49069
  ViewUtils.ApplyDefaultBrightness(viewer);
48961
49070
  backgroundRendering(viewer);
49071
+ InstallPickLightingPatch(viewer);
49072
+ InstallPickGroundPatch(viewer);
48962
49073
  if (cameraControls != false) {
48963
49074
  CameraControls.Attach(viewer);
48964
49075
  if (ViewUtils.GetModelSpace(viewer)) {
@@ -61160,7 +61271,7 @@ var StyleUtils;
61160
61271
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
61161
61272
  })(StyleUtils || (StyleUtils = {}));
61162
61273
 
61163
- const VERSION = "7.8.7";
61274
+ const VERSION = "7.8.9";
61164
61275
  /**
61165
61276
  * Updates the environment instance used by bruce-cesium to one specified.
61166
61277
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.