large polygon has low performance when rendering

Demo: Cesium Sandcastle
Description: As in the Demo, small polygon could render per 50ms and 100ms, large polygon could render per 100ms, but could not render per 100ms. I think it is because rendering large polygon has lower performance. Any solution to improve it?

small polygon:

large polygon:

You should not try to remove and add primitives 20 times per second. If you provide a description about what you are actually trying to achieve, then there’s likely a better solution for that. (For example: If you want to animate a polygon or update its positions, then there are better approaches than removing the old one and adding a new one)

“animate* a polygon or update its positions”
Yes, it is what I want to achieve. Could you give me some suggestions? Thank you.

It the goal ist to animate the polygon itself, as a whole, then you could probably use an entity with a CallbackPositionProperty.

If the goal ist to animate individual points of the polygon independently: This is currently not possible. This was requested in Updating of primitives. The corresponding issue is Dynamic Buffers · Issue #932 · CesiumGS/cesium · GitHub , and unlikely to be addressed any time soon.

I want to bind the polygon with dragginig event, so could dragging implemented by animatioin?

As I said: You shouldn’t frequently remove and add primitives. And it is not possible to update primitives right now. But based on your description, it could make sense to consider Entity that uses a CallbackProperty for the PolygonHierarchy.

"What does that mean? :confused: "

Yeah: Use some of the classes of CesiumJS in a very specific way. Since this is a pretty common task, I summarized that in a utility function. That function receives an array of positions (as Cartesian3 objects), and returns an ‘entity’ - a polygon that can be rendered.

Modifications of the positions will change the shape of the polygon. In the demo sandcastle, this looks like this:

Cesium Dynamic Polygon

The actual positions in this example are just some ~“animated sine-wave”. But the point is: You can fill and modify this array with any data (even with many points and large polygons), and CesiumJS will take care of rendering them.

Here’s the sandcastle:

I get it. But I still have a question: It seems CallbackProperty only support Entity. Does CallbackProperty suppport Primitive?

As far as I know, the CallbackProperty is not used in the ‘primitive’ API, but only the ‘entity’ API.