bruce-cesium 7.1.9 → 7.2.0

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, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, Cartesian2, JulianDate, Quaternion, HeadingPitchRoll, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, DistanceDisplayCondition, ArcType, CornerType, ConstantPositionProperty, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, CustomDataSource, CesiumInspector, ClockRange, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
- import { Cartes, Entity as Entity$1, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Carto, Geometry as Geometry$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, Api, BruceEvent, EntityCoords, Bounds, Color as Color$1, DataLab, DelayQueue, EntityHistoricData, BruceApi, EntityRelation, AccountConcept, RecordChangeFeed, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, UrlUtils, ProjectViewBookmarkGroup, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } 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, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, Cartesian2, DistanceDisplayCondition, JulianDate, Quaternion, HeadingPitchRoll, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, SceneMode, 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, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, CustomDataSource, PolygonPipeline, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Api, Carto, Geometry as Geometry$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, Bounds, Color as Color$1, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, EntityRelation, AccountConcept, RecordChangeFeed, BruceApi, EntitySource, Camera, ProgramKey, ProjectViewLegacyTile, Account, AccountLimits, Session, UrlUtils, ProjectViewBookmarkGroup, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -2975,9 +2975,30 @@ const CESIUM_TIMELINE_LIVE_PADDING_KEY = "_nextspace_timeline_live_padding";
2975
2975
  const CESIUM_TIMELINE_INTERVAL_KEY = "_nextspace_timeline_interval";
2976
2976
  const CESIUM_MODEL_SPACE_KEY = "_nextspace_model_space";
2977
2977
  const DEFAULT_LIVE_PADDING_SECONDS = 30 * 60;
2978
- const DEFAULT_BRIGHTNESS_SHIFT = 0.2;
2979
- const DEFAULT_LIGHT_INTENSITY = 3;
2978
+ // Atmosphere shifts are left alone by default. Tuning against a CAD scene showed the lift washing the
2979
+ // sky without helping models, which are lit by the environment map rather than by the atmosphere.
2980
+ const DEFAULT_BRIGHTNESS_SHIFT = 0;
2981
+ /*
2982
+ * Environment lighting defaults, arrived at by tuning against a white CAD model on CesiumJS 1.143.
2983
+ */
2984
+ function neutralEnvironmentMapOptions() {
2985
+ return {
2986
+ groundColor: Color.WHITE.clone(),
2987
+ groundAlbedo: 0.26,
2988
+ brightness: 1.5,
2989
+ atmosphereScatteringIntensity: 3.2
2990
+ };
2991
+ }
2992
+ // Sun intensity used when the bookmark's lighting settings name none.
2993
+ const DEFAULT_LIGHT_INTENSITY = 2;
2994
+ // Current shape of a bookmark's lighting settings.
2980
2995
  const LIGHTING_SETTINGS_VERSION = 2;
2996
+ // Settings we apply when version is unset or <=1 to compensate for newer Cesium looking darker and more yellow.
2997
+ const LIGHT_INTENSITY_COMPENSATION = 1.2;
2998
+ const MAX_COMPENSATED_LIGHT_INTENSITY = 3;
2999
+ // Set by a host that wants something other than the defaults above. Undefined means "not overridden".
3000
+ let overriddenEnvironmentMapOptions;
3001
+ let overriddenImageBasedLighting;
2981
3002
  var ViewUtils;
2982
3003
  (function (ViewUtils) {
2983
3004
  function GatherLegacyMapTiles(params) {
@@ -3346,33 +3367,97 @@ var ViewUtils;
3346
3367
  SCENE.skyAtmosphere.brightnessShift = shift;
3347
3368
  }
3348
3369
  }
3370
+ // The environment map is built from the atmosphere, and lighting it from the scene's own light
3371
+ // rather than from straight above is what stops it reading flat.
3372
+ const CESIUM = Cesium;
3373
+ if (EngineShadesModelsDarker() && SCENE.atmosphere && CESIUM.DynamicAtmosphereLightingType) {
3374
+ SCENE.atmosphere.dynamicLighting = CESIUM.DynamicAtmosphereLightingType.SCENE_LIGHT;
3375
+ }
3349
3376
  }
3350
3377
  ViewUtils.ApplyDefaultBrightness = ApplyDefaultBrightness;
3378
+ /**
3379
+ * Options applied to the environment based lighting of every tileset and model this library creates.
3380
+ * Null leaves CesiumJS's own defaults in place.
3381
+ * @param options eg { enabled: false } to switch the lighting off, or { saturation: 0 } to keep the
3382
+ * lift without the ground bounce tinting untextured geometry.
3383
+ */
3384
+ function SetDefaultEnvironmentMapOptions(options) {
3385
+ overriddenEnvironmentMapOptions = options;
3386
+ }
3387
+ ViewUtils.SetDefaultEnvironmentMapOptions = SetDefaultEnvironmentMapOptions;
3388
+ /**
3389
+ * Whether the host app's CesiumJS is a build that shades models darker than the ones these bookmarks were set up against.
3390
+ * DynamicEnvironmentMapManager arrived with that change, so its presence marks
3391
+ */
3392
+ function GetDefaultEnvironmentMapOptions(
3393
+ // Overridable so the tuned values can be asserted without swapping out CesiumJS.
3394
+ engineShadesDarker = EngineShadesModelsDarker()) {
3395
+ if (overriddenEnvironmentMapOptions !== undefined) {
3396
+ return overriddenEnvironmentMapOptions ? { ...overriddenEnvironmentMapOptions } : null;
3397
+ }
3398
+ if (!engineShadesDarker) {
3399
+ return null;
3400
+ }
3401
+ return neutralEnvironmentMapOptions();
3402
+ }
3403
+ ViewUtils.GetDefaultEnvironmentMapOptions = GetDefaultEnvironmentMapOptions;
3404
+ /**
3405
+ * The lighting options every tileset and model this library creates is built with.
3406
+ * Spread into the construction options, since both are read once when a primitive is made.
3407
+ */
3408
+ function DefaultLightingProps(engineShadesDarker = EngineShadesModelsDarker()) {
3409
+ const props = {};
3410
+ const environmentMapOptions = GetDefaultEnvironmentMapOptions(engineShadesDarker);
3411
+ if (environmentMapOptions) {
3412
+ props.environmentMapOptions = environmentMapOptions;
3413
+ }
3414
+ const imageBasedLighting = GetDefaultImageBasedLighting();
3415
+ if (imageBasedLighting) {
3416
+ props.imageBasedLighting = imageBasedLighting;
3417
+ }
3418
+ return props;
3419
+ }
3420
+ ViewUtils.DefaultLightingProps = DefaultLightingProps;
3421
+ /**
3422
+ * ImageBasedLighting applied to every tileset and model this library creates. Null, the default,
3423
+ * leaves CesiumJS's own in place.
3424
+ * @param imageBasedLighting a Cesium.ImageBasedLighting, shared across primitives.
3425
+ */
3426
+ function SetDefaultImageBasedLighting(imageBasedLighting) {
3427
+ overriddenImageBasedLighting = imageBasedLighting;
3428
+ }
3429
+ ViewUtils.SetDefaultImageBasedLighting = SetDefaultImageBasedLighting;
3430
+ function GetDefaultImageBasedLighting() {
3431
+ return overriddenImageBasedLighting || null;
3432
+ }
3433
+ ViewUtils.GetDefaultImageBasedLighting = GetDefaultImageBasedLighting;
3434
+ function EngineShadesModelsDarker() {
3435
+ return typeof DynamicEnvironmentMapManager !== "undefined";
3436
+ }
3437
+ ViewUtils.EngineShadesModelsDarker = EngineShadesModelsDarker;
3351
3438
  /**
3352
3439
  * Resolves the sun colour and intensity to apply for a bookmark's lighting settings.
3353
3440
  * @param lighting the bookmark's lighting settings, or null when it carries none.
3354
3441
  * @returns the colour and intensity to put on the scene light.
3355
3442
  */
