# Is there a way to compute the distance (in miles, feet, etc) between an entity and the camera?

**URL:** <https://community.cesium.com/t/is-there-a-way-to-compute-the-distance-in-miles-feet-etc-between-an-entity-and-the-camera/3410>\
**Category:** CesiumJS\
**Created:** [December 2, 2015, 7:06pm UTC](https://community.cesium.com/t/is-there-a-way-to-compute-the-distance-in-miles-feet-etc-between-an-entity-and-the-camera/3410 "2015-12-02T19:06:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lionel.delmo](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lionel.delmo](https://community.cesium.com/u/lionel.delmo)\
**Post date:** [December 2, 2015, 7:06pm UTC](https://community.cesium.com/t/is-there-a-way-to-compute-the-distance-in-miles-feet-etc-between-an-entity-and-the-camera/3410/1 "2015-12-02T19:06:01Z")

</div>

Hi,

I want to calculate the distance between the \_viewer.trackedEntity and the \_viewer.camera in feet, or meters, miles. Is this something built-in in Cesium?

Thanks,

Lionel

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [December 8, 2015, 12:19am UTC](https://community.cesium.com/t/is-there-a-way-to-compute-the-distance-in-miles-feet-etc-between-an-entity-and-the-camera/3410/2 "2015-12-08T00:19:24Z")

</div>

Hello

This will give you the distance in meters:

```
    var position = entity.position.getValue(viewer.clock.currentTime);
    var distance = Cesium.Cartesian3.magnitude(Cesium.Cartesian3.subtract(scene.camera.position, position, new Cesium.Cartesian3()));

```

``

Best,

Hannah

---

<div class="post-metadata">

**Author:** ![lionel.delmo](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@lionel.delmo](https://community.cesium.com/u/lionel.delmo)\
**Post date:** [December 10, 2015, 11:52pm UTC](https://community.cesium.com/t/is-there-a-way-to-compute-the-distance-in-miles-feet-etc-between-an-entity-and-the-camera/3410/3 "2015-12-10T23:52:58Z")

</div>

Thank you Hannah.
