6

Some background: I'm loading a three.js project (written by a colleague) in an iFrame on a responsive page.

The goal: Be able to grab a screenshot of the three.js at a specific resolution (regardless of the viewport size)

I'm currently successful in grabbing a screenshot of the three.js project following advice found here: Three.js Screenshot

The problem: The png produced is always the same size as the iFrame.

Is it possible to duplicate the renderer in some sort of offscreen renderer that I can resize and take a snapshot of without impacting the end user? Or any advice on a different solution?

Community
  • 1
  • 1
EL45
  • 470
  • 4
  • 16

1 Answers1

10

One suggestion, do something like this?

renderer.setSize( widthOfScreenshot, heightOfScreenshot );
renderer.render( scene, camera );
var screenshot = renderer.domElement.toDataURL();
renderer.setSize( originalWidth, originalHeight );
renderer.render( scene, camera );
gman
  • 100,619
  • 31
  • 269
  • 393