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.
@@ -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, 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, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, OrthographicFrustum, ColorMaterialProperty, Matrix3, Matrix4, EasingFunction, GeometryInstance, Cesium3DTileset, IonResource, ScreenSpaceEventHandler, ScreenSpaceEventType, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, Model, CesiumInspector, 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;
@@ -1863,7 +1900,6 @@ var EntityRenderEngine;
1863
1900
  return __generator(this, function (_j) {
1864
1901
  switch (_j.label) {
1865
1902
  case 0:
1866
- console.log("Rendering entities", params);
1867
1903
  groupRenderParams = {
1868
1904
  apiGetter: params.apiGetter,
1869
1905
  viewer: params.viewer,
@@ -2115,7 +2151,7 @@ var EntityRenderEngine;
2115
2151
  (function (Point) {
2116
2152
  function Render(params) {
2117
2153
  return __awaiter(this, void 0, void 0, function () {
2118
- 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;
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;
2119
2155
  return __generator(this, function (_a) {
2120
2156
  switch (_a.label) {
2121
2157
  case 0:
@@ -2212,35 +2248,60 @@ var EntityRenderEngine;
2212
2248
  bFill = style.CylinderFillColor ? Calculator.GetColor(style.CylinderFillColor, entity, params.tags) : null;
2213
2249
  cFill = bFill ? colorToCColor(bFill) : Color.RED;
2214
2250
  outline = Boolean(style.CylinderBorderEnabled);
2215
- bOutline = style.CylinderBorderColor ? Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
2216
- cOutline = bOutline ? colorToCColor(bOutline) : Color.BLACK;
2217
- outlineWidth = EnsureNumber(Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
2218
- outlineHeight = EnsureNumber(Calculator.GetNumber(style.CylinderBorderExtrusion, entity, params.tags), 0);
2219
- fillHeight = EnsureNumber(Calculator.GetNumber(style.CylinderFillExtrusion, entity, params.tags));
2220
- 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({
2221
2260
  viewer: params.viewer,
2222
2261
  entity: entity,
2223
- recordHeightRef: HeightReference.RELATIVE_TO_GROUND,
2224
- returnHeightRef: HeightReference.RELATIVE_TO_GROUND
2262
+ recordHeightRef: heightRef,
2263
+ returnHeightRef: heightRef
2225
2264
  });
2226
- // Adjust the position to consider half the height of the cylinder
2227
- if (pos) {
2228
- cartographicPosition = Cartographic.fromCartesian(pos);
2229
- cartographicPosition.height += fillHeight / 2;
2230
- pos = Cartographic.toCartesian(cartographicPosition);
2231
- }
2265
+ extrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderFillExtrusion);
2232
2266
  cEntity = new Entity({
2233
- position: pos,
2234
- cylinder: {
2235
- length: fillHeight,
2236
- topRadius: radius,
2237
- bottomRadius: radius,
2267
+ ellipse: {
2268
+ semiMajorAxis: radius,
2269
+ semiMinorAxis: radius,
2238
2270
  material: cFill,
2239
- outline: outline,
2240
- outlineColor: cOutline,
2241
- outlineWidth: outlineWidth
2242
- }
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
2243
2281
  });
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
+ }
2244
2305
  }
2245
2306
  if (!cEntity) {
2246
2307
  bColor = style.color ? Calculator.GetColor(style.color, entity, params.tags) : null;
@@ -2269,8 +2330,6 @@ var EntityRenderEngine;
2269
2330
  }),
2270
2331
  show: true
2271
2332
  });
2272
- console.log("Created point", cEntity);
2273
- debugger;
2274
2333
  }
2275
2334
  if (cEntity) {
2276
2335
  cEntity._siblingGraphics = siblings;
@@ -14996,7 +15055,7 @@ var ViewerUtils;
14996
15055
  ViewerUtils.CreateWidgets = CreateWidgets;
14997
15056
  })(ViewerUtils || (ViewerUtils = {}));
14998
15057
 
14999
- var VERSION$1 = "2.5.9";
15058
+ var VERSION$1 = "2.6.3";
15000
15059
 
15001
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 };
15002
15061
  //# sourceMappingURL=bruce-cesium.es5.js.map