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

HtmlMesh Renders Incorrectly When Browser Window is Resized #304

Closed
Dorado8 opened this issue Jul 26, 2024 · 3 comments
Closed

HtmlMesh Renders Incorrectly When Browser Window is Resized #304

Dorado8 opened this issue Jul 26, 2024 · 3 comments

Comments

@Dorado8
Copy link

Dorado8 commented Jul 26, 2024

In the example [https://www.babylonjs-playground.com/#Y2LIXI#44], when you drag to resize the right-side canvas, you will notice that the overlayMesh and overlayMeshDiv are misaligned. After reviewing the source code, I found that the issue lies in the createGetCanvasRectGenerator function in the utils.ts file. This method uses updateInterval for throttling, which causes the final render to be misaligned. This issue is most noticeable when the browser is zoomed in or out. My solution is to use lodash.throttle(boundOnResize, 500, { leading: true, trailing: true }) for throttling.

11_202472617526.mp4
@Dorado8
Copy link
Author

Dorado8 commented Jul 26, 2024

After making this change, the HtmlMesh renders correctly. I initially positioned it on the yellow sphere, and no matter how the canvas size is changed, it remains properly aligned.

22_2024726171047.mp4

@PSI497
Copy link

PSI497 commented Oct 25, 2024

for anyone looking for a solution that does the resizing immediately by the next render, I wrote about another hacky workaround to solve this in BabylonJS/Babylon.js#15788

@deltakosh
Copy link
Contributor

Closing as we will tackle it with BabylonJS/Babylon.js#15788

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

3 participants