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.
@@ -1,6 +1,6 @@
1
1
  import { BruceEvent, Cartes, Carto, Entity as Entity$1, Geometry, Tileset, MathUtils, LRUCache, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, EntityRelationType, DelayQueue, BatchedDataGetter, EntityCoords, EntityFilterGetter, EntitySource, MenuItem, EntityRelation, ENVIRONMENT, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, ProgramKey, Camera, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, CallbackProperty, Cartesian3, Color, Rectangle, Math as Math$1, JulianDate, HeightReference, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, OrthographicFrustum, EllipsoidGeodesic, EllipsoidTerrainProvider, sampleTerrainMostDetailed, defined, Cesium3DTileset, Model, PolygonPipeline, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumInspector, Matrix4, Matrix3, IonResource, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, EasingFunction, GeometryInstance, Ion, BoundingSphere } from 'cesium';
3
+ import { Cartographic, Cartesian3, SceneMode, Math as Math$1, Cartesian2, CallbackProperty, Color, Rectangle, JulianDate, HeightReference, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, HeadingPitchRange, Cesium3DTileColorBlendMode, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, OrthographicFrustum, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumInspector, defined, PolygonPipeline, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, Model, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, EasingFunction, GeometryInstance, Ion, BoundingSphere } from 'cesium';
4
4
 
5
5
  var TIME_LAG = 300;
6
6
  var POSITION_CHECK_TIMER = 950;
@@ -1630,6 +1630,43 @@ function getPolygonExtrusion(entity, tags, ring, posses, heightRef, pStyle) {
1630
1630
  }
1631
1631
  return data;
1632
1632
  }
