bruce-cesium 6.9.4 → 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.
@@ -1717,6 +1717,13 @@
1717
1717
  return STORE_KEY_STATE_PREFIX + key;
1718
1718
  }
1719
1719
  const LAST_APPLIED_OPACITY_KEY = "_lastAppliedOpacityKey";
1720
+ const STORE_TEXTURE_IMAGE_KEY = "_storeTextureImage_default";
1721
+ function storeDefaultTextureImage(graphic, image) {
1722
+ graphic[STORE_TEXTURE_IMAGE_KEY] = image;
1723
+ }
1724
+ function getDefaultTextureImage(graphic) {
1725
+ return graphic[STORE_TEXTURE_IMAGE_KEY];
1726
+ }
1720
1727
  /**
1721
1728
  * Returns a color property from a graphic.
1722
1729
  * This will turn materials properties into colors before returning them.
@@ -1808,6 +1815,9 @@
1808
1815
  if (color) {
1809
1816
  storeColor(key, color, graphic);
1810
1817
  }
1818
+ if (graphic instanceof Cesium.PolygonGraphics && graphic.material instanceof Cesium.ImageMaterialProperty) {
1819
+ storeDefaultTextureImage(graphic, graphic.material.image);
1820
+ }
1811
1821
  }
1812
1822
  else if (key == "highlight") {
1813
1823
  color = _highlightColor;
@@ -1897,11 +1907,27 @@
1897
1907
  }
1898
1908
  }
1899
1909
  else if (graphic instanceof Cesium.PolygonGraphics) {
1900
- // See if it's changed before applying.
1901
- // Applying a new material to a polygon causes a flicker we want to avoid when possible.
1902
- const currentColor = calculateCurColor(viewer, graphic);
1903
- if (currentColor == null || !currentColor.equals(color)) {
1904
- graphic.material = new Cesium.ColorMaterialProperty(color);
1910
+ const storedTextureImage = key == "default" ? getDefaultTextureImage(graphic) : undefined;
1911
+ if (storedTextureImage) {
1912
+ const tintAlpha = opacity != null ? opacity : 1;
1913
+ const currentMaterial = graphic.material;
1914
+ const currentIsSameImage = currentMaterial instanceof Cesium.ImageMaterialProperty;
1915
+ const currentAlpha = currentIsSameImage ? getCesiumColorValue(viewer, currentMaterial).alpha : null;
1916
+ if (!currentIsSameImage || currentAlpha == null || Math.abs(currentAlpha - tintAlpha) > 0.001) {
1917
+ graphic.material = new Cesium.ImageMaterialProperty({
1918
+ image: storedTextureImage,
1919
+ color: Cesium.Color.WHITE.withAlpha(tintAlpha),
1920
+ transparent: true
1921
+ });
1922
+ }
1923
+ }
1924
+ else {
1925
+ // See if it's changed before applying.
1926
+ // Applying a new material to a polygon causes a flicker we want to avoid when possible.
1927
+ const currentColor = calculateCurColor(viewer, graphic);
1928
+ if (currentColor == null || !currentColor.equals(color)) {
1929
+ graphic.material = new Cesium.ColorMaterialProperty(color);
1930
+ }
1905
1931
  }
1906
1932
  }
1907
1933
  else if (graphic instanceof Cesium.PolylineGraphics) {
@@ -38443,7 +38469,7 @@
38443
38469
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
38444
38470
  })(exports.StyleUtils || (exports.StyleUtils = {}));
38445
38471
 
38446
- const VERSION = "6.9.4";
38472
+ const VERSION = "6.9.5";
38447
38473
  /**
38448
38474
  * Updates the environment instance used by bruce-cesium to one specified.
38449
38475
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.