Gregg Tavares 6 years ago
parent
commit
d6960374db
2 changed files with 5 additions and 5 deletions
  1. 3 3
      threejs/lessons/threejs-responsive.md
  2. 2 2
      threejs/threejs-responsive-hd-dpi.html

+ 3 - 3
threejs/lessons/threejs-responsive.md

@@ -233,7 +233,7 @@ and pass that to three.js
 
 After that any calls to `renderer.setSize` will magicially
 use the size you request multiplied by whatever pixel ratio
-you passed in. This is strongly **NOT RECOMMENDED**. See below
+you passed in. **This is strongly NOT RECOMMENDED**. See below
 
 The other way is to do it yourself when you resize the canvas.
 
@@ -241,8 +241,8 @@ The other way is to do it yourself when you resize the canvas.
     function resizeRendererToDisplaySize(renderer) {
       const canvas = renderer.domElement;
       const pixelRatio = window.devicePixelRatio;
-      const width = canvas.clientWidth * pixelRatio;
-      const height = canvas.clientHeight * pixelRatio;
+      const width  = canvas.clientWidth  * pixelRatio | 0;
+      const height = canvas.clientHeight * pixelRatio | 0;
       const needResize = canvas.width !== width || canvas.height !== height;
       if (needResize) {
         renderer.setSize(width, height, false);

+ 2 - 2
threejs/threejs-responsive-hd-dpi.html

@@ -72,8 +72,8 @@ function main() {
   function resizeRendererToDisplaySize(renderer) {
     const canvas = renderer.domElement;
     const pixelRatio = window.devicePixelRatio;
-    const width = canvas.clientWidth * pixelRatio;
-    const height = canvas.clientHeight * pixelRatio;
+    const width  = canvas.clientWidth  * pixelRatio | 0;
+    const height = canvas.clientHeight * pixelRatio | 0;
     const needResize = canvas.width !== width || canvas.height !== height;
     if (needResize) {
       renderer.setSize(width, height, false);