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.
@@ -3063,6 +3063,7 @@
3063
3063
  */
3064
3064
  var CesiumParabola = /** @class */ (function () {
3065
3065
  function CesiumParabola(params) {
3066
+ this.disposed = false;
3066
3067
  this.color = "white";
3067
3068
  this.width = 2;
3068
3069
  this.duration = 10;
@@ -3144,6 +3145,9 @@
3144
3145
  };
3145
3146
  CesiumParabola.prototype.Animate = function () {
3146
3147
  var _this = this;
3148
+ if (this.disposed) {
3149
+ return null;
3150
+ }
3147
3151
  if (this.parabola && !this.viewer.entities.contains(this.parabola)) {
3148
3152
  this.viewer.entities.add(this.parabola);
3149
3153
  }
@@ -3175,9 +3179,34 @@
3175
3179
  var RATE_PER_SECOND = 1000 / 40;
3176
3180
  var SEC_DURATION = this.duration;
3177
3181
  var HEIGHT_DISTANCE_RATIO = this.heightDistanceRatio;
3178
- var TOTAL_POINTS = Math.max(50, Math.min(1000, TOTAL_LENGTH * 0.1));
3179
- var POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
3180
- var TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
3182
+ var TOTAL_POINTS = null;
3183
+ var POINT_LENGTH = null;
3184
+ var TICK_LENGTH_INC = null;
3185
+ // Updates TOTAL_POINTS, POINT_LENGTH, and TICK_LENGTH_INC based on current TOTAL_LENGTH and camera position.
3186
+ // We want less points the further away the camera is.
3187
+ var updateParams = function () {
3188
+ var _a, _b;
3189
+ // TODO: Do distance to parabola line instead.
3190
+ var MIN_POINTS = 30;
3191
+ var totalPoints = 80;
3192
+ var cameraHeight = (_b = (_a = _this.viewer.camera) === null || _a === void 0 ? void 0 : _a.positionCartographic) === null || _b === void 0 ? void 0 : _b.height;
3193
+ if (isNaN(cameraHeight) || cameraHeight >= 100000) {
3194
+ totalPoints = MIN_POINTS;
3195
+ }
3196
+ else if (cameraHeight >= 10000) {
3197
+ totalPoints = 50;
3198
+ }
3199
+ else if (cameraHeight >= 1000) {
3200
+ totalPoints = 80;
3201
+ }
3202
+ else if (cameraHeight >= 100) {
3203
+ totalPoints = 100;
3204
+ }
3205
+ TOTAL_POINTS = Math.max(MIN_POINTS, Math.min(totalPoints, TOTAL_LENGTH * 0.1));
3206
+ POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
3207
+ TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
3208
+ };
3209
+ updateParams();
3181
3210
  var curPoint = 0;
3182
3211
  var quadraticKey = null;
3183
3212
  var quadratic = null;
@@ -3333,30 +3362,45 @@
3333
3362
  for (var i = 0; i < totalCycles; i++) {
3334
3363
  posses.push(getPosition(i));
3335
3364
  }
3336
- posses.push(getPosition(increment + chips));
3365
+ if (chips) {
3366
+ posses.push(getPosition(increment + chips));
3367
+ }
3337
3368
  if (posses.find(function (x) { return !x || !bruceModels.Cartes.ValidateCartes3(x); })) {
3338
3369
  return;
3339
3370
  }
3340
3371
  _this.curPoints = posses;
3341
3372
  };
3373
+ var lastTickDate = new Date();
3374
+ var finished = false;
3342
3375
  var doTick = function () {
3343
- var p1 = _this.curPos1;
3344
- var p2 = _this.curPos2;
3345
- var newLength = p1 && p2 ? Cesium.Cartesian3.distance(p1, p2) : -1;
3346
- if (newLength > 0 && newLength != TOTAL_LENGTH) {
3347
- TOTAL_LENGTH = newLength;
3348
- TOTAL_POINTS = Math.max(50, Math.min(1000, TOTAL_LENGTH * 0.1));
3349
- POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
3350
- TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
3351
- }
3352
- prepareQuadratic();
3353
- if (quadratic) {
3354
- if (curPoint < TOTAL_POINTS) {
3355
- curPoint += TICK_LENGTH_INC;
3376
+ var curDate = new Date();
3377
+ var seconds = (curDate.getTime() - lastTickDate.getTime()) / 1000;
3378
+ var ticks = seconds * RATE_PER_SECOND;
3379
+ if (!isNaN(ticks) && ticks >= 1) {
3380
+ lastTickDate = curDate;
3381
+ var p1 = _this.curPos1;
3382
+ var p2 = _this.curPos2;
3383
+ var newLength = p1 && p2 ? Cesium.Cartesian3.distance(p1, p2) : -1;
3384
+ if (newLength > 0 && newLength != TOTAL_LENGTH) {
3385
+ TOTAL_LENGTH = newLength;
3386
+ updateParams();
3387
+ }
3388
+ prepareQuadratic();
3389
+ if (quadratic) {
3390
+ if (curPoint < TOTAL_POINTS) {
3391
+ curPoint += (TICK_LENGTH_INC * ticks);
3392
+ }
3393
+ updatePoints();
3394
+ }
3395
+ _this.viewer.scene.requestRender();
3396
+ if (curPoint >= TOTAL_POINTS && !finished) {
3397
+ finished = true;
3398
+ // We can make the interval update super slow now.
3399
+ // We keep it updating in case the positions move.
3400
+ clearInterval(_this.animateInterval);
3401
+ _this.animateInterval = setInterval(doTick, 3000);
3356
3402
  }
3357
- updatePoints();
3358
3403
  }
3359
- _this.viewer.scene.requestRender();
3360
3404
  };
3361
3405
  this.animateInterval = setInterval(doTick, RATE_PER_SECOND);
3362
3406
  return {
@@ -3366,6 +3410,7 @@
3366
3410
  };
3367
3411
  CesiumParabola.prototype.Dispose = function () {
3368
3412
  var _this = this;
3413
+ this.disposed = true;
3369
3414
  clearTimeout(this.retryTimeout);
3370
3415
  clearInterval(this.animateInterval);
3371
3416
  var cEntities = [
@@ -9074,6 +9119,12 @@
9074
9119
  })];
9075
9120
  case 1:
9076
9121
  cEntities = _c.sent();
9122
+ if (this.disposed) {
9123
+ this.register.RemoveRegos({
9124
+ menuItemId: this.item.id
9125
+ });
9126
+ return [2 /*return*/];
9127
+ }
9077
9128
  for (i = 0; i < relations.length; i++) {
9078
9129
  relation = relations[i];
9079
9130
  key = RelationRenderEngine.GetRenderGroupId(relation);
@@ -15167,7 +15218,7 @@
15167
15218
  ViewerUtils.CreateWidgets = CreateWidgets;
15168
15219
  })(exports.ViewerUtils || (exports.ViewerUtils = {}));
15169
15220
 
15170
- var VERSION$1 = "2.7.3";
15221
+ var VERSION$1 = "2.7.4";
15171
15222
 
15172
15223
  exports.VERSION = VERSION$1;
15173
15224
  exports.CesiumViewMonitor = CesiumViewMonitor;