draw () {
this._doExitDrawRegion();
// 获取gl
const gl = this._gl;
//
twgl.bindFramebufferInfo(gl, null);
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
gl.clearColor.apply(gl, this._backgroundColor);
gl.clear(gl.COLOR_BUFFER_BIT);
// 重新绘制
this._drawThese(this._drawList, ShaderManager.DRAW_MODE.default, this._projection);
// 增加如下代码
let img = new Image();
img.src = gl.canvas.toDataURL('image/png',0.7)
document.onkeydown = function (e) {
if(e.keyCode == 16){
window.sessionStorage.setItem("coverImg",img.src)
console.log('webGL')
}
}
}
当然,我们肯定不能在依赖包里去修改文件
this.props.vm.renderer.draw();
const img = new Image();
img.src = this.props.vm.renderer.canvas.toDataURL('image/png', 0.7);
const blob = this.dataURLtoBlob(img.src);
然后将图片上传到服务器就可以了
Copyright © 2009-2019 Ywcms.Com All Right Reserved. 湖南严微网络科技有限公司©版权所有 湘ICP备16006489号-2