bruce-cesium 2.7.3 → 2.7.4

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, Color, HeightReference, Cartesian3, DistanceDisplayCondition, NearFarScalar, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, HeadingPitchRoll, Math as Math$1, Transforms, ColorBlendMode, JulianDate, Cartesian2, CallbackProperty, Rectangle, SceneMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, EllipsoidTerrainProvider, sampleTerrainMostDetailed, defined, Model, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, OrthographicFrustum, EasingFunction, PolygonPipeline, CesiumInspector, ColorMaterialProperty, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, Ion, BoundingSphere } from 'cesium';
3
+ import { Cartographic, Entity, Primitive, Cesium3DTileFeature, Color, Cartesian2, JulianDate, Cartesian3, SceneMode, Math as Math$1, CallbackProperty, Rectangle, HeightReference, DistanceDisplayCondition, NearFarScalar, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, HeadingPitchRoll, Transforms, ColorBlendMode, Cesium3DTileColorBlendMode, HeadingPitchRange, createOsmBuildings, Cesium3DTileStyle, KmlDataSource, EllipsoidTerrainProvider, CesiumInspector, OrthographicFrustum, defined, createWorldTerrain, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, EllipsoidGeodesic, sampleTerrainMostDetailed, Cesium3DTileset, Model, PolygonPipeline, Matrix4, Matrix3, IonResource, ScreenSpaceEventHandler, ScreenSpaceEventType, ColorMaterialProperty, EasingFunction, GeometryInstance, Ion, BoundingSphere } from 'cesium';
4
4
 
5
5
  var TIME_LAG = 300;
6
6
  var POSITION_CHECK_TIMER = 950;
@@ -3066,6 +3066,7 @@ var EntityRenderEngine;
3066
3066
  */
