stats.js icon indicating copy to clipboard operation
stats.js copied to clipboard

window.devicePixelRatio being less than 1 causes stats window not having correct width and height

Open hellochenwang opened this issue 6 years ago • 3 comments

window.devicePixelRatio could be less than 1 when zoomed out in chrome, in the following code, after rounding, the var PR = 0, and this value is used to calculate the width and height of the stats window. thus errors.

https://github.com/mrdoob/three.js/blob/5bf335ab57c6030b91469ad5212fe1bd37c19106/examples/jsm/libs/stats.module.js#L115

it's valid to have a float number as px, e.g. 12.321px, the rounding seems not necessary.

hellochenwang avatar Aug 25 '19 02:08 hellochenwang

Does this still occur if you add the following to your HTML <head> section?

<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

looeee avatar Aug 25 '19 05:08 looeee

it certainly shouldn't occur if you disable zooming.

hellochenwang avatar Aug 29 '19 09:08 hellochenwang

@looeee That doesn't prevent me from being able to zoom out in Chrome (see https://stackoverflow.com/questions/27116221/prevent-zoom-cross-browser). I made a PR to fix the issue.

Methuselah96 avatar Sep 26 '19 18:09 Methuselah96