场景导出之后图片之后,存储到指定的文件夹目录下,而不是浏览器的默认文件夹,怎么样指定自定义的存储路径呢?
在官网的例子中的,方法是如下,
function convertImageToCanvas(image) {
var canvas = document.createElement("canvas");
canvas.width = 400;
canvas.height = 300;
canvas.getContext("2d").drawImage(image, -700, 0);
return canvas;
}
/**
* 下载图片
*/
function download(base64data) {
var image = new Image();
image.src = base64data;
image.onload = function() {
var canvas = convertImageToCanvas(image);
url = canvas.toDataURL("image/jpeg");
var a = document.createElement('a');
var event = new MouseEvent('click');
a.download = (new Date()).getTime() + ".png"; // 指定下载图片的名称
a.href = url;
a.dispatchEvent(event); // 触发超链接的点击事件
}
}