flyTo + trackedEntity?

I would like, when the user hits a button, to have the camera fly to a particular entity and then track it. Is there a way to do this using existing functions or do I need to implement it myself using a CallbackProperty?

Hello,

viewer.flyTo returns a promise that is resolved when the camera flight is finished, so you can set the tracked entity after the flight. Here is a code example:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {timeline : false, animation : false});

var pinBuilder = new Cesium.PinBuilder();

var bluePin = viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.170726, 39.9208667),
billboard : {
image : pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}
});

Sandcastle.addToolbarButton(‘Track Pin’, function() {
viewer.flyTo(bluePin)
.then(function() {
viewer.trackedEntity = bluePin;
});
});

``

Best,

Hannah

Thanks, Hannah … I didn’t realize that flyTo returned a promise. That’s nice.

Now the problem that I’m having is two-fold:

  1. It appears that flyTo does not use the object’s viewFrom property the same way that trackedEntity does, so flyTo takes the camera to one location and then pops to the viewFrom location at the end
  2. For similar reasons, flyTo does not move the camera orientation to that which it needs to be when it arrives at the viewFrom location. In my case, the camera smoothly tips up during the flyTo and then snaps back down when trackedEntity is set.
    Any advice? I could try to flyTo a location, but that’s tricky since the object is moving.

Hmm, sorry, I don’t have any good suggestions. It’s a bit of a complicated problem, especially if the object is moving.
This is something that has been on our roadmap for a little while, but I created an issue so we know that it is something that has been asked for from our users:

Best,

Hannah

Thanks, Hannah!

I’m having this issue as well.
I wrote the following code to zoom in to a certain distance and then track the “plane” as it flys it’s intended route. The offset works well then BLIP it blinks to the super close up of the plane moving along it’s route.
I want the tracking but keep the original camera distance.

viewer.flyTo(plane,{
offset: new Cesium.HeadingPitchRange(0, -Cesium.Math.PI_OVER_FOUR, 150000)
}).then(function(){
viewer.trackedEntity = plane;
viewer.clock.multiplier = 10;
viewer.clock.shouldAnimate = true;
});

Hannah, I’ll second that motion: “something that has been asked for from our users”. default behavior is less than ideal. I tried a similar solution to Gerry’s, but the results were disappointing.
PS. I’m looking forward to release 1.30 tomorrow! I can’t believe its February already!