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

Fix resize drift bug, may depend on devicePixelRatio #62

Open
jimbojw opened this issue Sep 28, 2022 · 0 comments
Open

Fix resize drift bug, may depend on devicePixelRatio #62

jimbojw opened this issue Sep 28, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@jimbojw
Copy link
Collaborator

jimbojw commented Sep 28, 2022

The Scene's resize() method allows the caller to recompute the offset and the underlying canvas element's dimensions after the canvas DOM size has been changed. If resize() is not called, then the canvas element's dimensions will often have a different aspect ratio from the DOM size and cause the rendered visualization to appear stretched or squished.

The resize() method takes an optional fixed canvas point. This point specifies the pixel location to keep fixed after the aspect ratio transformation. By default, the fixed canvas point used will be the center point of the canvas. Using scene.offset as the fixed point should have the effect of preserving the location of the world origin (0,0).

There is a bug where one or both of the offset components may be a pixel off after the resize(). If calls to resize() are repeated, this can cause the offset to creep in one direction or the other. This seems to occur more readily when the devicePixelRatio is 1.

Develop an example which consistently produces this behavior, then fix it.

@jimbojw jimbojw added the bug Something isn't working label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant