Tracked Entity - Camera Angle

2,241 views
Skip to first unread message

Aaron Bird

unread,
Mar 23, 2015, 11:11:50 AM3/23/15
to cesiu...@googlegroups.com
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

Hyper Sonic

unread,
Mar 23, 2015, 1:54:38 PM3/23/15
to cesiu...@googlegroups.com
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?

Matthew Amato

unread,
Mar 23, 2015, 2:19:20 PM3/23/15
to cesiu...@googlegroups.com
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.


On Mon, Mar 23, 2015 at 1:54 PM, Hyper Sonic <gman...@gmail.com> wrote:
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?

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Bird

unread,
Mar 23, 2015, 2:20:55 PM3/23/15
to cesiu...@googlegroups.com
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

Aaron Bird

unread,
Mar 23, 2015, 2:24:51 PM3/23/15
to cesiu...@googlegroups.com
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

Hyper Sonic

unread,
Mar 23, 2015, 4:58:06 PM3/23/15
to cesiu...@googlegroups.com
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.)

Hyper Sonic

unread,
Mar 23, 2015, 5:14:23 PM3/23/15
to cesiu...@googlegroups.com
Oh ya it is continuously set. 

tack on this piece of code
viewer.clock.onTick.addEventListener(function(clock)
{
    console.log(viewer.scene.camera);
});
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.

Hyper Sonic

unread,
Mar 23, 2015, 5:16:52 PM3/23/15
to cesiu...@googlegroups.com
I forgot to add the .transform property on code snippet
viewer.clock.onTick.addEventListener(function(clock)
{
    console
.log(viewer.scene.camera.transform);
});

Message has been deleted

Qandeel Abbassi

unread,
Feb 19, 2017, 3:04:55 PM2/19/17
to cesium-dev
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? 
Reply all
Reply to author
Forward
0 new messages