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.
@@ -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, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, JulianDate, Quaternion, HeadingPitchRoll, HeightReference, ConstantPositionProperty, DistanceDisplayCondition, ColorBlendMode, Model, ClassificationType, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, FeatureDetection, Matrix3, NearFarScalar, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileset, OrthographicFrustum, EasingFunction, Intersect, ShadowMode, CustomDataSource, WebGLConstants, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, GeometryInstance, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, Event, CameraEventType, Plane, OrientedBoundingBox, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, PolygonPipeline, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, 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, Api, Bounds, ClientFileValueMap, Color as Color$1, Geometry as Geometry$1, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, BruceApi, EntityRelation, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttribute, MathUtils, ProjectViewBookmarkGroup } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -48874,6 +48874,103 @@ class WidgetNavCompass$$1 extends Widget.AWidget {
48874
48874
  }
48875
48875
  }
48876
48876
 
48877
+ /*
48878
+ * Keeps glTF and 3D Tiles pickable where a GPU shader compiler mangles CesiumJS's lit pick shaders.
48879
+ */
48880
+ const PICK_LIGHTING_PATCH_KEY = "_nextspacePickLightingPatch";
48881
+ // Added by CesiumJS's ImageBasedLightingPipelineStage; every use in its shaders sits behind an #ifdef.
48882
+ const IBL_DEFINE = "USE_IBL_LIGHTING";
48883
+ /**
48884
+ * Removes image based lighting from a derived "pick" shader's fragment options, returning whether it did.
48885
+ */
48886
+ function StripPickLighting(keyword, options) {
48887
+ const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
48888
+ const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
48889
+ if (keyword !== "pick" ||
48890
+ !Array.isArray(defines) ||
48891
+ !defines.includes(IBL_DEFINE)) {
48892
+ return false;
48893
+ }
48894
+ fragment.defines = defines.filter(x => x !== IBL_DEFINE);
48895
+ return true;
48896
+ }
48897
+ /**
48898
+ * Compiles a viewer's pick shaders unlit, since NVIDIA via ANGLE (Edge 155, CesiumJS 1.120) drops every lit pick.
48899
+ */
48900
+ function InstallPickLightingPatch(viewer) {
48901
+ var _a, _b;
48902
+ 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;
48903
+ if (!cache || typeof cache.createDerivedShaderProgram !== "function") {
48904
+ return false;
48905
+ }
48906
+ if (cache[PICK_LIGHTING_PATCH_KEY]) {
48907
+ return true;
48908
+ }
48909
+ const original = cache.createDerivedShaderProgram;
48910
+ cache.createDerivedShaderProgram = function (shaderProgram, keyword, options) {
48911
+ try {
48912
+ StripPickLighting(keyword, options);
48913
+ }
48914
+ catch (e) {
48915
+ console.error("Failed to strip lighting from a pick shader.", e);
48916
+ }
48917
+ return original.call(this, shaderProgram, keyword, options);
48918
+ };
48919
+ cache[PICK_LIGHTING_PATCH_KEY] = true;
48920
+ return true;
48921
+ }
48922
+
48923
+ /*
48924
+ * Makes a click on a ground clamped polygon pick that polygon rather than another one batched with it.
48925
+ */
48926
+ const PICK_GROUND_PATCH_KEY = "_nextspacePickGroundPatch";
48927
+ // Before CesiumJS 1.135 this keeps any pick fragment over the globe, so far batched polygons win the pick.
48928
+ const BROKEN_CULL = "uv.y <= 1.0 || logDepthOrDepth != 0.0)";
48929
+ // The same test the render path uses: the ground under the pixel lies within this polygon's extents.
48930
+ const FIXED_CULL = "uv.y <= 1.0 && logDepthOrDepth != 0.0)";
48931
+ /**
48932
+ * Corrects the extents cull in a ground primitive pick shader's fragment options, returning whether it did.
48933
+ */
48934
+ function FixPickGround(options) {
48935
+ const fragment = options === null || options === void 0 ? void 0 : options.fragmentShaderSource;
48936
+ const defines = fragment === null || fragment === void 0 ? void 0 : fragment.defines;
48937
+ const sources = fragment === null || fragment === void 0 ? void 0 : fragment.sources;
48938
+ if (!Array.isArray(defines) ||
48939
+ !Array.isArray(sources) ||
48940
+ !defines.includes("PICK") ||
48941
+ !defines.includes("CULL_FRAGMENTS") ||
48942
+ !sources.some(x => typeof x === "string" && x.includes(BROKEN_CULL))) {
48943
+ return false;
48944
+ }
48945
+ fragment.sources = sources.map(x => typeof x === "string" ? x.replace(BROKEN_CULL, FIXED_CULL) : x);
48946
+ return true;
48947
+ }
48948
+ /**
48949
+ * Patches a viewer's shader cache so batched ground clamped polygons pick only where they cover the ground.
48950
+ */
48951
+ function InstallPickGroundPatch(viewer) {
48952
+ var _a, _b;
48953
+ 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;
48954
+ if (!cache || typeof cache.getShaderProgram !== "function") {
48955
+ return false;
48956
+ }
48957
+ if (cache[PICK_GROUND_PATCH_KEY]) {
48958
+ return true;
48959
+ }
48960
+ const original = cache.getShaderProgram;
48961
+ cache.getShaderProgram = function (options) {
48962
+ try {
48963
+ FixPickGround(options);
48964
+ }
48965
+ catch (e) {
48966
+ console.error("Failed to fix a ground pick shader.", e);
48967
+ }
48968
+ return original.call(this, options);
48969
+ };
48970
+ cache[PICK_GROUND_PATCH_KEY] = true;
48971
+ return true;
48972
+ }
48973
+
48877
48974
  const CESIUM_VIEWER_MANAGER_KEY = "_cesiumViewerManager";
48878
48975
  const CESIUM_VIEWER_EVENT_TRACKER_KEY = "_cesiumViewerEventTracker";
48879
48976
  const BACKGROUND_RENDERING_KEY = "_backgroundRendering";
@@ -48959,6 +49056,8 @@ var ViewerUtils;
48959
49056
  // Newer cesium is much dimmer by default so we shift brightness a bit.
48960
49057
  ViewUtils.ApplyDefaultBrightness(viewer);
48961
49058
  backgroundRendering(viewer);
49059
+ InstallPickLightingPatch(viewer);
49060
+ InstallPickGroundPatch(viewer);
48962
49061
  if (cameraControls != false) {
48963
49062
  CameraControls.Attach(viewer);
48964
49063
  if (ViewUtils.GetModelSpace(viewer)) {
@@ -61160,7 +61259,7 @@ var StyleUtils;
61160
61259
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
61161
61260
  })(StyleUtils || (StyleUtils = {}));
61162
61261
 
61163
- const VERSION = "7.8.7";
61262
+ const VERSION = "7.8.8";
61164
61263
  /**
61165
61264
  * Updates the environment instance used by bruce-cesium to one specified.
61166
61265
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.