Reduced Test Case for 8th Wall Screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1, user-scalable=no"/> | |
<title>Screenshot Test</title> | |
<style> | |
html, body { | |
height: 100%; | |
width: 100%; | |
} | |
.controls { | |
position: absolute; | |
bottom: 0; | |
background: white; | |
z-index: 1000; | |
} | |
.error { | |
color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<canvas id="xrcanvas"></canvas> | |
<div class="controls"> | |
<button id="shotbutton">Take Screenshot</button> | |
<h2 id="output"></h2> | |
</div> | |
<script src="//cdn.8thwall.com/web/xrextras/xrextras.js"></script> | |
<script async src="//apps.8thwall.com/xrweb?appKey=XXXXXXXX"></script> | |
<script> | |
const canvas = document.querySelector('#xrcanvas') | |
const shotButton = document.querySelector('#shotbutton') | |
const outputEl = document.querySelector('#output') | |
let numShots = 0 | |
const onxrloaded = () => { | |
XR.addCameraPipelineModules([ | |
XR.GlTextureRenderer.pipelineModule(), | |
XRExtras.FullWindowCanvas.pipelineModule(), // Error occurs more often with full screen enabled | |
XR.canvasScreenshot().cameraPipelineModule(), | |
]) | |
XR.run({ canvas }) | |
shotButton.addEventListener('click', () => { | |
XR.canvasScreenshot().takeScreenshot().then( | |
data => { | |
numShots++ | |
outputEl.innerHTML = `${numShots} Screenshots Complete` | |
outputEl.classList.remove('error') | |
}, | |
error => { | |
outputEl.innerHTML = error.message | |
outputEl.classList.add('error') | |
}) | |
}) | |
} | |
window.XR ? onxrloaded() : window.addEventListener('xrloaded', onxrloaded) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment