Created
February 4, 2021 19:32
-
-
Save jordyhenry/14649067bb7627c4bb061b41c7f2ff69 to your computer and use it in GitHub Desktop.
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
/* | |
INSTRUCTIONS | |
- Join a Mozilla Hubs room | |
- Open your browser console (f12) | |
- Copy and paste this snippet on the console, and press Enter | |
- Walk with your avatar to wherever the viewpoint you wish to capture | |
- Press the left Ctrl+Space on your keyboard, and download your 360 image. | |
*/ | |
function setupAndGetScreenshooter() { | |
AFRAME.scenes[0].setAttribute('screenshot', '') | |
return AFRAME.scenes[0].components.screenshot | |
} | |
// equirectangular or perspective | |
function takeScreenshot(screenShooter, type='equirectangular') { | |
let params = screenShooter.setCapture(type) | |
screenShooter.renderCapture(params.camera, params.size, params.projection); | |
screenShooter.saveCapture() | |
} | |
const screenShooter = setupAndGetScreenshooter() | |
const keysPressed = {} | |
// Adding new keybinding | |
document.addEventListener('keydown', (event) => { | |
keysPressed[event.code] = true | |
if(keysPressed['ControlLeft'] && keysPressed['Space']) takeScreenshot(screenShooter) | |
}); | |
document.addEventListener('keyup', event => delete keysPressed[event.code]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment