bruce-cesium 5.9.5 → 5.9.7
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.
- package/dist/bruce-cesium.es5.js +274 -156
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +272 -154
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/cesium-animated-property.js +216 -136
- package/dist/lib/rendering/cesium-animated-property.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-model3d.js +49 -14
- package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -1
- package/dist/lib/rendering/visual-register-culler.js +6 -2
- package/dist/lib/rendering/visual-register-culler.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/cesium-animated-property.d.ts +17 -15
- package/package.json +2 -2
package/dist/bruce-cesium.umd.js
CHANGED
|
@@ -1142,48 +1142,70 @@
|
|
|
1142
1142
|
*/
|
|
1143
1143
|
class AnimatePositionSeries {
|
|
1144
1144
|
constructor(params) {
|
|
1145
|
-
//
|
|
1146
|
-
this.
|
|
1147
|
-
this.
|
|
1148
|
-
this.
|
|
1149
|
-
|
|
1145
|
+
// Animation state.
|
|
1146
|
+
this.currentAnimatedPos = null;
|
|
1147
|
+
this.actualTargetPos = null;
|
|
1148
|
+
this.animationStartPos = null;
|
|
1149
|
+
this.animationStartTime = null;
|
|
1150
|
+
this.animationDuration = 350;
|
|
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
|
-
|
|
1164
|
+
this.processHeadings();
|
|
1165
|
+
this.sortPositions();
|
|
1166
|
+
// Initialize animation from starting position if provided.
|
|
1164
1167
|
if (params.animateFromPos3d) {
|
|
1165
|
-
this.
|
|
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
|
|
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.
|
|
1173
|
+
this.animationStartTime = currentTime;
|
|
1172
1174
|
}
|
|
1173
1175
|
else {
|
|
1174
|
-
this.
|
|
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
|
-
|
|
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
|
-
|
|
1186
|
-
|
|
1206
|
+
invalidateCache() {
|
|
1207
|
+
this.lastCalcSeriesTime = null;
|
|
1208
|
+
this.lastCalcOrientTime = null;
|
|
1187
1209
|
}
|
|
1188
1210
|
/**
|
|
1189
1211
|
* Pre-process headings in the series.
|
|
@@ -1207,130 +1229,178 @@
|
|
|
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
|
-
*
|
|
1236
|
+
* Calculate the desired position based on current time without any animation smoothing.
|
|
1218
1237
|
*/
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
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
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
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
|
-
|
|
1231
|
-
|
|
1232
|
-
return
|
|
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
|
+
};
|
|
1233
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
|
+
}
|
|
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
|
-
let
|
|
1240
|
-
if (!
|
|
1241
|
-
|
|
1319
|
+
let viewerTime = this.viewer.scene.lastRenderTime;
|
|
1320
|
+
if (!viewerTime) {
|
|
1321
|
+
viewerTime = this.viewer.clock.currentTime;
|
|
1242
1322
|
}
|
|
1243
|
-
const
|
|
1323
|
+
const viewerTimeMs = Cesium.JulianDate.toDate(viewerTime).getTime();
|
|
1244
1324
|
const currentRealTimeMs = Date.now();
|
|
1245
|
-
// Calculate the
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
this.
|
|
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(viewerTimeMs);
|
|
1327
|
+
if (!desired.position) {
|
|
1328
|
+
this.currentAnimatedPos = null;
|
|
1329
|
+
this.actualTargetPos = null;
|
|
1280
1330
|
return new Cesium.Cartesian3();
|
|
1281
1331
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
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;
|
|
1302
|
-
}
|
|
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();
|
|
1332
|
+
this.lastDesiredPosIndex = desired.lastIndex;
|
|
1333
|
+
this.lastDesiredNextIndex = desired.nextIndex;
|
|
1334
|
+
// Determine the desired position without interpolation.
|
|
1335
|
+
let discreteTarget;
|
|
1336
|
+
if (desired.lastIndex === desired.nextIndex) {
|
|
1337
|
+
discreteTarget = this.positions[desired.lastIndex].pos3d;
|
|
1310
1338
|
}
|
|
1311
|
-
//
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1339
|
+
// Use the next position as the target.
|
|
1340
|
+
else {
|
|
1341
|
+
discreteTarget = this.positions[desired.nextIndex].pos3d;
|
|
1342
|
+
}
|
|
1343
|
+
// Check if we have a new actual target
|
|
1344
|
+
const actualTargetChanged = !this.actualTargetPos || !Cesium.Cartesian3.equals(this.actualTargetPos, discreteTarget);
|
|
1345
|
+
// First time or no previous position - start here.
|
|
1346
|
+
if (!this.currentAnimatedPos) {
|
|
1347
|
+
if (this.animationStartPos) {
|
|
1348
|
+
this.actualTargetPos = discreteTarget;
|
|
1349
|
+
const progress = this.getAnimationProgress(currentRealTimeMs, this.animationStartTime);
|
|
1350
|
+
// Animation from start position complete.
|
|
1351
|
+
if (progress >= 1.0) {
|
|
1352
|
+
this.currentAnimatedPos = desired.position;
|
|
1353
|
+
this.animationStartPos = null;
|
|
1354
|
+
this.animationStartTime = null;
|
|
1355
|
+
return desired.position;
|
|
1356
|
+
}
|
|
1357
|
+
// Still animating from initial position.
|
|
1358
|
+
else {
|
|
1359
|
+
const easedProgress = this.easeInOutQuad(progress);
|
|
1360
|
+
this.currentAnimatedPos = Cesium.Cartesian3.lerp(this.animationStartPos, desired.position, easedProgress, new Cesium.Cartesian3());
|
|
1361
|
+
return this.currentAnimatedPos;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
// No initial animation needed.
|
|
1365
|
+
else {
|
|
1366
|
+
this.currentAnimatedPos = desired.position;
|
|
1367
|
+
this.actualTargetPos = discreteTarget;
|
|
1368
|
+
return desired.position;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
// Target changed.
|
|
1372
|
+
if (actualTargetChanged) {
|
|
1373
|
+
this.animationStartPos = this.currentAnimatedPos;
|
|
1374
|
+
this.animationStartTime = currentRealTimeMs;
|
|
1375
|
+
this.actualTargetPos = discreteTarget;
|
|
1376
|
+
}
|
|
1377
|
+
// Continue or start animation to target if we have an active animation.
|
|
1378
|
+
if (this.animationStartPos && this.animationStartTime) {
|
|
1379
|
+
const progress = this.getAnimationProgress(currentRealTimeMs, this.animationStartTime);
|
|
1380
|
+
// Animation complete.
|
|
1381
|
+
if (progress >= 1.0) {
|
|
1382
|
+
this.currentAnimatedPos = desired.position;
|
|
1383
|
+
this.animationStartPos = null;
|
|
1384
|
+
this.animationStartTime = null;
|
|
1385
|
+
return desired.position;
|
|
1386
|
+
}
|
|
1387
|
+
// Continue animation to interpolated position.
|
|
1388
|
+
else {
|
|
1389
|
+
const easedProgress = this.easeInOutQuad(progress);
|
|
1390
|
+
this.currentAnimatedPos = Cesium.Cartesian3.lerp(this.animationStartPos, desired.position, easedProgress, new Cesium.Cartesian3());
|
|
1391
|
+
return this.currentAnimatedPos;
|
|
1322
1392
|
}
|
|
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
|
-
}
|
|
1327
|
-
catch (e) {
|
|
1328
|
-
console.error("Error in ideal position calculation: ", e);
|
|
1329
|
-
return last.pos3d || new Cesium.Cartesian3();
|
|
1330
1393
|
}
|
|
1394
|
+
// No active animation - follow interpolated path directly.
|
|
1395
|
+
this.currentAnimatedPos = desired.position;
|
|
1396
|
+
return desired.position;
|
|
1397
|
+
}
|
|
1398
|
+
getAnimationProgress(currentTime, startTime) {
|
|
1399
|
+
const elapsed = currentTime - startTime;
|
|
1400
|
+
return Math.min(elapsed / this.animationDuration, 1.0);
|
|
1331
1401
|
}
|
|
1332
1402
|
/**
|
|
1333
|
-
* Returns a series of positions to use for rendering the path
|
|
1403
|
+
* Returns a series of positions to use for rendering the path.
|
|
1334
1404
|
*/
|
|
1335
1405
|
GetSeries() {
|
|
1336
1406
|
// Update at 30 fps.
|
|
@@ -1354,8 +1424,7 @@
|
|
|
1354
1424
|
this.lastCalcSeriesPos3d = [];
|
|
1355
1425
|
return [];
|
|
1356
1426
|
}
|
|
1357
|
-
const totalDuration = this.positions[this.positions.length - 1].dateTime.getTime() -
|
|
1358
|
-
this.positions[0].dateTime.getTime();
|
|
1427
|
+
const totalDuration = this.positions[this.positions.length - 1].dateTime.getTime() - this.positions[0].dateTime.getTime();
|
|
1359
1428
|
// Percentage of the polyline to be visible before and after each point.
|
|
1360
1429
|
const visibilityPercentage = 0.05; // 5%
|
|
1361
1430
|
const visibilityDuration = totalDuration * visibilityPercentage;
|
|
@@ -1363,13 +1432,14 @@
|
|
|
1363
1432
|
const newPosses = [];
|
|
1364
1433
|
for (let i = 0; i < this.positions.length; i++) {
|
|
1365
1434
|
const pos = this.positions[i];
|
|
1366
|
-
if (!pos.pos3d)
|
|
1435
|
+
if (!pos.pos3d) {
|
|
1367
1436
|
continue;
|
|
1437
|
+
}
|
|
1368
1438
|
let add = nowDate >= new Date(pos.dateTime.getTime() - visibilityDuration / 2) &&
|
|
1369
1439
|
nowDate <= new Date(pos.dateTime.getTime() + visibilityDuration / 2);
|
|
1370
1440
|
// Also include the segment we're currently traversing.
|
|
1371
|
-
if (!add && this.
|
|
1372
|
-
add = i >= this.
|
|
1441
|
+
if (!add && this.lastDesiredPosIndex > -1 && this.lastDesiredNextIndex > -1) {
|
|
1442
|
+
add = i >= this.lastDesiredPosIndex && i <= this.lastDesiredNextIndex;
|
|
1373
1443
|
}
|
|
1374
1444
|
if (add) {
|
|
1375
1445
|
newPosses.push(pos.pos3d);
|
|
@@ -1407,10 +1477,10 @@
|
|
|
1407
1477
|
}
|
|
1408
1478
|
const nowTime = Cesium.JulianDate.toDate(now).getTime();
|
|
1409
1479
|
try {
|
|
1410
|
-
// Get
|
|
1411
|
-
const lastIndex = this.
|
|
1412
|
-
const nextIndex = this.
|
|
1413
|
-
//
|
|
1480
|
+
// Get current position indices.
|
|
1481
|
+
const lastIndex = this.lastDesiredPosIndex;
|
|
1482
|
+
const nextIndex = this.lastDesiredNextIndex;
|
|
1483
|
+
// Invalid indices.
|
|
1414
1484
|
if (lastIndex < 0 || nextIndex < 0 ||
|
|
1415
1485
|
lastIndex >= this.positions.length || nextIndex >= this.positions.length) {
|
|
1416
1486
|
return this.lastCalcOrient || defaultQuaternion;
|
|
@@ -1420,6 +1490,17 @@
|
|
|
1420
1490
|
if (!lastPos || !nextPos) {
|
|
1421
1491
|
return this.lastCalcOrient || defaultQuaternion;
|
|
1422
1492
|
}
|
|
1493
|
+
// Single position case - use its heading if available.
|
|
1494
|
+
if (lastIndex === nextIndex) {
|
|
1495
|
+
if (lastPos.heading !== null) {
|
|
1496
|
+
this.lastCalcOrient = Cesium.Transforms.headingPitchRollQuaternion(currentPosition, new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(lastPos.heading), Cesium.Math.toRadians(this.pitch), Cesium.Math.toRadians(this.roll)));
|
|
1497
|
+
this.lastCalcOrientTime = Date.now();
|
|
1498
|
+
return this.lastCalcOrient;
|
|
1499
|
+
}
|
|
1500
|
+
// No heading data and single position, return previous or default.
|
|
1501
|
+
return this.lastCalcOrient || defaultQuaternion;
|
|
1502
|
+
}
|
|
1503
|
+
// Two different positions - we can calculate orientation.
|
|
1423
1504
|
// Use explicit heading values if available.
|
|
1424
1505
|
if (lastPos.heading !== null && nextPos.heading !== null) {
|
|
1425
1506
|
// Calculate interpolated heading.
|
|
@@ -1433,8 +1514,7 @@
|
|
|
1433
1514
|
}
|
|
1434
1515
|
// Calculate interpolation factor.
|
|
1435
1516
|
let factor = 0;
|
|
1436
|
-
if (
|
|
1437
|
-
lastPos.dateTime.getTime() !== nextPos.dateTime.getTime()) {
|
|
1517
|
+
if (lastPos.dateTime.getTime() !== nextPos.dateTime.getTime()) {
|
|
1438
1518
|
factor = (nowTime - lastPos.dateTime.getTime()) /
|
|
1439
1519
|
(nextPos.dateTime.getTime() - lastPos.dateTime.getTime());
|
|
1440
1520
|
factor = Math.max(0, Math.min(1, factor));
|
|
@@ -1447,7 +1527,7 @@
|
|
|
1447
1527
|
// Create quaternion from heading, pitch, roll.
|
|
1448
1528
|
this.lastCalcOrient = Cesium.Transforms.headingPitchRollQuaternion(currentPosition, new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(interpolatedHeading), Cesium.Math.toRadians(this.pitch), Cesium.Math.toRadians(this.roll)));
|
|
1449
1529
|
}
|
|
1450
|
-
// Calculate heading from position changes if not available.
|
|
1530
|
+
// Calculate heading from position changes if heading data not available.
|
|
1451
1531
|
else {
|
|
1452
1532
|
if (!lastPos.pos3d || !nextPos.pos3d) {
|
|
1453
1533
|
return this.lastCalcOrient || defaultQuaternion;
|
|
@@ -6828,7 +6908,9 @@
|
|
|
6828
6908
|
continue;
|
|
6829
6909
|
}
|
|
6830
6910
|
entityRemoveAddState.delete(entity.id);
|
|
6831
|
-
viewer.entities.
|
|
6911
|
+
if (viewer.entities.contains(entity)) {
|
|
6912
|
+
viewer.entities.remove(entity);
|
|
6913
|
+
}
|
|
6832
6914
|
}
|
|
6833
6915
|
});
|
|
6834
6916
|
}
|
|
@@ -6850,7 +6932,9 @@
|
|
|
6850
6932
|
continue;
|
|
6851
6933
|
}
|
|
6852
6934
|
entityRemoveAddState.delete(entity.id);
|
|
6853
|
-
viewer.entities.
|
|
6935
|
+
if (!viewer.entities.contains(entity)) {
|
|
6936
|
+
viewer.entities.add(entity);
|
|
6937
|
+
}
|
|
6854
6938
|
}
|
|
6855
6939
|
});
|
|
6856
6940
|
}
|
|
@@ -6953,7 +7037,7 @@
|
|
|
6953
7037
|
* @returns
|
|
6954
7038
|
*/
|
|
6955
7039
|
function Render(params) {
|
|
6956
|
-
var _a, _b;
|
|
7040
|
+
var _a, _b, _c, _d;
|
|
6957
7041
|
const entity = params.entity;
|
|
6958
7042
|
if (!params.entityHistoric) {
|
|
6959
7043
|
params.entityHistoric = [];
|
|
@@ -7055,6 +7139,7 @@
|
|
|
7055
7139
|
}
|
|
7056
7140
|
};
|
|
7057
7141
|
let cEntity = params.rendered;
|
|
7142
|
+
let prevPos3d = cEntity ? GetCValue(params.viewer, cEntity.position) : null;
|
|
7058
7143
|
if (!cEntity || !cEntity.model) {
|
|
7059
7144
|
updateShouldShowTrack();
|
|
7060
7145
|
if (!color) {
|
|
@@ -7144,12 +7229,11 @@
|
|
|
7144
7229
|
cEntity.model.colorBlendAmount = new Cesium.ConstantProperty(blendAmount);
|
|
7145
7230
|
cEntity.model.colorBlendMode = new Cesium.ConstantProperty(blendMode);
|
|
7146
7231
|
cEntity.model.distanceDisplayCondition = new Cesium.ConstantProperty(exports.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
7147
|
-
const prevPos3d = GetCValue(params.viewer, cEntity.position);
|
|
7148
7232
|
let prevStartTime = null;
|
|
7149
7233
|
if (cEntity.position && cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"]) {
|
|
7150
7234
|
prevStartTime = cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"].GetAnimateFromDateTime();
|
|
7151
7235
|
}
|
|
7152
|
-
// If we
|
|
7236
|
+
// If we've loaded a set of series positions then we'll animate through them.
|
|
7153
7237
|
const series = exports.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, heightRef, params.entityHistoric);
|
|
7154
7238
|
if (series.length > 1) {
|
|
7155
7239
|
animatePosition = new exports.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
@@ -7164,17 +7248,50 @@
|
|
|
7164
7248
|
cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"] = animatePosition;
|
|
7165
7249
|
}
|
|
7166
7250
|
else {
|
|
7251
|
+
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;
|
|
7252
|
+
const dateTime = dateTimeStr ? new Date(dateTimeStr) : null;
|
|
7167
7253
|
const posChanged = !prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d);
|
|
7168
7254
|
if (posChanged) {
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7255
|
+
if (cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"]) {
|
|
7256
|
+
const prevAnimatePosition = cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"];
|
|
7257
|
+
animatePosition = prevAnimatePosition;
|
|
7258
|
+
animatePosition.AddPosition({
|
|
7259
|
+
pos3d: pos3d,
|
|
7260
|
+
dateTime: dateTime,
|
|
7261
|
+
heading: !EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading) ? null : heading
|
|
7262
|
+
});
|
|
7263
|
+
animatePosition.UpdatePitchRoll(pitch, roll);
|
|
7264
|
+
}
|
|
7265
|
+
else {
|
|
7266
|
+
let posses = [];
|
|
7267
|
+
const isLive = exports.ViewUtils.GetTimeDetails({ viewer: params.viewer }).isLive;
|
|
7268
|
+
if (prevPos3d && isLive) {
|
|
7269
|
+
posses.push({
|
|
7270
|
+
pos3d: prevPos3d,
|
|
7271
|
+
// Guess so that we can determine a direction of movement right away :)
|
|
7272
|
+
dateTime: new Date(dateTime.getTime() - 1000),
|
|
7273
|
+
heading: !EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading) ? null : heading
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7276
|
+
posses.push({
|
|
7277
|
+
pos3d: pos3d,
|
|
7278
|
+
dateTime: dateTime,
|
|
7279
|
+
heading: !EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading) ? null : heading
|
|
7280
|
+
});
|
|
7281
|
+
animatePosition = new exports.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
7282
|
+
posses: posses,
|
|
7283
|
+
viewer: params.viewer,
|
|
7284
|
+
pitch: pitch,
|
|
7285
|
+
roll: roll,
|
|
7286
|
+
animateFromPos3d: prevPos3d && !isLive ? prevPos3d : null,
|
|
7287
|
+
animateFromPos3dTimeStart: null
|
|
7288
|
+
});
|
|
7289
|
+
cEntity.position = new Cesium.CallbackProperty(() => animatePosition.GetValue(), false);
|
|
7290
|
+
cEntity.position["CesiumAnimatedProperty.AnimatePositionSeries"] = animatePosition;
|
|
7291
|
+
}
|
|
7176
7292
|
}
|
|
7177
7293
|
}
|
|
7294
|
+
// If we're animating position then we can animate orientation too based on the interpolated position.
|
|
7178
7295
|
if (animatePosition && animatePosition instanceof exports.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetOrient) {
|
|
7179
7296
|
cEntity.orientation = new Cesium.CallbackProperty(() => {
|
|
7180
7297
|
return animatePosition.GetOrient();
|
|
@@ -7182,15 +7299,16 @@
|
|
|
7182
7299
|
}
|
|
7183
7300
|
else {
|
|
7184
7301
|
const prevHeading = cEntity.model._heading;
|
|
7302
|
+
// Not worth animating.
|
|
7185
7303
|
if (prevHeading == null || prevHeading == heading || isNaN(prevHeading)) {
|
|
7186
7304
|
const hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
|
|
7187
7305
|
const orient = Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr);
|
|
7188
7306
|
cEntity.orientation = new Cesium.CallbackProperty(() => orient, true);
|
|
7189
7307
|
}
|
|
7190
|
-
// Animate
|
|
7308
|
+
// Animate the change.
|
|
7191
7309
|
else {
|
|
7192
7310
|
const animateHeading = new exports.CesiumAnimatedProperty.AnimateHeading({
|
|
7193
|
-
durationMs:
|
|
7311
|
+
durationMs: 500,
|
|
7194
7312
|
targetHeading: heading,
|
|
7195
7313
|
viewer: params.viewer,
|
|
7196
7314
|
startHeading: prevHeading
|
|
@@ -7222,7 +7340,7 @@
|
|
|
7222
7340
|
else {
|
|
7223
7341
|
cEntity.model.scale = new Cesium.CallbackProperty(() => scale * styleScale, true);
|
|
7224
7342
|
}
|
|
7225
|
-
// We'll use "SetDefaultColor" to
|
|
7343
|
+
// We'll use "SetDefaultColor" to update the internal reference and to allow for an animation.
|
|
7226
7344
|
// cEntity.model.color = new Cesium.CallbackProperty(() => color, true);
|
|
7227
7345
|
exports.CesiumEntityStyler.SetDefaultColor({
|
|
7228
7346
|
color: color ? color : new Cesium.Color(),
|
|
@@ -7319,7 +7437,7 @@
|
|
|
7319
7437
|
// Generate a polyline 'track' for the historic data.
|
|
7320
7438
|
// We do this for historic data that exists and is moving.
|
|
7321
7439
|
if (shouldShowTrack && animatePosition && animatePosition instanceof exports.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetSeries) {
|
|
7322
|
-
const lStyle = (
|
|
7440
|
+
const lStyle = (_d = (_c = params.fullStyle) === null || _c === void 0 ? void 0 : _c.polylineStyle) !== null && _d !== void 0 ? _d : {};
|
|
7323
7441
|
const bColor = lStyle.lineColor ? BModels.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
|
|
7324
7442
|
const cColor = bColor ? ColorToCColor(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
7325
7443
|
let width = lStyle.lineWidth ? EnsureNumber(BModels.Calculator.GetNumber(lStyle.lineWidth, entity, params.tags)) : 2;
|
|
@@ -33027,7 +33145,7 @@
|
|
|
33027
33145
|
}
|
|
33028
33146
|
}
|
|
33029
33147
|
|
|
33030
|
-
const VERSION = "5.9.
|
|
33148
|
+
const VERSION = "5.9.7";
|
|
33031
33149
|
|
|
33032
33150
|
exports.VERSION = VERSION;
|
|
33033
33151
|
exports.isOutlineChanged = isOutlineChanged;
|