Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js Screenshot custom size (using an offscreen rendere?)

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?

like image 949
EL45 Avatar asked Dec 17 '14 20:12

EL45


1 Answers

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 );
like image 88
gman Avatar answered Sep 22 '22 12:09

gman