bruce-cesium 5.9.4 → 5.9.6

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.
@@ -1142,48 +1142,70 @@
1142
1142
  */
1143
1143
  class AnimatePositionSeries {
1144
1144
  constructor(params) {
1145
- // Current position state.
1146
- this.lastCalcPos3d = null;
1147
- this.lastCalcPosIndexLast = -1;
1148
- this.lastCalcPosIndexNext = -1;
1149
- // Series data for rendering path.
1145
+ // Animation state.
1146
+ this.currentAnimatedPos = null;
1147
+ this.currentTargetPos = null;
1148
+ this.animationStartPos = null;
1149
+ this.animationStartTime = null;
1150
+ this.animationDuration = 200;
1151
+ // Cached data for performance.
1152
+ this.lastDesiredPosIndex = -1;
1153
+ this.lastDesiredNextIndex = -1;
1154
+ // Series data for rendering path
1150
1155
  this.lastCalcSeriesPos3d = [];
1151
1156
  this.lastCalcSeriesTime = null;
1152
- // Orientation.
1157
+ // Orientation cache.
1153
1158
  this.lastCalcOrient = null;
1154
1159
  this.lastCalcOrientTime = null;
1155
- // Starting animation state.
1156
- this.animateFromPos3d = null;
1157
- this.animateFromPos3dTimeStart = null;
1158
- this.animationDuration = 200; // milliseconds
1159
1160
  this.viewer = params.viewer;
1160
1161
  this.positions = params.posses || [];
1161
1162
  this.pitch = params.pitch || 0;
1162
1163
  this.roll = params.roll || 0;
1163
- // Animation from a starting position.
1164
+ this.processHeadings();
1165
+ this.sortPositions();
1166
+ // Initialize animation from starting position if provided.
1164
1167
  if (params.animateFromPos3d) {
1165
- this.animateFromPos3d = params.animateFromPos3d;
1168
+ this.animationStartPos = params.animateFromPos3d;
1166
1169
  const currentTime = Date.now();
1167
1170
  const providedTime = params.animateFromPos3dTimeStart || 0;
1168
- // Check if the provided timestamp is stale (animation would have already completed)
1169
- // If so, use current time to restart the animation.
1171
+ // Check if the provided timestamp is stale.
1170
1172
  if (!providedTime || (currentTime - providedTime) >= this.animationDuration) {
1171
- this.animateFromPos3dTimeStart = currentTime;
1173
+ this.animationStartTime = currentTime;
1172
1174
  }
1173
1175
  else {
1174
- this.animateFromPos3dTimeStart = providedTime;
1176
+ this.animationStartTime = providedTime;
1175
1177
  }
1176
1178
  }
1179
+ }
1180
+ AddPosition(pos) {
1181
+ if (!pos || !pos.pos3d || !pos.dateTime) {
1182
+ console.warn("Invalid position provided to AnimatePositionSeries.");
1183
+ return;
1184
+ }
1185
+ this.positions.push(pos);
1177
1186
  this.processHeadings();
1178
- // Order positions by date.
1187
+ this.sortPositions();
1188
+ this.invalidateCache();
1189
+ }
1190
+ UpdatePitchRoll(pitch, roll) {
1191
+ this.pitch = pitch;
1192
+ this.roll = roll;
1193
+ this.invalidateCache();
1194
+ }
1195
+ GetAnimateFromDateTime() {
1196
+ return this.animationStartTime;
1197
+ }
1198
+ GetPositions() {
1199
+ return this.positions;
1200
+ }
1201
+ sortPositions() {
1179
1202
  if (this.positions.length > 0) {
1180
- this.positions.sort((a, b) => {
1181
- return a.dateTime.getTime() - b.dateTime.getTime();
1182
- });
1203
+ this.positions.sort((a, b) => a.dateTime.getTime() - b.dateTime.getTime());
1183
1204
  }
1184
1205
  }
1185
- GetAnimateFromDateTime() {
1186
- return this.animateFromPos3dTimeStart;
1206
+ invalidateCache() {
1207
+ this.lastCalcSeriesTime = null;
1208
+ this.lastCalcOrientTime = null;
1187
1209
  }
1188
1210
  /**
1189
1211
  * Pre-process headings in the series.
@@ -1207,33 +1229,91 @@
1207
1229
  }
1208
1230
  }
1209
1231
  }
1210
- GetPositions() {
1211
- return this.positions;
1212
- }
1213
1232
  easeInOutQuad(t) {
1214
1233
  return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
1215
1234
  }
1216
1235
  /**
1217
- * Interpolates between the starting position and target position.
1236
+ * Calculate the desired position based on current time without any animation smoothing.
1218
1237
  */
1219
- interpolateToTargetPosition(startPos, targetPos, startTimeMs, currentTimeMs) {
1220
- if (!startPos || !targetPos) {
1221
- return startPos || targetPos || new Cesium.Cartesian3();
1238
+ calculateDesiredPosition(timeMs) {
1239
+ // No positions available
1240
+ if (!this.positions || this.positions.length === 0) {
1241
+ return { position: null, lastIndex: -1, nextIndex: -1 };
1222
1242
  }
1223
- const elapsedTime = currentTimeMs - startTimeMs;
1224
- let progress = Math.min(elapsedTime / this.animationDuration, 1.0);
1225
- // Apply easing for more natural motion.
1226
- progress = this.easeInOutQuad(progress);
1227
- try {
1228
- return Cesium.Cartesian3.lerp(startPos, targetPos, progress, new Cesium.Cartesian3());
1243
+ // Only one position.
1244
+ if (this.positions.length === 1) {
1245
+ return {
1246
+ position: this.positions[0].pos3d || null,
1247
+ lastIndex: 0,
1248
+ nextIndex: 0
1249
+ };
1229
1250
  }
1230
- catch (e) {
1231
- console.error("Error in position interpolation: ", e);
1232
- return targetPos;
1251
+ // Before first position - use first two positions for orientation.
1252
+ if (timeMs <= this.positions[0].dateTime.getTime()) {
1253
+ return {
1254
+ position: this.positions[0].pos3d || null,
1255
+ lastIndex: 0,
1256
+ nextIndex: Math.min(1, this.positions.length - 1)
1257
+ };
1258
+ }
1259
+ // After last position - use last two positions for orientation.
1260
+ const lastIdx = this.positions.length - 1;
1261
+ if (timeMs >= this.positions[lastIdx].dateTime.getTime()) {
1262
+ return {
1263
+ position: this.positions[lastIdx].pos3d || null,
1264
+ lastIndex: Math.max(0, lastIdx - 1),
1265
+ nextIndex: lastIdx
1266
+ };
1267
+ }
1268
+ // Find positions to interpolate between.
1269
+ for (let i = 0; i < this.positions.length - 1; i++) {
1270
+ const current = this.positions[i];
1271
+ const next = this.positions[i + 1];
1272
+ if (timeMs >= current.dateTime.getTime() && timeMs < next.dateTime.getTime()) {
1273
+ // Exact match on current position - still use current and next for orientation.
1274
+ if (timeMs === current.dateTime.getTime()) {
1275
+ return {
1276
+ position: current.pos3d || null,
1277
+ lastIndex: i,
1278
+ nextIndex: i + 1
1279
+ };
1280
+ }
1281
+ // Interpolate between current and next.
1282
+ if (!current.pos3d || !next.pos3d) {
1283
+ return {
1284
+ position: current.pos3d || next.pos3d || null,
1285
+ lastIndex: i,
1286
+ nextIndex: i + 1
1287
+ };
1288
+ }
1289
+ try {
1290
+ const progress = (timeMs - current.dateTime.getTime()) / (next.dateTime.getTime() - current.dateTime.getTime());
1291
+ const interpolatedPos = Cesium.Cartesian3.lerp(current.pos3d, next.pos3d, progress, new Cesium.Cartesian3());
1292
+ return {
1293
+ position: interpolatedPos,
1294
+ lastIndex: i,
1295
+ nextIndex: i + 1
1296
+ };
1297
+ }
1298
+ catch (e) {
1299
+ console.error("Error in position interpolation: ", e);
1300
+ return {
1301
+ position: current.pos3d,
1302
+ lastIndex: i,
1303
+ nextIndex: i + 1
1304
+ };
1305
+ }
1306
+ }
1233
1307
  }
1308
+ // Fallback to last position with previous position for orientation.
1309
+ return {
1310
+ position: this.positions[lastIdx].pos3d || null,
1311
+ lastIndex: Math.max(0, lastIdx - 1),
1312
+ nextIndex: lastIdx
1313
+ };
1234
1314
  }
1235
1315
  /**
1236
- * Main method to get the current position based on time
1316
+ * Main method to get the current position based on time.
1237
1317
  */
1238
1318
  GetValue() {
1239
1319
  let now = this.viewer.scene.lastRenderTime;
@@ -1242,95 +1322,79 @@
1242
1322
  }
1243
1323
  const nowTimeMs = Cesium.JulianDate.toDate(now).getTime();
1244
1324
  const currentRealTimeMs = Date.now();
1245
- // Calculate the ideal position based on time.
1246
- const idealPosition = this.calculateIdealPosition(nowTimeMs);
1247
- // First run initialization.
1248
- if (!this.lastCalcPos3d) {
1249
- this.lastCalcPos3d = idealPosition;
1250
- // If we have a starting position, animate from it.
1251
- if (this.animateFromPos3d) {
1252
- return this.interpolateToTargetPosition(this.animateFromPos3d, idealPosition, this.animateFromPos3dTimeStart, currentRealTimeMs);
1253
- }
1254
- return idealPosition;
1255
- }
1256
- // If we're animating from a start position.
1257
- if (this.animateFromPos3d) {
1258
- const elapsedTime = currentRealTimeMs - this.animateFromPos3dTimeStart;
1259
- // If animation is complete, just return ideal position and clear animation state.
1260
- if (elapsedTime >= this.animationDuration) {
1261
- this.animateFromPos3d = null;
1262
- this.lastCalcPos3d = idealPosition;
1263
- return idealPosition;
1264
- }
1265
- // Otherwise continue interpolation.
1266
- const interpolatedPos = this.interpolateToTargetPosition(this.animateFromPos3d, idealPosition, this.animateFromPos3dTimeStart, currentRealTimeMs);
1267
- this.lastCalcPos3d = interpolatedPos;
1268
- return interpolatedPos;
1269
- }
1270
- // If we're not animating, directly use the ideal position.
1271
- // This ensures we're exactly where we should be based on time.
1272
- this.lastCalcPos3d = idealPosition;
1273
- return idealPosition;
1274
- }
1275
- /**
1276
- * Calculate the ideal position based on current time without any smoothing.
1277
- */
1278
- calculateIdealPosition(timeMs) {
1279
- if (!this.positions || this.positions.length === 0) {
1325
+ // Calculate the desired position based on time.
1326
+ const desired = this.calculateDesiredPosition(nowTimeMs);
1327
+ // If no desired position, return empty position.
1328
+ if (!desired.position) {
1329
+ this.currentAnimatedPos = null;
1330
+ this.currentTargetPos = null;
1280
1331
  return new Cesium.Cartesian3();
1281
1332
  }
1282
- // Before first position.
1283
- if (timeMs <= this.positions[0].dateTime.getTime()) {
1284
- this.lastCalcPosIndexLast = 0;
1285
- this.lastCalcPosIndexNext = 0;
1286
- return this.positions[0].pos3d || new Cesium.Cartesian3();
1287
- }
1288
- // After last position.
1289
- if (timeMs >= this.positions[this.positions.length - 1].dateTime.getTime()) {
1290
- const lastIndex = this.positions.length - 1;
1291
- this.lastCalcPosIndexLast = lastIndex;
1292
- this.lastCalcPosIndexNext = lastIndex;
1293
- return this.positions[lastIndex].pos3d || new Cesium.Cartesian3();
1294
- }
1295
- // Find the position before and after the current time.
1296
- let lastIndex = 0;
1297
- for (let i = 0; i < this.positions.length - 1; i++) {
1298
- if (timeMs >= this.positions[i].dateTime.getTime() &&
1299
- timeMs < this.positions[i + 1].dateTime.getTime()) {
1300
- lastIndex = i;
1301
- break;
1333
+ // Cache the desired position info for orientation calculations.
1334
+ this.lastDesiredPosIndex = desired.lastIndex;
1335
+ this.lastDesiredNextIndex = desired.nextIndex;
1336
+ // First time or no previous position - start here.
1337
+ if (!this.currentAnimatedPos) {
1338
+ // If we have a starting animation position, animate from it.
1339
+ if (this.animationStartPos) {
1340
+ this.currentTargetPos = desired.position;
1341
+ const progress = this.getAnimationProgress(currentRealTimeMs, this.animationStartTime);
1342
+ if (progress >= 1.0) {
1343
+ // Animation complete.
1344
+ this.currentAnimatedPos = desired.position;
1345
+ this.animationStartPos = null;
1346
+ this.animationStartTime = null;
1347
+ return desired.position;
1348
+ }
1349
+ else {
1350
+ // Continue animation.
1351
+ const easedProgress = this.easeInOutQuad(progress);
1352
+ this.currentAnimatedPos = Cesium.Cartesian3.lerp(this.animationStartPos, desired.position, easedProgress, new Cesium.Cartesian3());
1353
+ return this.currentAnimatedPos;
1354
+ }
1302
1355
  }
1303
- }
1304
- const last = this.positions[lastIndex];
1305
- this.lastCalcPosIndexLast = lastIndex;
1306
- // If we're exactly at this position's time.
1307
- if (timeMs === last.dateTime.getTime()) {
1308
- this.lastCalcPosIndexNext = lastIndex;
1309
- return last.pos3d || new Cesium.Cartesian3();
1310
- }
1311
- // Interpolate between surrounding positions.
1312
- const next = this.positions[lastIndex + 1];
1313
- if (!next) {
1314
- this.lastCalcPosIndexNext = lastIndex;
1315
- return last.pos3d || new Cesium.Cartesian3();
1316
- }
1317
- this.lastCalcPosIndexNext = lastIndex + 1;
1318
- try {
1319
- // Ensure both position vectors are valid.
1320
- if (!last.pos3d || !next.pos3d) {
1321
- return last.pos3d || next.pos3d || new Cesium.Cartesian3();
1356
+ else {
1357
+ // No animation, start at desired position.
1358
+ this.currentAnimatedPos = desired.position;
1359
+ this.currentTargetPos = desired.position;
1360
+ return desired.position;
1322
1361
  }
1323
- const progress = (timeMs - last.dateTime.getTime()) /
1324
- (next.dateTime.getTime() - last.dateTime.getTime());
1325
- return Cesium.Cartesian3.lerp(last.pos3d, next.pos3d, progress, new Cesium.Cartesian3());
1326
1362
  }
1327
- catch (e) {
1328
- console.error("Error in ideal position calculation: ", e);
1329
- return last.pos3d || new Cesium.Cartesian3();
1363
+ // Check if target has changed.
1364
+ const targetChanged = !this.currentTargetPos || !Cesium.Cartesian3.equals(this.currentTargetPos, desired.position);
1365
+ if (targetChanged) {
1366
+ // Target changed mid-animation - start new animation from current position.
1367
+ this.animationStartPos = this.currentAnimatedPos;
1368
+ this.animationStartTime = currentRealTimeMs;
1369
+ this.currentTargetPos = desired.position;
1370
+ }
1371
+ // Continue or start animation to target.
1372
+ if (this.animationStartPos && this.animationStartTime) {
1373
+ const progress = this.getAnimationProgress(currentRealTimeMs, this.animationStartTime);
1374
+ // Animation complete.
1375
+ if (progress >= 1.0) {
1376
+ this.currentAnimatedPos = desired.position;
1377
+ this.animationStartPos = null;
1378
+ this.animationStartTime = null;
1379
+ return desired.position;
1380
+ }
1381
+ // Continue animation.
1382
+ else {
1383
+ const easedProgress = this.easeInOutQuad(progress);
1384
+ this.currentAnimatedPos = Cesium.Cartesian3.lerp(this.animationStartPos, desired.position, easedProgress, new Cesium.Cartesian3());
1385
+ return this.currentAnimatedPos;
1386
+ }
1330
1387
  }
1388
+ // No animation needed - already at target.
1389
+ this.currentAnimatedPos = desired.position;
1390
+ return desired.position;
1391
+ }
1392
+ getAnimationProgress(currentTime, startTime) {
1393
+ const elapsed = currentTime - startTime;
1394
+ return Math.min(elapsed / this.animationDuration, 1.0);
1331
1395
  }
1332
1396
  /**
1333
- * Returns a series of positions to use for rendering the path..
1397
+ * Returns a series of positions to use for rendering the path.
1334
1398
  */
1335
1399
  GetSeries() {
1336
1400
  // Update at 30 fps.
@@ -1368,8 +1432,8 @@
1368
1432
  let add = nowDate >= new Date(pos.dateTime.getTime() - visibilityDuration / 2) &&
1369
1433
  nowDate <= new Date(pos.dateTime.getTime() + visibilityDuration / 2);
1370
1434
  // Also include the segment we're currently traversing.
1371
- if (!add && this.lastCalcPosIndexLast > -1 && this.lastCalcPosIndexNext > -1) {
1372
- add = i >= this.lastCalcPosIndexLast && i <= this.lastCalcPosIndexNext;
1435
+ if (!add && this.lastDesiredPosIndex > -1 && this.lastDesiredNextIndex > -1) {
1436
+ add = i >= this.lastDesiredPosIndex && i <= this.lastDesiredNextIndex;
1373
1437
  }
1374
1438
  if (add) {
1375
1439
  newPosses.push(pos.pos3d);
@@ -1407,10 +1471,10 @@
1407
1471
  }
1408
1472
  const nowTime = Cesium.JulianDate.toDate(now).getTime();
1409
1473
  try {
1410
- // Get last and next position indices.
1411
- const lastIndex = this.lastCalcPosIndexLast;
1412
- const nextIndex = this.lastCalcPosIndexNext;
1413
- // Validate indices.
1474
+ // Get current position indices.
1475
+ const lastIndex = this.lastDesiredPosIndex;
1476
+ const nextIndex = this.lastDesiredNextIndex;
1477
+ // Invalid indices.
1414
1478
  if (lastIndex < 0 || nextIndex < 0 ||
1415
1479
  lastIndex >= this.positions.length || nextIndex >= this.positions.length) {
1416
1480
  return this.lastCalcOrient || defaultQuaternion;
@@ -1420,6 +1484,17 @@
1420
1484
  if (!lastPos || !nextPos) {
1421
1485
  return this.lastCalcOrient || defaultQuaternion;
1422
1486
  }
1487
+ // Single position case - use its heading if available.
1488
+ if (lastIndex === nextIndex) {
1489
+ if (lastPos.heading !== null) {
1490
+ this.lastCalcOrient = Cesium.Transforms.headingPitchRollQuaternion(currentPosition, new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(lastPos.heading), Cesium.Math.toRadians(this.pitch), Cesium.Math.toRadians(this.roll)));
1491
+ this.lastCalcOrientTime = Date.now();
1492
+ return this.lastCalcOrient;
1493
+ }
1494
+ // No heading data and single position, return previous or default.
1495
+ return this.lastCalcOrient || defaultQuaternion;
1496
+ }
1497
+ // Two different positions - we can calculate orientation.
1423
1498
  // Use explicit heading values if available.
1424
1499
  if (lastPos.heading !== null && nextPos.heading !== null) {
1425
1500
  // Calculate interpolated heading.
@@ -1433,8 +1508,7 @@
1433
1508
  }
1434
1509
  // Calculate interpolation factor.
1435
1510
  let factor = 0;
1436
- if (lastIndex !== nextIndex &&
1437
- lastPos.dateTime.getTime() !== nextPos.dateTime.getTime()) {
1511
+ if (lastPos.dateTime.getTime() !== nextPos.dateTime.getTime()) {
1438
1512
  factor = (nowTime - lastPos.dateTime.getTime()) /
1439
1513
  (nextPos.dateTime.getTime() - lastPos.dateTime.getTime());
1440
1514
  factor = Math.max(0, Math.min(1, factor));
@@ -1447,7 +1521,7 @@
1447
1521
  // Create quaternion from heading, pitch, roll.
1448
1522
  this.lastCalcOrient = Cesium.Transforms.headingPitchRollQuaternion(currentPosition, new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(interpolatedHeading), Cesium.Math.toRadians(this.pitch), Cesium.Math.toRadians(this.roll)));
1449
1523
  }
1450
- // Calculate heading from position changes if not available.
1524
+ // Calculate heading from position changes if heading data not available.
1451
1525
  else {
1452
1526
  if (!lastPos.pos3d || !nextPos.pos3d) {
1453
1527
  return this.lastCalcOrient || defaultQuaternion;
@@ -6119,20 +6193,20 @@
6119
6193
  */
6120
6194
  function extractMetadataFromFileUrl(url) {
6121
6195
  var _a;
6122
- url = url.toLowerCase();
6196
+ const lowercased = url.toLowerCase();
6123
6197
  // Bzzt, invalid url format for our purposes.
6124
- if (!url.includes(".api.") || !url.includes("/file/")) {
6198
+ if (!lowercased.includes(".api.") || !lowercased.includes("/file/")) {
6125
6199
  return null;
6126
6200
  }
6127
6201
  url = url.replace("https://", "").replace("http://", "");
6128
6202
  let envId = BModels.Api.EEnv.PROD;
6129
- if (url.includes("-dev.net")) {
6203
+ if (lowercased.includes("-dev.net")) {
6130
6204
  envId = BModels.Api.EEnv.DEV;
6131
6205
  }
6132
- else if (url.includes("-stg.net")) {
6206
+ else if (lowercased.includes("-stg.net")) {
6133
6207
  envId = BModels.Api.EEnv.STG;
6134
6208
  }
6135
- else if (url.includes("-uat.net")) {
6209
+ else if (lowercased.includes("-uat.net")) {
6136
6210
  envId = BModels.Api.EEnv.UAT;
6137
6211
  }
6138
6212
  const parts = url.split("/");
@@ -6828,7 +6902,9 @@
6828
6902
  continue;
6829
6903
  }
6830
6904
  entityRemoveAddState.delete(entity.id);
6831
- viewer.entities.remove(entity);
6905
+ if (viewer.entities.contains(entity)) {
6906
+ viewer.entities.remove(entity);
6907
+ }
6832
6908
  }
6833
6909
  });
6834
6910
  }
@@ -6850,7 +6926,9 @@
6850
6926
  continue;
6851
6927
  }
6852
6928
  entityRemoveAddState.delete(entity.id);
6853
- viewer.entities.add(entity);
6929
+ if (!viewer.entities.contains(entity)) {
6930
+ viewer.entities.add(entity);
6931
+ }
6854
6932
  }
6855
6933
  });
6856
6934
  }
@@ -6953,7 +7031,7 @@
6953
7031
  * @returns
6954
7032
  */
6955
7033
  function Render(params) {
6956
- var _a, _b;
7034
+ var _a, _b, _c, _d;
6957
7035
  const entity = params.entity;
6958
7036
  if (!params.entityHistoric) {
6959
7037
  params.entityHistoric = [];
@@ -7055,6 +7133,7 @@
7055
7133
  }
7056
7134
  };
7057
7135
  let cEntity = params.rendered;
7136
+ let prevPos3d = cEntity ? GetCValue(params.viewer, cEntity.position) : null;
7058
7137
  if (!cEntity || !cEntity.model) {
7059
7138
  updateShouldShowTrack();
7060
7139
  if (!color) {
@@ -7144,12 +7223,11 @@
7144
7223
  cEntity.model.colorBlendAmount = new Cesium.ConstantProperty(blendAmount);
7145
7224
  cEntity.model.colorBlendMode = new Cesium.ConstantProperty(blendMode);
7146
7225
  cEntity.model.distanceDisplayCondition = new Cesium.ConstantProperty(exports.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
7147
- const prevPos3d = GetCValue(params.viewer, cEntity.position);
7148
7226
  let prevStartTime = null;
7149
7227
  if (cEntity.position && cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"]) {
7150
7228
  prevStartTime = cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"].GetAnimateFromDateTime();
7151
7229
  }
7152
- // If we have a series of time-based positions then we'll animate as time changes.
7230
+ // If we've loaded a set of series positions then we'll animate through them.
7153
7231
  const series = exports.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, heightRef, params.entityHistoric);
7154
7232
  if (series.length > 1) {
7155
7233
  animatePosition = new exports.CesiumAnimatedProperty.AnimatePositionSeries({
@@ -7164,17 +7242,50 @@
7164
7242
  cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"] = animatePosition;
7165
7243
  }
7166
7244
  else {
7245
+ const dateTimeStr = (_b = (_a = entity.Bruce.Outline) === null || _a === void 0 ? void 0 : _a.find(x => !!x.DateTime)) === null || _b === void 0 ? void 0 : _b.DateTime;
7246
+ const dateTime = dateTimeStr ? new Date(dateTimeStr) : null;
7167
7247
  const posChanged = !prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d);
7168
7248
  if (posChanged) {
7169
- animatePosition = new exports.CesiumAnimatedProperty.AnimatePosition({
7170
- durationMs: 200,
7171
- targetPos3d: pos3d,
7172
- viewer: params.viewer,
7173
- startPos3d: prevPos3d
7174
- });
7175
- cEntity.position = new Cesium.CallbackProperty(() => animatePosition.GetValue(), false);
7249
+ if (cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"]) {
7250
+ const prevAnimatePosition = cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"];
7251
+ animatePosition = prevAnimatePosition;
7252
+ animatePosition.AddPosition({
7253
+ pos3d: pos3d,
7254
+ dateTime: dateTime,
7255
+ heading: !EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading) ? null : heading
7256
+ });
7257
+ animatePosition.UpdatePitchRoll(pitch, roll);
7258
+ }
7259
+ else {
7260
+ let posses = [];
7261
+ const isLive = exports.ViewUtils.GetTimeDetails({ viewer: params.viewer }).isLive;
7262
+ if (prevPos3d && isLive) {
7263
+ posses.push({
7264
+ pos3d: prevPos3d,
7265
+ // Guess so that we can determine a direction of movement right away :)
7266
+ dateTime: new Date(dateTime.getTime() - 1000),
7267
+ heading: !EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading) ? null : heading
7268
+ });
7269
+ }
7270
+ posses.push({
7271
+ pos3d: pos3d,
7272
+ dateTime: dateTime,
7273
+ heading: !EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading) ? null : heading
7274
+ });
7275
+ animatePosition = new exports.CesiumAnimatedProperty.AnimatePositionSeries({
7276
+ posses: posses,
7277
+ viewer: params.viewer,
7278
+ pitch: pitch,
7279
+ roll: roll,
7280
+ animateFromPos3d: prevPos3d && !isLive ? prevPos3d : null,
7281
+ animateFromPos3dTimeStart: null
7282
+ });
7283
+ cEntity.position = new Cesium.CallbackProperty(() => animatePosition.GetValue(), false);
7284
+ cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"] = animatePosition;
7285
+ }
7176
7286
  }
7177
7287
  }
7288
+ // If we're animating position then we can animate orientation too based on the interpolated position.
7178
7289
  if (animatePosition && animatePosition instanceof exports.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetOrient) {
7179
7290
  cEntity.orientation = new Cesium.CallbackProperty(() => {
7180
7291
  return animatePosition.GetOrient();
@@ -7182,15 +7293,16 @@
7182
7293
  }
7183
7294
  else {
7184
7295
  const prevHeading = cEntity.model._heading;
7296
+ // Not worth animating.
7185
7297
  if (prevHeading == null || prevHeading == heading || isNaN(prevHeading)) {
7186
7298
  const hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
7187
7299
  const orient = Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr);
7188
7300
  cEntity.orientation = new Cesium.CallbackProperty(() => orient, true);
7189
7301
  }
7190
- // Animate orientation. We'll calculate the heading based on movement.
7302
+ // Animate the change.
7191
7303
  else {
7192
7304
  const animateHeading = new exports.CesiumAnimatedProperty.AnimateHeading({
7193
- durationMs: 200,
7305
+ durationMs: 500,
7194
7306
  targetHeading: heading,
7195
7307
  viewer: params.viewer,
7196
7308
  startHeading: prevHeading
@@ -7222,7 +7334,7 @@
7222
7334
  else {
7223
7335
  cEntity.model.scale = new Cesium.CallbackProperty(() => scale * styleScale, true);
7224
7336
  }
7225
- // We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
7337
+ // We'll use "SetDefaultColor" to update the internal reference and to allow for an animation.
7226
7338
  // cEntity.model.color = new Cesium.CallbackProperty(() => color, true);
7227
7339
  exports.CesiumEntityStyler.SetDefaultColor({
7228
7340
  color: color ? color : new Cesium.Color(),
@@ -7319,7 +7431,7 @@
7319
7431
  // Generate a polyline 'track' for the historic data.
7320
7432
  // We do this for historic data that exists and is moving.
7321
7433
  if (shouldShowTrack && animatePosition && animatePosition instanceof exports.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetSeries) {
7322
- const lStyle = (_b = (_a = params.fullStyle) === null || _a === void 0 ? void 0 : _a.polylineStyle) !== null && _b !== void 0 ? _b : {};
7434
+ const lStyle = (_d = (_c = params.fullStyle) === null || _c === void 0 ? void 0 : _c.polylineStyle) !== null && _d !== void 0 ? _d : {};
7323
7435
  const bColor = lStyle.lineColor ? BModels.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
7324
7436
  const cColor = bColor ? ColorToCColor(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
7325
7437
  let width = lStyle.lineWidth ? EnsureNumber(BModels.Calculator.GetNumber(lStyle.lineWidth, entity, params.tags)) : 2;
@@ -14915,9 +15027,7 @@
14915
15027
  this.renderPriority = 2;
14916
15028
  }
14917
15029
  if (!this.getter) {
14918
- this.getter = new BatchedDataGetter.Getter(this.item.BruceEntity.EntityIds, this.monitor, BATCH_SIZE$2,
14919
- // Don't emit the same Entity multiple times.
14920
- true);
15030
+ this.getter = new BatchedDataGetter.Getter(this.item.BruceEntity.EntityIds, this.monitor, BATCH_SIZE$2, false);
14921
15031
  this.getterSub = this.getter.OnUpdate.Subscribe((ids) => {
14922
15032
  this.onGetterUpdate(ids);
14923
15033
  });
@@ -33029,7 +33139,7 @@
33029
33139
  }
33030
33140
  }
33031
33141
 
33032
- const VERSION = "5.9.4";
33142
+ const VERSION = "5.9.6";
33033
33143
 
33034
33144
  exports.VERSION = VERSION;
33035
33145
  exports.isOutlineChanged = isOutlineChanged;