bruce-cesium 6.9.3 → 6.9.5

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, Entity, DistanceDisplayCondition, ColorMaterialProperty, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, HeightReference, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, ShadowMode, Cartesian3, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, JulianDate, Quaternion, Matrix4, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileset, Cesium3DTileColorBlendMode, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, PolygonPipeline, CesiumInspector, ClockRange, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
3
- import { Cartes, Entity as Entity$1, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Api, Carto, Geometry, Bounds, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, BruceApi, EntityRelation, AccountConcept, RecordChangeFeed, ProgramKey, EntitySource, ProjectViewLegacyTile, ProjectViewTile, Camera, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } from 'bruce-models';
2
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, BoundingSphere, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, Intersect, CzmlDataSource } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Calculator, ClientFile, EntityLod, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Api, Bounds, Color as Color$1, Geometry, Carto, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, AccountConcept, RecordChangeFeed, BruceApi, EntityRelation, ProgramKey, EntitySource, ProjectViewLegacyTile, ProjectViewTile, Camera, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session, EntityRelationType } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -1718,6 +1718,13 @@ function getStoreStateKey(key) {
1718
1718
  return STORE_KEY_STATE_PREFIX + key;
1719
1719
  }
1720
1720
  const LAST_APPLIED_OPACITY_KEY = "_lastAppliedOpacityKey";
1721
+ const STORE_TEXTURE_IMAGE_KEY = "_storeTextureImage_default";
1722
+ function storeDefaultTextureImage(graphic, image) {
1723
+ graphic[STORE_TEXTURE_IMAGE_KEY] = image;
1724
+ }
1725
+ function getDefaultTextureImage(graphic) {
1726
+ return graphic[STORE_TEXTURE_IMAGE_KEY];
1727
+ }
1721
1728
  /**
1722
1729
  * Returns a color property from a graphic.
1723
1730
  * This will turn materials properties into colors before returning them.
@@ -1809,6 +1816,9 @@ function getColor$1(viewer, key, graphic) {
1809
1816
  if (color) {
1810
1817
  storeColor(key, color, graphic);
1811
1818
  }
1819
+ if (graphic instanceof PolygonGraphics && graphic.material instanceof ImageMaterialProperty) {
1820
+ storeDefaultTextureImage(graphic, graphic.material.image);
1821
+ }
1812
1822
  }
1813
1823
  else if (key == "highlight") {
1814
1824
  color = _highlightColor;
@@ -1898,11 +1908,27 @@ function refreshColor(viewer, graphic, opacity) {
1898
1908
  }
1899
1909
  }
1900
1910
  else if (graphic instanceof PolygonGraphics) {
1901
- // See if it's changed before applying.
1902
- // Applying a new material to a polygon causes a flicker we want to avoid when possible.
1903
- const currentColor = calculateCurColor(viewer, graphic);
1904
- if (currentColor == null || !currentColor.equals(color)) {
1905
- graphic.material = new ColorMaterialProperty(color);
1911
+ const storedTextureImage = key == "default" ? getDefaultTextureImage(graphic) : undefined;
1912
+ if (storedTextureImage) {
1913
+ const tintAlpha = opacity != null ? opacity : 1;
1914
+ const currentMaterial = graphic.material;
1915
+ const currentIsSameImage = currentMaterial instanceof ImageMaterialProperty;
1916
+ const currentAlpha = currentIsSameImage ? getCesiumColorValue(viewer, currentMaterial).alpha : null;
1917
+ if (!currentIsSameImage || currentAlpha == null || Math.abs(currentAlpha - tintAlpha) > 0.001) {
1918
+ graphic.material = new ImageMaterialProperty({
1919
+ image: storedTextureImage,
1920
+ color: Color.WHITE.withAlpha(tintAlpha),
1921
+ transparent: true
1922
+ });
1923
+ }
1924
+ }
1925
+ else {
1926
+ // See if it's changed before applying.
1927
+ // Applying a new material to a polygon causes a flicker we want to avoid when possible.
1928
+ const currentColor = calculateCurColor(viewer, graphic);
1929
+ if (currentColor == null || !currentColor.equals(color)) {
1930
+ graphic.material = new ColorMaterialProperty(color);
1931
+ }
1906
1932
  }
1907
1933
  }
1908
1934
  else if (graphic instanceof PolylineGraphics) {
@@ -37186,7 +37212,13 @@ function looksLikeTextureUrl(value) {
37186
37212
  */
37187
37213
  async function resolveTexturedFill(params) {
37188
37214
  const { api, style, entity, tags } = params;
37189
- const textureTrace = style.texture ? Calculator.TraceGetString(style.texture, entity, tags) : { value: null, effective: null };
37215
+ let textureRows = style.texture == null ? [] : style.texture;
37216
+ textureRows.forEach((row) => {
37217
+ if (row.type == Calculator.EValueType.Color) {
37218
+ row.type = Calculator.EValueType.Input;
37219
+ }
37220
+ });
37221
+ const textureTrace = textureRows.length ? Calculator.TraceGetString(textureRows, entity, tags) : { value: null, effective: null };
37190
37222
  const raw = textureTrace.value;
37191
37223
  if (!raw || typeof raw != "string" || !api) {
37192
37224
  return { dataUri: null, effective: textureTrace.effective };
@@ -38559,7 +38591,7 @@ var StyleUtils;
38559
38591
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
38560
38592
  })(StyleUtils || (StyleUtils = {}));
38561
38593
 
38562
- const VERSION = "6.9.3";
38594
+ const VERSION = "6.9.5";
38563
38595
  /**
38564
38596
  * Updates the environment instance used by bruce-cesium to one specified.
38565
38597
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.