Skip to content
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

Manual: Refactor canvas width and height computation. #27606

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions manual/en/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ <h2 id="handling-hd-dpi-displays">Handling HD-DPI displays</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/examples/responsive-hd-dpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@

const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if ( needResize ) {

Expand Down
4 changes: 2 additions & 2 deletions manual/fr/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ <h2 id="g-rer-les-affichages-hd-dpi">Gérer les affichages HD-DPI</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/ja/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ <h2 id="hd-dpi-">HD-DPIディスプレイの取り扱い</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/ko/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ <h2 id="hd-dpi-">HD-DPI 디스플레이 다루기</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/ru/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ <h2 id="-hd-dpi">Обработка дисплеев HD-DPI</h2>
<pre class="prettyprint showlinemods notranslate notranslate" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/zh/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ <h2 id="-hd-dpi-">应对HD-DPI显示器</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down