Fly To Tracked Entity

Hi

I am looking at the sandbox examples and like the flyTo feature.

What I would like to do is perform a fly to and then track an entity from a given height. I have tried using the “complete” callback function and then tracking the entity in here.

Is there a way to fly to an entity and then track it from a given height? At the moment, it flyTo a location, then jumps to the entity at ground level.

Thanks

Aaron

Anyone have any suggestions? Maybe I am thinking along the wrong lines?

Should I instead be using the onTick even listener to look at the entity position?

Hello Aaron,

I don’t think there is anything currently in to Cesium to track the entity at a given height. However, here is an example that flies to an entity then tracks it without the camera jumping:

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

var pinBuilder = new Cesium.PinBuilder();

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

viewer.flyTo(bluePin).then(function(){
viewer.trackedEntity = bluePin;
});

``

Does that example help you?

Best,

Hannah

Hi Hannah

Thanks for the reply

My code is almost exactly the same as this. I don’t want to camera to zoom into the marker as close as it does. I am trying to zoom in about 1000 meters above it.

Ok,

I am coming at this from a differnent angle.

I would like to now get the position of the entity (used in the onTick), and then pass this to the camera, lookAt function.

entity.position() provides me info, but I am not sure how I can use this to pass it to the lookAt function.

Any ideas?

Thanks

Hello,

Here is an example of how to use lookAt:

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
}
});

viewer.scene.camera.lookAt(bluePin.position.getValue(viewer.clock.currentTime), new Cesium.Cartesian3(0,0,1000));

``

The first argument is the pin position. The second argument is a Cartesian3 offset in the pin’s reference frame, so z=1000 puts the camera 1000m above the pin.

Does this answer your question?

-Hannah