vasturiano / react-globe.gl

React component for Globe Data Visualization using ThreeJS/WebGL
https://vasturiano.github.io/react-globe.gl/example/world-population/
MIT License
904 stars 156 forks source link

Performance Issues of Hexed Country Polygons #160

Open DannyYangPersonal opened 1 year ago

DannyYangPersonal commented 1 year ago

Hello,

I hope everyone is doing great! I was wondering if people have tips on improving the performance when using the Hexed Country Polygons Globe. Our team has been interested in using this product, however, it seems unfeasible to use as the high burst of CPU causes users to not be able to scroll and temporarily lag the site heavily. It also does not help that this project can not be used asynchronously. Thus, we resided to turning antialias to false, using the hex resolution of 3, and using a margin value between 0 and 1. Even with these configurations, the performance is just not good enough to release to production. The page will still freeze and causes users to not be able to scroll and also cause custom animations to delay. This leads me to ask, has anyone been able to successfully improve the performance of using the Hexed Country Polygons globe, and if they did, could they please remark some tips.

Thanks and take care everyone!

BangNguyen1992 commented 1 year ago

Hello @DannyYangPersonal, in my opinion, you can try to use the useCallback such as below

Hope this help

        hexPolygonsData={HEX_DATA}
        hexPolygonResolution={useCallback(() => 3, [])}
        hexPolygonMargin={useCallback(() => 0.7, [])}
        hexPolygonAltitude={useCallback(() => 0, [])}
        hexPolygonColor={useCallback(() => COUNTRY_DOT_COLOR, [])}
DannyYangPersonal commented 1 year ago

Hi @BangNguyen1992 ,

Thanks for the comment! Our team decided to create a scratch solution as this library is unfeasible for performant loading. We even tried with a hexPolygonResolution of 2 and many countries, such as South Korea, are out of place causing this library to be inoperable.