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

[Bug?]: the hexPolygonResolution doesnt update after init #135

Closed
BangNguyen1992 opened this issue Aug 1, 2023 · 7 comments
Closed

[Bug?]: the hexPolygonResolution doesnt update after init #135

BangNguyen1992 opened this issue Aug 1, 2023 · 7 comments

Comments

@BangNguyen1992
Copy link

Describe the bug
I want to change the hexPolygonResolution of the hexPolygon layer when the user zoom in/out. However, after the 1st init, the hexPolygonResolution doesn't update accordingly to the input value. I have tried with function as well, but still still not work.

Example:

hexPolygonResolution={() => zoomIn ? 4 : 3 } -> but it doesn't change when zoomIn value changed

To Reproduce

  • try to change the hexPolygonResolution value dynamically like the example above

Expected behavior

  • The hexPolygonResolution should be changed accordingly

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

Desktop (please complete the following information):

  • OS: MacOS
  • Browser [e.g. chrome, safari]: Chrome
  • Version [e.g. 22]: 114.0.5735.248

Additional context

  • If it is not a bug, are there other ways to achieve this? Like force re-render, or update hex polygon?
@vasturiano
Copy link
Owner

@BangNguyen1992 thanks for reaching out.

This was indeed a bug that was just fixed in this underlying module: vasturiano/three-globe@dfa2f8d

If you update your dependency tree to include at least v2.27.5 of three-globe, you shouldn't experience the issue anymore.

@BangNguyen1992
Copy link
Author

Hello @vasturiano, thank you for the quick update, it works for me now.

However, when I change the hexPolygonResolution value, the app is freezing for about 1~2 sec. Do you have any suggestions on how to prevent that?

Thank you

@vasturiano
Copy link
Owner

@BangNguyen1992 are you using high values for the resolution? That would explain the CPU burst. The higher the value the more strain it puts on the Hex processor and more ThreeJS objects get generated.

@BangNguyen1992
Copy link
Author

Hello @vasturiano, I am not sure if changing from 3 to 4 is considered high.

What I want is to have a hex polygon layer but when the user zoom in, I want them to see the hexagon as a rounded shape. Therefore, my idea is to increase the hexPolygonResolution from 3 to 4 when the user zooms in enough and change it back to 3 when they zoom out.

@BangNguyen1992
Copy link
Author

Hello @vasturiano, I understand that increasing the hexPolygonResolution CPU burst, thus, making the app freeze.

Is there any way to make the generating new Theejs objects without blocking the transition/animation of the current process? It's fine if the generation takes a longer time.

Example:

  • I have a globe that rotates around the y-axis
  • I use a hex polygon layer to represent the countries around the world
  • After changing the hexPolygonResolution, the globe is still able to rotate smoothly, and the hex processor gradually updates and re-renders with the new hexPolygonResolution

Is it possible to achieve that scenario?

Thank you for this amazing library

@vasturiano
Copy link
Owner

@BangNguyen1992 the bulk of the CPU load is caused by the hex coordinate generation by h3-js. I can only imagine what you describe being possible if that operation is offloaded off the main thread using web workers. Unfortunately this is not currently supported in this module, it would be a non-trivial change to add this type of asynchronous functionality.

@BangNguyen1992
Copy link
Author

Thank you @vasturiano, I think I have approached it in the wrong way, which makes the issue become more complicated than it should be. 😅

I am closing the issue now since the bug had been fixed.

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