Skip to content

Commit

Permalink
Merge pull request #12314 from jfayot/feat_tracking_reference_frame
Browse files Browse the repository at this point in the history
Added TrackingReferenceFrame.ENU
  • Loading branch information
ggetz authored Nov 22, 2024
2 parents 124fd43 + b653ea1 commit 90a17ef
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Apps/Sandcastle/gallery/Entity tracking.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@
drone.trackingReferenceFrame = Cesium.TrackingReferenceFrame.VELOCITY;
},
},
{
text: "Tracking reference frame: East-North-Up",
onselect: function () {
satellite.trackingReferenceFrame = Cesium.TrackingReferenceFrame.ENU;
drone.trackingReferenceFrame = Cesium.TrackingReferenceFrame.ENU;
},
},
]);
//Sandcastle_End
};
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Interpolation.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
{
text: "Tracking reference frame: East-North-Up",
onselect: function () {
entity.trackingReferenceFrame = Cesium.TrackingReferenceFrame.EAST_NORTH_UP;
entity.trackingReferenceFrame = Cesium.TrackingReferenceFrame.ENU;
},
},
{
Expand Down
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
##### Additions :tada:

- Added `getSample` to `SampledProperty` to get the time of samples. [#12253](https://github.com/CesiumGS/cesium/pull/12253)
- Added `Entity.trackingReferenceFrame` property to allow tracking entities in their own inertial reference frame. [#12194](https://github.com/CesiumGS/cesium/pull/12194)
- Added `Entity.trackingReferenceFrame` property to allow tracking entities in various reference frames. [#12194](https://github.com/CesiumGS/cesium/pull/12194), [#12314](https://github.com/CesiumGS/cesium/pull/12314)
- `TrackingReferenceFrame.AUTODETECT` (default): uses either VVLH or ENU dependeding on entity's dynamic. Use `TrackingReferenceFrame.ENU` if your camera orientation flips abruptly from time to time.
- `TrackingReferenceFrame.ENU`: uses the entity's local East-North-Up reference frame.
- `TrackingReferenceFrame.INERTIAL`: uses the entity's inertial reference frame.
- `TrackingReferenceFrame.VELOCITY`: uses entity's `VelocityOrientationProperty` as orientation.
- Added `GoogleGeocoderService` for standalone usage of Google geocoder. [#12299](https://github.com/CesiumGS/cesium/pull/12299)

##### Fixes :wrench:
Expand Down
17 changes: 11 additions & 6 deletions packages/engine/Source/Core/TrackingReferenceFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,30 @@ const TrackingReferenceFrame = {
*/
AUTODETECT: 0,

/**
* The entity's local East-North-Up reference frame.
*
* @type {number}
* @constant
*/
ENU: 1,

/**
* The entity's inertial reference frame. If entity has no defined orientation
* property, a {@link VelocityOrientationProperty} is used instead, thus
* falling back to <code>TrackingReferenceFrame.VELOCITY</code>.
* When selected, the auto-detect algorithm is overridden.
* property, it falls back to auto-detect algorithm.
*
* @type {number}
* @constant
*/
INERTIAL: 1,
INERTIAL: 2,

/**
* The entity's inertial reference frame with orientation fixed to its
* {@link VelocityOrientationProperty}, ignoring its own orientation.
* When selected, the auto-detect algorithm is overridden.
*
* @type {number}
* @constant
*/
VELOCITY: 2,
VELOCITY: 3,
};
export default Object.freeze(TrackingReferenceFrame);
10 changes: 6 additions & 4 deletions packages/engine/Source/DataSources/EntityView.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ function updateTransform(
rotationScratch,
);
Matrix4.fromRotationTranslation(rotation, cartesian, transform);
} else if (hasBasis) {
} else if (
trackingReferenceFrame === TrackingReferenceFrame.ENU ||
!hasBasis
) {
Transforms.eastNorthUpToFixedFrame(cartesian, ellipsoid, transform);
} else {
transform[0] = xBasis.x;
transform[1] = xBasis.y;
transform[2] = xBasis.z;
Expand All @@ -286,9 +291,6 @@ function updateTransform(
transform[13] = cartesian.y;
transform[14] = cartesian.z;
transform[15] = 0.0;
} else {
// Stationary or slow-moving, low-altitude objects use East-North-Up.
Transforms.eastNorthUpToFixedFrame(cartesian, ellipsoid, transform);
}

camera._setTransform(transform);
Expand Down
15 changes: 15 additions & 0 deletions packages/engine/Specs/DataSources/EntityViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ describe(
entity.trackingReferenceFrame = TrackingReferenceFrame.VELOCITY;
view.update(JulianDate.now());
expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10);

entity.trackingReferenceFrame = TrackingReferenceFrame.ENU;
view.update(JulianDate.now());
expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10);
});

it("uses entity bounding sphere", function () {
Expand Down Expand Up @@ -115,6 +119,13 @@ describe(
new BoundingSphere(new Cartesian3(3, 4, 5), 6),
);
expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10);

entity.trackingReferenceFrame = TrackingReferenceFrame.ENU;
view.update(
JulianDate.now(),
new BoundingSphere(new Cartesian3(3, 4, 5), 6),
);
expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10);
});

it("uses entity viewFrom if available and boundingsphere is supplied", function () {
Expand All @@ -140,6 +151,10 @@ describe(
entity.trackingReferenceFrame = TrackingReferenceFrame.VELOCITY;
view.update(JulianDate.now());
expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10);

entity.trackingReferenceFrame = TrackingReferenceFrame.ENU;
view.update(JulianDate.now());
expect(view.scene.camera.position).toEqualEpsilon(sampleOffset, 1e-10);
});

it("update throws without time parameter", function () {
Expand Down

0 comments on commit 90a17ef

Please sign in to comment.