Move an entity on button click

I have a polygon, which must move by a specified distance, upon clicking a button. I stumbled upon this interpolation example, wherein SampledPositionProperty is used to define the positions at different timestamps. However, in my usecase, I have a couple of differences compared to the example.

  1. I need to use a different clock/timer, than the one attached with the viewer/timeline, to animate the entity. This is because, the timeline is used to control a different variable associated with the entities. So is there a way to move the entities based on a different clock instance, which I instantiate?
  1. My entity is a polygon, for which the position is defined by the PolygonHierarchy, which takes in an array of positions. How can I use SampledPositionProperty for a PolygonHierarchy?

PS 1. I use Cesium 1.56.1 on Google Chrome 76.0.3809.132 on Windows 10.

PS 2. I looked into the Cesium source code to figure out how the position, at a given timestamp, is retrieved from the SampledPositionProperty. I believe there is some kind of an event listener that listens on the ontick event. But I couldn’t figure out where that code is. I would appreciate if I can be pointed out to that piece of code as well.

Thanks in advance.

If an entity can be moved using a different approach, other than using SampledPositionProperty, I am happy to know that as well. Please note that, the entity should move by itself, and the user is not expected to click-and-drag an entity.

Thanks.

Using Cesium 1.84 and trying to figure out the same thing… How to use SampledPositionProperty with PolygonHierarchy so polygon will “slide” to different location over time. Haven’t found any success stories on this topic so far.

My thought is to have a SampledPositionProperty for each vertex of the polygon and add a sample for each time+coordinate of the vertex. So if a 5-vertex polygon is at coordinate set C1 at time T1 and want it to move to coordinate set C2 at time T2, then I’d be dealing with the following:

SampledPositionProperty[0]
	Add sample for T1 and C1[0]
	Add sample for T2 and C2[0]

SampledPositionProperty[1]
	Add sample for T1 and C1[1]
	Add sample for T2 and C2[1]

...and so forth through to...

SampledPositionProperty[4]
	Add sample for T1 and C1[4]
	Add sample for T2 and C2[4]

I tried this idea on a PolylineGraphics object and it worked, so I assumed it would also work for PolygonGraphics object, but it does not.

Documentation indicates PolygonGraphics.hierarchy can take a Property or PolygonHierarchy. Since I have an array of SampledPositionProperty, I placed them in a PositionPropertyArray (which from my understanding derives from Property), and then assigned to PolygonGraphics.hierarchy…didn’t work. Also tried SampledProperty and that didn’t work either.

Now using a TimedIntervalCollectionProperty (also derives from Property), adding TimeInterval objects for both T1-C1 and T2-C2 pairs, and setting PolygonGraphics.hierarchy to the TimedIntervalCollectionProperty object does work. The polygon instantly moved from the first location to the second location as expected.

Since TimedIntervalCollectionProperty is based on Property and it works, I’m rather confused on why PolygonGraphics.hierarchy being set to the PositionPropertyArray did not work.

So Cesium staff, is using SampledPositionProperty with PolygonHierarchy possible? If so can you give us some sample code to guide us?

Thanks!

@grady.dill.trideum

Welcome to the community and thank you for the detailed forum post! :rocket: :fireworks:

I read through your post earlier this afternoon and was not able to come up with a robust solution. I reached out to the rest of the Cesium development team for support. We should get back to you with a response in the next week. I apologize for the delay. In the meantime, please keep this thread up to date with any progress you make. Support from other members of the community is always welcomed!

-Sam