I make a scene, and now I want to save it when user click a button. Everything comes from I want to do some image processing through shader and save the result, because I know that shader has high performance. The demo is below: JSFiddle demo
I know how to save 2d canvas:
init2D()
function init2D() {
// 2d context save code
var cav = document.querySelector('#ctx2d'),
ctx = cav.getContext('2d')
ctx.beginPath();
ctx.arc(20, 20, 50, 0, Math.PI);
ctx.stroke();
ctx.closePath()
var base64 = cav.toDataURL()
document.querySelector('#img').src = base64
}
Hey, I think the answer is in preserving the drawing buffer. it is a gl property, which defaults to false, and you want it set to false generally for performance, so you could use some logic here to set it to true just before snapping the shot, then set it back to false after the image has been snapped and returned.