Hi all,
My scene is a complex scene.
To get a screenshot using CreateScreenshotUsingRenderTarget, we need to wait for the scene to be fully rendered. I tried with the below two approaches but none of them are working as expected. I am getting only the background in the image.
Please help me.
Thanks in advance.
CameraHelper.TakeScreenshotInMemory1 = function (camera, callback) {
var scene = camera.getScene();
var engine = scene.getEngine();
var current = scene.afterRender;
scene.afterRender = function () {
scene.afterRender = current;
BABYLON.Tools.CreateScreenshotUsingRenderTarget(engine, camera, { precision: 1 }, callback);
};
scene.render();
};
CameraHelper.TakeScreenshotInMemory2 = function (camera, callback) {
var scene = camera.getScene();
var engine = scene.getEngine();
var func = function () {
scene.unregisterAfterRender(func);
BABYLON.Tools.CreateScreenshotUsingRenderTarget(engine, camera, { precision: 1 }, callback);
};
scene.registerAfterRender(func);
scene.render();
};