bruce-cesium 6.4.3 → 6.4.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
- import { Cartes, Entity as Entity$1, Calculator, EntityRelationType, EntityType, Style, ENVIRONMENT, ProjectViewTile, DelayQueue, LRUCache, BruceEvent, ObjectUtils, Geometry, EntityHistoricData, EntityLod, ZoomControl, EntityTag, Tileset, Api, EntityCoords, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, ProgramKey, Carto, ProjectView, ProjectViewBookmark, Bounds, Camera, ProjectViewLegacyTile, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session } from 'bruce-models';
1
+ import { Cartes, Entity as Entity$1, Calculator, EntityRelationType, EntityType, Style, ENVIRONMENT, ProjectViewTile, DelayQueue, LRUCache, BruceEvent, ObjectUtils, Geometry, EntityHistoricData, EntityLod, ZoomControl, EntityTag, Tileset, Api, EntityCoords, DataLab, EntitySource, ClientFile, MenuItem, EntityRelation, ProgramKey, Bounds, Carto, ProjectView, ProjectViewBookmark, ProjectViewLegacyTile, Camera, AbstractApi, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, Session } from 'bruce-models';
2
2
  import * as Cesium from 'cesium';
3
- import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, DistanceDisplayCondition, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, ArcType, CornerType, PolygonHierarchy, PolylineGraphics, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Ion, Cesium3DTileset, IonResource, OrthographicFrustum, EasingFunction, Cesium3DTileColorBlendMode, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, BoundingSphere, GeometryInstance, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
3
+ import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, Math as Math$1, Cartesian3, JulianDate, Quaternion, Transforms, HeadingPitchRoll, Matrix4, DistanceDisplayCondition, HeightReference, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ConstantPositionProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Cartesian2, SceneTransforms, NearFarScalar, Matrix3, Rectangle, KmlDataSource, GeoJsonDataSource, SceneMode, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, IonResource, Cesium3DTileset, OrthographicFrustum, EasingFunction, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, BoundingSphere, GeometryInstance, PolygonPipeline, CesiumInspector, ClockRange, ScreenSpaceEventHandler, ScreenSpaceEventType, Intersect, CzmlDataSource, Fullscreen } from 'cesium';
4
4
 
5
5
  /**
6
6
  * Ensures a number is returned from a given value.
@@ -31420,7 +31420,8 @@ var EntityRenderEngineModel3d;
31420
31420
  else {
31421
31421
  const hpr = new HeadingPitchRoll(Math$1.toRadians(heading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
31422
31422
  getOrient = new CallbackProperty(() => {
31423
- return Transforms.headingPitchRollQuaternion(pos3d, hpr);
31423
+ const currentPos = position ? GetCValue(params.viewer, position) : pos3d;
31424
+ return Transforms.headingPitchRollQuaternion(currentPos, hpr);
31424
31425
  }, false);
31425
31426
  }
31426
31427
  cEntity = new Entity({
@@ -31530,9 +31531,23 @@ var EntityRenderEngineModel3d;
31530
31531
  // Just using real time for animation to avoid it teleporting on first movement.
31531
31532
  // If the prior update was too long ago our velocity estimate will make it teleport.
31532
31533
  const animStartTime = new Date();
31533
- if (prevPos3d && isLive) {
31534
+ // Get the current animated position if available, otherwise fall back to prevPos3d.
31535
+ // This prevents flickering when direction changes mid-animation.
31536
+ let currentAnimatedPos = prevPos3d;
31537
+ if (cEntity.position && isLive) {
31538
+ try {
31539
+ const animPos = GetCValue(params.viewer, cEntity.position);
31540
+ if (animPos) {
31541
+ currentAnimatedPos = animPos;
31542
+ }
31543
+ }
31544
+ catch (e) {
31545
+ // Fall back to prevPos3d if we can't get current position.
31546
+ }
31547
+ }
31548
+ if (currentAnimatedPos && isLive) {
31534
31549
  posses.push({
31535
- pos3d: prevPos3d,
31550
+ pos3d: currentAnimatedPos,
31536
31551
  dateTime: animStartTime,
31537
31552
  heading: !EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading) ? null : heading
31538
31553
  });
@@ -31563,7 +31578,17 @@ var EntityRenderEngineModel3d;
31563
31578
  const updatedTimeChanged = prevUpdatedTime && curUpdatedTime && prevUpdatedTime !== curUpdatedTime;
31564
31579
  const hasHistoricSeries = isHistoric || (params.entityHistoric && params.entityHistoric.length > 0);
31565
31580
  const shouldInterpolateHeading = !updatedTimeChanged || hasHistoricSeries;
31566
- if (shouldInterpolateHeading && dateTime && animatePosition && animatePosition instanceof CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetOrient) {
31581
+ const hasExplicitTransformHeading = (transform === null || transform === void 0 ? void 0 : transform.heading) != null && !isNaN(EnsureNumber(transform === null || transform === void 0 ? void 0 : transform.heading));
31582
+ const isDirectRealtimeUpdate = !isHistoric && !(params.entityHistoric && params.entityHistoric.length > 0);
31583
+ const preferTransformHeadingForRealtime = isDirectRealtimeUpdate && hasExplicitTransformHeading;
31584
+ if (preferTransformHeadingForRealtime) {
31585
+ const hpr = new HeadingPitchRoll(Math$1.toRadians(heading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
31586
+ cEntity.orientation = new CallbackProperty(() => {
31587
+ const currentPos = GetCValue(params.viewer, cEntity.position);
31588
+ return Transforms.headingPitchRollQuaternion(currentPos || pos3d, hpr);
31589
+ }, false);
31590
+ }
31591
+ else if (shouldInterpolateHeading && dateTime && animatePosition && animatePosition instanceof CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetOrient) {
31567
31592
  cEntity.orientation = new CallbackProperty(() => {
31568
31593
  return animatePosition.GetOrient();
31569
31594
  }, false);
@@ -31573,8 +31598,11 @@ var EntityRenderEngineModel3d;
31573
31598
  // Not worth animating.
31574
31599
  if (prevHeading == null || prevHeading == heading || isNaN(prevHeading)) {
31575
31600
  const hpr = new HeadingPitchRoll(Math$1.toRadians(heading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
31576
- const orient = Transforms.headingPitchRollQuaternion(pos3d, hpr);
31577
- cEntity.orientation = new CallbackProperty(() => orient, true);
31601
+ cEntity.orientation = new CallbackProperty(() => {
31602
+ const currentPos = GetCValue(params.viewer, cEntity.position);
31603
+ const orient = Transforms.headingPitchRollQuaternion(currentPos || pos3d, hpr);
31604
+ return orient;
31605
+ }, false);
31578
31606
  }
31579
31607
  // Animate the change.
31580
31608
  else {
@@ -31587,7 +31615,8 @@ var EntityRenderEngineModel3d;
31587
31615
  cEntity.orientation = new CallbackProperty(() => {
31588
31616
  const calcHeading = animateHeading.GetValue();
31589
31617
  const hpr = new HeadingPitchRoll(Math$1.toRadians(calcHeading), Math$1.toRadians(pitch), Math$1.toRadians(roll));
31590
- const orient = Transforms.headingPitchRollQuaternion(pos3d, hpr);
31618
+ const currentPos = GetCValue(params.viewer, cEntity.position);
31619
+ const orient = Transforms.headingPitchRollQuaternion(currentPos || pos3d, hpr);
31591
31620
  // We'll stop the costly animation if it's done.
31592
31621
  if (animateHeading.IsDone()) {
31593
31622
  cEntity.orientation = new ConstantProperty(orient);
@@ -34950,7 +34979,7 @@ class WidgetViewBar extends Widget.AWidget {
34950
34979
  }
34951
34980
  }
34952
34981
 
34953
- const VERSION = "6.4.3";
34982
+ const VERSION = "6.4.4";
34954
34983
  /**
34955
34984
  * Updates the environment instance used by bruce-cesium to one specified.
34956
34985
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.