ShotgunJed Posted January 25, 2018 Share Posted January 25, 2018 Zooming with the browser seems to affect the size of the game. This is my code here: window.onresize = function (event) { var w = window.innerWidth; var h = window.innerHeight; renderer.view.style.width = w + "px"; renderer.view.style.height = h + "px"; renderer.resize(w, h); } How do I make it so regardless of how much the user is zoomed in their browser, the values w and h shouldn't change? (If the user resizes their window, it should change though) ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 25, 2018 Share Posted January 25, 2018 var resolution = window.devicePixelRatio; var w = window.innerWidth; var h = window.innerHeight; var w2 = Math.round(w * resolution); var h2 = Math.round(h * resolution); renderer.view.style.width = w + "px"; renderer.view.style.height = h + "px"; renderer.resize(w2, h2); w2 and h2 will be the same if user zooms. I also recommend to abandon it, and allow users to zoom. Quote Link to comment Share on other sites More sharing options...
ShotgunJed Posted January 26, 2018 Author Share Posted January 26, 2018 Thank you very much ivan! I need it for a multiplayer game so players do not see outside of their screen ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 26, 2018 Share Posted January 26, 2018 That's a strange solution of that issue. I hope that it works for you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.