question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

window.devicePixelRatio support?

See original GitHub issue

I’m struggling to decide whether three.js should handle window.devicePixelRatio internally or not.

This would mean adding this kind of code to each renderer:

var ratio = window.devicePixelRatio || 1;

canvas.width = width * ratio;
canvas.height = height * ratio;

canvas.style.width = width + 'px';
canvas.style.height = height + 'px';

The good thing is that people wouldn’t have to worry about having to implement it on their end. But I don’t know what the bad things would be. I’m sure this could lead to some confusion at some point.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mrdoobcommented, Mar 17, 2016

😊

0reactions
that-bencommented, Mar 17, 2016

MY FACE WHEN I DISCOVERED renderer.setPixelRatio(1)

Thanks Ricardo for talking about this! That small detail by itself made my 3D FPS implementation achieve almost 60fps without changing anything else. Incredibly useful for mobile devices and horrible laptop GPU’s.

jaw drop wtf wow

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window.devicePixelRatio | Can I use... Support ... - CanIUse
Read-only property that returns the ratio of the (vertical) size of one physical pixel on the current display device to the size of...
Read more >
Window.devicePixelRatio - Web APIs | MDN
The devicePixelRatio of Window interface returns the ratio of the resolution in physical pixels to the resolution in CSS pixels for the ...
Read more >
Browser Compatibility of Window.devicePixelRatio on Safari 15
devicePixelRatio is Fully Supported on Safari 15, which means that any user who'd be accessing your page through Safari 15 can see it...
Read more >
window.devicePixelRatio browser support - Stack Overflow
1 Answer 1 · window.devicePixelRatio is mostly trustworthy on most browsers. · On iOS devices, multiply devicePixelRatio by screen.width to get ...
Read more >
Support table - device pixel ratio.md - GitHub Gist
Device OS OS version Browser Browser version Device pixel ratio Apple iPad 5th iOS 11.0.3 Mobile Safari 11.0 2 Apple iPad Air 2 iOS 8.4...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found