WebGL often comes with a size restriction. While some modern GPUs can handle limits as high as 8192x8192 (256meg) or even 16384x16384 (one gig), there may still be memory constraints in other areas of the browser, such as for taking a screenshot.
To work around this limitation, you can render portions of a larger image as separate pieces and then combine them using software like photoshop or the gIMP.
In the world of Three.js, you can approach this task like so. Let's say you start with one of the provided samples
function makeScreenshots() {
var desiredWidth = 7000;
var desiredHeight = 7000;
var stepX = 1000;
var stepY = 1000;
for (var y = 0; y < desiredHeight; y += stepY) {
for (var x = 0; x < desiredWidth; x += stepX) {
camera.setViewOffset( desiredWidth, desiredHeight, x, y, stepX, stepY );
renderer.render( scene, camera );
var screenshotDataURL = renderer.domElement.toDataURL();
saveScreenshot( "screenshot" + x + "-" + y + ".png", screenshotDataURL );
}
}
}
Keep in mind that you'll need to create the function saveScreenshot
and likely run a small node.js or python server to save the screenshots. However, this technique allows you to generate images of almost any resolution you desire.
For more information, visit: