flyTo + trackedEntity?

1,214 views
Skip to first unread message

Eric Burns

unread,
Feb 23, 2016, 5:15:32 PM2/23/16
to cesium-dev
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?


Hannah Pinkos

unread,
Feb 24, 2016, 10:19:32 AM2/24/16
to cesium-dev
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

Eric Burns

unread,
Mar 1, 2016, 10:50:45 AM3/1/16
to cesium-dev
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.

Hannah Pinkos

unread,
Mar 1, 2016, 11:31:11 AM3/1/16
to cesium-dev
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:

Hannah

Eric Burns

unread,
Mar 2, 2016, 10:38:06 AM3/2/16
to cesium-dev
Thanks, Hannah!

Gerry Creighton

unread,
Jan 26, 2017, 2:45:20 PM1/26/17
to cesium-dev
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;
    }); 

Left Gully

unread,
Feb 1, 2017, 12:10:45 AM2/1/17
to cesium-dev
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!


On Tuesday, March 1, 2016 at 11:31:11 AM UTC-5, Hannah Pinkos wrote:
Reply all
Reply to author
Forward
0 new messages