threejs 获取场景中某一个平面图,是否能够实现?

需求:最近在研究threejs,因为一个物件是由多个模型组合而成,但是想着用户在旋转3d模型的时候,是否能够在当前旋转角度截取一个平面图,就类似手机的截屏,不知道在软件技术方面能否实现?

神不在的星期二
浏览 1648回答 1
1回答

慕标琳琳

threejs本身就是绘制一个canvas,然而canvas本身就可以获取平面图,&nbsp;function drawImg(){&nbsp; &nbsp; &nbsp; &nbsp; var mycanvas = document.getElementById("canvas");&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; var image&nbsp; &nbsp; = mycanvas.toDataURL("image/png");&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; var w=window.open('about:blank','image from canvas');&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; w.document.write("<img src='"+image+"' alt='from canvas'/>");&nbsp;&nbsp; &nbsp; }&nbsp; &nbsp; $('#saveImg').click(function(){&nbsp; &nbsp; &nbsp; &nbsp; drawImg();&nbsp; &nbsp; })
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript