Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue for cursor events on 3d polygon geometry. #32

Closed
knackstedt opened this issue Feb 8, 2021 · 4 comments
Closed

Performance issue for cursor events on 3d polygon geometry. #32

knackstedt opened this issue Feb 8, 2021 · 4 comments

Comments

@knackstedt
Copy link

Describe the bug
Cursor movements triggering polygon expansion via .onPolygonHover causes significant delay when animating multiple polygons at the same time.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://globe.gl/example/choropleth-countries/'
  2. Quickly pan cursor over multiple countries in Europe
  3. See 100% CPU spikes in Chrome DevTools; Noticable lag in WebGL renderer.

Expected behavior
Smooth transitions and animations when animating polygon geometry.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows x64
  • Browser Chrome
  • Version 90

Additional context
Likely an issue with re-generating the mesh for the animation.

@vasturiano
Copy link
Owner

Thanks for reaching out @knackstedt.

Yes, it is expected that animations on the conic polygons do consume a bit of CPU capacity. The reason is that geometries need to be calculated for all the intermediate positions of the interpolator. These geometries are calculated using three-conic-polygon-geometry and there is some complexity to those objects.

I've optimized what I could in both the geometry lib and in globe.gl, and not certain there's a lot more that can be done other than use it on powerful enough GPU hardware.

@knackstedt
Copy link
Author

The system that I'm using for this is very beefy. It's running a Ryzen 9 3900XT and a GeForce RTX 3090.
I feel like there shouldn't be any noticeable lag during transitions. I also notice significant lag on the geometry changes on this scene load https://globe.gl/example/countries-population/, which I suspect has the same origin cause.

A Possible remedy would be enforcing this transition to only apply to a single mesh at a time. It might be better suited as an issue with three-globe instead of globe.gl. I'm not sure I fully understand the differences between the two yet.
If possible you could use scaling to tween between the mesh geometry sizes.

@vasturiano
Copy link
Owner

@knackstedt I've done some experimenting and ended up with a solution that has better performance during transitions.
It's applied to the latest version and you can see it the example: https://globe.gl/example/countries-population/

Essentially, as you suggested, instead of re-generating geometries at every tick of the tween it's merely applying a scaling factor to the existing geometries.

Let me know if you see an improvement on your side.

@knackstedt
Copy link
Author

@vasturiano I can clearly see better performance this way. The fact that you were able to implement a solution so quickly is very impressive :)
It looks very smooth and doesn't make my CPU performance hit 100% at any point during the transition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants