I am new to using three js
. I have successfully exported an image in png format using the WebGL renderer
. However, when attempting to export the image in a different custom size resolution, the resolution does not change. How can I set the image resolution
?
var width,height,renderer3D;
renderer3D = new THREE.WebGLRenderer({
antialias: true,preserveDrawingBuffer: true
});
this.ExportImage = function(){
var imgSize = document.getElementById('imageSizeOption').value;
if(imgSize =='small'){
imgWidth = 640;
imgHeight = 480;
}else if(imgSize =='medium'){
imgWidth = 1024;
imgHeight = 768;
}else if(imgSize =='large'){
imgWidth = 1536;
imgHeight = 1024;
}
fileName = 'construction'+".png";
var a = window.document.createElement("a");
a.href = renderer3D.domElement.toDataURL("image/png", 1.0);
a.style.width= imgWidth + 'px'; //setting resolution width
a.style.height= imgHeight + 'px'; //setting resolution height (does not work)
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
};