3067
3067
  var CesiumParabola = /** @class */ (function () {
3068
3068
  function CesiumParabola(params) {
3069
+ this.disposed = false;
3069
3070
  this.color = "white";
3070
3071
  this.width = 2;
3071
3072
  this.duration = 10;
@@ -3147,6 +3148,9 @@ var CesiumParabola = /** @class */ (function () {
3147
3148
  };
3148
3149
  CesiumParabola.prototype.Animate = function () {
3149
3150
  var _this = this;
3151
+ if (this.disposed) {
3152
+ return null;
3153
+ }
3150
3154
  if (this.parabola && !this.viewer.entities.contains(this.parabola)) {
3151
3155
  this.viewer.entities.add(this.parabola);
3152
3156
  }
@@ -3178,9 +3182,34 @@ var CesiumParabola = /** @class */ (function () {
3178
3182
  var RATE_PER_SECOND = 1000 / 40;
3179
3183
  var SEC_DURATION = this.duration;
3180
3184
  var HEIGHT_DISTANCE_RATIO = this.heightDistanceRatio;
3181
- var TOTAL_POINTS = Math.max(50, Math.min(1000, TOTAL_LENGTH * 0.1));
3182
- var POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
3183
- var TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
3185
+ var TOTAL_POINTS = null;
3186
+ var POINT_LENGTH = null;
3187
+ var TICK_LENGTH_INC = null;
3188
+ // Updates TOTAL_POINTS, POINT_LENGTH, and TICK_LENGTH_INC based on current TOTAL_LENGTH and camera position.
3189
+ // We want less points the further away the camera is.
3190
+ var updateParams = function () {
3191
+ var _a, _b;
3192
+ // TODO: Do distance to parabola line instead.
3193
+ var MIN_POINTS = 30;
3194
+ var totalPoints = 80;
3195
+ var cameraHeight = (_b = (_a = _this.viewer.camera) === null || _a === void 0 ? void 0 : _a.positionCartographic) === null || _b === void 0 ? void 0 : _b.height;
3196
+ if (isNaN(cameraHeight) || cameraHeight >= 100000) {
3197
+ totalPoints = MIN_POINTS;
3198
+ }
3199
+ else if (cameraHeight >= 10000) {
3200
+ totalPoints = 50;
3201
+ }
3202
+ else if (cameraHeight >= 1000) {
3203
+ totalPoints = 80;
3204
+ }
3205
+ else if (cameraHeight >= 100) {
3206
+ totalPoints = 100;
3207
+ }
3208
+ TOTAL_POINTS = Math.max(MIN_POINTS, Math.min(totalPoints, TOTAL_LENGTH * 0.1));
3209
+ POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
3210
+ TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
3211
+ };
3212
+ updateParams();
3184
3213
  var curPoint = 0;
3185
3214
  var quadraticKey = null;
3186
3215
  var quadratic = null;
@@ -3336,30 +3365,45 @@ var CesiumParabola = /** @class */ (function () {
3336
3365
  for (var i = 0; i < totalCycles; i++) {
3337
3366
  posses.push(getPosition(i));
3338
3367
  }
3339
- posses.push(getPosition(increment + chips));
3368
+ if (chips) {
3369
+ posses.push(getPosition(increment + chips));
3370
+ }
3340
3371
  if (posses.find(function (x) { return !x || !Cartes.ValidateCartes3(x); })) {
3341
3372
  return;
3342
3373
  }
3343
3374
  _this.curPoints = posses;
3344
3375
  };
3376
+ var lastTickDate = new Date();
3377
+ var finished = false;
3345
3378
  var doTick = function () {
3346
- var p1 = _this.curPos1;
3347
- var p2 = _this.curPos2;
3348
- var newLength = p1 && p2 ? Cartesian3.distance(p1, p2) : -1;
3349
- if (newLength > 0 && newLength != TOTAL_LENGTH) {
3350
- TOTAL_LENGTH = newLength;
3351
- TOTAL_POINTS = Math.max(50, Math.min(1000, TOTAL_LENGTH * 0.1));
3352
- POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
3353
- TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
3354
- }
3355
- prepareQuadratic();
3356
- if (quadratic) {
3357
- if (curPoint < TOTAL_POINTS) {
3358
- curPoint += TICK_LENGTH_INC;
3379
+ var curDate = new Date();
3380
+ var seconds = (curDate.getTime() - lastTickDate.getTime()) / 1000;
3381
+ var ticks = seconds * RATE_PER_SECOND;
3382
+ if (!isNaN(ticks) && ticks >= 1) {
3383
+ lastTickDate = curDate;
3384
+ var p1 = _this.curPos1;
3385
+ var p2 = _this.curPos2;
3386
+ var newLength = p1 && p2 ? Cartesian3.distance(p1, p2) : -1;
3387
+ if (newLength > 0 && newLength != TOTAL_LENGTH) {
3388
+ TOTAL_LENGTH = newLength;
3389
+ updateParams();
3390
+ }
3391
+ prepareQuadratic();
3392
+ if (quadratic) {
3393
+ if (curPoint < TOTAL_POINTS) {
3394
+ curPoint += (TICK_LENGTH_INC * ticks);
3395
+ }
3396
+ updatePoints();
3397
+ }
3398
+ _this.viewer.scene.requestRender();
3399
+ if (curPoint >= TOTAL_POINTS && !finished) {
3400
+ finished = true;
3401
+ // We can make the interval update super slow now.
3402
+ // We keep it updating in case the positions move.
3403
+ clearInterval(_this.animateInterval);
3404
+ _this.animateInterval = setInterval(doTick, 3000);
3359
3405
  }
3360
- updatePoints();
3361
3406
  }
3362
- _this.viewer.scene.requestRender();
3363
3407
  };
3364
3408
  this.animateInterval = setInterval(doTick, RATE_PER_SECOND);
3365
3409
  return {
@@ -3369,6 +3413,7 @@ var CesiumParabola = /** @class */ (function () {
3369
3413
  };
3370
3414
  CesiumParabola.prototype.Dispose = function () {
3371
3415
  var _this = this;
3416
+ this.disposed = true;
3372
3417
  clearTimeout(this.retryTimeout);
3373
3418
  clearInterval(this.animateInterval);
3374
3419
  var cEntities = [
@@ -9115,6 +9160,12 @@ var RelationsRenderManager;
9115
9160
  })];
9116
9161
  case 1:
9117
9162
  cEntities = _c.sent();
9163
+ if (this.disposed) {
9164
+ this.register.RemoveRegos({
9165
+ menuItemId: this.item.id
9166
+ });
9167
+ return [2 /*return*/];
9168
+ }
9118
9169
  for (i = 0; i < relations.length; i++) {
9119
9170
  relation = relations[i];
9120
9171
  key = RelationRenderEngine.GetRenderGroupId(relation);
@@ -15221,7 +15272,7 @@ var ViewerUtils;
15221
15272
  ViewerUtils.CreateWidgets = CreateWidgets;
15222
15273
  })(ViewerUtils || (ViewerUtils = {}));
15223
15274
 
15224
- var VERSION$1 = "2.7.3";
15275
+ var VERSION$1 = "2.7.4";
15225
15276
 
15226
15277
  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 };
15227
15278
  //# sourceMappingURL=bruce-cesium.es5.js.map