Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1, user-scalable=no"/>
  6. <title>Screenshot Test</title>
  7. <style>
  8. html, body {
  9. height: 100%;
  10. width: 100%;
  11. }
  12.  
  13. .controls {
  14. position: absolute;
  15. bottom: 0;
  16. background: white;
  17. z-index: 1000;
  18. }
  19. .error {
  20. color: red;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <canvas id="xrcanvas"></canvas>
  26. <div class="controls">
  27. <button id="shotbutton">Take Screenshot</button>
  28. <h2 id="output"></h2>
  29. </div>
  30.  
  31. <script src="//cdn.8thwall.com/web/xrextras/xrextras.js"></script>
  32. <script async src="//apps.8thwall.com/xrweb?appKey=XXXXXXXX"></script>
  33.  
  34. <script>
  35. const canvas = document.querySelector('#xrcanvas')
  36. const shotButton = document.querySelector('#shotbutton')
  37. const outputEl = document.querySelector('#output')
  38. let numShots = 0
  39. const onxrloaded = () => {
  40. XR.addCameraPipelineModules([
  41. XR.GlTextureRenderer.pipelineModule(),
  42. XRExtras.FullWindowCanvas.pipelineModule(), // Error occurs more often with full screen enabled
  43. XR.canvasScreenshot().cameraPipelineModule(),
  44. ])
  45. XR.run({ canvas })
  46. shotButton.addEventListener('click', () => {
  47. XR.canvasScreenshot().takeScreenshot().then(
  48. data => {
  49. numShots++
  50. outputEl.innerHTML = `${numShots} Screenshots Complete`
  51. outputEl.classList.remove('error')
  52. },
  53. error => {
  54. outputEl.innerHTML = error.message
  55. outputEl.classList.add('error')
  56. })
  57. })
  58. }
  59. window.XR ? onxrloaded() : window.addEventListener('xrloaded', onxrloaded)
  60. </script>
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement