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.
@@ -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) {
@@ -37079,7 +37105,13 @@
37079
37105
  */
37080
37106
  async function resolveTexturedFill(params) {
37081
37107
  const { api, style, entity, tags } = params;
37082
- const textureTrace = style.texture ? BModels.Calculator.TraceGetString(style.texture, entity, tags) : { value: null, effective: null };
37108
+ let textureRows = style.texture == null ? [] : style.texture;
37109
+ textureRows.forEach((row) => {
37110
+ if (row.type == BModels.Calculator.EValueType.Color) {
37111
+ row.type = BModels.Calculator.EValueType.Input;
37112
+ }
37113
+ });
37114
+ const textureTrace = textureRows.length ? BModels.Calculator.TraceGetString(textureRows, entity, tags) : { value: null, effective: null };
37083
37115
  const raw = textureTrace.value;
37084
37116
  if (!raw || typeof raw != "string" || !api) {
37085
37117
  return { dataUri: null, effective: textureTrace.effective };
@@ -38437,7 +38469,7 @@
38437
38469
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
38438
38470
  })(exports.StyleUtils || (exports.StyleUtils = {}));
38439
38471
 
38440
- const VERSION = "6.9.3";
38472
+ const VERSION = "6.9.5";
38441
38473
  /**
38442
38474
  * Updates the environment instance used by bruce-cesium to one specified.
38443
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.