bruce-cesium 7.7.9 → 7.8.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, ConstantPositionProperty, HeightReference, DistanceDisplayCondition, 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, ColorBlendMode, Model, ClassificationType, HorizontalOrigin, VerticalOrigin, ArcType, CornerType, SceneMode, IntersectionTests, Ray, SceneTransforms, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, NearFarScalar, Matrix3, KmlDataSource, GeoJsonDataSource, FeatureDetection, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, OrthographicFrustum, EasingFunction, Cesium3DTileset, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Intersect, WebGLConstants, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ShadowMode, CustomDataSource, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, PrimitiveCollection, PolylineCollection, LabelCollection, LabelStyle, Material, GeometryInstance, 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, Api, Geometry as Geometry$1, Bounds, ClientFileValueMap, Color as Color$1, Assembly, EntityCoords, ZoomControl, ProjectView, ProjectViewBookmark, EntityRelation, BruceApi, 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, 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, ColorBlendMode, Model, ClassificationType, ArcType, CornerType, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, NearFarScalar, Matrix3, KmlDataSource, FeatureDetection, GeoJsonDataSource, 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, WebGLConstants, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, PolygonPipeline, PrimitiveCollection, ShadowMode, PolylineCollection, LabelCollection, LabelStyle, Material, CustomDataSource, GeometryInstance, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, 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, ProjectView, ProjectViewBookmark, ZoomControl, Assembly, EntityCoords, Bounds, ClientFileValueMap, Color as Color$1, 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.
@@ -7640,6 +7640,36 @@ var EntityLabel;
7640
7640
  * Prefer declared semantics; only infers from recognisable glyphs and filename tokens, never image pixels.
7641
7641
  */
7642
7642
  EntityLabel.IconPriority = GetClusterIconPriority;
7643
+ /*
7644
+ * The glyph and chip colours an icon draws with: each given one as is, a missing one inferred from the other.
7645
+ */
7646
+ function IconColors(options) {
7647
+ var _a;
7648
+ const icon = typeof options.iconColor === "string" && options.iconColor ? options.iconColor : undefined;
7649
+ const background = typeof options.iconBackground === "string" && options.iconBackground.trim() ? options.iconBackground : undefined;
7650
+ if (background) {
7651
+ return { icon: icon !== null && icon !== void 0 ? icon : contrasting(background, 1), background };
7652
+ }
7653
+ if (options.iconBackground === true) {
7654
+ return { icon, background: (_a = contrasting(icon, ICON_BACKGROUND_ALPHA)) !== null && _a !== void 0 ? _a : contrasting("white", ICON_BACKGROUND_ALPHA) };
7655
+ }
7656
+ return { icon };
7657
+ }
7658
+ EntityLabel.IconColors = IconColors;
7659
+ /*
7660
+ * A light colour darkened, or a dark one brightened, far enough to read against it.
7661
+ */
7662
+ function contrasting(css, alpha) {
7663
+ const color = css ? Color.fromCssColorString(css) : undefined;
7664
+ if (!color) {
7665
+ return undefined;
7666
+ }
7667
+ const luminance = 0.2126 * color.red + 0.7152 * color.green + 0.0722 * color.blue;
7668
+ const shade = luminance > 0.5 ?
7669
+ color.darken(ICON_BACKGROUND_BLEND, new Color()) :
7670
+ color.brighten(ICON_BACKGROUND_BLEND, new Color());
7671
+ return shade.withAlpha(alpha).toCssColorString();
7672
+ }
7643
7673
  function iconLook(options) {
7644
7674
  return {
7645
7675
  icon: options.icon || undefined,
@@ -10321,8 +10351,10 @@ var EntityLabel;
10321
10351
  }
10322
10352
  icon.style.cssText = `font-size:${(options.iconSize || 24) * ((_a = options.iconScale) !== null && _a !== void 0 ? _a : 1)}px;line-height:1;`;
10323
10353
  icon.style.textShadow = "0 1px 2px rgba(0, 0, 0, 0.25)";
10324
- const iconColor = typeof options.iconColor === "string" ? options.iconColor : undefined;
10325
- const iconBackground = options.iconBackground && options.iconScale !== 0;
10354
+ const colors = IconColors(options);
10355
+ // A file keeps its own colours unless one was given; only a glyph takes an inferred one.
10356
+ const iconColor = options.iconUrl ? (typeof options.iconColor === "string" ? options.iconColor : undefined) : colors.icon;
10357
+ const iconBackground = options.iconScale !== 0 ? colors.background : undefined;
10326
10358
  if (iconColor) {
10327
10359
  icon.style.color = iconColor;
10328
10360
  }
@@ -10387,12 +10419,8 @@ var EntityLabel;
10387
10419
  icon.textContent = options.icon || "●";
10388
10420
  }
10389
10421
  if (iconBackground) {
10390
- const color = Color.fromCssColorString(iconColor || "white") || Color.WHITE;
10391
- const luminance = 0.2126 * color.red + 0.7152 * color.green + 0.0722 * color.blue;
10392
- const background = (luminance > 0.5 ? color.darken(ICON_BACKGROUND_BLEND, new Color()) :
10393
- color.brighten(ICON_BACKGROUND_BLEND, new Color()));
10394
10422
  const size = (options.iconSize || 24) * ((_c = options.iconScale) !== null && _c !== void 0 ? _c : 1);
10395
- icon.style.backgroundColor = background.withAlpha(ICON_BACKGROUND_ALPHA).toCssColorString();
10423
+ icon.style.backgroundColor = iconBackground;
10396
10424
  icon.style.borderRadius = "50%";
10397
10425
  icon.style.padding = `${size / 3}px`;
10398
10426
  icon.style.display = "inline-flex";
@@ -10767,7 +10795,7 @@ var EntityLabelGroup;
10767
10795
  }
10768
10796
  return [
10769
10797
  options.text, options.icon, options.iconUrl, options.iconClass,
10770
- options.iconColor, options.iconStatus, options.iconPriority, options.iconScale
10798
+ options.iconColor, options.iconBackground, options.iconStatus, options.iconPriority, options.iconScale
10771
10799
  ].some(Array.isArray);
10772
10800
  }
10773
10801
  EntityLabelGroup.NeedsEntityData = NeedsEntityData;
@@ -10895,6 +10923,12 @@ var EntityLabelGroup;
10895
10923
  return null;
10896
10924
  }
10897
10925
  }
10926
+ /*
10927
+ * A calculated chip colour that finds nothing for an entity draws no chip, as an unset one would.
10928
+ */
10929
+ function resolveBackground(value, entity) {
10930
+ return typeof value === "boolean" ? value : resolveIcon(value, entity) || undefined;
10931
+ }
10898
10932
  // How many entities one attachment read asks for.
10899
10933
  const IMAGES_AT_ONCE = 100;
10900
10934
  // How long on-screen requests gather before they are read together.
@@ -11132,7 +11166,7 @@ var EntityLabelGroup;
11132
11166
  iconUrl: resolveIcon((_h = group.definition.options) === null || _h === void 0 ? void 0 : _h.iconUrl, entity),
11133
11167
  iconClass: resolveIcon((_j = group.definition.options) === null || _j === void 0 ? void 0 : _j.iconClass, entity),
11134
11168
  iconColor: resolveIcon((_k = group.definition.options) === null || _k === void 0 ? void 0 : _k.iconColor, entity),
11135
- iconBackground: (_l = group.definition.options) === null || _l === void 0 ? void 0 : _l.iconBackground,
11169
+ iconBackground: resolveBackground((_l = group.definition.options) === null || _l === void 0 ? void 0 : _l.iconBackground, entity),
11136
11170
  iconPriority: Number.isFinite(iconPriority) ? iconPriority : item.iconPriority,
11137
11171
  iconStatus: (_o = resolveIcon((_m = group.definition.options) === null || _m === void 0 ? void 0 : _m.iconStatus, entity)) !== null && _o !== void 0 ? _o : item.iconStatus
11138
11172
  };
@@ -11387,8 +11421,11 @@ var EntityLabelGroup;
11387
11421
  if (!options) {
11388
11422
  return;
11389
11423
  }
11390
- if (options.iconBackground != null && typeof options.iconBackground !== "boolean") {
11391
- throw new Error("Label iconBackground must be a boolean");
11424
+ if (options.iconBackground != null &&
11425
+ typeof options.iconBackground !== "boolean" &&
11426
+ typeof options.iconBackground !== "string" &&
11427
+ !Array.isArray(options.iconBackground)) {
11428
+ throw new Error("Label iconBackground must be a boolean, a colour or a Calculator field array");
11392
11429
  }
11393
11430
  for (const value of [options.icon, options.iconUrl, options.iconClass, options.iconColor, options.text]) {
11394
11431
  if (value != null && typeof value !== "string" && !Array.isArray(value)) {
@@ -60328,7 +60365,7 @@ var StyleUtils;
60328
60365
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60329
60366
  })(StyleUtils || (StyleUtils = {}));
60330
60367
 
60331
- const VERSION = "7.7.9";
60368
+ const VERSION = "7.8.0";
60332
60369
  /**
60333
60370
  * Updates the environment instance used by bruce-cesium to one specified.
60334
60371
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.