bruce-cesium 6.9.4 → 6.9.6

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, DistanceDisplayCondition, HeightReference, ColorBlendMode, HeadingPitchRoll, Math as Math$1, Transforms, ShadowMode, Cartesian3, ClassificationType, Model, ArcType, CornerType, ConstantPositionProperty, HorizontalOrigin, VerticalOrigin, JulianDate, Quaternion, Matrix4, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, IonResource, Cesium3DTileColorBlendMode, Cesium3DTileset, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, 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, Carto, Geometry, Api, Bounds, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, AccountConcept, RecordChangeFeed, BruceApi, EntityRelation, ProgramKey, EntitySource, Camera, ProjectViewTile, ProjectViewLegacyTile, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } from 'bruce-models';
2
+ import { Cartographic, Entity, DistanceDisplayCondition, Color, HeightReference, CallbackProperty, HorizontalOrigin, VerticalOrigin, ConstantProperty, Cartesian3, ClassificationType, ConstantPositionProperty, ArcType, CornerType, ShadowMode, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, Cartesian2, Math as Math$1, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, Primitive, Cesium3DTileFeature, Cesium3DTileStyle, HeadingPitchRange, SceneMode, Ion, IonResource, ColorBlendMode, Model, Cesium3DTileColorBlendMode, OrthographicFrustum, EasingFunction, EllipsoidGeodesic, EllipsoidTerrainProvider, sampleTerrainMostDetailed, defined, Cesium3DTileset, PolygonPipeline, CesiumInspector, ClockRange, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, BoundingSphere, GeometryInstance, Fullscreen, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, CzmlDataSource, Intersect } from 'cesium';
3
+ import { Cartes, Entity as Entity$1, ENVIRONMENT, Api, Calculator, ClientFile, EntityTag, EntityType, LRUCache, ObjectUtils, Style, Carto, Geometry, Bounds, Color as Color$1, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, EntityHistoricData, EntityLod, EntityRelation, BruceApi, AccountConcept, RecordChangeFeed, ProgramKey, EntitySource, Camera, ProjectViewTile, Session, ProjectViewLegacyTile, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, EntityRelationType } from 'bruce-models';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -1718,6 +1718,16 @@ 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
+ }
1728
+ function clearDefaultTextureImage(graphic) {
1729
+ delete graphic[STORE_TEXTURE_IMAGE_KEY];
1730
+ }
1721
1731
  /**
1722
1732
  * Returns a color property from a graphic.
1723
1733
  * This will turn materials properties into colors before returning them.
@@ -1809,6 +1819,9 @@ function getColor$1(viewer, key, graphic) {
1809
1819
  if (color) {
1810
1820
  storeColor(key, color, graphic);
1811
1821
  }
1822
+ if (graphic instanceof PolygonGraphics && graphic.material instanceof ImageMaterialProperty) {
1823
+ storeDefaultTextureImage(graphic, graphic.material.image);
1824
+ }
1812
1825
  }
1813
1826
  else if (key == "highlight") {
1814
1827
  color = _highlightColor;
@@ -1898,11 +1911,27 @@ function refreshColor(viewer, graphic, opacity) {
1898
1911
  }
1899
1912
  }
1900
1913
  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);
1914
+ const storedTextureImage = key == "default" ? getDefaultTextureImage(graphic) : undefined;
1915
+ if (storedTextureImage) {
1916
+ const tintAlpha = opacity != null ? opacity : 1;
1917
+ const currentMaterial = graphic.material;
1918
+ const currentIsSameImage = currentMaterial instanceof ImageMaterialProperty;
1919
+ const currentAlpha = currentIsSameImage ? getCesiumColorValue(viewer, currentMaterial).alpha : null;
1920
+ if (!currentIsSameImage || currentAlpha == null || Math.abs(currentAlpha - tintAlpha) > 0.001) {
1921
+ graphic.material = new ImageMaterialProperty({
1922
+ image: storedTextureImage,
1923
+ color: Color.WHITE.withAlpha(tintAlpha),
1924
+ transparent: true
1925
+ });
1926
+ }
1927
+ }
1928
+ else {
1929
+ // See if it's changed before applying.
1930
+ // Applying a new material to a polygon causes a flicker we want to avoid when possible.
1931
+ const currentColor = calculateCurColor(viewer, graphic);
1932
+ if (currentColor == null || !currentColor.equals(color)) {
1933
+ graphic.material = new ColorMaterialProperty(color);
1934
+ }
1906
1935
  }
1907
1936
  }
1908
1937
  else if (graphic instanceof PolylineGraphics) {
@@ -2236,6 +2265,39 @@ var CesiumEntityStyler;
2236
2265
  }
2237
2266
  }
2238
2267
  CesiumEntityStyler.SetDefaultColor = SetDefaultColor;
2268
+ /*
2269
+ * Updates (or clears) the baked default texture image for a graphic's polygon parts.
2270
+ */
2271
+ function SetDefaultTextureImage(params) {
2272
+ const { viewer, entity, image, requestRender } = params;
2273
+ if (!entity) {
2274
+ return;
2275
+ }
2276
+ const parts = EntityUtils.GatherEntity({
2277
+ entity: entity,
2278
+ selectable: true
2279
+ });
2280
+ for (let i = 0; i < parts.length; i++) {
2281
+ const part = parts[i];
2282
+ if (!isAlive(viewer, part)) {
2283
+ continue;
2284
+ }
2285
+ // Texture fill only applies to polygons.
2286
+ if (part instanceof Entity && part.polygon) {
2287
+ if (image == null) {
2288
+ clearDefaultTextureImage(part.polygon);
2289
+ }
2290
+ else {
2291
+ storeDefaultTextureImage(part.polygon, image);
2292
+ }
2293
+ refreshColor(viewer, part.polygon, getAppliedOpacity(part.polygon));
2294
+ }
2295
+ }
2296
+ if (requestRender != false) {
2297
+ viewer.scene.requestRender();
2298
+ }
2299
+ }
2300
+ CesiumEntityStyler.SetDefaultTextureImage = SetDefaultTextureImage;
2239
2301
  /**
2240
2302
  * Updates the opacity of the graphic.
2241
2303
  * This will multiply against the current colour's opacity before applying.
@@ -36835,9 +36897,23 @@ var EntityRenderEnginePolygon;
36835
36897
  cEntity.polygon.classificationType = new ConstantProperty(classification);
36836
36898
  // TODO: animate the texture!
36837
36899
  if (textureDataUri) {
36900
+ // Rebaking texture to ensure we don't revert to the wrong one later.
36838
36901
  cEntity.polygon.material = fillMaterial;
36902
+ CesiumEntityStyler.SetDefaultTextureImage({
36903
+ entity: cEntity,
36904
+ image: textureDataUri,
36905
+ viewer: params.viewer,
36906
+ requestRender: false
36907
+ });
36839
36908
  }
36840
36909
  else {
36910
+ // Clear any baked texture from a previous textured style so reverting to default uses the colour fill.
36911
+ CesiumEntityStyler.SetDefaultTextureImage({
36912
+ entity: cEntity,
36913
+ image: null,
36914
+ viewer: params.viewer,
36915
+ requestRender: false
36916
+ });
36841
36917
  // We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
36842
36918
  // WARNING: polygon does not support animation (yet?).
36843
36919
  CesiumEntityStyler.SetDefaultColor({
@@ -38565,7 +38641,7 @@ var StyleUtils;
38565
38641
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
38566
38642
  })(StyleUtils || (StyleUtils = {}));
38567
38643
 
38568
- const VERSION = "6.9.4";
38644
+ const VERSION = "6.9.6";
38569
38645
  /**
38570
38646
  * Updates the environment instance used by bruce-cesium to one specified.
38571
38647
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.