Screen size custom size. (With offscreen rendere?)

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

Objective: be able to take a screenshot of a three.js image at a specific resolution (regardless of viewport size)

Currently I have successfully captured a screenshot of the three.js project given below: Three.js screenshot

Problem. The produced png is always the same size as the iFrame.

Is it possible to duplicate a renderer in some renderer that can be modified and take a snapshot without affecting the end user? Or any advice for another solution?

+3


source to share


1 answer


One suggestion, do something like that?



renderer.setSize( widthOfScreenshot, heightOfScreenshot );
renderer.render( scene, camera );
var screenshot = renderer.domElement.toDataURL();
renderer.setSize( originalWidth, originalHeight );
renderer.render( scene, camera );

      

+7


source







All Articles