bruce-cesium 3.8.0 → 3.8.2

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, ProjectViewTile, DelayQueue, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, ObjectUtils, Bounds, Api, EntityRelationType, ENVIRONMENT, EntityCoords, EntitySource, MenuItem, EntityRelation, ProgramKey, AbstractApi, ProjectViewBookmark, EntityAttachment, EntityAttachmentType, EntityAttribute, ProjectView, ProjectViewLegacyTile, Camera } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, GeoJsonDataSource, SceneMode, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, OrthographicFrustum, EasingFunction, SceneTransforms, EllipsoidTerrainProvider, CesiumInspector, defined, ClockRange, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, PolygonPipeline, Cesium3DTileset, Matrix4, Matrix3, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, BoundingSphere, GeometryInstance, ScreenSpaceEventHandler, ScreenSpaceEventType, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, CzmlDataSource, Quaternion, Intersect } from 'cesium';
3
+ import { Cartographic, Cartesian2, Math as Math$1, Cartesian3, CallbackProperty, Color, HeightReference, Rectangle, JulianDate, DistanceDisplayCondition, NearFarScalar, Model, Entity, HorizontalOrigin, VerticalOrigin, ConstantProperty, ConstantPositionProperty, ClassificationType, ArcType, CornerType, ShadowMode, PolygonHierarchy, PolylineGraphics, ColorMaterialProperty, ColorBlendMode, HeadingPitchRoll, Transforms, Primitive, Cesium3DTileFeature, SceneMode, GeoJsonDataSource, Cesium3DTileColorBlendMode, HeadingPitchRange, Ion, Cesium3DTileStyle, KmlDataSource, SceneTransforms, OrthographicFrustum, EasingFunction, EllipsoidTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, CesiumTerrainProvider, Cesium3DTileset, Matrix4, Matrix3, IonResource, CesiumInspector, defined, ClockRange, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, BoundingSphere, GeometryInstance, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, ScreenSpaceEventHandler, ScreenSpaceEventType, CzmlDataSource, Quaternion, Intersect } from 'cesium';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -931,6 +931,20 @@ function getNumber(viewer, obj) {
931
931
  }
932
932
  return value;
933
933
  }
934
+ function getPosition(viewer, obj) {
935
+ var value = null;
936
+ if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
937
+ var date = viewer.scene.lastRenderTime;
938
+ if (!date) {
939
+ date = viewer.clock.currentTime;
940
+ }
941
+ value = obj.getValue(date);
942
+ }
943
+ else {
944
+ value = obj;
945
+ }
946
+ return value;
947
+ }
934
948
  /**
935
949
  * Returns if a given visual is alive and in the scene.
936
950
  * @param viewer
@@ -985,7 +999,7 @@ var CesiumAnimatedProperty;
985
999
  function AnimateColor(params) {
986
1000
  var _a;
987
1001
  this.viewer = params.viewer;
988
- this.color = params.color;
1002
+ this.targetColor = params.targetColor;
989
1003
  this.durationMs = params.durationMs;
990
1004
  this.startColor = getColor(this.viewer, params.startColor);
991
1005
  if ((_a = this.startColor) === null || _a === void 0 ? void 0 : _a.clone) {
@@ -1006,18 +1020,18 @@ var CesiumAnimatedProperty;
1006
1020
  var elapsedMs = now.getTime() - this.startTime.getTime();
1007
1021
  // Animation over.
1008
1022
  if (elapsedMs >= this.durationMs) {
1009
- return this.color;
1023
+ return this.targetColor;
1010
1024
  }
1011
1025
  try {
1012
1026
  var progress = elapsedMs / this.durationMs;
1013
- return Color.lerp(this.startColor, this.color, progress, new Color());
1027
+ return Color.lerp(this.startColor, this.targetColor, progress, new Color());
1014
1028
  }
1015
1029
  catch (e) {
1016
1030
  console.error(e);
1017
1031
  }
1018
1032
  // Failed to calculate color.
1019
1033
  // We'll just return the target color.
1020
- return this.color;
1034
+ return this.targetColor;
1021
1035
  };
1022
1036
  /**
1023
1037
  * Returns the calculated color as a material property.
@@ -1035,7 +1049,7 @@ var CesiumAnimatedProperty;
1035
1049
  this.paused = false;
1036
1050
  this.paused = Boolean(params.startPaused);
1037
1051
  this.viewer = params.viewer;
1038
- this.value = params.value;
1052
+ this.targetValue = params.targetValue;
1039
1053
  this.durationMs = params.durationMs;
1040
1054
  this.startValue = getNumber(this.viewer, params.startValue);
1041
1055
  if (!this.startValue) {
@@ -1059,18 +1073,18 @@ var CesiumAnimatedProperty;
1059
1073
  var elapsedMs = now.getTime() - this.startTime.getTime();
1060
1074
  // Animation over.
1061
1075
  if (elapsedMs >= this.durationMs) {
1062
- return this.value;
1076
+ return this.targetValue;
1063
1077
  }
1064
1078
  try {
1065
1079
  var progress = elapsedMs / this.durationMs;
1066
- return Math$1.lerp(this.startValue, this.value, progress);
1080
+ return Math$1.lerp(this.startValue, this.targetValue, progress);
1067
1081
  }
1068
1082
  catch (e) {
1069
1083
  console.error(e);
1070
1084
  }
1071
1085
  // Failed to calculate value.
1072
1086
  // We'll just return the target value.
1073
- return this.value;
1087
+ return this.targetValue;
1074
1088
  };
1075
1089
  return AnimateNumber;
1076
1090
  }());
@@ -1093,7 +1107,7 @@ var CesiumAnimatedProperty;
1093
1107
  * @returns
1094
1108
  */
1095
1109
  function AnimateTFeatureColor(params) {
1096
- var viewer = params.viewer, feature = params.feature, color = params.color, startColor = params.startColor, durationMs = params.durationMs;
1110
+ var viewer = params.viewer, feature = params.feature, color = params.targetColor, startColor = params.startColor, durationMs = params.durationMs;
1097
1111
  ClearTFeatureColorAnimation(feature);
1098
1112
  if (!startColor) {
1099
1113
  if (feature.color) {
@@ -1174,6 +1188,75 @@ var CesiumAnimatedProperty;
1174
1188
  }
1175
1189
  }
1176
1190
  CesiumAnimatedProperty.ClearTFeatureColorAnimation = ClearTFeatureColorAnimation;
1191
+ var AnimatePosition = /** @class */ (function () {
1192
+ function AnimatePosition(params) {
1193
+ this.viewer = params.viewer;
1194
+ this.targetPos3d = params.targetPos3d;
1195
+ this.durationMs = params.durationMs;
1196
+ this.startPos3d = getPosition(this.viewer, params.startPos3d);
1197
+ if (!this.startPos3d) {
1198
+ this.startPos3d = Cartesian3.clone(this.targetPos3d);
1199
+ }
1200
+ this.startTime = new Date();
1201
+ }
1202
+ AnimatePosition.prototype.GetValue = function () {
1203
+ var now = new Date();
1204
+ var elapsedMs = now.getTime() - this.startTime.getTime();
1205
+ // Animation over.
1206
+ if (elapsedMs >= this.durationMs) {
1207
+ return this.targetPos3d;
1208
+ }
1209
+ try {
1210
+ var progress = elapsedMs / this.durationMs;
1211
+ return Cartesian3.lerp(this.startPos3d, this.targetPos3d, progress, new Cartesian3());
1212
+ }
1213
+ catch (e) {
1214
+ console.error(e);
1215
+ }
1216
+ // Failed to calculate value.
1217
+ // We'll just return the target value.
1218
+ return this.targetPos3d;
1219
+ };
1220
+ return AnimatePosition;
1221
+ }());
1222
+ CesiumAnimatedProperty.AnimatePosition = AnimatePosition;
1223
+ var AnimateHeading = /** @class */ (function () {
1224
+ function AnimateHeading(params) {
1225
+ this.viewer = params.viewer;
1226
+ this.targetHeadingDeg = params.targetHeading;
1227
+ this.durationMs = params.durationMs;
1228
+ this.startHeadingDeg = getNumber(this.viewer, params.startHeading);
1229
+ if (!this.startHeadingDeg) {
1230
+ this.startHeadingDeg = 0;
1231
+ }
1232
+ this.startTime = new Date();
1233
+ }
1234
+ AnimateHeading.prototype.IsDone = function () {
1235
+ var now = new Date();
1236
+ var elapsedMs = now.getTime() - this.startTime.getTime();
1237
+ return elapsedMs >= this.durationMs;
1238
+ };
1239
+ AnimateHeading.prototype.GetValue = function () {
1240
+ var now = new Date();
1241
+ var elapsedMs = now.getTime() - this.startTime.getTime();
1242
+ // Animation over.
1243
+ if (elapsedMs >= this.durationMs) {
1244
+ return this.targetHeadingDeg;
1245
+ }
1246
+ try {
1247
+ var progress = elapsedMs / this.durationMs;
1248
+ return Math$1.lerp(this.startHeadingDeg, this.targetHeadingDeg, progress);
1249
+ }
1250
+ catch (e) {
1251
+ console.error(e);
1252
+ }
1253
+ // Failed to calculate value.
1254
+ // We'll just return the target value.
1255
+ return this.targetHeadingDeg;
1256
+ };
1257
+ return AnimateHeading;
1258
+ }());
1259
+ CesiumAnimatedProperty.AnimateHeading = AnimateHeading;
1177
1260
  })(CesiumAnimatedProperty || (CesiumAnimatedProperty = {}));
1178
1261
 
1179
1262
  /**
@@ -1373,7 +1456,7 @@ function refreshColor(viewer, graphic, opacity) {
1373
1456
  }
1374
1457
  else {
1375
1458
  CesiumAnimatedProperty.AnimateTFeatureColor({
1376
- color: color.clone(),
1459
+ targetColor: color.clone(),
1377
1460
  durationMs: animateMs,
1378
1461
  feature: graphic,
1379
1462
  viewer: viewer,
@@ -1384,7 +1467,7 @@ function refreshColor(viewer, graphic, opacity) {
1384
1467
  else if (graphic instanceof ModelGraphics) {
1385
1468
  // graphic.color = new Cesium.ConstantProperty(color);
1386
1469
  var animateColor_1 = new CesiumAnimatedProperty.AnimateColor({
1387
- color: color,
1470
+ targetColor: color,
1388
1471
  durationMs: animateMs,
1389
1472
  viewer: viewer,
1390
1473
  startColor: graphic.color
@@ -1408,7 +1491,7 @@ function refreshColor(viewer, graphic, opacity) {
1408
1491
  else if (graphic instanceof PointGraphics) {
1409
1492
  // graphic.color = new Cesium.ConstantProperty(color);
1410
1493
  var animateColor_2 = new CesiumAnimatedProperty.AnimateColor({
1411
- color: color,
1494
+ targetColor: color,
1412
1495
  durationMs: animateMs,
1413
1496
  viewer: viewer,
1414
1497
  startColor: graphic.color
@@ -1423,7 +1506,7 @@ function refreshColor(viewer, graphic, opacity) {
1423
1506
  else if (graphic instanceof BillboardGraphics) {
1424
1507
  // graphic.color = new Cesium.ConstantProperty(color);
1425
1508
  var animateColor_3 = new CesiumAnimatedProperty.AnimateColor({
1426
- color: color,
1509
+ targetColor: color,
1427
1510
  durationMs: animateMs,
1428
1511
  viewer: viewer,
1429
1512
  startColor: graphic.color
@@ -2119,6 +2202,9 @@ var EntityUtils;
2119
2202
  if (!paddingAlt) {
2120
2203
  paddingAlt = 0;
2121
2204
  }
2205
+ if (!Array.isArray(samples)) {
2206
+ samples = [samples];
2207
+ }
2122
2208
  MAX_DISTANCE_BETWEEN_SAMPLES = 5000;
2123
2209
  MAX_TERRAIN_SAMPLES = 25;
2124
2210
  terrainSamples = 0;
@@ -5098,7 +5184,7 @@ var EntityRenderEngine;
5098
5184
  function Render(params) {
5099
5185
  var _a, _b, _c, _d;
5100
5186
  return __awaiter(this, void 0, void 0, function () {
5101
- var entity, style, type, cEntity, siblings, prepareExistingGraphic, iconUrlRows, icon, iconUrl, metadata, api, image, e_5, iconScale, disableDepthTest, bColor, cColor_1, heightRef, currentImgKey, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, heightRef, pos3d, extrusion, hasOutline, outlineExtrusion, outlineEntity, bColor, cColor, size, heightRef, circleBillboard, disableDepthTest, imgKey, currentImgKey;
5187
+ var entity, style, type, cEntity, siblings, prepareExistingGraphic, iconUrlRows, icon, iconUrl, metadata, api, image, e_5, iconScale, disableDepthTest, bColor, cColor_1, heightRef_1, currentImgKey, pos3d, prevPos3d, animatePosition_1, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, heightRef, pos3d, extrusion, hasOutline, outlineExtrusion, outlineEntity, bColor, cColor, size, heightRef_2, circleBillboard, disableDepthTest, imgKey, currentImgKey, pos3d, prevPos3d, animatePosition_2;
5102
5188
  return __generator(this, function (_e) {
5103
5189
  switch (_e.label) {
5104
5190
  case 0:
@@ -5199,7 +5285,7 @@ var EntityRenderEngine;
5199
5285
  if (iconScale > 0) {
5200
5286
  bColor = style.iconTintColor ? Calculator.GetColor(style.iconTintColor, entity, params.tags) : null;
5201
5287
  cColor_1 = bColor ? colorToCColor(bColor) : undefined;
5202
- heightRef = getHeightRef(style);
5288
+ heightRef_1 = getHeightRef(style);
5203
5289
  if (!params.rendered || !params.rendered.billboard) {
5204
5290
  cEntity = new Entity({
5205
5291
  id: ObjectUtils.UId(10),
@@ -5215,12 +5301,12 @@ var EntityRenderEngine;
5215
5301
  // Would be great once we have a setting for this.
5216
5302
  // translucencyByDistance: getTranslucencyByDistance(params.minDistance, params.maxDistance),
5217
5303
  },
5218
- position: EntityUtils.GetPos({
5304
+ position: new CallbackProperty(function () { return EntityUtils.GetPos({
5219
5305
  viewer: params.viewer,
5220
5306
  entity: entity,
5221
- recordHeightRef: heightRef,
5222
- returnHeightRef: heightRef
5223
- }),
5307
+ recordHeightRef: heightRef_1,
5308
+ returnHeightRef: heightRef_1
5309
+ }); }, true),
5224
5310
  show: true
5225
5311
  });
5226
5312
  }
@@ -5235,12 +5321,22 @@ var EntityRenderEngine;
5235
5321
  cEntity.billboard.heightReference = new ConstantProperty(getHeightRef(style));
5236
5322
  cEntity.billboard.disableDepthTestDistance = new ConstantProperty(disableDepthTest ? Number.POSITIVE_INFINITY : undefined);
5237
5323
  cEntity.billboard.distanceDisplayCondition = new ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
5238
- cEntity.position = new ConstantPositionProperty(EntityUtils.GetPos({
5324
+ pos3d = EntityUtils.GetPos({
5239
5325
  viewer: params.viewer,
5240
5326
  entity: entity,
5241
- recordHeightRef: heightRef,
5242
- returnHeightRef: heightRef
5243
- }));
5327
+ recordHeightRef: heightRef_1,
5328
+ returnHeightRef: heightRef_1
5329
+ });
5330
+ prevPos3d = getValue$1(params.viewer, cEntity.position);
5331
+ if (!prevPos3d || !Cartesian3.equals(prevPos3d, pos3d)) {
5332
+ animatePosition_1 = new CesiumAnimatedProperty.AnimatePosition({
5333
+ durationMs: 200,
5334
+ targetPos3d: pos3d,
5335
+ viewer: params.viewer,
5336
+ startPos3d: prevPos3d
5337
+ });
5338
+ cEntity.position = new CallbackProperty(function () { return animatePosition_1.GetValue(); }, false);
5339
+ }
5244
5340
  // We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
5245
5341
  CesiumEntityStyler.SetDefaultColor({
5246
5342
  color: cColor_1 ? cColor_1 : new Color(),
@@ -5384,7 +5480,7 @@ var EntityRenderEngine;
5384
5480
  if (size <= 0) {
5385
5481
  return [2 /*return*/, null];
