-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.js
34 lines (33 loc) · 984 Bytes
/
render.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const puppeteer = require('puppeteer-core');
const fs = require('fs').promises;
(async () => {
const browser = await puppeteer.launch({
product: 'chrome',
executablePath: '../../../../../usr/bin/google-chrome-stable',
defaultViewport: {
width: 1920,
height: 1080,
},
});
const page = await browser.newPage();
await page.goto('http://localhost:8000/index.html');
await page.keyboard.press('F2');
let frame = 0;
const date = +new Date();
await fs.mkdir(`render${date}`);
while (true) {
try {
console.log(`Rendering frame ${frame}`);
await page.waitForSelector('#fullscreen-scene', {timeout: 500});
await page.screenshot({path: `render${date}/frame${frame.toString().padStart(3,'0')}.png`});
await page.keyboard.press('F1');
frame++;
} catch (e) {
console.log('error');
console.log(e);
await page.screenshot({path: 'error.png'});
break;
}
}
await browser.close();
})();