Wrong function signature type for Create Screenshot Using RenderTarget

Hi BabylonJS team

In current version 7.24 the type definition for CreateScreenshotUsingRenderTarget (and CreateScreenshotUsingRenderTargetAsync) is missing the last argument customizeTexture-callback. Not sure how many versions that is affected.

My current workaround is to cast the screenshot function to any before using it.

Here is a playground showing the problem

And here is the interesting code snippet from the playground:

            // ***** This gives us Typescript errors ******* //
            // BABYLON.Tools.CreateScreenshotUsingRenderTarget(engine, camera, {precision: 1.0}, undefined, undefined, undefined, false, undefined, false, false, true, undefined, (texture) => {
            //     texture.renderList = [ground];
            //     texture.useCameraPostProcesses = false;
            // });

            // ***** This works ****** //
            const screenshotfunction_untyped = BABYLON.Tools.CreateScreenshotUsingRenderTarget as any
            screenshotfunction_untyped(engine, camera, {precision: 1.0}, undefined, undefined, undefined, false, undefined, false, false, true, undefined, (texture) => {
                texture.renderList = [ground];
                texture.useCameraPostProcesses = false;
            });

This is only available on the global namespace as it is https://playground.babylonjs.com/#2MVLUB#59

I will add it to the Tools one today

1 Like
1 Like

Thanks for fixing this.