5386
5482
  }
5387
- heightRef = getHeightRef(style);
5483
+ heightRef_2 = getHeightRef(style);
5388
5484
  circleBillboard = createCircleBillboard(size, cColor.toCssColorString());
5389
5485
  disableDepthTest = Boolean(style.renderOnTop);
5390
5486
  if (!params.rendered || !params.rendered.billboard) {
@@ -5404,16 +5500,16 @@ var EntityRenderEngine;
5404
5500
  width: circleBillboard.width,
5405
5501
  image: circleBillboard.canvasDataUri,
5406
5502
  color: new CallbackProperty(function () { return undefined; }, true),
5407
- heightReference: heightRef,
5503
+ heightReference: heightRef_2,
5408
5504
  distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
5409
5505
  disableDepthTestDistance: disableDepthTest ? Number.POSITIVE_INFINITY : undefined
5410
5506
  },
5411
- position: EntityUtils.GetPos({
5507
+ position: new CallbackProperty(function () { return EntityUtils.GetPos({
5412
5508
  viewer: params.viewer,
5413
5509
  entity: entity,
5414
- recordHeightRef: heightRef,
5415
- returnHeightRef: heightRef
5416
- }),
5510
+ recordHeightRef: heightRef_2,
5511
+ returnHeightRef: heightRef_2
5512
+ }); }, true),
5417
5513
  show: true
5418
5514
  });
5419
5515
  }
@@ -5427,15 +5523,25 @@ var EntityRenderEngine;
5427
5523
  }
5428
5524
  cEntity.billboard.height = new ConstantProperty(circleBillboard.height);
5429
5525
  cEntity.billboard.width = new ConstantProperty(circleBillboard.width);
5430
- cEntity.billboard.heightReference = new ConstantProperty(heightRef);
5526
+ cEntity.billboard.heightReference = new ConstantProperty(heightRef_2);
5431
5527
  cEntity.billboard.distanceDisplayCondition = new ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
5432
5528
  cEntity.billboard.disableDepthTestDistance = new ConstantProperty(disableDepthTest ? Number.POSITIVE_INFINITY : undefined);
5433
- cEntity.position = new ConstantPositionProperty(EntityUtils.GetPos({
5529
+ pos3d = EntityUtils.GetPos({
5434
5530
  viewer: params.viewer,
5435
5531
  entity: entity,
5436
- recordHeightRef: heightRef,
5437
- returnHeightRef: heightRef
5438
- }));
5532
+ recordHeightRef: heightRef_2,
5533
+ returnHeightRef: heightRef_2
5534
+ });
5535
+ prevPos3d = getValue$1(params.viewer, cEntity.position);
5536
+ if (!prevPos3d || !Cartesian3.equals(prevPos3d, pos3d)) {
5537
+ animatePosition_2 = new CesiumAnimatedProperty.AnimatePosition({
5538
+ durationMs: 200,
5539
+ targetPos3d: pos3d,
5540
+ viewer: params.viewer,
5541
+ startPos3d: prevPos3d
5542
+ });
5543
+ cEntity.position = new CallbackProperty(function () { return animatePosition_2.GetValue(); }, false);
5544
+ }
5439
5545
  // We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
