# Polygon with Orientation based on entity position

**URL:** https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690
**Category:** CesiumJS
**Created:** [August 3, 2021, 2:33pm UTC](https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690 "2021-08-03T14:33:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![avmet.cesium](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/avmet.cesium/32/3476_2.png) [@avmet.cesium](https://community.cesium.com/u/avmet.cesium)
#### Post date: [August 3, 2021, 2:33pm UTC](https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690/1 "2021-08-03T14:33:15Z")

</div>

Greetings,  
I’m working with the CesiumJS tutorial “Build a Flight Tracker”. For our application instead of the full plane model we wanted to just draw a triangle. The triangle should point towards were it is flying like the model does. However, I cannot get the triangle to show up at all.  
Much appreciated,  
Jason Rogers

const vehicle\_entity = viewer.entities.add({  
name: vehicles[i].name,  
availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({start: vehicles[i].start, stop: vehicles[i].stop})]),  
position: position\_properties[i],  
polygon: {  
hierarchy: new Cesium.PolygonHierarchy(  
Cesium.Cartesian3.fromDegreesArray([  
-10.0,  
-10.0,  
0.0,  
0.0,  
-10.0,  
10.0  
])  
),  
material : Cesium.Color.BLUE,  
},  
orientation: new Cesium.VelocityOrientationProperty(position\_properties[i]),  
path: new Cesium.PathGraphics({width:2})  
});

Previously I accidently posted this under my personal account, instead of my work account. Appologies.

---

<div class="post-metadata">

### Author: ![sam.rothstein](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sam.rothstein/32/6584_2.png) [@sam.rothstein](https://community.cesium.com/u/sam.rothstein)
#### Post date: [August 3, 2021, 11:16pm UTC](https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690/2 "2021-08-03T23:16:39Z")

</div>

@avmet.cesium

Welcome to the community 🎊

Interesting application - I am looking forward to seeing where you take this! I recommend looking at our CZML Path sandcastle demo:

[https://sandcastle.cesium.com/?src=CZML%20Path.html](https://sandcastle.cesium.com/?src=CZML%20Path.html)

I think this demo might have all of the functionality that you are looking for! If you are looking for just more information about creating a cone or a triangle in the Cesium viewer, you should check out this demo:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=CZML%20Cones%20and%20Cylinders.html&label=CZML)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

and take a look at our `CZML` guide:

> **[CZML Guide](https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/CZML-Guide)**
>
> A library for writing CZML content for use with Cesium. - AnalyticalGraphicsInc/czml-writer

Let me know if you have any other questions or concerns!

Best,  
Sam

---

<div class="post-metadata">

### Author: ![avmet.cesium](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/avmet.cesium/32/3476_2.png) [@avmet.cesium](https://community.cesium.com/u/avmet.cesium)
#### Post date: [August 4, 2021, 2:12pm UTC](https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690/3 "2021-08-04T14:12:31Z")

</div>

Sam,  
Thanks for the demos. I think the first one, making use of the image (billboard) could be exactly what we need. However, I’m unsure as to how I can tie the rotation of the image to the current heading.  
Jason

---

<div class="post-metadata">

### Author: ![sam.rothstein](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sam.rothstein/32/6584_2.png) [@sam.rothstein](https://community.cesium.com/u/sam.rothstein)
#### Post date: [August 4, 2021, 2:34pm UTC](https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690/4 "2021-08-04T14:34:30Z")

</div>

@avmet.cesium

I am glad to hear that the demo I sent over is almost exactly what you are looking for. To tie the rotation of the billboard to the current heading, I recommend using the `Billboard` member `rotation`. Maybe you can update this member each frame to ensure that the `Billboard` is correctly oriented (based on the points in the `CZML` path)? Admittedly, I haven’t fleshed out all of the details of this implementation but I suspect that this is the optimal approach. You can find more information here:

> **[Billboard · AnalyticalGraphicsInc/czml-writer Wiki](https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Billboard)**
>
> A library for writing CZML content for use with Cesium. - Billboard · AnalyticalGraphicsInc/czml-writer Wiki

This will involve a little bit of engineering on your end. Please keep me posted with updates! Looking forward to seeing what you come up with 😃 Let me know if any other questions arise.

Best,  
Sam

---

<div class="post-metadata">

### Author: ![avmet.cesium](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/avmet.cesium/32/3476_2.png) [@avmet.cesium](https://community.cesium.com/u/avmet.cesium)
#### Post date: [August 13, 2021, 8:13pm UTC](https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690/5 "2021-08-13T20:13:58Z")

</div>

Sam,  
Here is what we ended up doing. I drew a cone (cylinder) and then set the “orientation” property. I was able to calculate the heading for each time interval ahead of time and then set the orientation along with the path. Orientation does not seem to be available in CesiumJS directly so we switched to using CZML. This worked much better for our workflow anyway. Your examples were a big help even though we didn’t end up following your suggestion exactly.  
Thanks,  
Jason

---

<div class="post-metadata">

### Author: ![sam.rothstein](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sam.rothstein/32/6584_2.png) [@sam.rothstein](https://community.cesium.com/u/sam.rothstein)
#### Post date: [August 16, 2021, 1:29pm UTC](https://community.cesium.com/t/polygon-with-orientation-based-on-entity-position/14690/6 "2021-08-16T13:29:48Z")

</div>

@avmet.cesium

Happy to hear that the resources that I provided were helpful. I am also glad that you were able to find a robust solution 🎆 Let me know if any other questions arise!

-Sam
