# DynamicObject

**URL:** <https://community.cesium.com/t/dynamicobject/254>\
**Category:** CesiumJS\
**Created:** [February 1, 2013, 5:46pm UTC](https://community.cesium.com/t/dynamicobject/254 "2013-02-01T17:46:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamy](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tamy](https://community.cesium.com/u/Tamy)\
**Post date:** [February 1, 2013, 5:46pm UTC](https://community.cesium.com/t/dynamicobject/254/1 "2013-02-01T17:46:43Z")

</div>

Hi!  
How can I track an object with the camera, like Simple CZML Demo (Vehicle), without CZML? Just with tick() function?

Thanks!

---

<div class="post-metadata">

**Author:** ![Dan\_Bagnell](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@Dan\_Bagnell](https://community.cesium.com/u/Dan_Bagnell)\
**Post date:** [February 2, 2013, 1:11am UTC](https://community.cesium.com/t/dynamicobject/254/2 "2013-02-02T01:11:07Z")

</div>

Hi Tamy,

You can set the camera reference frame to be centered at the object each frame. For example:

var position = … // position of object to follow

camera.transform = Transforms.eastNorthUpToFixedFrame(position, ellipsoid);

A camera tutorial for the blog is in progress, but you can check out the camera-tutorial branch ([https://github.com/AnalyticalGraphicsInc/cesium/tree/camera-tutorial](https://github.com/AnalyticalGraphicsInc/cesium/tree/camera-tutorial)) for a Sandcastle example that has the camera follow a moving billboard.

Dan

---

<div class="post-metadata">

**Author:** ![Tamy](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tamy](https://community.cesium.com/u/Tamy)\
**Post date:** [February 4, 2013, 2:07pm UTC](https://community.cesium.com/t/dynamicobject/254/3 "2013-02-04T14:07:45Z")

</div>

Thank you, Dan,

But it doesn’t work as I wanted.

Following a billboard, It doesn’t let me zoom in much.

On another test, when I zoom, I want to put the point where the mouse position is on the middle screen, like google maps.

I have this code:

_var handlerZoom = new Cesium.ScreenSpaceEventHandler(scene.getCanvas());_

_handlerZoom.setInputAction(function(delta) {_

_var cartesian2 = new Cesium.Cartesian2(window.event.clientX, window.event.clientY);_

_var cartesian = scene.getCamera().controller.pickEllipsoid(cartesian2, ellipsoid);_

_if(cartesian){_

_camera.transform = Cesium.Transforms.eastNorthUpToFixedFrame(cartesian, ellipsoid);_

_}_

_}, Cesium.ScreenSpaceEventType.WHEEL);_

Another thing…I want to rotate the camera around the middle screen.

If I have it:

[![](https://lh5.googleusercontent.com/-jI2HnbfrRr8/UQ-_Q9KG91I/AAAAAAAAADc/58-8n8n-2x8/s320/cesium.png)](https://lh5.googleusercontent.com/-jI2HnbfrRr8/UQ-_Q9KG91I/AAAAAAAAADc/58-8n8n-2x8/s1600/cesium.png)

After something like it:

_var cam = scene.getCamera().controller;_

_cam.rotate(scene.getCamera().position, Math.PI);_

I want to see it:

[![](https://lh6.googleusercontent.com/-Z-BCWi9YiIU/UQ-_VCu6mFI/AAAAAAAAADk/9Kf_T5-_dUo/s320/cesium2.png)](https://lh6.googleusercontent.com/-Z-BCWi9YiIU/UQ-_VCu6mFI/AAAAAAAAADk/9Kf_T5-_dUo/s1600/cesium2.png)

But with this code just the world rotates. There’s a way to do it?

---

<div class="post-metadata">

**Author:** ![Poul\_Sorensen](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@Poul\_Sorensen](https://community.cesium.com/u/Poul_Sorensen)\
**Post date:** [December 9, 2014, 4:36am UTC](https://community.cesium.com/t/dynamicobject/254/4 "2014-12-09T04:36:53Z")

</div>

Would it be possible to get a little more information on this one? I cant seem to figure out what to do for making the camera follow my moving object.

My example is identical to the [http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=CZML.html&label=Showcases](http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=CZML.html&label=Showcases) build in czml

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [December 16, 2014, 5:40am UTC](https://community.cesium.com/t/dynamicobject/254/5 "2014-12-16T05:40:08Z")

</div>

You can opt-in to the automatic camera following capabilities of Entity instances (such as those that come from CZML), by calling viewer.extend(Cesium.viewerEntityMixin) and then setting the viewer.trackedEntity property. However, we are getting rid of the extend requirement in the next release, so any Entity will be able to be followed easily out of the box.

If you aren’t using Viewer, you can check out the EntityView class, which is what is being used by viewer: [https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/DataSources/EntityView.js](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/DataSources/EntityView.js)

---

<div class="post-metadata">

**Author:** ![Poul\_Sorensen](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@Poul\_Sorensen](https://community.cesium.com/u/Poul_Sorensen)\
**Post date:** [December 16, 2014, 6:01am UTC](https://community.cesium.com/t/dynamicobject/254/6 "2014-12-16T06:01:51Z")

</div>

Thanks. I found EntityView the other day and have used it with clock.onTick to get tracking started. Works out fine.

Will take a deeper look to figure out if I can position the camera closer to the object than the default.

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [December 16, 2014, 9:39pm UTC](https://community.cesium.com/t/dynamicobject/254/7 "2014-12-16T21:39:54Z")

</div>

You can use the viewFrom property in CZML to have per-entity default camera distance. It’s fairly limited, but is good enough for now until we have a better solution. Similarly, if you want to set the default for all entities, you can set the EntityViewer.defaultOffset3D property.
