Search code examples
three.jsrenderingviewportoutline

Is it possible to Outline a view port in threejs?


I've created a scene with two cameras and one renderer. each camera is looking at the scene from a different angle and I have the first camera rendering on the entire screen then the second camera I have rendering in a small view port laying on top of the first render. I was wondering if there is a way to have that second view port outlined so that each look separate


Solution

  • Yes, you can outline an inset viewport by rendering a solid-colored rectangle slightly larger than the inset prior to rendering the inset.

    // border
    renderer.setScissorTest( true );
    renderer.setScissor( x, y, width, height );
    renderer.setClearColor( 0xffffff, 1 ); // border color
    renderer.clearColor(); // clear color buffer
    

    Then, render the inset. Just make sure the inset background is opaque.

    three.js r.86