bruce-cesium 4.4.6 → 4.4.8

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
- import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, Session, EntityAttribute, EntityAttachment, EntityAttachmentType, AbstractApi } from 'bruce-models';
1
+ import { BruceEvent, Cartes, Entity as Entity$1, Carto, Geometry, MathUtils, LRUCache, Api, Calculator, ClientFile, EntityTag, EntityType, ObjectUtils, Style, ProjectViewTile, DelayQueue, EntityLod, Bounds, ZoomControl, EntityRelationType, ENVIRONMENT, EntityHistoricData, Tileset, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, ProjectView, ProjectViewBookmark, Camera, ProjectViewLegacyTile, AbstractApi, Session, EntityAttribute, EntityAttachment, EntityAttachmentType } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, ClockRange, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, Quaternion, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect } from 'cesium';
3
+ import { Cartographic, JulianDate, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, Entity, DistanceDisplayCondition, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, PolygonHierarchy, ShadowMode, PolylineGraphics, ArcType, CornerType, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Model, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Cesium3DTileStyle, Ion, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, NearFarScalar, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, CesiumInspector, defined, ClockRange, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, Quaternion, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Intersect } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6876,6 +6876,22 @@ var EntityRenderEnginePolyline;
6876
6876
  if (totalLength < MIN_LEN || totalLength > MAX_LEN) {
6877
6877
  return null;
6878
6878
  }
6879
+ // Smoothening the line.
6880
+ // Warning: we don't have a way to indicate that this is not the original set of points yet.
6881
+ // This means editing tools in our apps will bake these in on save.
6882
+ var orgPosses = null;
6883
+ if (style.smoothen && style.smoothen > 2) {
6884
+ // Keeping reference to original points for editing tools.
6885
+ orgPosses = posses.map(function (x) { return x.clone ? x.clone() : new Cartesian3(x.x, x.y, x.z); });
6886
+ var smoothed = smoothenPoints(posses, style.smoothen, false);
6887
+ if (smoothed.find(function (x) { return !Cartes.ValidateCartes3(x); })) {
6888
+ console.error("Polyline.Render: Smoothening failed. Invalid Cartesian3 found. Defaulting to original points.");
6889
+ orgPosses = null;
6890
+ }
6891
+ else {
6892
+ posses = smoothed;
6893
+ }
6894
+ }
6879
6895
  var bColor = style.lineColor ? Calculator.GetColor(style.lineColor, entity, params.tags) : null;
6880
6896
  var cColor = bColor ? ColorToCColor(bColor) : Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
6881
6897
  if (cColor.alpha <= 0) {
@@ -7028,6 +7044,11 @@ var EntityRenderEnginePolyline;
7028
7044
  }
7029
7045
  cEntity.show = true;
7030
7046
  }
7047
+ // Keeping reference to original points for editing tools.
7048
+ // Used when we run a smooth.
7049
+ if (cEntity === null || cEntity === void 0 ? void 0 : cEntity.polyline) {
7050
+ cEntity.polyline._orgPosses = orgPosses;
7051
+ }
7031
7052
  return cEntity;
7032
7053
  }
7033
7054
  EntityRenderEnginePolyline.Render = Render;
@@ -7233,6 +7254,52 @@ function getHeightRef$2(style, defaultStyle) {
7233
7254
  }
7234
7255
  return heightRef;
7235
7256
  }
7257
+ function smoothenPoints(points, multiplier, closed) {
7258
+ if (points.length < 4 || multiplier < 2) {
7259
+ return points;
7260
+ }
7261
+ if (!closed) {
7262
+ points.unshift(Cartesian3.subtract(points[0], points[1], new Cartesian3()));
7263
+ points.push(Cartesian3.subtract(points[points.length - 1], points[points.length - 2], new Cartesian3()));
7264
+ }
7265
+ else {
7266
+ points.unshift(points[points.length - 1]);
7267
+ points.unshift(points[points.length - 2]);
7268
+ points.push(points[2]);
7269
+ }
7270
+ var splinePoints = [];
7271
+ var _loop_1 = function (i) {
7272
+ var _a = [0, 1, 2, 3].map(function (n) { return points[i + n]; }), P0 = _a[0], P1 = _a[1], P2 = _a[2], P3 = _a[3];
7273
+ for (var j = 0; j <= multiplier; j++) {
7274
+ splinePoints.push(catmullRom$1(P0, P1, P2, P3, j / multiplier));
7275
+ }
7276
+ };
7277
+ for (var i = 0; i < points.length - 3; i++) {
7278
+ _loop_1(i);
7279
+ }
7280
+ return splinePoints;
7281
+ }
7282
+ function catmullRom$1(p0, p1, p2, p3, t) {
7283
+ var t0 = 0;
7284
+ var t1 = getT$1(t0, 0.5, p0, p1);
7285
+ var t2 = getT$1(t1, 0.5, p1, p2);
7286
+ var t3 = getT$1(t2, 0.5, p2, p3);
7287
+ t = Math$1.lerp(t1, t2, t);
7288
+ var _a = [function (l, r) { return Cartesian3.add(l, r, new Cartesian3()); }, function (l, r) { return Cartesian3.multiplyByScalar(l, r, new Cartesian3()); }], add = _a[0], mul = _a[1];
7289
+ var A1 = add(mul(p0, (t1 - t) / (t1 - t0)), mul(p1, (t - t0) / (t1 - t0)));
7290
+ var A2 = add(mul(p1, (t2 - t) / (t2 - t1)), mul(p2, (t - t1) / (t2 - t1)));
7291
+ var A3 = add(mul(p2, (t3 - t) / (t3 - t2)), mul(p3, (t - t2) / (t3 - t2)));
7292
+ var B1 = add(mul(A1, (t2 - t) / (t2 - t0)), mul(A2, (t - t0) / (t2 - t0)));
7293
+ var B2 = add(mul(A2, (t3 - t) / (t3 - t1)), mul(A3, (t - t1) / (t3 - t1)));
7294
+ var C = add(mul(B1, (t2 - t) / (t2 - t1)), mul(B2, (t - t1) / (t2 - t1)));
7295
+ return C;
7296
+ }
7297
+ function getT$1(t, alpha, p0, p1) {
7298
+ var d = Cartesian3.subtract(p1, p0, new Cartesian3());
7299
+ var a = Cartesian3.dot(d, d);
7300
+ var b = Math.pow(a, alpha * 0.5);
7301
+ return b + t;
7302
+ }
7236
7303
 
