Skip to main content

xr:screenshotrequest

this.app.fire('xr:screenshotrequest')

Parameters​

None

Description​

Emits a request to the engine to capture a screenshot of the PlayCanvas canvas. The engine will emit a xr:screenshotready event with the JPEG compressed image or xr:screenshoterror if an error has occured.

Example​

this.app.on('xr:screenshotready', (event) => {
// screenshotPreview is an <img> HTML element
const image = document.getElementById('screenshotPreview')
image.src = 'data:image/jpeg;base64,' + event.detail
}, this)

this.app.on('xr:screenshoterror', (detail) => {
console.log(detail)
// Handle screenshot error.
}, this)

this.app.fire('xr:screenshotrequest')