Hello Cesium,
In our application we want to viewer.flyTo(,…) a line (plus a glTF model, but that is outside the scope now). The line is a PathGraphics because it is updated in real time.
For some reason this does not seem to work. Flying to e.g. a PolylineGraphics does work.
Any idea what is wrong? I tested in 1.16 and 1.17.
Thanks, Willem
Sandcastle:
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var sampledPositions = new Cesium.SampledPositionProperty();
sampledPositions.setInterpolationOptions({
interpolationDegree: 2,
interpolationAlgorithm: Cesium.LinearApproximation
});
sampledPositions.forwardExtrapolationType = Cesium.ExtrapolationType.HOLD;
sampledPositions.forwardExtrapolationDuration = 0;
var jsonTimedPoints = ‘[{“TimeStampUTC”:“2015-09-20T14:53:26.0000000Z”, “Latitude”:20.0, “Longitude”:7.0}, {“TimeStampUTC”:“2015-10-20T14:53:26.0000000Z”, “Latitude”:44.0, “Longitude”:8.0}]’;
var latLonArrayDegrees = JSON.parse(jsonTimedPoints);
var scratchC3 = new Cesium.Cartesian3();
for (var idx = 0; idx < latLonArrayDegrees.length; idx++) {
var timedPoint = latLonArrayDegrees[idx]; // array with timestamp, latitude and longitude.
sampledPositions.addSample(Cesium.JulianDate.fromIso8601(timedPoint['TimeStampUTC']), Cesium.Cartesian3.fromDegrees(timedPoint['Longitude'], timedPoint['Latitude'], 0.0, undefined, scratchC3));
}
var entity1 = viewer.entities.add({
id: ‘TestLine-1’,
path: { // this is a PathGraphics
material: new Cesium.Color(1, 0, 0, 1),
leadTime: 0,
trailTime: 365*24*60*60,
show: true,
width: 4
},
position: sampledPositions
});
var entity2 = viewer.entities.add({
id: ‘TestLine-2’,
polyline: {
positions: Cesium.Cartesian3.fromDegreesArray([-35, 12, -4, 22, -8, 25]),
material: new Cesium.Color(0, 1, 0, 1),
show: true,
followSurface: true,
width: 4
},
});
function flyToPathGraphics() {
Sandcastle.declare(flyToPathGraphics);
var promise = viewer.flyTo([entity1], {duration:10 });
promise.then(function (result) {
console.log('result=' + result);
}).otherwise(function (error) {
console.log('error=' + error);
});
}
function flyToPolyLine() {
Sandcastle.declare(flyToPolyLine);
var promise = viewer.flyTo([entity2], {duration:10 });
promise.then(function (result) {
console.log('result=' + result);
}).otherwise(function (error) {
console.log('error=' + error);
});
}
Sandcastle.addToolbarMenu([{
text : 'fly here:',
onselect : function() {
}
}, {
text : 'FLY path',
onselect : function() {
flyToPathGraphics();
Sandcastle.highlight(flyToPathGraphics);
}
}, {
text : 'FLY poly',
onselect : function() {
flyToPolyLine();
Sandcastle.highlight(flyToPolyLine);
}
}]);