Server side rendering possibility

Thanks, @ladris, for your immediate answer:

Following your statement, may I call Pupetter’s APIs from inside BJS’ executeWhenReady?

Let me explain all this a bit. I’m following the example code to get to this:

var puppeteer = require('puppeteer');

async function takeScreenshot(params) {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.setViewport({
        width: 1920,
        height: 1080
    });
    await page.goto('https://playground.babylonjs.com/#KBS9I5');
    await page.screenshot({
        path: params.path
    });
    await page.close();
    await browser.close();
}

module.exports = takeScreenshot;

…using, as you can see, the more trivial scene I’ve managed to find (https://playground.babylonjs.com/#KBS9I5).

When executed I’ve just get the following screenshot:

…because, of course, the scene has not been created/shown at the moment the screenshot is taken.

Following your advice, I must move part of the custom NodeJS module inside my BJS logic more or less this way (please note the SCREENSHOT HERE indication):

...
function _create() {
        //1
        _engine = new BABYLON.Engine(canvas, true, {
            preserveDrawingBuffer: true
        });

        //2
        _scene = new BABYLON.Scene(_engine);
        _scene.clearColor = BABYLON.Color4.FromHexString('#00000000');

        //3
        _scene.executeWhenReady(function () {
            _engine.runRenderLoop(function () {
                _scene.render();
                //SCREENSHOT HERE and ONCE!!!<-------------------------
            });
        });

        //4
        /*_scene.registerBeforeRender(function () {
        });*/

        //5
        /*_scene.registerAfterRender(function () {
        });
        */

        console.log(_TAG + "Object created.");
}
...

Is this the approach are you proposing? Is a call to Puppeteer’s API possible from inside executeWhenReady? Honestly, I can’t see how, but of course I’m a newbie on NodeJS!

Thanks for your time.