How can I draw an arrow head at both ends of a polyline?

I have a sandcastle.

The sandcastle produces:

image

How can I control the size of the arrow head being drawn?

How can I get an arrow head on the other end of the polyline pointed in the opposite direction?

Hi there,

There’s no double headed arrow option in PolylineArrowMaterial unfortunately. You could achieve something with a custom material. There’s more info on how to do so in this thread.

Thanks!
Gabby

Thank you. I had found that thread already. It seems like a lot of complex work for something that I would have thought to be straightforward.

One of the difficulties is that the solution in the thread you pointed at is using the Cesium primitive API. What I am finding is that it is difficult to create a primitive polyline that follows the curvature of the earth.

For example, if in the sandcastle mentioned in the thread, on increases the width, it polyline starts looking terrible…a behavior that the entity api avoids.

However, to use the entity api to get this working is equally complex and would appear to require writing a custom material property which may require writing a custom shader.

What is making this harder is there is little to no documentation or discussion on any of these complex topics.

I am thinking the most straightforward way to solve this issue is to bypass primitive api or a requirement to write a custom shader and just construct a filled polygon with arrowheads at each end.

And for future reference… I did find this thread which briefly mentions creating a custom MaterialProperty which could be used with an entity…

@Gabby_Getz … the other odd thing about the thread you pointed to is that the sandcastle there is using Cesium.PolylinePipeline … this is not documented at Index - Cesium Documentation.

Is that an oversight or has that functionality been deprecated?

@eric-g-97477 PolylinePipeline is private API-- So it’s still included in CesiumJS, it’s just not documented and is subject to change in future updates without warning.

What is making this harder is there is little to no documentation or discussion on any of these complex topics.

Yes, that’s fair. We are typically lacking examples, tutorials, and API documentation for the more advanced graphics topics beyond typical use.

The best documentation for the time being is probably the source code itself. Entities are ultimately a wrapper around the primitive APIs, so you should be able to explore the Visualizer classes to find out how they use primitives to get the appearance you’re looking for.

Could you not simply make 2 arrow lines with the same positions array in reverse order? You’d end up wtith a single line with an arrow at both ends

What I ended up going is just constructing my own polygon which looks like a simple line with two arrow heads. This was easy. The best solution would be a feature rich double arrow head material which can be applied to a line. I am sure building the material would not be that bad, but without documentation it is a significant effort to learn the uncommented system.