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
@@ -9664,7 +9664,7 @@
9664
9664
  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; });
9665
9665
  if (places.length) {
9666
9666
  const keys = event;
9667
- this.visualRegister.ClickLabelPlaces(places, Boolean(keys.ctrlKey || keys.metaKey || keys.shiftKey));
9667
+ this.visualRegister.ClickLabelPlaces(places, Boolean(keys.ctrlKey || keys.metaKey || keys.shiftKey), clickEntityIds.length > 1);
9668
9668
  }
9669
9669
  const entityIds = clickEntityIds.filter(id => !places.includes(id));
9670
9670
  if (!entityIds.length) {
@@ -11240,7 +11240,8 @@
11240
11240
  latitude: place.latitude,
11241
11241
  altitude: place.altitude,
11242
11242
  look: place.look,
11243
- selected: place.selected || undefined
11243
+ selected: place.selected || undefined,
11244
+ interactive: place.interactive || undefined
11244
11245
  }));
11245
11246
  }
11246
11247
  EntityLabelGroup.FromPlaces = FromPlaces;
@@ -11793,7 +11794,7 @@
11793
11794
  }
11794
11795
  if (item.placeId) {
11795
11796
  // Clickable only when the app asks, and reported then, as there is no Entity to select.
11796
- options.selectOnClick = this.placesInteractive;
11797
+ options.selectOnClick = this.placesInteractive || Boolean(item.interactive);
11797
11798
  options.highlightColor = item.selected ? PLACE_SELECTED_COLOR : undefined;
11798
11799
  const look = item.look;
11799
11800
  if ((look === null || look === void 0 ? void 0 : look.iconUrl) || (look === null || look === void 0 ? void 0 : look.iconClass)) {
@@ -16805,13 +16806,13 @@
16805
16806
  this.labelGroups.SetPlacesInteractive(on);
16806
16807
  }
16807
16808
  /*
16808
- * Called by a label clicked while places are interactive, with the place keys it stands for.
16809
+ * Called by a clicked label that stands for places, with their keys and whether it was a cluster.
16809
16810
  */
16810
- ClickLabelPlaces(keys, additive) {
16811
+ ClickLabelPlaces(keys, additive, cluster = keys.length > 1) {
16811
16812
  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 }); })
16812
16813
  .filter(place => place.groupId && place.placeId);
16813
16814
  if (places.length) {
16814
- this.labelPlaceClicked.Trigger({ places, additive });
16815
+ this.labelPlaceClicked.Trigger({ places, additive, cluster });
16815
16816
  }
16816
16817
  }
16817
16818
  /*
@@ -18621,11 +18622,16 @@
18621
18622
  cTilesetExt._bruceModelSpace = Boolean(params.modelSpace);
18622
18623
  }
18623
18624
  TilesetRenderEngine.ApplyPosition = ApplyPosition;
18625
+ // Eye dome lighting strength that keeps depth readable as soft grey edges, tuned on a coloured scan in November 2026.
18626
+ TilesetRenderEngine.POINT_OUTLINE_STRENGTH = 0.02;
18624
18627
  function ApplySettings(params) {
18625
18628
  const { cTileset, settings } = params;
18626
18629
  cTileset.maximumScreenSpaceError = EnsureNumber(settings.maxScreenSpaceError, 5);
18627
18630
  cTileset.pointCloudShading.attenuation = Boolean(settings.attenuation);
18628
18631
  cTileset.pointCloudShading.maximumAttenuation = EnsureNumber(settings.maximumAttenuation, 4);
18632
+ // Cesium's eye dome lighting is the point outline, at its default strength of 1 they render black.
18633
+ cTileset.pointCloudShading.eyeDomeLighting = settings.pointOutlines !== false;
18634
+ cTileset.pointCloudShading.eyeDomeLightingStrength = TilesetRenderEngine.POINT_OUTLINE_STRENGTH;
18629
18635
  if (settings.colorMask) {
18630
18636
  cTileset.style = new Cesium.Cesium3DTileStyle({
18631
18637
  color: settings.colorMask
@@ -18755,6 +18761,7 @@
18755
18761
  settings: {
18756
18762
  attenuation: settings.attenuation,
18757
18763
  maximumAttenuation: settings.attenuationMax,
18764
+ pointOutlines: settings.pointOutlines,
18758
18765
  maxScreenSpaceError: settings.maximumScreenSpaceError
18759
18766
  }
18760
18767
  });
@@ -18871,6 +18878,7 @@
18871
18878
  attenuation: visual.attenuation != false,
18872
18879
  colorMask: visual.colorMask,
18873
18880
  maximumAttenuation: visual.attenuationMax,
18881
+ pointOutlines: visual.pointOutlines,
18874
18882
  maxScreenSpaceError: visual.maximumScreenSpaceError
18875
18883
  }
18876
18884
  });
@@ -29457,7 +29465,8 @@
29457
29465
  cTileset: this.cTileset,
29458
29466
  settings: {
29459
29467
  attenuation: attenuation,
29460
- maximumAttenuation: attenuationMax
29468
+ maximumAttenuation: attenuationMax,
29469
+ pointOutlines: this.item.pointOutlines
29461
29470
  }
29462
29471
  });
29463
29472
  });
@@ -29828,7 +29837,8 @@
29828
29837
  cTileset: this.cTileset,
29829
29838
  settings: {
29830
29839
  attenuation: attenuation,
29831
- maximumAttenuation: attenuationMax
29840
+ maximumAttenuation: attenuationMax,
29841
+ pointOutlines: this.item.pointOutlines
29832
29842
  }
29833
29843
  });
29834
29844
  this.viewer.scene.requestRender();
@@ -36028,7 +36038,8 @@
36028
36038
  Type: item.Type,
36029
36039
  BruceEntity: { SelectedExpandLayers: (_a = eItem.BruceEntity) === null || _a === void 0 ? void 0 : _a.SelectedExpandLayers },
36030
36040
  attenuation: tItem.attenuation,
36031
- attenuationMax: tItem.attenuationMax
36041
+ attenuationMax: tItem.attenuationMax,
36042
+ pointOutlines: tItem.pointOutlines
36032
36043
  }));
36033
36044
  this.authoredAlternations.set(item, authored);
36034
36045
  }
@@ -39481,10 +39492,11 @@
39481
39492
  const tItem = item;
39482
39493
  const authored = manager.GetAuthoredAlternation(item);
39483
39494
  const tItemAlt = alternations[item.id];
39484
- const hasAttenuation = (tItemAlt === null || tItemAlt === void 0 ? void 0 : tItemAlt.attenuation) !== undefined || (tItemAlt === null || tItemAlt === void 0 ? void 0 : tItemAlt.attenuationMax) !== undefined;
39495
+ 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;
39485
39496
  const source = hasAttenuation ? tItemAlt : authored;
39486
39497
  tItem.attenuation = source.attenuation;
39487
39498
  tItem.attenuationMax = source.attenuationMax;
39499
+ tItem.pointOutlines = source.pointOutlines;
39488
39500
  }
39489
39501
  (_d = item.Children) === null || _d === void 0 ? void 0 : _d.forEach(alternateItems);
39490
39502
  };
@@ -48745,6 +48757,103 @@
48745
48757
  }
48746
48758
  }
48747
48759
 
48760
+ /*
48761
+ * Keeps glTF and 3D Tiles pickable where a GPU shader compiler mangles CesiumJS's lit pick shaders.
48762
+ */
48763
+ const PICK_LIGHTING_PATCH_KEY = "_nextspacePickLightingPatch";
48764
+ // Added by CesiumJS's ImageBasedLightingPipelineStage; every use in its shaders sits behind an #ifdef.
48765
+ const IBL_DEFINE = "USE_IBL_LIGHTING";
48766
+ /**
48767
+ * Removes image based lighting from a derived "pick" shader's fragment options, returning whether it did.
48768
+ */
48769
+ function StripPickLighting(keyword, options) {
48770
+ const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
48771
+ const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
48772
+ if (keyword !== "pick" ||
48773
+ !Array.isArray(defines) ||
48774
+ !defines.includes(IBL_DEFINE)) {
48775
+ return false;
48776
+ }
48777
+ fragment.defines = defines.filter(x => x !== IBL_DEFINE);
48778
+ return true;
48779
+ }
48780
+ /**
48781
+ * Compiles a viewer's pick shaders unlit, since NVIDIA via ANGLE (Edge 155, CesiumJS 1.120) drops every lit pick.
48782
+ */
48783
+ function InstallPickLightingPatch(viewer) {
48784
+ var _a, _b;
48785
+ 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;
48786
+ if (!cache || typeof cache.createDerivedShaderProgram !== "function") {
48787
+ return false;
48788
+ }
48789
+ if (cache[PICK_LIGHTING_PATCH_KEY]) {
48790
+ return true;
48791
+ }
48792
+ const original = cache.createDerivedShaderProgram;
48793
+ cache.createDerivedShaderProgram = function (shaderProgram, keyword, options) {
48794
+ try {
48795
+ StripPickLighting(keyword, options);
48796
+ }
48797
+ catch (e) {
48798
+ console.error("Failed to strip lighting from a pick shader.", e);
48799
+ }
48800
+ return original.call(this, shaderProgram, keyword, options);
48801
+ };
48802
+ cache[PICK_LIGHTING_PATCH_KEY] = true;
48803
+ return true;
48804
+ }
48805
+
48806
+ /*
48807
+ * Makes a click on a ground clamped polygon pick that polygon rather than another one batched with it.
48808
+ */
48809
+ const PICK_GROUND_PATCH_KEY = "_nextspacePickGroundPatch";
48810
+ // Before CesiumJS 1.135 this keeps any pick fragment over the globe, so far batched polygons win the pick.
48811
+ const BROKEN_CULL = "uv.y <= 1.0 || logDepthOrDepth != 0.0)";
48812
+ // The same test the render path uses: the ground under the pixel lies within this polygon's extents.
48813
+ const FIXED_CULL = "uv.y <= 1.0 && logDepthOrDepth != 0.0)";
48814
+ /**
48815
+ * Corrects the extents cull in a ground primitive pick shader's fragment options, returning whether it did.
48816
+ */
48817
+ function FixPickGround(options) {
48818
+ const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
48819
+ const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
48820
+ const sources = fragment === null || fragment === void 0 ? void 0 : fragment.sources;
48821
+ if (!Array.isArray(defines) ||
48822
+ !Array.isArray(sources) ||
48823
+ !defines.includes("PICK") ||
48824
+ !defines.includes("CULL_FRAGMENTS") ||
48825
+ !sources.some(x => typeof x === "string" && x.includes(BROKEN_CULL))) {
48826
+ return false;
48827
+ }
48828
+ fragment.sources = sources.map(x => typeof x === "string" ? x.replace(BROKEN_CULL, FIXED_CULL) : x);
48829
+ return true;
48830
+ }
48831
+ /**
48832
+ * Patches a viewer's shader cache so batched ground clamped polygons pick only where they cover the ground.
48833
+ */
48834
+ function InstallPickGroundPatch(viewer) {
48835
+ var _a, _b;
48836
+ 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;
48837
+ if (!cache || typeof cache.getShaderProgram !== "function") {
48838
+ return false;
48839
+ }
48840
+ if (cache[PICK_GROUND_PATCH_KEY]) {
48841
+ return true;
48842
+ }
48843
+ const original = cache.getShaderProgram;
48844
+ cache.getShaderProgram = function (options) {
48845
+ try {
48846
+ FixPickGround(options);
48847
+ }
48848
+ catch (e) {
48849
+ console.error("Failed to fix a ground pick shader.", e);
48850
+ }
48851
+ return original.call(this, options);
48852
+ };
48853
+ cache[PICK_GROUND_PATCH_KEY] = true;
48854
+ return true;
48855
+ }
48856
+
48748
48857
  const CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
48749
48858
  const CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
48750
48859
  const BACKGROUND_RENDERING_KEY = "_backgroundRendering";
@@ -48829,6 +48938,8 @@
48829
48938
  // Newer cesium is much dimmer by default so we shift brightness a bit.
48830
48939
  exports.ViewUtils.ApplyDefaultBrightness(viewer);
48831
48940
  backgroundRendering(viewer);
48941
+ InstallPickLightingPatch(viewer);
48942
+ InstallPickGroundPatch(viewer);
48832
48943
  if (cameraControls != false) {
48833
48944
  exports.CameraControls.Attach(viewer);
48834
48945
  if (exports.ViewUtils.GetModelSpace(viewer)) {
@@ -60990,7 +61101,7 @@ void main() {
60990
61101
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60991
61102
  })(exports.StyleUtils || (exports.StyleUtils = {}));
60992
61103
 
60993
- const VERSION = "7.8.7";
61104
+ const VERSION = "7.8.9";
60994
61105
  /**
60995
61106
  * Updates the environment instance used by bruce-cesium to one specified.
60996
61107
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.