 canvas.clientWidth / canvas.clientHeight;
+  const imageAspect = bgTexture.image ? bgTexture.image.width / bgTexture.image.height : 1;
+  const aspect = imageAspect / canvasAspect;
+
+  bgTexture.offset.x = aspect &gt; 1 ? (1 - 1 / aspect) / 2 : 0;
+  bgTexture.repeat.x = aspect &gt; 1 ? 1 / aspect : 1;
+
+  bgTexture.offset.y = aspect &gt; 1 ? 0 : (1 - aspect) / 2;
+  bgTexture.repeat.y = aspect &gt; 1 ? 1 : aspect;

  ...

  renderer.render(scene, camera);

  requestAnimationFrame(render);
}
</pre>
<p>et