bruce-cesium 7.8.7 → 7.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-cesium.es5.js +102 -3
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +100 -1
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/internal/cesium-patch-pick-ground.js +56 -0
- package/dist/lib/internal/cesium-patch-pick-ground.js.map +1 -0
- package/dist/lib/internal/cesium-patch-pick-lighting.js +51 -0
- package/dist/lib/internal/cesium-patch-pick-lighting.js.map +1 -0
- package/dist/lib/viewer/viewer-utils.js +4 -0
- package/dist/lib/viewer/viewer-utils.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/internal/cesium-patch-pick-ground.d.ts +8 -0
- package/dist/types/internal/cesium-patch-pick-lighting.d.ts +8 -0
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -48745,6 +48745,103 @@
|
|
|
48745
48745
|
}
|
|
48746
48746
|
}
|
|
48747
48747
|
|
|
48748
|
+
/*
|
|
48749
|
+
* Keeps glTF and 3D Tiles pickable where a GPU shader compiler mangles CesiumJS's lit pick shaders.
|
|
48750
|
+
*/
|
|
48751
|
+
const PICK_LIGHTING_PATCH_KEY = "_nextspacePickLightingPatch";
|
|
48752
|
+
// Added by CesiumJS's ImageBasedLightingPipelineStage; every use in its shaders sits behind an #ifdef.
|
|
48753
|
+
const IBL_DEFINE = "USE_IBL_LIGHTING";
|
|
48754
|
+
/**
|
|
48755
|
+
* Removes image based lighting from a derived "pick" shader's fragment options, returning whether it did.
|
|
48756
|
+
*/
|
|
48757
|
+
function StripPickLighting(keyword, options) {
|
|
48758
|
+
const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
|
|
48759
|
+
const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
|
|
48760
|
+
if (keyword !== "pick" ||
|
|
48761
|
+
!Array.isArray(defines) ||
|
|
48762
|
+
!defines.includes(IBL_DEFINE)) {
|
|
48763
|
+
return false;
|
|
48764
|
+
}
|
|
48765
|
+
fragment.defines = defines.filter(x => x !== IBL_DEFINE);
|
|
48766
|
+
return true;
|
|
48767
|
+
}
|
|
48768
|
+
/**
|
|
48769
|
+
* Compiles a viewer's pick shaders unlit, since NVIDIA via ANGLE (Edge 155, CesiumJS 1.120) drops every lit pick.
|
|
48770
|
+
*/
|
|
48771
|
+
function InstallPickLightingPatch(viewer) {
|
|
48772
|
+
var _a, _b;
|
|
48773
|
+
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;
|
|
48774
|
+
if (!cache || typeof cache.createDerivedShaderProgram !== "function") {
|
|
48775
|
+
return false;
|
|
48776
|
+
}
|
|
48777
|
+
if (cache[PICK_LIGHTING_PATCH_KEY]) {
|
|
48778
|
+
return true;
|
|
48779
|
+
}
|
|
48780
|
+
const original = cache.createDerivedShaderProgram;
|
|
48781
|
+
cache.createDerivedShaderProgram = function (shaderProgram, keyword, options) {
|
|
48782
|
+
try {
|
|
48783
|
+
StripPickLighting(keyword, options);
|
|
48784
|
+
}
|
|
48785
|
+
catch (e) {
|
|
48786
|
+
console.error("Failed to strip lighting from a pick shader.", e);
|
|
48787
|
+
}
|
|
48788
|
+
return original.call(this, shaderProgram, keyword, options);
|
|
48789
|
+
};
|
|
48790
|
+
cache[PICK_LIGHTING_PATCH_KEY] = true;
|
|
48791
|
+
return true;
|
|
48792
|
+
}
|
|
48793
|
+
|
|
48794
|
+
/*
|
|
48795
|
+
* Makes a click on a ground clamped polygon pick that polygon rather than another one batched with it.
|
|
48796
|
+
*/
|
|
48797
|
+
const PICK_GROUND_PATCH_KEY = "_nextspacePickGroundPatch";
|
|
48798
|
+
// Before CesiumJS 1.135 this keeps any pick fragment over the globe, so far batched polygons win the pick.
|
|
48799
|
+
const BROKEN_CULL = "uv.y <= 1.0 || logDepthOrDepth != 0.0)";
|
|
48800
|
+
// The same test the render path uses: the ground under the pixel lies within this polygon's extents.
|
|
48801
|
+
const FIXED_CULL = "uv.y <= 1.0 && logDepthOrDepth != 0.0)";
|
|
48802
|
+
/**
|
|
48803
|
+
* Corrects the extents cull in a ground primitive pick shader's fragment options, returning whether it did.
|
|
48804
|
+
*/
|
|
48805
|
+
function FixPickGround(options) {
|
|
48806
|
+
const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
|
|
48807
|
+
const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
|
|
48808
|
+
const sources = fragment === null || fragment === void 0 ? void 0 : fragment.sources;
|
|
48809
|
+
if (!Array.isArray(defines) ||
|
|
48810
|
+
!Array.isArray(sources) ||
|
|
48811
|
+
!defines.includes("PICK") ||
|
|
48812
|
+
!defines.includes("CULL_FRAGMENTS") ||
|
|
48813
|
+
!sources.some(x => typeof x === "string" && x.includes(BROKEN_CULL))) {
|
|
48814
|
+
return false;
|
|
48815
|
+
}
|
|
48816
|
+
fragment.sources = sources.map(x => typeof x === "string" ? x.replace(BROKEN_CULL, FIXED_CULL) : x);
|
|
48817
|
+
return true;
|
|
48818
|
+
}
|
|
48819
|
+
/**
|
|
48820
|
+
* Patches a viewer's shader cache so batched ground clamped polygons pick only where they cover the ground.
|
|
48821
|
+
*/
|
|
48822
|
+
function InstallPickGroundPatch(viewer) {
|
|
48823
|
+
var _a, _b;
|
|
48824
|
+
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;
|
|
48825
|
+
if (!cache || typeof cache.getShaderProgram !== "function") {
|
|
48826
|
+
return false;
|
|
48827
|
+
}
|
|
48828
|
+
if (cache[PICK_GROUND_PATCH_KEY]) {
|
|
48829
|
+
return true;
|
|
48830
|
+
}
|
|
48831
|
+
const original = cache.getShaderProgram;
|
|
48832
|
+
cache.getShaderProgram = function (options) {
|
|
48833
|
+
try {
|
|
48834
|
+
FixPickGround(options);
|
|
48835
|
+
}
|
|
48836
|
+
catch (e) {
|
|
48837
|
+
console.error("Failed to fix a ground pick shader.", e);
|
|
48838
|
+
}
|
|
48839
|
+
return original.call(this, options);
|
|
48840
|
+
};
|
|
48841
|
+
cache[PICK_GROUND_PATCH_KEY] = true;
|
|
48842
|
+
return true;
|
|
48843
|
+
}
|
|
48844
|
+
|
|
48748
48845
|
const CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
|
|
48749
48846
|
const CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
|
|
48750
48847
|
const BACKGROUND_RENDERING_KEY = "_backgroundRendering";
|
|
@@ -48829,6 +48926,8 @@
|
|
|
48829
48926
|
// Newer cesium is much dimmer by default so we shift brightness a bit.
|
|
48830
48927
|
exports.ViewUtils.ApplyDefaultBrightness(viewer);
|
|
48831
48928
|
backgroundRendering(viewer);
|
|
48929
|
+
InstallPickLightingPatch(viewer);
|
|
48930
|
+
InstallPickGroundPatch(viewer);
|
|
48832
48931
|
if (cameraControls != false) {
|
|
48833
48932
|
exports.CameraControls.Attach(viewer);
|
|
48834
48933
|
if (exports.ViewUtils.GetModelSpace(viewer)) {
|
|
@@ -60990,7 +61089,7 @@ void main() {
|
|
|
60990
61089
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
60991
61090
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
60992
61091
|
|
|
60993
|
-
const VERSION = "7.8.
|
|
61092
|
+
const VERSION = "7.8.8";
|
|
60994
61093
|
/**
|
|
60995
61094
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
60996
61095
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|