Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a parameter to CreateScreenshotUsingRenderTarget(Async) to allow … #13384

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/dev/core/src/Misc/screenshotTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export function CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera,
* @param fileName A name for for the downloaded file.
* @param renderSprites Whether the sprites should be rendered or not (default: false)
* @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
* @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)
*/
export function CreateScreenshotUsingRenderTarget(
engine: Engine,
Expand All @@ -199,7 +200,8 @@ export function CreateScreenshotUsingRenderTarget(
antialiasing: boolean = false,
fileName?: string,
renderSprites: boolean = false,
enableStencilBuffer: boolean = false
enableStencilBuffer: boolean = false,
useLayerMask: boolean = true
): void {
const { height, width } = _GetScreenshotSize(engine, camera, size);
const targetTextureSize = { width, height };
Expand Down Expand Up @@ -235,6 +237,7 @@ export function CreateScreenshotUsingRenderTarget(
texture.samples = samples;
texture.renderSprites = renderSprites;
texture.activeCamera = camera;
texture.forceLayerMaskCheck = useLayerMask;

const renderToTexture = () => {
engine.onEndFrameObservable.addOnce(() => {
Expand Down Expand Up @@ -293,6 +296,8 @@ export function CreateScreenshotUsingRenderTarget(
* @param antialiasing Whether antialiasing should be turned on or not (default: false)
* @param fileName A name for for the downloaded file.
* @param renderSprites Whether the sprites should be rendered or not (default: false)
* @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
* @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)
* @returns screenshot as a string of base64-encoded characters. This string can be assigned
* to the src parameter of an <img> to display it
*/
Expand All @@ -304,7 +309,9 @@ export function CreateScreenshotUsingRenderTargetAsync(
samples: number = 1,
antialiasing: boolean = false,
fileName?: string,
renderSprites: boolean = false
renderSprites: boolean = false,
enableStencilBuffer: boolean = false,
useLayerMask: boolean = true
): Promise<string> {
return new Promise((resolve, reject) => {
CreateScreenshotUsingRenderTarget(
Expand All @@ -322,7 +329,9 @@ export function CreateScreenshotUsingRenderTargetAsync(
samples,
antialiasing,
fileName,
renderSprites
renderSprites,
enableStencilBuffer,
useLayerMask
);
});
}
Expand Down