-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Entity.trackingReferenceFrame #12194
Changes from all commits
76cd99c
916689c
295d6fb
78cc807
917adb2
4b3303d
32c8e63
e69487a
3a019bb
d9e3859
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" | ||
/> | ||
<meta | ||
name="description" | ||
content="Apply different tracking reference frames to tracked entities." | ||
/> | ||
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases" /> | ||
<title>Cesium Demo</title> | ||
<script type="text/javascript" src="../Sandcastle-header.js"></script> | ||
<script | ||
type="text/javascript" | ||
src="../../../Build/CesiumUnminified/Cesium.js" | ||
nomodule | ||
></script> | ||
<script type="module" src="../load-cesium-es6.js"></script> | ||
</head> | ||
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> | ||
<style> | ||
@import url(../templates/bucket.css); | ||
</style> | ||
<div id="cesiumContainer" class="fullSize"></div> | ||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||
<div id="toolbar"></div> | ||
<script id="cesium_sandcastle_script"> | ||
window.startup = async function (Cesium) { | ||
"use strict"; | ||
//Sandcastle_Begin | ||
// This example illustrates the possible tracking reference frames | ||
// apllied to two different entities: a near surface slow moving | ||
// object and a satellite | ||
const viewer = new Cesium.Viewer("cesiumContainer", { | ||
terrain: Cesium.Terrain.fromWorldTerrain(), | ||
shouldAnimate: true, | ||
}); | ||
|
||
const startTime = Cesium.JulianDate.fromIso8601("2012-03-15T10:00:00Z"); | ||
|
||
const satelliteStopTime = Cesium.JulianDate.fromIso8601("2012-03-16T10:00:00Z"); | ||
|
||
const droneStopTime = Cesium.JulianDate.fromIso8601("2012-03-15T10:00:30Z"); | ||
|
||
const dataSource = await viewer.dataSources.add( | ||
Cesium.CzmlDataSource.load("../../SampleData/tracking.czml"), | ||
); | ||
|
||
const satellite = dataSource.entities.getById("Satellite/ISS"); | ||
const drone = dataSource.entities.getById("CesiumDrone"); | ||
|
||
satellite.viewFrom = new Cesium.Cartesian3(-300, 20, 100); | ||
drone.viewFrom = new Cesium.Cartesian3(-50, 0, 5); | ||
|
||
Sandcastle.addDefaultToolbarButton("Satellites", function () { | ||
viewer.clock.stopTime = satelliteStopTime; | ||
viewer.clock.currentTime = startTime; | ||
viewer.clock.multiplier = 30; | ||
viewer.timeline.zoomTo(startTime, satelliteStopTime); | ||
viewer.trackedEntity = satellite; | ||
}); | ||
|
||
Sandcastle.addToolbarButton("Drone", function () { | ||
viewer.clock.stopTime = droneStopTime; | ||
viewer.clock.currentTime = startTime; | ||
viewer.clock.multiplier = 1; | ||
viewer.timeline.zoomTo(startTime, droneStopTime); | ||
viewer.trackedEntity = drone; | ||
}); | ||
|
||
Sandcastle.addToolbarMenu([ | ||
{ | ||
text: "Tracking reference frame: Auto-detect", | ||
onselect: function () { | ||
satellite.trackingReferenceFrame = Cesium.TrackingReferenceFrame.AUTODETECT; | ||
drone.trackingReferenceFrame = Cesium.TrackingReferenceFrame.AUTODETECT; | ||
}, | ||
}, | ||
{ | ||
text: "Tracking reference frame: Inertial", | ||
onselect: function () { | ||
satellite.trackingReferenceFrame = Cesium.TrackingReferenceFrame.INERTIAL; | ||
drone.trackingReferenceFrame = Cesium.TrackingReferenceFrame.INERTIAL; | ||
}, | ||
}, | ||
{ | ||
text: "Tracking reference frame: Velocity", | ||
onselect: function () { | ||
satellite.trackingReferenceFrame = Cesium.TrackingReferenceFrame.VELOCITY; | ||
drone.trackingReferenceFrame = Cesium.TrackingReferenceFrame.VELOCITY; | ||
}, | ||
}, | ||
]); | ||
//Sandcastle_End | ||
}; | ||
if (typeof Cesium !== "undefined") { | ||
window.startupCalled = true; | ||
window.startup(Cesium).catch((error) => { | ||
"use strict"; | ||
console.error(error); | ||
}); | ||
Sandcastle.finishedLoading(); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Constants for identifying well-known tracking reference frames. | ||
* | ||
* @enum {number} | ||
*/ | ||
const TrackingReferenceFrame = { | ||
/** | ||
* Auto-detect algorithm. The reference frame used to track the Entity will | ||
* be automatically selected based on its trajectory: near-surface slow moving | ||
* objects will be tracked in the entity's local east-north-up reference | ||
* frame, while faster objects like satellites will use VVLH (Vehicle Velocity, | ||
* Local Horizontal). | ||
* | ||
* @type {number} | ||
* @constant | ||
*/ | ||
AUTODETECT: 0, | ||
|
||
/** | ||
* 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. | ||
* | ||
* @type {number} | ||
* @constant | ||
*/ | ||
INERTIAL: 1, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to fall back to autodetect in the case where an entity has no defined orientation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree on that point, as we already have |
||
|
||
/** | ||
* 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens when an entity's velocity is 0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is mentioned in #8900: |
||
}; | ||
export default Object.freeze(TrackingReferenceFrame); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of our enums use
NONE
for an undefined or default state. Does that make sense here>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the enum with a NONE value I've seen are reflecting something meaningful:
ArcType.NONE
ExtrapolationType.NONE
Visibility.NONE
HeightReference.NONE
I'm not sure a
TrackingReferenceFrame.NONE
value would be of any interest. This would represent an invalid value that should be tested against, and add more noise to the code IMO.Unless you would prefer me to replace the
TrackingReferenceFrame.AUTODETECT
byTrackingReferenceFrame.NONE
?