How to render polygon faster?

Polygon is initialized for the first time takes a long time, but the next time is much faster, how to make the polygon to initialize quickly the first time? here is my example using Left-click on features to show polygon Cesium Sandcastle

1 Like

upppp

:sneezing_face: :sneezing_face: :sneezing_face: :sneezing_face:

Hi @Yen_Woody,

Thank you for sharing such a cool sandcastle demo with our community! I ran your demo various times in different browsers. I did not experience any significant or noteworthy amount of latency.


Is it possible that this issue is mostly related to the strength of your broadband access?

I also took some time to look through your code. I did not see any “red flags” in terms of optimization. Is there a particular part of your code that you believe is inefficient? I am looking forward to hearing from you and learning more!

-Sam

i tried initializing datasource polygon

const dataSource = new Cesium.CustomDataSource("custom");

        viewer.dataSources.add(dataSource);

        const redPolygon = dataSource.entities.add({

            polygon: {

                hierarchy: Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,

                -115.0, 32.0,

                -107.0, 33.0,

                -102.0, 31.0,

                -102.0, 35.0]),

                material: Cesium.Color.RED.withAlpha(0.001)

            }

        });

and it works faster

2 Likes

@Yen_Woody, thanks for sharing your problem and best of all, your solution!

1 Like

@Yen_Woody

Thank you for sharing this update! I am happy to hear that you were able to resolve your issue.

-Sam

2 Likes

I met the identical problem. Using devtools, I noticed when I try to render a polygon or polyline on the ground (where its height need to be resampled according to the local height) for the first time after refreshing, a few xxxshader.js are loaded in sequence, and each of them takes about one second.

I am located in mainland China, is that the problem?

@Inu_Dog

Welcome to the community! Out of curiosity, why do you suspect that your location could be related to this issue? I suspect that the latency that you are noticing is due to caching within the browser. Regardless, I am looking forward to learning more!

-Sam