bruce-cesium 2.6.2 → 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;
@@ -1860,7 +1897,6 @@
1860
1897
  return __generator(this, function (_j) {
1861
1898
  switch (_j.label) {
1862
1899
  case 0:
1863
- console.log("Rendering entities", params);
1864
1900
  groupRenderParams = {
1865
1901
  apiGetter: params.apiGetter,
1866
1902
  viewer: params.viewer,
@@ -2112,7 +2148,7 @@
2112
2148
  (function (Point) {
2113
2149
  function Render(params) {
2114
2150
  return __awaiter(this, void 0, void 0, function () {
2115
- 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, cartographicPosition, 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;
2116
2152
  return __generator(this, function (_a) {
2117
2153
  switch (_a.label) {
2118
2154
  case 0:
@@ -2209,35 +2245,60 @@
2209
2245
  bFill = style.CylinderFillColor ? bruceModels.Calculator.GetColor(style.CylinderFillColor, entity, params.tags) : null;
2210
2246
  cFill = bFill ? colorToCColor(bFill) : Cesium.Color.RED;
2211
2247
  outline = Boolean(style.CylinderBorderEnabled);
2212
- bOutline = style.CylinderBorderColor ? bruceModels.Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
2213
- cOutline = bOutline ? colorToCColor(bOutline) : Cesium.Color.BLACK;
2214
- outlineWidth = EnsureNumber(bruceModels.Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
2215
- outlineHeight = EnsureNumber(bruceModels.Calculator.GetNumber(style.CylinderBorderExtrusion, entity, params.tags), 0);
2216
- fillHeight = EnsureNumber(bruceModels.Calculator.GetNumber(style.CylinderFillExtrusion, entity, params.tags));
2217
- 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({
2218
2257
  viewer: params.viewer,
2219
2258
  entity: entity,
2220
- recordHeightRef: Cesium.HeightReference.RELATIVE_TO_GROUND,
2221
- returnHeightRef: Cesium.HeightReference.RELATIVE_TO_GROUND
2259
+ recordHeightRef: heightRef,
2260
+ returnHeightRef: heightRef
2222
2261
  });
2223
- // Adjust the position to consider half the height of the cylinder
2224
- if (pos) {
2225
- cartographicPosition = Cesium.Cartographic.fromCartesian(pos);
2226
- cartographicPosition.height += fillHeight / 2;
2227
- pos = Cesium.Cartographic.toCartesian(cartographicPosition);
2228
- }
2262
+ extrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderFillExtrusion);
2229
2263
  cEntity = new Cesium.Entity({
2230
- position: pos,
2231
- cylinder: {
2232
- length: fillHeight,
2233
- topRadius: radius,
2234
- bottomRadius: radius,
2264
+ ellipse: {
2265
+ semiMajorAxis: radius,
2266
+ semiMinorAxis: radius,
2235
2267
  material: cFill,
2236
- outline: outline,
2237
- outlineColor: cOutline,
2238
- outlineWidth: outlineWidth
2239
- }
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
2240
2278
  });
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
+ }
2241
2302
  }
2242
2303
  if (!cEntity) {
2243
2304
  bColor = style.color ? bruceModels.Calculator.GetColor(style.color, entity, params.tags) : null;
@@ -2266,8 +2327,6 @@
2266
2327
  }),
2267
2328
  show: true
2268
2329
  });
2269
- console.log("Created point", cEntity);
2270
- debugger;
2271
2330
  }
2272
2331
  if (cEntity) {
2273
2332
  cEntity._siblingGraphics = siblings;
@@ -14942,7 +15001,7 @@
14942
15001
  ViewerUtils.CreateWidgets = CreateWidgets;
14943
15002
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
14944
15003
 
14945
- var VERSION$1 = "2.5.9";
15004
+ var VERSION$1 = "2.6.3";
14946
15005
 
14947
15006
  exports.VERSION = VERSION$1;
14948
15007
  exports.CesiumViewMonitor = CesiumViewMonitor;