Indeed, the scene can be rendered into a THREE.WebGLRenderTarget
. By utilizing
renderer.readRenderTargetPixels()
, it is possible to access the rendered data with some limitations such as the absence of antialiasing.
An example implementation would resemble this:
const renderTarget = new THREE.WebGLRenderTarget(rendererWidth, rendererHeight);
renderer.render(scene, camera, renderTarget);
// Define the width and height of the target region
// Specify the coordinates of the bottom-left area
const pixelBuffer = new Uint8Array(width * height * 4);
renderer.readRenderTargetPixels(renderTarget, x, y, width, height, pixelBuffer);
If you wish to focus on rendering only a specific section of the screen, you may opt for scissor-testing:
renderer.setScissor(x, y, width, height);
renderer.setScissorTest(true);
renderer.render(scene, camera, renderTarget);
renderer.setScissor(0, 0, rendererWidth, rendererHeight);
renderer.setScissorTest(false);