bruce-cesium 2.6.1 → 2.6.3

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.
@@ -1628,6 +1628,43 @@
1628
1628
  }
1629
1629
  return data;
1630
1630
  }
1631
+ function getCylinderStyleExtrusion(style, entity, tags, heightRef) {
1632
+ var _a;
1633
+ if (!style) {
1634
+ return null;
1635
+ }
1636
+ try {
1637
+ var extrusion = +bruceModels.Calculator.GetNumber(style, entity, tags);
1638
+ if (!extrusion && extrusion != 0) {
1639
+ return null;
1640
+ }
1641
+ /*
1642
+ Cesium extrudes in strange way.
1643
+ If you want something that is 50 meters above sea, and 5 meters tall,
1644
+ You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
1645
+ */
1646
+ var height = EnsureNumber((_a = entity.location) === null || _a === void 0 ? void 0 : _a.altitude, 0);
1647
+ return heightRef != Cesium.HeightReference.CLAMP_TO_GROUND ? extrusion + height : extrusion;
1648
+ }
1649
+ catch (e) {
1650
+ console.error(e);
1651
+ }
1652
+ return 0;
1653
+ }
1654
+ function getCylinderExtrusion(entity, tags, heightRef, style) {
1655
+ var data = {
1656
+ value: undefined,
1657
+ exHeightRef: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? Cesium.HeightReference.RELATIVE_TO_GROUND : heightRef
1658
+ };
1659
+ var extrusion = getCylinderStyleExtrusion(style, entity, tags, heightRef);
1660
+ if (extrusion) {
1661
+ data.value = extrusion;
1662
+ }
1663
+ if (data.value != undefined) {
1664
+ data.value = EnsureNumber(data.value);
1665
+ }
1666
+ return data;
1667
+ }
1631
1668
  function getHeightRef(style, defaultStyle) {
1632
1669
  var _a;
1633
1670
  var heightRef = defaultStyle == null ? Cesium.HeightReference.CLAMP_TO_GROUND : defaultStyle;
@@ -2111,7 +2148,7 @@
2111
2148
  (function (Point) {
2112
2149
  function Render(params) {
2113
2150
  return __awaiter(this, void 0, void 0, function () {
2114
- var entity, style, type, cEntity, siblings, iconUrlRows, icon, iconUrl, res, e_4, iconScale, disableDepthTest, heightRef, radius, bFill, cFill, outline, bOutline, cOutline, outlineWidth, outlineHeight, fillHeight, pos, bColor, cColor, size, heightRef;
2151
+ var entity, style, type, cEntity, siblings, iconUrlRows, icon, iconUrl, res, e_4, iconScale, disableDepthTest, heightRef, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, heightRef, pos3d, extrusion, outlineExtrusion, bColor, cColor, size, heightRef;
2115
2152
  return __generator(this, function (_a) {
2116
2153
  switch (_a.label) {
2117
2154
  case 0:
@@ -2208,30 +2245,60 @@
2208
2245
  bFill = style.CylinderFillColor ? bruceModels.Calculator.GetColor(style.CylinderFillColor, entity, params.tags) : null;
2209
2246
  cFill = bFill ? colorToCColor(bFill) : Cesium.Color.RED;
2210
2247
  outline = Boolean(style.CylinderBorderEnabled);
2211
- bOutline = style.CylinderBorderColor ? bruceModels.Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
2212
- cOutline = bOutline ? colorToCColor(bOutline) : Cesium.Color.BLACK;
2213
- outlineWidth = EnsureNumber(bruceModels.Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
2214
- outlineHeight = EnsureNumber(bruceModels.Calculator.GetNumber(style.CylinderBorderExtrusion, entity, params.tags), 0);
2215
- fillHeight = EnsureNumber(bruceModels.Calculator.GetNumber(style.CylinderFillExtrusion, entity, params.tags));
2216
- pos = exports.EntityUtils.GetPos({
2248
+ cOutline = null;
2249
+ outlineWidth = 1;
2250
+ if (outline) {
2251
+ bOutline = style.CylinderBorderColor ? bruceModels.Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
2252
+ cOutline = bOutline ? colorToCColor(bOutline) : Cesium.Color.BLACK;
2253
+ outlineWidth = EnsureNumber(bruceModels.Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
2254
+ }
2255
+ heightRef = getHeightRef(style);
2256
+ pos3d = exports.EntityUtils.GetPos({
2217
2257
  viewer: params.viewer,
2218
2258
  entity: entity,
2219
- recordHeightRef: Cesium.HeightReference.CLAMP_TO_GROUND,
2220
- returnHeightRef: Cesium.HeightReference.RELATIVE_TO_GROUND
2259
+ recordHeightRef: heightRef,
2260
+ returnHeightRef: heightRef
2221
2261
  });
2262
+ extrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderFillExtrusion);
2222
2263
  cEntity = new Cesium.Entity({
2223
- position: pos === null || pos === void 0 ? void 0 : pos.clone(),
2224
- cylinder: {
2225
- length: fillHeight,
2226
- topRadius: radius,
2227
- bottomRadius: radius,
2264
+ ellipse: {
2265
+ semiMajorAxis: radius,
2266
+ semiMinorAxis: radius,
2228
2267
  material: cFill,
2229
- outline: outline,
2230
- outlineColor: cOutline,
2231
- outlineWidth: outlineWidth
2232
- }
2268
+ outlineWidth: null,
2269
+ extrudedHeight: extrusion.value,
2270
+ heightReference: heightRef,
2271
+ extrudedHeightReference: extrusion.exHeightRef,
2272
+ height: Cesium.Cartographic.fromCartesian(pos3d).height,
2273
+ zIndex: 1,
2274
+ distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2275
+ },
2276
+ position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone(),
2277
+ show: true
2233
2278
  });
2234
- // Here you can add additional logic if you need more customization for the cylinder
2279
+ if (outline && outlineWidth > 0) {
2280
+ outlineExtrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderBorderExtrusion);
2281
+ // If this doesn't have its own extrusion, we must make it match the sibling.
2282
+ // This way they render in a uniform way.
2283
+ if (!outlineExtrusion.value && extrusion.value) {
2284
+ outlineExtrusion.exHeightRef = extrusion.exHeightRef;
2285
+ }
2286
+ siblings.push(new Cesium.Entity({
2287
+ ellipse: {
2288
+ semiMajorAxis: radius + outlineWidth,
2289
+ semiMinorAxis: radius + outlineWidth,
2290
+ material: cOutline,
2291
+ outlineWidth: undefined,
2292
+ extrudedHeight: outlineExtrusion.value,
2293
+ heightReference: heightRef,
2294
+ extrudedHeightReference: outlineExtrusion.exHeightRef,
2295
+ height: Cesium.Cartographic.fromCartesian(pos3d).height,
2296
+ zIndex: 2,
2297
+ distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2298
+ },
2299
+ position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone()
2300
+ }));
2301
+ }
2235
2302
  }
2236
2303
  if (!cEntity) {
2237
2304
  bColor = style.color ? bruceModels.Calculator.GetColor(style.color, entity, params.tags) : null;
@@ -14934,7 +15001,7 @@
14934
15001
  ViewerUtils.CreateWidgets = CreateWidgets;
14935
15002
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
14936
15003
 
14937
- var VERSION$1 = "2.5.9";
15004
+ var VERSION$1 = "2.6.3";
14938
15005
 
14939
15006
  exports.VERSION = VERSION$1;
14940
15007
  exports.CesiumViewMonitor = CesiumViewMonitor;