1633
+ function getCylinderStyleExtrusion(style, entity, tags, heightRef) {
1634
+ var _a;
1635
+ if (!style) {
1636
+ return null;
1637
+ }
1638
+ try {
1639
+ var extrusion = +Calculator.GetNumber(style, entity, tags);
1640
+ if (!extrusion && extrusion != 0) {
1641
+ return null;
1642
+ }
1643
+ /*
1644
+ Cesium extrudes in strange way.
1645
+ If you want something that is 50 meters above sea, and 5 meters tall,
1646
+ You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
1647
+ */
1648
+ var height = EnsureNumber((_a = entity.location) === null || _a === void 0 ? void 0 : _a.altitude, 0);
1649
+ return heightRef != HeightReference.CLAMP_TO_GROUND ? extrusion + height : extrusion;
1650
+ }
1651
+ catch (e) {
1652
+ console.error(e);
1653
+ }
1654
+ return 0;
1655
+ }
1656
+ function getCylinderExtrusion(entity, tags, heightRef, style) {
1657
+ var data = {
1658
+ value: undefined,
1659
+ exHeightRef: heightRef == HeightReference.CLAMP_TO_GROUND ? HeightReference.RELATIVE_TO_GROUND : heightRef
1660
+ };
1661
+ var extrusion = getCylinderStyleExtrusion(style, entity, tags, heightRef);
1662
+ if (extrusion) {
1663
+ data.value = extrusion;
1664
+ }
1665
+ if (data.value != undefined) {
1666
+ data.value = EnsureNumber(data.value);
1667
+ }
1668
+ return data;
1669
+ }
1633
1670
  function getHeightRef(style, defaultStyle) {
1634
1671
  var _a;
1635
1672
  var heightRef = defaultStyle == null ? HeightReference.CLAMP_TO_GROUND : defaultStyle;
@@ -2114,7 +2151,7 @@ var EntityRenderEngine;
2114
2151
  (function (Point) {
2115
2152
  function Render(params) {
2116
2153
  return __awaiter(this, void 0, void 0, function () {
2117
- 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;
2154
+ 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;
2118
2155
  return __generator(this, function (_a) {
2119
2156
  switch (_a.label) {
2120
2157
  case 0:
@@ -2211,30 +2248,60 @@ var EntityRenderEngine;
2211
2248
  bFill = style.CylinderFillColor ? Calculator.GetColor(style.CylinderFillColor, entity, params.tags) : null;
2212
2249
  cFill = bFill ? colorToCColor(bFill) : Color.RED;
2213
2250
  outline = Boolean(style.CylinderBorderEnabled);
2214
- bOutline = style.CylinderBorderColor ? Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
2215
- cOutline = bOutline ? colorToCColor(bOutline) : Color.BLACK;
2216
- outlineWidth = EnsureNumber(Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
2217
- outlineHeight = EnsureNumber(Calculator.GetNumber(style.CylinderBorderExtrusion, entity, params.tags), 0);
2218
- fillHeight = EnsureNumber(Calculator.GetNumber(style.CylinderFillExtrusion, entity, params.tags));
2219
- pos = EntityUtils.GetPos({
2251
+ cOutline = null;
2252
+ outlineWidth = 1;
2253
+ if (outline) {
2254
+ bOutline = style.CylinderBorderColor ? Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
2255
+ cOutline = bOutline ? colorToCColor(bOutline) : Color.BLACK;
2256
+ outlineWidth = EnsureNumber(Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
2257
+ }
2258
+ heightRef = getHeightRef(style);
2259
+ pos3d = EntityUtils.GetPos({
2220
2260
  viewer: params.viewer,
2221
2261
  entity: entity,
2222
- recordHeightRef: HeightReference.CLAMP_TO_GROUND,
2223
- returnHeightRef: HeightReference.RELATIVE_TO_GROUND
2262
+ recordHeightRef: heightRef,
2263
+ returnHeightRef: heightRef
2224
2264
  });
2265
+ extrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderFillExtrusion);
2225
2266
  cEntity = new Entity({
2226
- position: pos === null || pos === void 0 ? void 0 : pos.clone(),
2227
- cylinder: {
2228
- length: fillHeight,
2229
- topRadius: radius,
2230
- bottomRadius: radius,
2267
+ ellipse: {
2268
+ semiMajorAxis: radius,
2269
+ semiMinorAxis: radius,
2231
2270
  material: cFill,
2232
- outline: outline,
2233
- outlineColor: cOutline,
2234
- outlineWidth: outlineWidth
2235
- }
2271
+ outlineWidth: null,
2272
+ extrudedHeight: extrusion.value,
2273
+ heightReference: heightRef,
2274
+ extrudedHeightReference: extrusion.exHeightRef,
2275
+ height: Cartographic.fromCartesian(pos3d).height,
2276
+ zIndex: 1,
2277
+ distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2278
+ },
2279
+ position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone(),
2280
+ show: true
2236
2281
  });
2237
- // Here you can add additional logic if you need more customization for the cylinder
2282
+ if (outline && outlineWidth > 0) {
2283
+ outlineExtrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderBorderExtrusion);
2284
+ // If this doesn't have its own extrusion, we must make it match the sibling.
2285
+ // This way they render in a uniform way.
2286
+ if (!outlineExtrusion.value && extrusion.value) {
2287
+ outlineExtrusion.exHeightRef = extrusion.exHeightRef;
2288
+ }
2289
+ siblings.push(new Entity({
2290
+ ellipse: {
2291
+ semiMajorAxis: radius + outlineWidth,
2292
+ semiMinorAxis: radius + outlineWidth,
2293
+ material: cOutline,
2294
+ outlineWidth: undefined,
2295
+ extrudedHeight: outlineExtrusion.value,
2296
+ heightReference: heightRef,
2297
+ extrudedHeightReference: outlineExtrusion.exHeightRef,
2298
+ height: Cartographic.fromCartesian(pos3d).height,
2299
+ zIndex: 2,
2300
+ distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
2301
+ },
2302
+ position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone()
2303
+ }));
2304
+ }
2238
2305
  }
2239
2306
  if (!cEntity) {
2240
2307
  bColor = style.color ? Calculator.GetColor(style.color, entity, params.tags) : null;
@@ -14988,7 +15055,7 @@ var ViewerUtils;
14988
15055
  ViewerUtils.CreateWidgets = CreateWidgets;
14989
15056
  })(ViewerUtils || (ViewerUtils = {}));
14990
15057
 
14991
- var VERSION$1 = "2.5.9";
15058
+ var VERSION$1 = "2.6.3";
14992
15059
 
14993
15060
  export { VERSION$1 as VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, RelationsRenderManager, SharedGetters, CesiumParabola, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, Draw3dPolygon, Draw3dPolyline };
14994
15061
  //# sourceMappingURL=bruce-cesium.es5.js.map