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.
- package/dist/bruce-cesium.es5.js +84 -8
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +82 -6
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/entity-render-engine-polygon.js +14 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
- package/dist/lib/utils/cesium-entity-styler.js +67 -5
- package/dist/lib/utils/cesium-entity-styler.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/utils/cesium-entity-styler.d.ts +6 -0
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -1717,6 +1717,16 @@
|
|
|
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
|
+
}
|
|
1727
|
+
function clearDefaultTextureImage(graphic) {
|
|
1728
|
+
delete graphic[STORE_TEXTURE_IMAGE_KEY];
|
|
1729
|
+
}
|
|
1720
1730
|
/**
|
|
1721
1731
|
* Returns a color property from a graphic.
|
|
1722
1732
|
* This will turn materials properties into colors before returning them.
|
|
@@ -1808,6 +1818,9 @@
|
|
|
1808
1818
|
if (color) {
|
|
1809
1819
|
storeColor(key, color, graphic);
|
|
1810
1820
|
}
|
|
1821
|
+
if (graphic instanceof Cesium.PolygonGraphics && graphic.material instanceof Cesium.ImageMaterialProperty) {
|
|
1822
|
+
storeDefaultTextureImage(graphic, graphic.material.image);
|
|
1823
|
+
}
|
|
1811
1824
|
}
|
|
1812
1825
|
else if (key == "highlight") {
|
|
1813
1826
|
color = _highlightColor;
|
|
@@ -1897,11 +1910,27 @@
|
|
|
1897
1910
|
}
|
|
1898
1911
|
}
|
|
1899
1912
|
else if (graphic instanceof Cesium.PolygonGraphics) {
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1913
|
+
const storedTextureImage = key == "default" ? getDefaultTextureImage(graphic) : undefined;
|
|
1914
|
+
if (storedTextureImage) {
|
|
1915
|
+
const tintAlpha = opacity != null ? opacity : 1;
|
|
1916
|
+
const currentMaterial = graphic.material;
|
|
1917
|
+
const currentIsSameImage = currentMaterial instanceof Cesium.ImageMaterialProperty;
|
|
1918
|
+
const currentAlpha = currentIsSameImage ? getCesiumColorValue(viewer, currentMaterial).alpha : null;
|
|
1919
|
+
if (!currentIsSameImage || currentAlpha == null || Math.abs(currentAlpha - tintAlpha) > 0.001) {
|
|
1920
|
+
graphic.material = new Cesium.ImageMaterialProperty({
|
|
1921
|
+
image: storedTextureImage,
|
|
1922
|
+
color: Cesium.Color.WHITE.withAlpha(tintAlpha),
|
|
1923
|
+
transparent: true
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
else {
|
|
1928
|
+
// See if it's changed before applying.
|
|
1929
|
+
// Applying a new material to a polygon causes a flicker we want to avoid when possible.
|
|
1930
|
+
const currentColor = calculateCurColor(viewer, graphic);
|
|
1931
|
+
if (currentColor == null || !currentColor.equals(color)) {
|
|
1932
|
+
graphic.material = new Cesium.ColorMaterialProperty(color);
|
|
1933
|
+
}
|
|
1905
1934
|
}
|
|
1906
1935
|
}
|
|
1907
1936
|
else if (graphic instanceof Cesium.PolylineGraphics) {
|
|
@@ -2230,6 +2259,39 @@
|
|
|
2230
2259
|
}
|
|
2231
2260
|
}
|
|
2232
2261
|
CesiumEntityStyler.SetDefaultColor = SetDefaultColor;
|
|
2262
|
+
/*
|
|
2263
|
+
* Updates (or clears) the baked default texture image for a graphic's polygon parts.
|
|
2264
|
+
*/
|
|
2265
|
+
function SetDefaultTextureImage(params) {
|
|
2266
|
+
const { viewer, entity, image, requestRender } = params;
|
|
2267
|
+
if (!entity) {
|
|
2268
|
+
return;
|
|
2269
|
+
}
|
|
2270
|
+
const parts = exports.EntityUtils.GatherEntity({
|
|
2271
|
+
entity: entity,
|
|
2272
|
+
selectable: true
|
|
2273
|
+
});
|
|
2274
|
+
for (let i = 0; i < parts.length; i++) {
|
|
2275
|
+
const part = parts[i];
|
|
2276
|
+
if (!isAlive(viewer, part)) {
|
|
2277
|
+
continue;
|
|
2278
|
+
}
|
|
2279
|
+
// Texture fill only applies to polygons.
|
|
2280
|
+
if (part instanceof Cesium.Entity && part.polygon) {
|
|
2281
|
+
if (image == null) {
|
|
2282
|
+
clearDefaultTextureImage(part.polygon);
|
|
2283
|
+
}
|
|
2284
|
+
else {
|
|
2285
|
+
storeDefaultTextureImage(part.polygon, image);
|
|
2286
|
+
}
|
|
2287
|
+
refreshColor(viewer, part.polygon, getAppliedOpacity(part.polygon));
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
if (requestRender != false) {
|
|
2291
|
+
viewer.scene.requestRender();
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
CesiumEntityStyler.SetDefaultTextureImage = SetDefaultTextureImage;
|
|
2233
2295
|
/**
|
|
2234
2296
|
* Updates the opacity of the graphic.
|
|
2235
2297
|
* This will multiply against the current colour's opacity before applying.
|
|
@@ -36728,9 +36790,23 @@
|
|
|
36728
36790
|
cEntity.polygon.classificationType = new Cesium.ConstantProperty(classification);
|
|
36729
36791
|
// TODO: animate the texture!
|
|
36730
36792
|
if (textureDataUri) {
|
|
36793
|
+
// Rebaking texture to ensure we don't revert to the wrong one later.
|
|
36731
36794
|
cEntity.polygon.material = fillMaterial;
|
|
36795
|
+
exports.CesiumEntityStyler.SetDefaultTextureImage({
|
|
36796
|
+
entity: cEntity,
|
|
36797
|
+
image: textureDataUri,
|
|
36798
|
+
viewer: params.viewer,
|
|
36799
|
+
requestRender: false
|
|
36800
|
+
});
|
|
36732
36801
|
}
|
|
36733
36802
|
else {
|
|
36803
|
+
// Clear any baked texture from a previous textured style so reverting to default uses the colour fill.
|
|
36804
|
+
exports.CesiumEntityStyler.SetDefaultTextureImage({
|
|
36805
|
+
entity: cEntity,
|
|
36806
|
+
image: null,
|
|
36807
|
+
viewer: params.viewer,
|
|
36808
|
+
requestRender: false
|
|
36809
|
+
});
|
|
36734
36810
|
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
36735
36811
|
// WARNING: polygon does not support animation (yet?).
|
|
36736
36812
|
exports.CesiumEntityStyler.SetDefaultColor({
|
|
@@ -38443,7 +38519,7 @@
|
|
|
38443
38519
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
38444
38520
|
})(exports.StyleUtils || (exports.StyleUtils = {}));
|
|
38445
38521
|
|
|
38446
|
-
const VERSION = "6.9.
|
|
38522
|
+
const VERSION = "6.9.6";
|
|
38447
38523
|
/**
|
|
38448
38524
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
38449
38525
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|