@babylonjs/core 8.6.2 → 8.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatable.core.js +2 -2
- package/Animations/animatable.core.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.d.ts +3 -35
- package/AudioV2/abstractAudio/abstractSound.js +2 -58
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundSource.d.ts +57 -0
- package/AudioV2/abstractAudio/abstractSoundSource.js +72 -0
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -0
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +33 -0
- package/AudioV2/abstractAudio/audioEngineV2.js +23 -0
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/webAudio/index.d.ts +1 -0
- package/AudioV2/webAudio/index.js +1 -0
- package/AudioV2/webAudio/index.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
- package/AudioV2/webAudio/webAudioEngine.js +18 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.d.ts +41 -0
- package/AudioV2/webAudio/webAudioSoundSource.js +115 -0
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -0
- package/AudioV2/webAudio/webAudioStaticSound.js +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/Collisions/collider.d.ts +1 -1
- package/Collisions/collider.js +14 -3
- package/Collisions/collider.js.map +1 -1
- package/Collisions/collisionCoordinator.d.ts +2 -2
- package/Collisions/collisionCoordinator.js +9 -5
- package/Collisions/collisionCoordinator.js.map +1 -1
- package/Culling/ray.core.d.ts +1 -1
- package/Culling/ray.core.js +1 -1
- package/Culling/ray.core.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -2
- package/Engines/abstractEngine.js +3 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +1 -1
- package/Engines/constants.js +1 -1
- package/Engines/constants.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +2 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +4 -3
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +46 -0
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +107 -0
- package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +1 -1
- package/FrameGraph/Passes/renderPass.js +3 -0
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/motionBlurTask.d.ts +27 -0
- package/FrameGraph/Tasks/PostProcesses/motionBlurTask.js +41 -0
- package/FrameGraph/Tasks/PostProcesses/motionBlurTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +12 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +30 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/index.d.ts +2 -1
- package/FrameGraph/index.js +2 -1
- package/FrameGraph/index.js.map +1 -1
- package/Gizmos/cameraGizmo.js +2 -2
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Maths/ThinMaths/index.d.ts +2 -0
- package/Maths/ThinMaths/index.js +3 -0
- package/Maths/ThinMaths/index.js.map +1 -0
- package/Maths/ThinMaths/thinMath.matrix.d.ts +20 -0
- package/Maths/ThinMaths/thinMath.matrix.functions.d.ts +53 -0
- package/Maths/ThinMaths/thinMath.matrix.functions.js +190 -0
- package/Maths/ThinMaths/thinMath.matrix.functions.js.map +1 -0
- package/Maths/ThinMaths/thinMath.matrix.js +23 -0
- package/Maths/ThinMaths/thinMath.matrix.js.map +1 -0
- package/Maths/index.d.ts +1 -0
- package/Maths/index.js +2 -0
- package/Maths/index.js.map +1 -1
- package/Maths/math.vector.js +7 -89
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +2 -1
- package/Meshes/abstractMesh.js +3 -2
- package/Meshes/abstractMesh.js.map +1 -1
- package/Misc/screenshotTools.js +2 -0
- package/Misc/screenshotTools.js.map +1 -1
- package/Particles/flowMap.d.ts +18 -3
- package/Particles/flowMap.js +19 -7
- package/Particles/flowMap.js.map +1 -1
- package/Particles/particleSystem.js +2 -1
- package/Particles/particleSystem.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +0 -3
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/index.d.ts +1 -0
- package/PostProcesses/index.js +1 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.d.ts +4 -11
- package/PostProcesses/motionBlurPostProcess.js +40 -62
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/thinMotionBlurPostProcess.d.ts +67 -0
- package/PostProcesses/thinMotionBlurPostProcess.js +127 -0
- package/PostProcesses/thinMotionBlurPostProcess.js.map +1 -0
- package/PostProcesses/thinSSRPostProcess.js +1 -2
- package/PostProcesses/thinSSRPostProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +1 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +1 -1
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/prePassRenderer.js +1 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js +5 -5
- package/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +0 -3
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/screenSpaceRayTrace.js +3 -2
- package/Shaders/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
- package/Shaders/motionBlur.fragment.js +6 -17
- package/Shaders/motionBlur.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +4 -4
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesVertex.js +8 -8
- package/ShadersWGSL/ShadersInclude/bonesVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +0 -3
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertex.js +8 -8
- package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/screenSpaceRayTrace.js +3 -0
- package/ShadersWGSL/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.js +8 -8
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/motionBlur.fragment.js +6 -17
- package/ShadersWGSL/motionBlur.fragment.js.map +1 -1
- package/assetContainer.js +3 -0
- package/assetContainer.js.map +1 -1
- package/package.json +5 -2
package/Misc/screenshotTools.js
CHANGED
|
@@ -272,6 +272,8 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
|
|
|
272
272
|
if (antialiasing) {
|
|
273
273
|
const fxaaPostProcess = new FxaaPostProcess("antialiasing", 1.0, scene.activeCamera);
|
|
274
274
|
texture.addPostProcess(fxaaPostProcess);
|
|
275
|
+
// Ensures the correct background color is used
|
|
276
|
+
fxaaPostProcess.autoClear = true;
|
|
275
277
|
// Async Shader Compilation can lead to none ready effects in synchronous code
|
|
276
278
|
fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {
|
|
277
279
|
if (!e.isReady()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB,EAChB,OAAO,GAAG,KAAK;IAEf,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAAiB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,qBAAqB;IAErB;;;;;;;;;;;;;OAaG;IACH,+BAA+B;IAE/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iCAAiC;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sCAAsC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { _RetryWithInterval } from \"./timingTools\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number,\r\n useFill = false\r\n): void {\r\n const { height, width } = GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n return;\r\n }\r\n\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (!renderContext || !renderingCanvas) {\r\n Logger.Error(\"Failed to create screenshot. Rendering context or rendering canvas is not available.\");\r\n return;\r\n }\r\n\r\n const srcWidth = renderingCanvas.width;\r\n const srcHeight = renderingCanvas.height;\r\n const destWidth = screenshotCanvas.width;\r\n const destHeight = screenshotCanvas.height;\r\n\r\n // Calculate scale factors for width and height.\r\n const scaleX = destWidth / srcWidth;\r\n const scaleY = destHeight / srcHeight;\r\n // Use the larger of the two scales to fill the screenshot dimensions, else use the smaller to fit.\r\n const scale = useFill ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);\r\n const newWidth = srcWidth * scale;\r\n const newHeight = srcHeight * scale;\r\n\r\n // Center the image in the screenshot canvas\r\n const offsetX = (destWidth - newWidth) / 2;\r\n const offsetY = (destHeight - newHeight) / 2;\r\n\r\n renderContext.drawImage(renderingCanvas, 0, 0, srcWidth, srcHeight, offsetX, offsetY, newWidth, newHeight);\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\nexport async function CreateScreenshotWithResizeAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n width: number,\r\n height: number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An 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.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n // Prevent engine to render on screen while we do the screenshot\r\n engine.skipFrameRender = true;\r\n\r\n const originalGetRenderWidth = engine.getRenderWidth;\r\n const originalGetRenderHeight = engine.getRenderHeight;\r\n\r\n // Override getRenderWidth and getRenderHeight to return the desired size of the render\r\n // A few internal methods are relying on the canvas size to compute the render size\r\n // so we need to override these methods to ensure the correct size is used during the preparation of the render\r\n // as well as the screenshot\r\n engine.getRenderWidth = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.width;\r\n }\r\n\r\n return width;\r\n };\r\n engine.getRenderHeight = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.height;\r\n }\r\n\r\n return height;\r\n };\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const dumpDataFunc = customDumpData || DumpData;\r\n\r\n const renderWhenReady = () => {\r\n _RetryWithInterval(\r\n () => texture.isReadyForRendering() && camera.isReady(true),\r\n () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n dumpDataFunc(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n importPromise.then(async () =>\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n dumpDataFunc(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n // Record the original scene setup\r\n const originalCamera = scene.activeCamera;\r\n const originalCameras = scene.activeCameras;\r\n const originalOutputRenderTarget = camera.outputRenderTarget;\r\n const originalSpritesEnabled = scene.spritesEnabled;\r\n\r\n // Swap with the requested one\r\n scene.activeCamera = camera;\r\n scene.activeCameras = null;\r\n camera.outputRenderTarget = texture;\r\n scene.spritesEnabled = renderSprites;\r\n\r\n const currentMeshList = scene.meshes;\r\n scene.meshes = texture.renderList || scene.meshes;\r\n\r\n // render the scene on the RTT\r\n try {\r\n scene.render();\r\n } finally {\r\n // Restore the original scene camera setup\r\n scene.activeCamera = originalCamera;\r\n scene.activeCameras = originalCameras;\r\n camera.outputRenderTarget = originalOutputRenderTarget;\r\n scene.spritesEnabled = originalSpritesEnabled;\r\n scene.meshes = currentMeshList;\r\n\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n\r\n engine.skipFrameRender = false;\r\n }\r\n },\r\n () => {\r\n // Restore engine frame rendering on error\r\n engine.skipFrameRender = false;\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n }\r\n );\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An 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.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture,\r\n customDumpData\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This size of the screenshot. can be a number or an object implementing IScreenshotSize\r\n * @returns height and width for screenshot size\r\n */\r\nfunction GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|
|
1
|
+
{"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,O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CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { _RetryWithInterval } from \"./timingTools\";\r\n\r\nlet screenshotCanvas: Nullable<HTMLCanvasElement> = null;\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\nexport function CreateScreenshot(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n forceDownload = false,\r\n quality?: number,\r\n useFill = false\r\n): void {\r\n const { height, width } = GetScreenshotSize(engine, camera, size);\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n const scene = camera.getScene();\r\n if (scene.activeCamera !== camera) {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (forceDownload) {\r\n const blob = new Blob([data]);\r\n Tools.DownloadBlob(blob);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else if (successCallback) {\r\n successCallback(data);\r\n }\r\n },\r\n mimeType,\r\n 1.0,\r\n engine.getCreationOptions().antialias,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n quality\r\n );\r\n return;\r\n }\r\n\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (!renderContext || !renderingCanvas) {\r\n Logger.Error(\"Failed to create screenshot. Rendering context or rendering canvas is not available.\");\r\n return;\r\n }\r\n\r\n const srcWidth = renderingCanvas.width;\r\n const srcHeight = renderingCanvas.height;\r\n const destWidth = screenshotCanvas.width;\r\n const destHeight = screenshotCanvas.height;\r\n\r\n // Calculate scale factors for width and height.\r\n const scaleX = destWidth / srcWidth;\r\n const scaleY = destHeight / srcHeight;\r\n // Use the larger of the two scales to fill the screenshot dimensions, else use the smaller to fit.\r\n const scale = useFill ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);\r\n const newWidth = srcWidth * scale;\r\n const newHeight = srcHeight * scale;\r\n\r\n // Center the image in the screenshot canvas\r\n const offsetX = (destWidth - newWidth) / 2;\r\n const offsetY = (destHeight - newHeight) / 2;\r\n\r\n renderContext.drawImage(renderingCanvas, 0, 0, srcWidth, srcHeight, offsetX, offsetY, newWidth, newHeight);\r\n\r\n if (forceDownload) {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, undefined, mimeType, undefined, quality);\r\n if (successCallback) {\r\n successCallback(\"\");\r\n }\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(screenshotCanvas, successCallback, mimeType, undefined, quality);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n undefined,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\nexport async function CreateScreenshotWithResizeAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n width: number,\r\n height: number,\r\n mimeType = \"image/png\",\r\n quality?: number,\r\n useFill = false\r\n): Promise<void> {\r\n return new Promise((resolve) => {\r\n CreateScreenshot(\r\n engine,\r\n camera,\r\n { width: width, height: height },\r\n () => {\r\n resolve();\r\n },\r\n mimeType,\r\n true,\r\n quality,\r\n useFill\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height, finalWidth, finalHeight. If a single number is passed,\r\n * it will be used for both width and height, as well as finalWidth, finalHeight. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An 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.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n */\r\nexport function CreateScreenshotUsingRenderTarget(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): void {\r\n const { height, width, finalWidth, finalHeight } = GetScreenshotSize(engine, camera, size);\r\n const targetTextureSize = { width, height };\r\n\r\n if (!(height && width)) {\r\n Logger.Error(\"Invalid 'size' parameter !\");\r\n return;\r\n }\r\n\r\n // Prevent engine to render on screen while we do the screenshot\r\n engine.skipFrameRender = true;\r\n\r\n const originalGetRenderWidth = engine.getRenderWidth;\r\n const originalGetRenderHeight = engine.getRenderHeight;\r\n\r\n // Override getRenderWidth and getRenderHeight to return the desired size of the render\r\n // A few internal methods are relying on the canvas size to compute the render size\r\n // so we need to override these methods to ensure the correct size is used during the preparation of the render\r\n // as well as the screenshot\r\n engine.getRenderWidth = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.width;\r\n }\r\n\r\n return width;\r\n };\r\n engine.getRenderHeight = (useScreen = false) => {\r\n if (!useScreen && engine._currentRenderTarget) {\r\n return engine._currentRenderTarget.height;\r\n }\r\n\r\n return height;\r\n };\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n const scene = camera.getScene();\r\n\r\n // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)\r\n const texture = new RenderTargetTexture(\r\n \"screenShot\",\r\n targetTextureSize,\r\n scene,\r\n false,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n false,\r\n Texture.BILINEAR_SAMPLINGMODE,\r\n undefined,\r\n enableStencilBuffer,\r\n undefined,\r\n undefined,\r\n undefined,\r\n samples\r\n );\r\n texture.renderList = scene.meshes.slice();\r\n texture.samples = samples;\r\n texture.renderSprites = renderSprites;\r\n texture.activeCamera = camera;\r\n texture.forceLayerMaskCheck = useLayerMask;\r\n customizeTexture?.(texture);\r\n\r\n const dumpDataFunc = customDumpData || DumpData;\r\n\r\n const renderWhenReady = () => {\r\n _RetryWithInterval(\r\n () => texture.isReadyForRendering() && camera.isReady(true),\r\n () => {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n if (finalWidth === width && finalHeight === height) {\r\n texture.readPixels(undefined, undefined, undefined, false)!.then((data) => {\r\n dumpDataFunc(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n texture.dispose();\r\n });\r\n } else {\r\n const importPromise = engine.isWebGPU ? import(\"../ShadersWGSL/pass.fragment\") : import(\"../Shaders/pass.fragment\");\r\n importPromise.then(async () =>\r\n ApplyPostProcess(\"pass\", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {\r\n engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {\r\n dumpDataFunc(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n })\r\n );\r\n }\r\n });\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n // Record the original scene setup\r\n const originalCamera = scene.activeCamera;\r\n const originalCameras = scene.activeCameras;\r\n const originalOutputRenderTarget = camera.outputRenderTarget;\r\n const originalSpritesEnabled = scene.spritesEnabled;\r\n\r\n // Swap with the requested one\r\n scene.activeCamera = camera;\r\n scene.activeCameras = null;\r\n camera.outputRenderTarget = texture;\r\n scene.spritesEnabled = renderSprites;\r\n\r\n const currentMeshList = scene.meshes;\r\n scene.meshes = texture.renderList || scene.meshes;\r\n\r\n // render the scene on the RTT\r\n try {\r\n scene.render();\r\n } finally {\r\n // Restore the original scene camera setup\r\n scene.activeCamera = originalCamera;\r\n scene.activeCameras = originalCameras;\r\n camera.outputRenderTarget = originalOutputRenderTarget;\r\n scene.spritesEnabled = originalSpritesEnabled;\r\n scene.meshes = currentMeshList;\r\n\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n\r\n // Trigger a resize event to ensure the intermediate renders have the correct size\r\n if (engine.onResizeObservable.hasObservers()) {\r\n engine.onResizeObservable.notifyObservers(engine);\r\n }\r\n\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n\r\n engine.skipFrameRender = false;\r\n }\r\n },\r\n () => {\r\n // Restore engine frame rendering on error\r\n engine.skipFrameRender = false;\r\n engine.getRenderWidth = originalGetRenderWidth;\r\n engine.getRenderHeight = originalGetRenderHeight;\r\n }\r\n );\r\n };\r\n\r\n const renderToTexture = () => {\r\n // render the RTT\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n\r\n renderWhenReady();\r\n };\r\n\r\n if (antialiasing) {\r\n const fxaaPostProcess = new FxaaPostProcess(\"antialiasing\", 1.0, scene.activeCamera);\r\n texture.addPostProcess(fxaaPostProcess);\r\n // Ensures the correct background color is used\r\n fxaaPostProcess.autoClear = true;\r\n\r\n // Async Shader Compilation can lead to none ready effects in synchronous code\r\n fxaaPostProcess.onEffectCreatedObservable.addOnce((e) => {\r\n if (!e.isReady()) {\r\n e.onCompiled = () => {\r\n renderToTexture();\r\n };\r\n }\r\n // The effect is ready we can render\r\n else {\r\n renderToTexture();\r\n }\r\n });\r\n } else {\r\n // No need to wait for extra resources to be ready\r\n renderToTexture();\r\n }\r\n}\r\n\r\n/**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param useLayerMask if the camera's layer mask should be used to filter what should be rendered (default: true)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param customizeTexture An 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.\r\n * @param customDumpData The function to use to dump the data. If not provided, the default DumpData function will be used.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\nexport async function CreateScreenshotUsingRenderTargetAsync(\r\n engine: AbstractEngine,\r\n camera: Camera,\r\n size: IScreenshotSize | number,\r\n mimeType = \"image/png\",\r\n samples = 1,\r\n antialiasing = false,\r\n fileName?: string,\r\n renderSprites = false,\r\n enableStencilBuffer = false,\r\n useLayerMask = true,\r\n quality?: number,\r\n customizeTexture?: (texture: RenderTargetTexture) => void,\r\n customDumpData?: (\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n ) => void\r\n): Promise<string> {\r\n return new Promise((resolve, reject) => {\r\n CreateScreenshotUsingRenderTarget(\r\n engine,\r\n camera,\r\n size,\r\n (data) => {\r\n if (typeof data !== \"undefined\") {\r\n resolve(data);\r\n } else {\r\n reject(new Error(\"Data is undefined\"));\r\n }\r\n },\r\n mimeType,\r\n samples,\r\n antialiasing,\r\n fileName,\r\n renderSprites,\r\n enableStencilBuffer,\r\n useLayerMask,\r\n quality,\r\n customizeTexture,\r\n customDumpData\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Gets height and width for screenshot size\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This size of the screenshot. can be a number or an object implementing IScreenshotSize\r\n * @returns height and width for screenshot size\r\n */\r\nfunction GetScreenshotSize(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number): { height: number; width: number; finalWidth: number; finalHeight: number } {\r\n let height = 0;\r\n let width = 0;\r\n let finalWidth = 0;\r\n let finalHeight = 0;\r\n\r\n //If a size value defined as object\r\n if (typeof size === \"object\") {\r\n const precision = size.precision\r\n ? Math.abs(size.precision) // prevent GL_INVALID_VALUE : glViewport: negative width/height\r\n : 1;\r\n\r\n //If a width and height values is specified\r\n if (size.width && size.height) {\r\n height = size.height * precision;\r\n width = size.width * precision;\r\n }\r\n //If passing only width, computing height to keep display canvas ratio.\r\n else if (size.width && !size.height) {\r\n width = size.width * precision;\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n //If passing only height, computing width to keep display canvas ratio.\r\n else if (size.height && !size.width) {\r\n height = size.height * precision;\r\n width = Math.round(height * engine.getAspectRatio(camera));\r\n } else {\r\n width = Math.round(engine.getRenderWidth() * precision);\r\n height = Math.round(width / engine.getAspectRatio(camera));\r\n }\r\n\r\n //If a finalWidth and finalHeight values is specified\r\n if (size.finalWidth && size.finalHeight) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = size.finalWidth;\r\n }\r\n //If passing only finalWidth, computing finalHeight to keep display canvas ratio.\r\n else if (size.finalWidth && !size.finalHeight) {\r\n finalWidth = size.finalWidth;\r\n finalHeight = Math.round(finalWidth / engine.getAspectRatio(camera));\r\n }\r\n //If passing only finalHeight, computing finalWidth to keep display canvas ratio.\r\n else if (size.finalHeight && !size.finalWidth) {\r\n finalHeight = size.finalHeight;\r\n finalWidth = Math.round(finalHeight * engine.getAspectRatio(camera));\r\n } else {\r\n finalWidth = width;\r\n finalHeight = height;\r\n }\r\n }\r\n //Assuming here that \"size\" parameter is a number\r\n else if (!isNaN(size)) {\r\n height = size;\r\n width = size;\r\n finalWidth = size;\r\n finalHeight = size;\r\n }\r\n\r\n // When creating the image data from the CanvasRenderingContext2D, the width and height is clamped to the size of the _gl context\r\n // On certain GPUs, it seems as if the _gl context truncates to an integer automatically. Therefore, if a user tries to pass the width of their canvas element\r\n // and it happens to be a float (1000.5 x 600.5 px), the engine.readPixels will return a different size array than context.createImageData\r\n // to resolve this, we truncate the floats here to ensure the same size\r\n if (width) {\r\n width = Math.floor(width);\r\n }\r\n if (height) {\r\n height = Math.floor(height);\r\n }\r\n if (finalWidth) {\r\n finalWidth = Math.floor(finalWidth);\r\n }\r\n if (finalHeight) {\r\n finalHeight = Math.floor(finalHeight);\r\n }\r\n\r\n return { height: height | 0, width: width | 0, finalWidth: finalWidth | 0, finalHeight: finalHeight | 0 };\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for screenshots\r\n */\r\nexport const ScreenshotTools = {\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback defines the callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param forceDownload force the system to download the image even if a successCallback is provided\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n */\r\n CreateScreenshot,\r\n\r\n /**\r\n * Captures a screenshot of the current rendering\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotAsync,\r\n\r\n /**\r\n * Captures and automatically downloads a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)\r\n * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine defines the rendering engine\r\n * @param camera defines the source camera. If the camera is not the scene's active camera, {@link CreateScreenshotUsingRenderTarget} will be used instead, and `useFill` will be ignored\r\n * @param width defines the expected width\r\n * @param height defines the expected height\r\n * @param mimeType defines the MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @param useFill fill the screenshot dimensions with the render canvas and clip any overflow. If false, fit the canvas within the screenshot, as in letterboxing.\r\n * @returns promise that resolves once the screenshot is taken\r\n */\r\n CreateScreenshotWithResizeAsync,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param successCallback The callback receives a single parameter which contains the\r\n * screenshot as a string of base64-encoded characters. This string can be assigned to the\r\n * src parameter of an <img> to display it\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n CreateScreenshotUsingRenderTarget,\r\n\r\n /**\r\n * Generates an image screenshot from the specified camera.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG\r\n * @param engine The engine to use for rendering\r\n * @param camera The camera to use for rendering\r\n * @param size This parameter can be set to a single number or to an object with the\r\n * following (optional) properties: precision, width, height. If a single number is passed,\r\n * it will be used for both width and height. If an object is passed, the screenshot size\r\n * will be derived from the parameters. The precision property is a multiplier allowing\r\n * rendering at a higher or lower resolution\r\n * @param mimeType The MIME type of the screenshot image (default: image/png).\r\n * Check your browser for supported MIME types\r\n * @param samples Texture samples (default: 1)\r\n * @param antialiasing Whether antialiasing should be turned on or not (default: false)\r\n * @param fileName A name for for the downloaded file.\r\n * @param renderSprites Whether the sprites should be rendered or not (default: false)\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns screenshot as a string of base64-encoded characters. This string can be assigned\r\n * to the src parameter of an <img> to display it\r\n */\r\n CreateScreenshotUsingRenderTargetAsync,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.CreateScreenshot = CreateScreenshot;\r\n Tools.CreateScreenshotAsync = CreateScreenshotAsync;\r\n Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget;\r\n Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
|
package/Particles/flowMap.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
2
|
+
import type { Particle } from "../Particles/particle.js";
|
|
3
|
+
import type { IVector3Like } from "../Maths/math.like.js";
|
|
4
|
+
/**
|
|
5
|
+
* Represents an object that can move or be influenced by FlowMap
|
|
6
|
+
*/
|
|
7
|
+
export interface IFlowable {
|
|
8
|
+
/**
|
|
9
|
+
* The direction vector indicating the flow or movement direction of the object.
|
|
10
|
+
*/
|
|
11
|
+
direction: Vector3;
|
|
12
|
+
/**
|
|
13
|
+
* The current position of the object in 3D space.
|
|
14
|
+
*/
|
|
15
|
+
position: Vector3;
|
|
16
|
+
}
|
|
3
17
|
/**
|
|
4
18
|
* Class used to represent a particle flow map.
|
|
5
19
|
* #5DM02T#7
|
|
@@ -17,8 +31,9 @@ export declare class FlowMap {
|
|
|
17
31
|
* @param data defines the data of the flow map
|
|
18
32
|
*/
|
|
19
33
|
constructor(width: number, height: number, data: Uint8ClampedArray);
|
|
34
|
+
processFlowable(flowable: IFlowable, strength?: number, flowMapSamplePosOrTransformationMatrix?: IVector3Like | Matrix): void;
|
|
20
35
|
/** @internal */
|
|
21
|
-
_processParticle(particle: Particle,
|
|
36
|
+
_processParticle(particle: Particle, strength?: number, matrix?: Matrix): void;
|
|
22
37
|
/**
|
|
23
38
|
* Creates a FlowMap from a url.
|
|
24
39
|
* @param url The url of the image to load
|
package/Particles/flowMap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3 } from "../Maths/math.vector.js";
|
|
1
|
+
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
2
2
|
const FlowVector = new Vector3(0, 0, 0);
|
|
3
3
|
const ScaledFlowVector = new Vector3(0, 0, 0);
|
|
4
4
|
const ScreenPos = new Vector3(0, 0, 0);
|
|
@@ -20,11 +20,19 @@ export class FlowMap {
|
|
|
20
20
|
this.height = height;
|
|
21
21
|
this.data = data;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
processFlowable(flowable, strength = 1, flowMapSamplePosOrTransformationMatrix) {
|
|
24
|
+
if (!flowMapSamplePosOrTransformationMatrix) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
26
27
|
// Convert world pos to screen pos
|
|
27
|
-
|
|
28
|
+
if (flowMapSamplePosOrTransformationMatrix instanceof Matrix) {
|
|
29
|
+
Vector3.TransformCoordinatesToRef(flowable.position, flowMapSamplePosOrTransformationMatrix, ScreenPos);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
ScreenPos.x = flowMapSamplePosOrTransformationMatrix.x;
|
|
33
|
+
ScreenPos.y = flowMapSamplePosOrTransformationMatrix.y;
|
|
34
|
+
ScreenPos.z = flowMapSamplePosOrTransformationMatrix.z;
|
|
35
|
+
}
|
|
28
36
|
const u = ScreenPos.x * 0.5 + 0.5;
|
|
29
37
|
const v = 1.0 - (ScreenPos.y * 0.5 + 0.5);
|
|
30
38
|
const x = Math.floor(u * this.width);
|
|
@@ -43,8 +51,12 @@ export class FlowMap {
|
|
|
43
51
|
const fz = (b / 255.0) * 2.0 - 1.0;
|
|
44
52
|
const localStrength = a / 255.0;
|
|
45
53
|
FlowVector.set(fx, fy, fz);
|
|
46
|
-
FlowVector.scaleToRef(
|
|
47
|
-
|
|
54
|
+
FlowVector.scaleToRef(strength * localStrength, ScaledFlowVector);
|
|
55
|
+
flowable.direction.addInPlace(ScaledFlowVector); // Update IFlowable velocity
|
|
56
|
+
}
|
|
57
|
+
/** @internal */
|
|
58
|
+
_processParticle(particle, strength = 1, matrix) {
|
|
59
|
+
this.processFlowable(particle, strength, matrix);
|
|
48
60
|
}
|
|
49
61
|
/**
|
|
50
62
|
* Creates a FlowMap from a url.
|
package/Particles/flowMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowMap.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/flowMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"flowMap.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/flowMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIvD,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAA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AE,EAAE;YACnC,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YACpD,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAE,CAAC;YAC7C,IAAI,aAAa,GAAG,IAAI,CAAC;YAEzB,MAAM,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;YACjC,YAAY,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,iCAAiC;YACzE,YAAY,CAAC,GAAG,GAAG,GAAG,CAAC;YAEvB,YAAY,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE;gBACzB,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7D,CAAC,CAAC;YAEF,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE;gBACvB,UAAU,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;gBACtC,UAAU,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;gBACxC,OAAO,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;gBACtC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;gBAEhF,OAAO,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport type { Particle } from \"../Particles/particle\";\r\nimport type { IVector3Like } from \"../Maths/math.like\";\r\n\r\nconst FlowVector = new Vector3(0, 0, 0);\r\nconst ScaledFlowVector = new Vector3(0, 0, 0);\r\nconst ScreenPos = new Vector3(0, 0, 0);\r\n\r\n/**\r\n * Represents an object that can move or be influenced by FlowMap\r\n */\r\nexport interface IFlowable {\r\n /**\r\n * The direction vector indicating the flow or movement direction of the object.\r\n */\r\n direction: Vector3;\r\n\r\n /**\r\n * The current position of the object in 3D space.\r\n */\r\n position: Vector3;\r\n}\r\n\r\n/**\r\n * Class used to represent a particle flow map.\r\n * #5DM02T#7\r\n * GPUParts: #5DM02T#12 (webgl2)\r\n * GPUParts: #5DM02T#13 (webgpu)\r\n */\r\nexport class FlowMap {\r\n /**\r\n * Create a new flow map.\r\n * @param width defines the width of the flow map\r\n * @param height defines the height of the flow map\r\n * @param data defines the data of the flow map\r\n */\r\n constructor(\r\n public readonly width: number,\r\n public readonly height: number,\r\n public readonly data: Uint8ClampedArray\r\n ) {}\r\n\r\n public processFlowable(flowable: IFlowable, strength = 1, flowMapSamplePosOrTransformationMatrix?: IVector3Like | Matrix) {\r\n if (!flowMapSamplePosOrTransformationMatrix) {\r\n return;\r\n }\r\n\r\n // Convert world pos to screen pos\r\n if (flowMapSamplePosOrTransformationMatrix instanceof Matrix) {\r\n Vector3.TransformCoordinatesToRef(flowable.position, flowMapSamplePosOrTransformationMatrix, ScreenPos);\r\n } else {\r\n ScreenPos.x = flowMapSamplePosOrTransformationMatrix.x;\r\n ScreenPos.y = flowMapSamplePosOrTransformationMatrix.y;\r\n ScreenPos.z = flowMapSamplePosOrTransformationMatrix.z;\r\n }\r\n\r\n const u = ScreenPos.x * 0.5 + 0.5;\r\n const v = 1.0 - (ScreenPos.y * 0.5 + 0.5);\r\n\r\n const x = Math.floor(u * this.width);\r\n const y = Math.floor(v * this.height);\r\n\r\n // Clamp\r\n if (x < 0 || x >= this.width || y < 0 || y >= this.height) {\r\n return;\r\n }\r\n\r\n const index = (y * this.width + x) * 4;\r\n const r = this.data[index];\r\n const g = this.data[index + 1];\r\n const b = this.data[index + 2];\r\n const a = this.data[index + 3];\r\n\r\n const fx = (r / 255.0) * 2.0 - 1.0;\r\n const fy = (g / 255.0) * 2.0 - 1.0;\r\n const fz = (b / 255.0) * 2.0 - 1.0;\r\n const localStrength = a / 255.0;\r\n\r\n FlowVector.set(fx, fy, fz);\r\n FlowVector.scaleToRef(strength * localStrength, ScaledFlowVector);\r\n\r\n flowable.direction.addInPlace(ScaledFlowVector); // Update IFlowable velocity\r\n }\r\n\r\n /** @internal */\r\n public _processParticle(particle: Particle, strength = 1, matrix?: Matrix) {\r\n this.processFlowable(particle, strength, matrix);\r\n }\r\n\r\n /**\r\n * Creates a FlowMap from a url.\r\n * @param url The url of the image to load\r\n * @returns a promise that resolves to a FlowMap object\r\n */\r\n public static async FromUrlAsync(url: string): Promise<FlowMap> {\r\n return new Promise((resolve, reject) => {\r\n const flowCanvas = document.createElement(\"canvas\");\r\n const flowCtx = flowCanvas.getContext(\"2d\")!;\r\n let flowImageData = null;\r\n\r\n const flowMapImage = new Image();\r\n flowMapImage.crossOrigin = \"anonymous\"; // If loading from another domain\r\n flowMapImage.src = url;\r\n\r\n flowMapImage.onerror = (e) => {\r\n reject(new Error(`Failed to load image: ${url} : ${e}`));\r\n };\r\n\r\n flowMapImage.onload = () => {\r\n flowCanvas.width = flowMapImage.width;\r\n flowCanvas.height = flowMapImage.height;\r\n flowCtx.drawImage(flowMapImage, 0, 0);\r\n flowImageData = flowCtx.getImageData(0, 0, flowCanvas.width, flowCanvas.height);\r\n\r\n resolve(new FlowMap(flowCanvas.width, flowCanvas.height, flowImageData.data));\r\n };\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -83,9 +83,10 @@ export class ParticleSystem extends ThinParticleSystem {
|
|
|
83
83
|
this._flowMapUpdate = null;
|
|
84
84
|
}
|
|
85
85
|
if (value) {
|
|
86
|
+
const matrix = this.getScene()?.getTransformMatrix();
|
|
86
87
|
this._flowMapUpdate = {
|
|
87
88
|
process: (particle) => {
|
|
88
|
-
this._flowMap._processParticle(particle, this
|
|
89
|
+
this._flowMap._processParticle(particle, this.flowMapStrength * this._tempScaledUpdateSpeed, matrix);
|
|
89
90
|
},
|
|
90
91
|
previousItem: null,
|
|
91
92
|
nextItem: null,
|