Tracked Entity - Camera Angle

Hi

I am currently tracking an entity which moves along a polyline. This works fine.

I would like the camera to flyTo the entity and then set the camera to a given pitch. At the moment, it flies to the entity, but is always vertically above the entity I wish to track.

viewer.trackedEntity = entity;

var camera = viewer.camera;

camera.flyTo({

destination: Cesium.Cartesian3.fromDegrees(data.waypoints[0], data.waypoints[1], 5000),

orientation: {

heading: Cesium.Math.toRadians(0),

pitch: Cesium.Math.toRadians(-30),

roll: 0

},

duration: 3,

complete: function() {

}

});

``

Any help/pointers would be great

Thanks

Maybe not set viewer.trackedEntity until after the flyTo is finished? I’m not sure if flyTo will chase a moving target, can you continuously change its destination in mid-flight?

This is a known limitation. flyTo flies to the target where it is at the start of the flyTo and not where it will be at the end (because camera flights currently only work on wall time and not simulation time). One way around this is to pause animation and then flyTo. Once the flyTo is done, you can set the trackedEntity and then unpause animation.

Of course this exposes a second problem which is the ability to control the initial view for a given entity so that the camera stays in the same spot after the flyTo when the trackedEntity is assigned. You may be able to manually set the camera position on the frame after trackedEnttiy is set, but I don’t have any code handy for that.

I’m sorry I don’t have a better answer for you, this is an area we definitely need/want to clean up but haven’t had the time because of all of the other feature work going on.

Thanks,

I have tried that (placing it in the complete callback).

The only way I can kind of get what I am after is if I change the camera properties in the complete function. It doesn’t seem the right thing to do so if anyone knows of a better way that would be great to hear.

Thanks

It looks like you posted at the exact same time I did. For reference, my entity only starts moving when i click a button (so this is after the fly to).

I have currently used these settings to move the camera

camera.zoomOut(100);

camera.rotateDown(Cesium.Math.toRadians(-60));

camera.rotateLeft(Cesium.Math.toRadians(-30));

Is that what you were reffering to?

Thanks

Those should work assuming you know the initial orientation of the camera before executing those commands. If not then maybe get the entity’s ENU transform and do camera.lookAtTransform to set the heading,pitch,range relative to it.

I’m not all that familiar with tracked entity, however. I’m assuming that as the tracked entity moves that the camera’s transform is continuously set to the tracked entity’s new ENU transform (and in that case simply get the Camera’s transform when doing camera.lookAtTransform since it is the same thing.)

Oh ya it is continuously set.

tack on this piece of code

viewer.clock.onTick.addEventListener(function(clock)

{

console.log(viewer.scene.camera);

});

to the end of this http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=KML.html&label=DataSources

select bike ride and you’ll notice that it continuously changes. So just do camera.lookAtTransform(camera.transform,offset).

Check here for info on camera.lookAtTransform, offset can be Cartesian or heading/pitch/range.

I forgot to add the .transform property on code snippet
viewer.clock.onTick.addEventListener(function(clock)
{
console.log(viewer.scene.camera.transform);
});

``

Hello Aaron, I am stuck in same problem. Can you please post a code snippet of your solution? What kind of properties are you changing in complete function?