3356
- function ResolveLightSettings(lighting) {
3443
+ function ResolveLightSettings(lighting,
3444
+ // Overridable so both branches can be exercised without swapping out CesiumJS.
3445
+ engineShadesDarker = EngineShadesModelsDarker()) {
3357
3446
  const raw = lighting === null || lighting === void 0 ? void 0 : lighting.color;
3358
- // An unreadable or missing colour would otherwise leave the light undefined.
3359
3447
  const parsed = raw ? Color.fromCssColorString(raw) : null;
3360
- const version = Number(lighting === null || lighting === void 0 ? void 0 : lighting.lightingVer);
3361
- const stale = !Number.isFinite(version) || version <= 1;
3362
3448
  const intensity = Number(lighting === null || lighting === void 0 ? void 0 : lighting.intensity);
3449
+ const named = Number.isFinite(intensity) ? intensity : DEFAULT_LIGHT_INTENSITY;
3450
+ // No settings at all means nothing was carried over from the older engine, so there is nothing
3451
+ // to compensate. A settings object with no version in it is the case that predates the field.
3452
+ const version = Number(lighting === null || lighting === void 0 ? void 0 : lighting.lightingVer);
3453
+ const legacy = lighting != null && (!Number.isFinite(version) || version <= 1);
3454
+ const compensated = Math.min(named * LIGHT_INTENSITY_COMPENSATION, MAX_COMPENSATED_LIGHT_INTENSITY);
3363
3455
  return {
3364
3456
  color: parsed || Color.WHITE,
3365
- intensity: stale || !Number.isFinite(intensity) ? DEFAULT_LIGHT_INTENSITY : intensity
3457
+ intensity: legacy && engineShadesDarker ? compensated : named
3366
3458
  };
3367
3459
  }
3368
3460
  ViewUtils.ResolveLightSettings = ResolveLightSettings;
3369
- /**
3370
- * Options handed to every tileset and model this library creates.
3371
- */
3372
- function DefaultEnvironmentMapOptions() {
3373
- return { enabled: false };
3374
- }
3375
- ViewUtils.DefaultEnvironmentMapOptions = DefaultEnvironmentMapOptions;
3376
3461
  function SetGlobeDetails(params) {
3377
3462
  let { viewer, hidden, baseColor } = params;
3378
3463
  const scene = viewer === null || viewer === void 0 ? void 0 : viewer.scene;
@@ -14731,8 +14816,8 @@ async function createTileset(url, props, noMemoryLimit) {
14731
14816
  const defaultProps = {
14732
14817
  // "Optimization option. Reduce the screen space error for tiles that are further away from the camera.".
14733
14818
  dynamicScreenSpaceError: true,
14734
- environmentMapOptions: ViewUtils.DefaultEnvironmentMapOptions()
14735
14819
  };
14820
+ Object.assign(defaultProps, ViewUtils.DefaultLightingProps());
14736
14821
  if (noMemoryLimit != true) {
14737
14822
  // "The maximum amount of memory in MB that can be used by the tileset.".
14738
14823
  defaultProps.maximumMemoryUsage = 512;
@@ -21469,7 +21554,7 @@ var TilesetGooglePhotosRenderManager;
21469
21554
  }
21470
21555
  this.cTileset = await CESIUM.Cesium3DTileset.fromUrl(proxyRootUrl, {
21471
21556
  showCreditsOnScreen: true,
21472
- environmentMapOptions: ViewUtils.DefaultEnvironmentMapOptions()
21557
+ ...ViewUtils.DefaultLightingProps()
21473
21558
  });
21474
21559
  }
21475
21560
  else {
@@ -23013,7 +23098,7 @@ var AssemblyRenderManager;
23013
23098
  const cEntity = this.viewer.entities.add({
23014
23099
  model: {
23015
23100
  uri: lod["ClientFile"].URL,
23016
- environmentMapOptions: ViewUtils.DefaultEnvironmentMapOptions(),
23101
+ ...ViewUtils.DefaultLightingProps(),
23017
23102
  heightReference: HeightReference.NONE
23018
23103
  },
23019
23104
  // point: {
@@ -38768,7 +38853,7 @@ var EntityRenderEngineModel3d;
38768
38853
  id: ObjectUtils.UId(15),
38769
38854
  model: {
38770
38855
  uri: params.lodUrl,
38771
- environmentMapOptions: ViewUtils.DefaultEnvironmentMapOptions(),
38856
+ ...ViewUtils.DefaultLightingProps(),
38772
38857
  heightReference: heightRef,
38773
38858
  scale: new CallbackProperty(() => scale * styleScale, true),
38774
38859
  shadows: ShadowMode.ENABLED,
@@ -39411,7 +39496,7 @@ async function getModelEntity(url, scale) {
39411
39496
  url: url,
39412
39497
  asynchronous: true,
39413
39498
  scale: scale,
39414
- environmentMapOptions: ViewUtils.DefaultEnvironmentMapOptions()
39499
+ ...ViewUtils.DefaultLightingProps()
39415
39500
  });
39416
39501
  }
39417
39502
  // Older versions of Cesium have a fromGltf method.
@@ -43573,7 +43658,7 @@ var StyleUtils;
43573
43658
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
43574
43659
  })(StyleUtils || (StyleUtils = {}));
43575
43660
 
43576
- const VERSION = "7.1.9";
43661
+ const VERSION = "7.2.0";
43577
43662
  /**
43578
43663
  * Updates the environment instance used by bruce-cesium to one specified.
43579
43664
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -43590,5 +43675,5 @@ const getENVIRONMENT = () => {
43590
43675
  return ENVIRONMENT;
43591
43676
  };
43592
43677
 
43593
- export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, DisplacedSurfacePrimitive, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, 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, DEFAULT_LIVE_PADDING_SECONDS, DEFAULT_BRIGHTNESS_SHIFT, DEFAULT_LIGHT_INTENSITY, LIGHTING_SETTINGS_VERSION, ViewUtils, CesiumViewMonitor, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, WidgetLeftPanelTabDashboard, EMenuItemState, WidgetLeftPanelTabMenuItems, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
43678
+ export { VERSION, setENVIRONMENT, getENVIRONMENT, CesiumAnimatedInOut, DisplacedSurfacePrimitive, CesiumAnimatedProperty, isStyleChanged, isOutlineChanged$1 as isOutlineChanged, StyleEffective, EntityRenderEngine, EntityRenderEngineModel3d, EntityRenderEnginePoint, EntityRenderEnginePolygon, EntityRenderEnginePolyline, MenuItemCreator, MenuItemManager, CesiumParabola, EntityLabel, LiveCursor, SharedGetters, 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, DEFAULT_LIVE_PADDING_SECONDS, DEFAULT_BRIGHTNESS_SHIFT, DEFAULT_LIGHT_INTENSITY, LIGHTING_SETTINGS_VERSION, LIGHT_INTENSITY_COMPENSATION, MAX_COMPENSATED_LIGHT_INTENSITY, ViewUtils, CesiumViewMonitor, ViewGroundArea, ViewerEventTracker, ViewerUtils, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Walkthrough, WidgetControlViewBar, WidgetControlViewBarSearch, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks, WidgetLeftPanelTabDashboard, EMenuItemState, WidgetLeftPanelTabMenuItems, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetNavCompass$$1 as WidgetNavCompass, VIEWER_VIEW_BAR_WIDGET_KEY, WidgetViewBar };
43594
43679
  //# sourceMappingURL=bruce-cesium.es5.js.map