screenshotrequest
scene.emit('screenshotrequest')
Description​
Emits a request to the engine to capture a screenshot of the AFrame canvas. The engine will emit a
screenshotready
event with the JPEG compressed image or
screenshoterror
if an error has occured.
Parameters​
None
Example​
const scene = this.el.sceneEl
const photoButton = document.getElementById('photoButton')
// Emit screenshotrequest when user taps
photoButton.addEventListener('click', () => {
image.src = ""
scene.emit('screenshotrequest')
})
scene.addEventListener('screenshotready', event => {
image.src = 'data:image/jpeg;base64,' + event.detail
})
scene.addEventListener('screenshoterror', event => {
console.log("error")
})