-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
CSS3DRenderer: Force canvas size to be even #20069
Conversation
Yes, making everything even does work, that's also the route I took in my project, since it also fixes the perspective camera problem (which I had). I went on to have the same resolution for the webgl renderer and the css renderer (so both would always be even). I'm not sure if that is necessary, but I think it might help with having cutouts fitting to the css renderer as clean as possible (so the antialiased line of the webgl renderer matching the css element). I think it is a good solution for now, since it consistently fixes the problem, but it still would be interesting to understand why the problem occurs in the first place. |
In var style = cameraCSSMatrix + 'translate(' + _widthHalf + 'px,' + _heightHalf + 'px)'; with var style = cameraCSSMatrix + 'translate(' + Math.round( _widthHalf ) + 'px,' + Math.round( _heightHalf ) + 'px)'; I observe the same artifacts in Chrome and Firefox as appear in Safari. Consequently, my hypothesis is Safari is rounding during the "translate" step, but in fact, should be rounding only after the entire matrix expression is evaluated. // I think I would prefer to not worry about this, and assume Safari will fix it at some point. In the mean time, users can pass in even-valued canvas dimensions at the app level and avoid these artifacts. // EDIT: macOS Safari 13.1.2 test case: https://threejs.org/examples/css3d_sandbox.html.
|
Should we notice it in the documentation? |
Ah, that does make a lot of sense! Thanks for your in depth analysis!
I think that would be the best solution. What do you think @WestLangley ? |
We do not document browser bugs in the documentation. I suggest we do nothing unless this becomes a serious user issue. |
Possible approach to addressing #19854. Posting as a DRAFT.
CSS3DRenderer
translates by half-width, so this PR prevents fractional pixels.It appears to work for every example I have tried.
Note that there is no three.js requirement that the passed-in canvas dimensions are whole numbers. This can happen, for example, if the user splits the screen.
/ping @JohannesDeml Can you please test this PR on all your examples?