Search code examples
javascripthtmlthree.jsaframe

A-Frame: Programmatically taking panoramic screenshots


Following docs here for panoramic screen shots https://aframe.io/blog/screenshot/ they have hot keys for users taking screen shots, is there a way for me to generate a panoramic screenshot without user input?

as well as choosing to save it (server side).


Solution

  • You can take screen captures programatically using the methods outlined in the following documentation: https://aframe.io/docs/0.8.0/components/screenshot.html#methods

    To take a screenshot programatically and get a canvas, call getCanvas():

    // `screenshot.projection` property can be `equirectangular` or `perspective`.
    document.querySelector('a-scene').components.screenshot.getCanvas('equirectangular');
    

    To take a screenshot programmatically and automatically save the file, call capture():

    document.querySelector('a-scene').components.screenshot.capture('perspective');