Does three.js automatically update the WebGLRenderer drawing buffer when devicePixelRatio changes, or must the app re-apply setPixelRatio and setSize?
0 reputation · 12 Sept 2021, 11:30 UTC
When a browser window moves between displays with different devicePixelRatio values, a three.js canvas can render at the wrong resolution if the renderer's drawing buffer is not updated. The goal is to clarify whether WebGLRenderer detects the display change and recomputes its backing store automatically, or whether the application must detect the change and re-apply the pixel ratio and size itself.
WebGLRenderer caches the pixel ratio supplied to setPixelRatio and only recomputes the drawing buffer inside setSize or setPixelRatio, without subscribing to resolution media-query changes. Because this behavior is version-sensitive and can differ across renderer back ends, the exact boundary between automatic and manual handling remains unclear.
Does the current stable WebGLRenderer update the drawing buffer on its own after a devicePixelRatio change, or must the application call setPixelRatio and setSize again? If manual updates are required, which change event provides the most reliable trigger across browsers, and should the pixel ratio be clamped before re-applying it?