小编San*_*ddi的帖子

threejs canvas todataurl为空

好的,我知道canvas.toDataUrl()会生成png格式的图像。但是,当我尝试从http://threejs.org/examples/#webgl_lines_sphere获取图像时。我所看到的只是镀铬的黑色图像。复制步骤-

1)打开开发者控制台,然后选择canvas元素。2)canvas = $0 3)context = canvas.getContext('webgl', {preserveDrawingBuffer: true}) 4)img = canvas.toDataUrl() 5)document.write('<img src="'+img+'"/>')

图像为空白。但是,我尝试使用链接http://threejs.org/examples/#canvas_geometry_cube上的其他画布。请执行以下步骤进行复制。

1)打开开发者控制台,然后选择canvas元素。2)canvas = $0 3)context = canvas.getContext('2d', {preserveDrawingBuffer: true}) 4)img = canvas.toDataUrl() 5)document.write('<img src="'+img+'"/>')

这给出了预期的结果。为什么会有区别?又如何避免获取第一张图片?

html5 canvas webgl three.js todataurl

4
推荐指数
2
解决办法
1001
查看次数

标签 统计

canvas ×1

html5 ×1

three.js ×1

todataurl ×1

webgl ×1