⚠⚠⚠⚠⚠this must be set when new a renderer object⚠⚠⚠⚠⚠
{preserveDrawingBuffer: true}
//⚠⚠⚠⚠⚠this must be set when new a renderer object⚠⚠⚠⚠⚠
//{preserveDrawingBuffer: true}
const renderer = new THREE.WebGLRenderer({preserveDrawingBuffer: true});
//set a id for getting the canvas
renderer.domElement.id = 'screenshot';
//to get canvas and turn to base64URL
const canvas = document.getElementById("screenshot");
const dataURL = canvas.toDataURL();
//console.log(dataURL);
//create a fake link to download
var a = document.createElement("a");
a.setAttribute("download", "screenshot");
a.setAttribute("href", dataURL);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);