5440
5546
  CesiumEntityStyler.SetDefaultColor({
5441
5547
  color: cColor,
@@ -6103,20 +6209,18 @@ var EntityRenderEngine;
6103
6209
  if (styleScale <= 0) {
6104
6210
  styleScale = 1;
6105
6211
  }
6106
- var hpr = new HeadingPitchRoll(Math$1.toRadians(heading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
6107
6212
  var heightRef = getHeightRef(style, HeightReference.RELATIVE_TO_GROUND);
6108
- var pos = EntityUtils.GetPos({
6213
+ var pos3d = EntityUtils.GetPos({
6109
6214
  viewer: params.viewer,
6110
6215
  entity: entity,
6111
6216
  recordHeightRef: heightRef,
6112
6217
  returnHeightRef: heightRef
6113
6218
  });
6114
6219
  if (heightRef == HeightReference.CLAMP_TO_GROUND) {
6115
- var carto = Cartographic.fromCartesian(pos);
6116
- pos = Cartesian3.fromRadians(EnsureNumber(carto.longitude), EnsureNumber(carto.latitude), 0);
6220
+ var carto = Cartographic.fromCartesian(pos3d);
6221
+ pos3d = Cartesian3.fromRadians(EnsureNumber(carto.longitude), EnsureNumber(carto.latitude), 0);
6117
6222
  heightRef = HeightReference.RELATIVE_TO_GROUND;
6118
6223
  }
6119
- var orientation = Transforms.headingPitchRollQuaternion(pos, hpr);
6120
6224
  var blendMode = null;
6121
6225
  var blendAmount = null;
6122
6226
  var color = null;
@@ -6157,6 +6261,8 @@ var EntityRenderEngine;
6157
6261
  var animateScale = null;
6158
6262
  var cEntity = params.rendered;
6159
6263
  if (!cEntity || !cEntity.model) {
6264
+ var hpr = new HeadingPitchRoll(Math$1.toRadians(heading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
6265
+ var orientation_1 = Transforms.headingPitchRollQuaternion(pos3d, hpr);
6160
6266
  cEntity = new Entity({
6161
6267
  id: ObjectUtils.UId(10),
6162
6268
  model: {
@@ -6169,8 +6275,8 @@ var EntityRenderEngine;
6169
6275
  color: new CallbackProperty(function () { return color; }, true),
6170
6276
  distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
6171
6277
  },
6172
- orientation: new ConstantProperty(orientation),
6173
- position: pos,
6278
+ orientation: new CallbackProperty(function () { return orientation_1; }, true),
6279
+ position: new CallbackProperty(function () { return pos3d; }, true),
6174
6280
  show: true
6175
6281
  });
6176
6282
  CesiumEntityStyler.BakeDefaultColor({
@@ -6206,14 +6312,50 @@ var EntityRenderEngine;
6206
6312
  cEntity.model.colorBlendAmount = new ConstantProperty(blendAmount);
6207
6313
  cEntity.model.colorBlendMode = new ConstantProperty(blendMode);
6208
6314
  cEntity.model.distanceDisplayCondition = new ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
6209
- cEntity.orientation = new ConstantProperty(orientation);
6210
- cEntity.position = new ConstantPositionProperty(pos);
6315
+ var prevPos3d = getValue$1(params.viewer, cEntity.position);
6316
+ var posChanged = !prevPos3d || !Cartesian3.equals(prevPos3d, pos3d);
6317
+ var animatePosition_3 = null;
6318
+ if (posChanged) {
6319
+ animatePosition_3 = new CesiumAnimatedProperty.AnimatePosition({
6320
+ durationMs: 200,
6321
+ targetPos3d: pos3d,
6322
+ viewer: params.viewer,
6323
+ startPos3d: prevPos3d
6324
+ });
6325
+ cEntity.position = new CallbackProperty(function () { return animatePosition_3.GetValue(); }, false);
6326
+ }
6327
+ // cEntity.orientation = new Cesium.ConstantProperty(orientation);
6328
+ var prevHeading = cEntity.model._heading;
6329
+ if (prevHeading == null || prevHeading == heading || isNaN(prevHeading)) {
6330
+ var hpr = new HeadingPitchRoll(Math$1.toRadians(heading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
6331
+ var orient_1 = Transforms.headingPitchRollQuaternion(pos3d, hpr);
6332
+ cEntity.orientation = new CallbackProperty(function () { return orient_1; }, true);
6333
+ }
6334
+ // Animate orientation. We'll calculate the heading based on movement.
6335
+ else {
6336
+ var animateHeading_1 = new CesiumAnimatedProperty.AnimateHeading({
6337
+ durationMs: 200,
6338
+ targetHeading: heading,
6339
+ viewer: params.viewer,
6340
+ startHeading: prevHeading
6341
+ });
6342
+ cEntity.orientation = new CallbackProperty(function () {
6343
+ var calcHeading = animateHeading_1.GetValue();
6344
+ var hpr = new HeadingPitchRoll(Math$1.toRadians(calcHeading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
6345
+ var orient = Transforms.headingPitchRollQuaternion(pos3d, hpr);
6346
+ // We'll stop the costly animation if it's done.
6347
+ if (animateHeading_1.IsDone()) {
6348
+ cEntity.orientation = new ConstantProperty(orient);
6349
+ }
6350
+ return orient;
6351
+ }, false);
6352
+ }
6211
6353
  // Same file but different scale. We'll animate the scale.
6212
6354
  var prevClientFileId = cEntity.model._clientFileId;
6213
6355
  if (prevClientFileId == params.lodClientFileId) {
6214
6356
  animateScale = new CesiumAnimatedProperty.AnimateNumber({
6215
6357
  durationMs: 200,
6216
- value: scale * styleScale,
6358
+ targetValue: scale * styleScale,
6217
6359
  viewer: params.viewer,
6218
6360
  startValue: cEntity.model.scale,
6219
6361
  startPaused: true
@@ -6324,6 +6466,7 @@ var EntityRenderEngine;
6324
6466
  record: scale,
6325
6467
  style: styleScale
6326
6468
  };
6469
+ model._heading = heading;
6327
6470
  return cEntity;
6328
6471
  }
6329
6472
  Model3d.Render = Render;
@@ -13772,15 +13915,30 @@ var EntityFilterGetter;
13772
13915
  */
13773
13916
  Getter.prototype.viewerDateTimeSub = function () {
13774
13917
  var _this = this;
13775
- this.viewerDateTimeDispose();
13776
- if (!this.historicAttrKey) {
13918
+ if (!this.historicAttrKey || this.viewerDateTimeChangeRemoval) {
13777
13919
  return;
13778
13920
  }
13921
+ // This is multiplied by the speed of animation to figure
13922
+ // out how many animation "ticks" before we allow an update.
13923
+ var INTERVAL_WHILE_ANIMATING = 2.5 * 1000;
13924
+ var lastUpdateTime = null;
13779
13925
  var delayQueue = new DelayQueue(function () {
13780
- var current = _this.historicAttrDateTime;
13781
- _this.updateHistoricDateTime();
13782
- if (current != _this.historicAttrDateTime) {
13783
- _this.updateState();
13926
+ try {
13927
+ // If the timeline is animating then we'll wait longer to update.
13928
+ if (_this.viewer.clock.shouldAnimate && lastUpdateTime) {
13929
+ if (Math.abs(new Date().getTime() - lastUpdateTime) < INTERVAL_WHILE_ANIMATING) {
13930
+ return;
13931
+ }
13932
+ }
13933
+ lastUpdateTime = new Date().getTime();
13934
+ var current = _this.historicAttrDateTime;
13935
+ _this.updateHistoricDateTime();
13936
+ if (current != _this.historicAttrDateTime) {
13937
+ _this.updateState();
13938
+ }
13939
+ }
13940
+ catch (e) {
13941
+ console.error(e);
13784
13942
  }
13785
13943
  }, 250);
13786
13944
  var postUpdateRemoval = this.viewer.scene.postUpdate.addEventListener(function () {
@@ -13887,6 +14045,7 @@ var EntityFilterGetter;
13887
14045
  else {
13888
14046
  this.getterLoopId += 1;
13889
14047
  this.viewAreaDispose();
14048
+ this.viewerDateTimeDispose();
13890
14049
  }
13891
14050
  };
13892
14051
  Getter.prototype.postStatus = function (status) {
@@ -23503,7 +23662,7 @@ var ViewRenderEngine;
23503
23662
  ViewRenderEngine.Render = Render;
23504
23663
  })(ViewRenderEngine || (ViewRenderEngine = {}));
23505
23664
 
23506
- var VERSION = "3.8.0";
23665
+ var VERSION = "3.8.2";
23507
23666
 
23508
23667
  export { VERSION, CesiumViewMonitor, ViewerUtils, MenuItemManager, EntityRenderEngine, MenuItemCreator, VisualsRegister, RenderManager, EntitiesIdsRenderManager, EntitiesLoadedRenderManager, EntitiesRenderManager, EntityRenderManager, TilesetCadRenderManager, TilesetArbRenderManager, TilesetEntitiesRenderManager, TilesetOsmRenderManager, TilesetPointcloudRenderManager, TilesetGooglePhotosRenderManager, DataSourceStaticKmlManager, RelationsRenderManager, SharedGetters, CesiumParabola, EntityLabel, ViewRenderEngine, TileRenderEngine, TilesetRenderEngine, CESIUM_INSPECTOR_KEY, CESIUM_TIMELINE_KEY, ViewUtils, DrawingUtils, MeasureUtils, EntityUtils, CesiumEntityStyler, Draw3dPolygon, Draw3dPolyline };
23509
23668
  //# sourceMappingURL=bruce-cesium.es5.js.map