7237
7304
  var EntityRenderEnginePolygon;
7238
7305
  (function (EntityRenderEnginePolygon) {
@@ -17712,6 +17779,24 @@ var TilesetArbRenderManager;
17712
17779
  }
17713
17780
  this.viewer.scene.requestRender();
17714
17781
  TilesetRenderEngine.OnTilesetReady(this.cTileset).then(function () {
17782
+ // Colour mask to apply to the Tileset as a whole.
17783
+ // Individual Entities can override this.
17784
+ // This is typically used for Tilesets without Entities to allow some sort of basic styling per-bookmark.
17785
+ try {
17786
+ var colorCss = _this.item.colorMask;
17787
+ if (colorCss) {
17788
+ _this.cTileset.style = new Cesium3DTileStyle({
17789
+ color: {
17790
+ conditions: [
17791
+ ["true", "color(\"".concat(colorCss, "\")")]
17792
+ ]
17793
+ }
17794
+ });
17795
+ }
17796
+ }
17797
+ catch (e) {
17798
+ console.error(e);
17799
+ }
17715
17800
  try {
17716
17801
  if (_this.item.ApplyStyles ||
17717
17802
  _this.item.Type == MenuItem.EType.IonTileset) {
@@ -24462,19 +24547,11 @@ function getInsertIndex(positions, pos3d) {
24462
24547
  if (startDist <= minDistance) {
24463
24548
  index = 0;
24464
24549
  minDistance = startDist;
24465
- console.log("Insert at start");
24466
- }
24467
- else {
24468
- console.log("Start distance was longer than cur distance. ".concat(startDist, " > ").concat(minDistance));
24469
24550
  }
24470
24551
  // Check against end point
24471
24552
  var endDist = Cartesian3.distance(pos3d, positions[positions.length - 1]);
24472
24553
  if (endDist <= minDistance) {
24473
24554
  index = positions.length;
24474
- console.log("Insert at end");
24475
- }
24476
- else {
24477
- console.log("End distance was longer than cur distance. ".concat(endDist, " > ").concat(minDistance));
24478
24555
  }
24479
24556
  return index;
24480
24557
  }
@@ -27204,7 +27281,7 @@ var ViewerUtils;
27204
27281
  ViewerUtils.AssertIonToken = AssertIonToken;
27205
27282
  })(ViewerUtils || (ViewerUtils = {}));
27206
27283
 
27207
- var VERSION = "4.4.6";
27284
+ var VERSION = "4.4.8";
27208
27285
 
27209
- export { VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, WidgetSearchBar, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
27286
+ export { VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, EntityRenderEnginePoint, EntityRenderEnginePolyline, smoothenPoints, EntityRenderEnginePolygon, EntityRenderEngineModel3d, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, GoogleSearchRenderManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, CesiumAnimatedProperty, CesiumAnimatedInOut, Draw3dPolygon, Draw3dPolyline, MeasureCreator, Widget, VIEWER_BOOKMARKS_WIDGET_KEY, WidgetBookmarks, WidgetBranding, WidgetCursorBar, WidgetEmbeddedInfoView, WidgetInfoView, WidgetNavCompass$$1 as WidgetNavCompass, WidgetSearchBar, VIEWER_LEFT_PANEL_WIDGET_KEY, VIEWER_LEFT_PANEL_CSS_VAR_LEFT, WidgetLeftPanel, WidgetLeftPanelTab, WidgetLeftPanelTabBookmarks };
27210
27287
  //# sourceMappingURL=bruce-cesium.es5.js.map