Why does the camera track a position offset from the the position of the trackedEntity when I load KML with a gxTrack?
The entity has an altitude, and the tracked position is always between the entity and ground, significantly below the entity itself. The offset seems to increase as the altitude increases, which makes me wonder if there's an incorrect unit conversion happening.
Link to executable Cesium sandbox demonstrating the issue: Cesium sandbox
In the image below, the green square indicates the position the camera is tracking. If you rotate the camera, it's easy for the tracked entity to not even be visible on the screen, especially if it's at a high altitude.
const viewer = new Cesium.Viewer("cesiumContainer");
const options = {
camera: viewer.scene.camera,
canvas: viewer.scene.canvas,
screenOverlayContainer: viewer.container,
};
Sandcastle.addToolbarMenu(
[
{
text: "gx KML extensions - Bike Ride",
onselect: function () {
viewer.dataSources
.add(
Cesium.KmlDataSource.load(
"https://gist.githubusercontent.com/wiseman/2b3d43bf853b0b9743239c2d50fc04e3/raw/6c22c145162757c4d7a175084f2b29f6d61cc51f/N367LJ-N64EF-track-press_alt_uncorrected.kml",
options
)
)
.then(function (dataSource) {
viewer.clock.shouldAnimate = false;
const rider = dataSource.entities.getById("tour");
viewer.flyTo(rider).then(function () {
viewer.trackedEntity = rider;
viewer.selectedEntity = viewer.trackedEntity;
viewer.clock.multiplier = 30;
viewer.clock.shouldAnimate = true;
});
});
},
},
],
"toolbar"
);
Sandcastle.reset = function () {
viewer.dataSources.removeAll();
viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;
viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK;
};
I don't think there's anything wrong with the KML, which looks like this and seems to work fine in Google Earth:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"><Folder ><Folder ><name >N367LJ track</name>
<Placemark id="tour"><name >N367LJ</name>
<Style ><LineStyle ><color >ff1c1ae3</color>
<width >4</width>
</LineStyle>
<IconStyle ><Icon ><href >http://maps.google.com/mapfiles/kml/shapes/airports.png</href>
</Icon>
</IconStyle>
</Style>
<gx:Track ><altitudeMode >absolute</altitudeMode>
<extrude >1</extrude>
<when >2023-12-01T17:30:47.324Z</when>
<when >2023-12-01T17:30:47.324Z</when>
<when >2023-12-01T17:30:49.984Z</when>
<!-- ... -->
<gx:coord >-70.778242 42.868326 1105</gx:coord>
<gx:coord >-70.778242 42.868326 1105</gx:coord>
<gx:coord >-70.78076 42.870712 1074</gx:coord>
<!-- ... -->
