我看到了一个html2canvas创建html块的“屏幕快照”的例子(例如:html2canvas实例)。
我想做的是,使用javascript捕捉three.js (或任何js 3d库)的“屏幕截图”。
请记住,用户在决定“屏幕截图”之前可能会玩(旋转等) 3d场景。
html2canvas能“捕捉”3d场景吗?
编辑 see plunker for code工作解决方案见柱塞
发布于 2016-02-04 15:16:44
既然three.js画了一个画布,我很肯定您可以复制它的当前状态,而不用使用html2canvas。
function cloneCanvas(oldCanvas) {
//create a new canvas
var newCanvas = document.createElement('canvas');
var context = newCanvas.getContext('2d');
//set dimensions
newCanvas.width = oldCanvas.width;
newCanvas.height = oldCanvas.height;
//apply the old canvas to the new one
context.drawImage(oldCanvas, 0, 0);
//return the new canvas
return newCanvas;
}关于html2canvas,这段文档让我相信它能够复制canva,因为它没有受到跨源内容的污染。
局限性 脚本使用的所有映像都需要驻留在相同的原点下,这样才能在没有代理帮助的情况下读取它们。类似地,如果页面上有其他受跨源内容污染的画布元素,它们将变得肮脏,不再被html2canvas读取。
https://stackoverflow.com/questions/35187194
复制相似问题