bruce-cesium 2.4.3 → 2.4.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.
- package/dist/bruce-cesium.es5.js +86 -8
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +84 -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.js +83 -5
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -1738,7 +1738,14 @@
|
|
|
1738
1738
|
return zoomItem.MinZoom + "-" + zoomItem.MaxZoom + "-" + shouldApplyFlatFix(terrain);
|
|
1739
1739
|
}
|
|
1740
1740
|
var _fileValidationCache = {};
|
|
1741
|
-
|
|
1741
|
+
/**
|
|
1742
|
+
* @param min
|
|
1743
|
+
* @param max
|
|
1744
|
+
* @param meterSize size of "thing" in meters, eg polyline is 0.5 meters width. If size is provided we can potentially cull it earlier.
|
|
1745
|
+
* @param isPolygon
|
|
1746
|
+
* @returns
|
|
1747
|
+
*/
|
|
1748
|
+
function getDisplayCondition(min, max, meterSize, isPolygon) {
|
|
1742
1749
|
// Max is required.
|
|
1743
1750
|
if (isNaN(+max)) {
|
|
1744
1751
|
return undefined;
|
|
@@ -1753,8 +1760,78 @@
|
|
|
1753
1760
|
if (min > 0) {
|
|
1754
1761
|
min = (+min) * 0.8;
|
|
1755
1762
|
}
|
|
1763
|
+
meterSize = +meterSize;
|
|
1764
|
+
if (!isNaN(meterSize) && meterSize > 0) {
|
|
1765
|
+
// A 1m thing at 2000m distance is barely visible, so we can cull it.
|
|
1766
|
+
// So we'll multiply this magic distance by the size of the thing and determine when it'll be too small to see.
|
|
1767
|
+
var METER_DISTANCE_PER_METER = isPolygon ? 100 : 2000;
|
|
1768
|
+
var newMax = meterSize * METER_DISTANCE_PER_METER;
|
|
1769
|
+
// Enforcing a minimum max distance in case something goes wrong we want stuff to always be visible when close.
|
|
1770
|
+
var MIN_MAX = 300;
|
|
1771
|
+
newMax = Math.max(newMax, MIN_MAX);
|
|
1772
|
+
//console.log(`meterSize ${isPolygon ? "polygon" : "thing"} of ${meterSize}m was provided so max was changed from ${max}m to ${Math.min(newMax, max)}m`)
|
|
1773
|
+
max = Math.min(newMax, max);
|
|
1774
|
+
if (max < min) {
|
|
1775
|
+
return undefined;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1756
1778
|
return new Cesium.DistanceDisplayCondition(min, max);
|
|
1757
1779
|
}
|
|
1780
|
+
/**
|
|
1781
|
+
* Returns an entity's "size" used for distance display condition calcs.
|
|
1782
|
+
* This will return the distance in meters between the two boundary corners.
|
|
1783
|
+
* @param entity
|
|
1784
|
+
*/
|
|
1785
|
+
function getSizeOfPolygonEntity(entity) {
|
|
1786
|
+
var _a, _b;
|
|
1787
|
+
if (!entity) {
|
|
1788
|
+
return null;
|
|
1789
|
+
}
|
|
1790
|
+
var hasResetBounds = false;
|
|
1791
|
+
var resetBounds = function () {
|
|
1792
|
+
hasResetBounds = true;
|
|
1793
|
+
entity.boundaries = bruceModels.Bounds.FromEntity(entity);
|
|
1794
|
+
return entity.boundaries;
|
|
1795
|
+
};
|
|
1796
|
+
var checkHasArea = function () {
|
|
1797
|
+
var _a, _b, _c, _d;
|
|
1798
|
+
return ((_a = entity.boundaries) === null || _a === void 0 ? void 0 : _a.minLongitude) != ((_b = entity.boundaries) === null || _b === void 0 ? void 0 : _b.maxLongitude) || ((_c = entity.boundaries) === null || _c === void 0 ? void 0 : _c.minLatitude) != ((_d = entity.boundaries) === null || _d === void 0 ? void 0 : _d.maxLatitude);
|
|
1799
|
+
};
|
|
1800
|
+
// Create bounds if missing entirely.
|
|
1801
|
+
if (!entity.boundaries) {
|
|
1802
|
+
resetBounds();
|
|
1803
|
+
}
|
|
1804
|
+
if (!((_a = entity.boundaries) === null || _a === void 0 ? void 0 : _a.minLatitude)) {
|
|
1805
|
+
return null;
|
|
1806
|
+
}
|
|
1807
|
+
// Check for bounds that are a single point.
|
|
1808
|
+
if (!checkHasArea()) {
|
|
1809
|
+
// Already tried to reconstruct, so we'll just give up.
|
|
1810
|
+
if (hasResetBounds) {
|
|
1811
|
+
return null;
|
|
1812
|
+
}
|
|
1813
|
+
resetBounds();
|
|
1814
|
+
// Check after reconstruction. If still bad then give up.
|
|
1815
|
+
if (!((_b = entity.boundaries) === null || _b === void 0 ? void 0 : _b.minLatitude) || !checkHasArea()) {
|
|
1816
|
+
return null;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
var bounds = entity === null || entity === void 0 ? void 0 : entity.boundaries;
|
|
1820
|
+
var minLat = +(bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude);
|
|
1821
|
+
var maxLat = +(bounds === null || bounds === void 0 ? void 0 : bounds.maxLatitude);
|
|
1822
|
+
var minLon = +(bounds === null || bounds === void 0 ? void 0 : bounds.minLongitude);
|
|
1823
|
+
var maxLon = +(bounds === null || bounds === void 0 ? void 0 : bounds.maxLongitude);
|
|
1824
|
+
if (isNaN(minLat) || isNaN(maxLat) || isNaN(minLon) || isNaN(maxLon)) {
|
|
1825
|
+
return null;
|
|
1826
|
+
}
|
|
1827
|
+
var p1 = Cesium.Cartesian3.fromDegrees(minLon, minLat);
|
|
1828
|
+
var p2 = Cesium.Cartesian3.fromDegrees(maxLon, maxLat);
|
|
1829
|
+
var length = Cesium.Cartesian3.distance(p1, p2);
|
|
1830
|
+
if (isNaN(length) || length <= 0) {
|
|
1831
|
+
return null;
|
|
1832
|
+
}
|
|
1833
|
+
return length;
|
|
1834
|
+
}
|
|
1758
1835
|
(function (EntityRenderEngine) {
|
|
1759
1836
|
function Render(params) {
|
|
1760
1837
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -2358,7 +2435,7 @@
|
|
|
2358
2435
|
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
2359
2436
|
heightReference: heightRef,
|
|
2360
2437
|
zIndex: getZIndex(style, entity, params.tags),
|
|
2361
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
|
|
2438
|
+
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
2362
2439
|
cornerType: Cesium.CornerType.MITERED,
|
|
2363
2440
|
shadows: Cesium.ShadowMode.ENABLED,
|
|
2364
2441
|
fill: true
|
|
@@ -2476,6 +2553,7 @@
|
|
|
2476
2553
|
return points.map(function (x) { return Cesium.Cartesian3.fromDegrees(EnsureNumber(x.longitude), EnsureNumber(x.latitude), EnsureNumber(flattenPoints ? 0 : x.altitude)); });
|
|
2477
2554
|
});
|
|
2478
2555
|
var zIndex = getZIndex(style, entity, params.tags);
|
|
2556
|
+
var size = getSizeOfPolygonEntity(entity);
|
|
2479
2557
|
var cEntity = new Cesium.Entity({
|
|
2480
2558
|
polygon: {
|
|
2481
2559
|
hierarchy: new Cesium.PolygonHierarchy(posses, holePosses.map(function (x) { return new Cesium.PolygonHierarchy(x); })),
|
|
@@ -2487,7 +2565,7 @@
|
|
|
2487
2565
|
classificationType: Cesium.ClassificationType.BOTH,
|
|
2488
2566
|
perPositionHeight: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true,
|
|
2489
2567
|
zIndex: zIndex,
|
|
2490
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
2568
|
+
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, size, true)
|
|
2491
2569
|
},
|
|
2492
2570
|
position: exports.EntityUtils.GetPos({
|
|
2493
2571
|
viewer: params.viewer,
|
|
@@ -2524,7 +2602,7 @@
|
|
|
2524
2602
|
zIndex: zIndex + 1,
|
|
2525
2603
|
cornerType: Cesium.CornerType.MITERED,
|
|
2526
2604
|
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
2527
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
|
|
2605
|
+
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
2528
2606
|
shadows: Cesium.ShadowMode.ENABLED
|
|
2529
2607
|
},
|
|
2530
2608
|
show: false
|
|
@@ -2555,7 +2633,7 @@
|
|
|
2555
2633
|
zIndex: zIndex + 1,
|
|
2556
2634
|
cornerType: Cesium.CornerType.MITERED,
|
|
2557
2635
|
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
2558
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
|
|
2636
|
+
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
2559
2637
|
shadows: Cesium.ShadowMode.ENABLED,
|
|
2560
2638
|
},
|
|
2561
2639
|
show: false
|
|
@@ -14395,7 +14473,7 @@
|
|
|
14395
14473
|
ViewerUtils.CreateWidgets = CreateWidgets;
|
|
14396
14474
|
})(exports.ViewerUtils || (exports.ViewerUtils = {}));
|
|
14397
14475
|
|
|
14398
|
-
var VERSION$1 = "2.4.
|
|
14476
|
+
var VERSION$1 = "2.4.5";
|
|
14399
14477
|
|
|
14400
14478
|
exports.VERSION = VERSION$1;
|
|
14401
14479
|
exports.CesiumViewMonitor = CesiumViewMonitor;
|