Screenshots without GUI

Hi There
I’m wondering if there’s a possibility to disable the GUI for screenshots (render to png)

The way i’m doing it now is stupid: put the GUI in the background, wait 1sec, do the screenshot, wait 2sec and re-put the GUI back to the foreground…

function guiToForeground() {
babylonGUI.isForeground = true;
};

meContTopSaveImage.onPointerClickObservable.add(function () {

                babylonGUI.isForeground = false;
                setTimeout(function(){
                  setTimeout(function(){
                    guiToForeground();
                },2000);
                BABYLON.Tools.CreateScreenshot(engine, camera1, {precision: 1.0});
              },1000);
              });

I just wanted to ask here if there’s a better way to do it.

I tried it with the onSuccess callback:

function guiToForeground() {
babylonGUI.isForeground = true;
};

meContTopSaveImage.onPointerClickObservable.add(function () {
babylonGUI.isForeground = false;
setTimeout(function(){
BABYLON.Tools.CreateScreenshot(engine, camera1, {precision: 1.0}, guiToForeground);
},2000);
});

It puts the GUi for 2 seconds in the back, but it does not take the screenshot anymore…

thanks

https://www.babylonjs-playground.com/#3GPEIL#1

2 Likes

perfect - thank you very much! :slight_smile: