可以html2canvas捕获一个javascript 3d' screenshot'?

时间:2016-02-03 20:36:58

标签: javascript 3d html2canvas

我看过一个html2canvas的例子,创建了一个'截图'一个html块(例如:html2canvas example)。

我想要做的是,使用javascript,捕获一个'截图'一个three.js(或任何js 3d库)场景。

请记住,用户可能会在决定“截图”之前使用(旋转等)3D场景。它

html2canvas'捕获'一个三维场景?

修改         see plunker for code see plunker for working solution

1 个答案:

答案 0 :(得分:0)

好吧,因为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;
}

Thanks to Robert Hurst for his answer on the subject

关于html2canvas,该文档的这一段让我相信它能够复制canva,因为它不会受到跨源内容的污染。

  

限制
  脚本使用的所有图像都需要位于相同的原点下,以便能够在没有代理帮助的情况下读取它们。同样,如果页面上有其他画布元素,这些元素已被多源内容污染,它们将变得脏,并且不再被html2canvas读取。