简体   繁体   English

拍摄框架场景的屏幕截图并将其保存到服务器而不会弹出窗口

[英]Taking a screenshot of aframe scene and save it to server without popups

The code: 编码:

<script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
<script>
  AFRAME.registerComponent("foo", {
    init: function() {
      document.querySelector('a-scene').components.screenshot.capture('perspective')
    }
  })

</script>
<a-scene screenshot="width: 640; height: 320" foo>
  <a-entity id="box" geometry="primitive: box; width: 1; depth: 1; height: 1" position="-1 0.5 -3" rotation="0 45 0" material="color: #4CC3D9"></a-entity>
  <a-entity id="sphere" geometry="primitive: sphere; radius: 1.25" material="color: #EF2D5E" position="0 1.25 -5"></a-entity>
  <a-entity id="cylinder" geometry="primitive: cylinder; radius: 0.5; height: 1.5" position="1 0.75 -3" material="color: #FFC65D"></a-entity>
  <a-entity id="plane" position="0 0 -4" rotation="-90 0 0" geometry="primitive: plane; width: 4; height: 4" material="color: #7BC8A4"></a-entity>
  <a-entity id="sky" geometry="primitive: sphere; radius: 100" material="color: #ECECEC; shader: flat; side: back"></a-entity>
</a-scene>

This code is like ctrl + alt + s click, and opens a new window. 此代码类似于ctrl + alt + s单击,并打开一个新窗口。 I need to save a screenshot of the scene without clicks or popups. 我需要保存场景的屏幕截图,而无需单击或弹出窗口。

Other problem is the screenshot goes completely white or like this: screenshot 另一个问题是屏幕截图完全变为白色或如下所示: 屏幕截图

Thank you all 谢谢你们

Take a look at html2canvas library its easy to use and works. 看一下html2canvas库,它易于使用且有效。 Also, Google used it to implement the Thanos click effect on the google page. 此外,谷歌使用它在Google页面上实现Thanos点击效果。 Here , visit the link and click on the gauntlet. 在这里 ,访问链接并单击手套。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM