Search code examples
javascriptthree.jscamera

How do I fit a textured quad to fill entire frustum of orthographic camera in threejs?


I would like to fill the frustum seen by an orthographic camera with a texture quad. What is the easiest way to do that so I don't get gaps on the sides or above where the scene background (GREEN) appears.

enter image description here


Solution

  • The x-scale of your square should match the ratio between viewport width / height. You didn't post a single line of code, so I'm just going to assume you're using a regular plane and the window object for your canvas sizing:

    const ratio = window.innerWidth / window.innerHeight;
    plane.scale.x = ratio;