Function CreateScreenshotUsingRenderTarget
-
CreateScreenshotUsingRenderTarget(
engine: AbstractEngine,
camera: Camera,
size: number | IScreenshotSize,
successCallback?: (data: string) => void,
mimeType?: string,
samples?: number,
antialiasing?: boolean,
fileName?: string,
renderSprites?: boolean,
enableStencilBuffer?: boolean,
useLayerMask?: boolean,
quality?: number,
customizeTexture?: (texture: RenderTargetTexture) => void,
customDumpData?: (
width: number,
height: number,
data: ArrayBufferView,
successCallback?: (data: string | ArrayBuffer) => void,
mimeType?: string,
fileName?: string,
invertY?: boolean,
toArrayBuffer?: boolean,
quality?: number,
) => void,
timeoutInMilliseconds?: number,
timeoutErrorCallback?: () => void,
): voidParameters
- engine: AbstractEngine
The engine to use for rendering
- camera: Camera
The camera to use for rendering
- size: number | IScreenshotSize
This parameter can be set to a single number or to an object with the following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed, it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size will be derived from the parameters. The precision property is a multiplier allowing rendering at a higher or lower resolution
OptionalsuccessCallback: (data: string) => voidThe callback receives a single parameter which contains the screenshot as a string of base64-encoded characters. This string can be assigned to the src parameter of an
to display it
- mimeType: string = "image/png"
The MIME type of the screenshot image (default: image/png). Check your browser for supported MIME types
- samples: number = 1
Texture samples (default: 1)
- antialiasing: boolean = false
Whether antialiasing should be turned on or not (default: false)
OptionalfileName: stringA name for for the downloaded file.
- renderSprites: boolean = false
Whether the sprites should be rendered or not (default: false)
- enableStencilBuffer: boolean = false
Whether the stencil buffer should be enabled or not (default: false)
- useLayerMask: boolean = true
if the camera's layer mask should be used to filter what should be rendered (default: true)
Optionalquality: numberThe quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See HTMLCanvasElement.toBlob()'s
qualityparameter.OptionalcustomizeTexture: (texture: RenderTargetTexture) => voidAn optional callback that can be used to modify the render target texture before taking the screenshot. This can be used, for instance, to enable camera post-processes before taking the screenshot.
OptionalcustomDumpData: (
width: number,
height: number,
data: ArrayBufferView,
successCallback?: (data: string | ArrayBuffer) => void,
mimeType?: string,
fileName?: string,
invertY?: boolean,
toArrayBuffer?: boolean,
quality?: number,
) => voidThe function to use to dump the data. If not provided, the default DumpData function will be used.
- timeoutInMilliseconds: number = 30000
The maximum time to wait for the screenshot to be ready before calling the timeoutErrorCallback (default: 30000 ms)
OptionaltimeoutErrorCallback: () => voidThe callback that will be called if the screenshot could not be taken before the timeoutInMilliseconds
Returns void
- engine: AbstractEngine
Generates an image screenshot from the specified camera. Please note that simultaneous screenshots are not supported: you must wait until one screenshot is complete before taking another.