@babylonjs/core 7.49.0 → 7.50.0
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/Behaviors/Cameras/framingBehavior.js +3 -0
- package/Behaviors/Cameras/framingBehavior.js.map +1 -1
- package/Behaviors/Meshes/baseSixDofDragBehavior.js +10 -9
- package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
- package/Buffers/bufferUtils.d.ts +9 -10
- package/Buffers/bufferUtils.js +16 -0
- package/Buffers/bufferUtils.js.map +1 -1
- package/Culling/Helper/transformFeedbackBoundingHelper.js +2 -1
- package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +23 -22
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.d.ts +43 -0
- package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.js +83 -0
- package/FrameGraph/Node/Blocks/Rendering/utilityLayerRendererBlock.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/Tasks/Rendering/utilityLayerRendererTask.d.ts +35 -0
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +40 -0
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -0
- package/FrameGraph/frameGraph.d.ts +4 -0
- package/FrameGraph/frameGraph.js +6 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -2
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Layers/thinEffectLayer.js +3 -1
- package/Layers/thinEffectLayer.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +3 -1
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +9 -20
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +8 -19
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.d.ts +8 -0
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js +36 -0
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +6 -3
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +8 -0
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +48 -0
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +2 -0
- package/Materials/Node/nodeMaterial.js +14 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
- package/Materials/PBR/pbrBaseMaterial.js +2 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +17 -1
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.js +3 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -0
- package/Materials/standardMaterial.js +2 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +4 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +11 -2
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +4 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +11 -2
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +4 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +11 -2
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
- package/Meshes/abstractMesh.js +6 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg2.js +14 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/mesh.d.ts +47 -1
- package/Meshes/mesh.js +28 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/screenshotTools.js +3 -0
- package/Misc/screenshotTools.js.map +1 -1
- package/Morph/morphTarget.d.ts +12 -0
- package/Morph/morphTarget.js +35 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +13 -0
- package/Morph/morphTargetManager.js +30 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +3 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +3 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +3 -1
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +3 -1
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Rendering/utilityLayerRenderer.d.ts +3 -1
- package/Rendering/utilityLayerRenderer.js +16 -7
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js +9 -0
- package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.js +3 -0
- package/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/vertexColorMixing.js +2 -2
- package/Shaders/ShadersInclude/vertexColorMixing.js.map +1 -1
- package/Shaders/background.vertex.js +1 -1
- package/Shaders/background.vertex.js.map +1 -1
- package/Shaders/color.vertex.js +3 -0
- package/Shaders/color.vertex.js.map +1 -1
- package/Shaders/default.vertex.js +3 -0
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/greasedLine.vertex.js +1 -2
- package/Shaders/greasedLine.vertex.js.map +1 -1
- package/Shaders/pbr.vertex.js +3 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +6 -0
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobalDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexGlobalDeclaration.js.map +1 -1
- package/ShadersWGSL/boundingInfo.compute.js +3 -0
- package/ShadersWGSL/boundingInfo.compute.js.map +1 -1
- package/ShadersWGSL/color.vertex.js +3 -0
- package/ShadersWGSL/color.vertex.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +3 -0
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/greasedLine.vertex.js +2 -3
- package/ShadersWGSL/greasedLine.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +3 -0
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js +1 -0
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +2 -0
- package/scene.js +13 -9
- package/scene.js.map +1 -1
- package/types.d.ts +22 -0
- package/types.js.map +1 -1
package/Misc/screenshotTools.js
CHANGED
|
@@ -232,6 +232,8 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
|
|
|
232
232
|
scene.activeCameras = null;
|
|
233
233
|
camera.outputRenderTarget = texture;
|
|
234
234
|
scene.spritesEnabled = renderSprites;
|
|
235
|
+
const currentMeshList = scene.meshes;
|
|
236
|
+
scene.meshes = texture.renderList || scene.meshes;
|
|
235
237
|
// render the scene on the RTT
|
|
236
238
|
try {
|
|
237
239
|
scene.render();
|
|
@@ -242,6 +244,7 @@ export function CreateScreenshotUsingRenderTarget(engine, camera, size, successC
|
|
|
242
244
|
scene.activeCameras = originalCameras;
|
|
243
245
|
camera.outputRenderTarget = originalOutputRenderTarget;
|
|
244
246
|
scene.spritesEnabled = originalSpritesEnabled;
|
|
247
|
+
scene.meshes = currentMeshList;
|
|
245
248
|
engine.getRenderWidth = originalGetRenderWidth;
|
|
246
249
|
engine.getRenderHeight = originalGetRenderHeight;
|
|
247
250
|
// Trigger a resize event to ensure the intermediate renders have the correct size
|
|
@@ -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,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;;;;;;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 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 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 */\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): 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 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 DumpData(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(() =>\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 DumpData(finalWidth, finalHeight, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\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 // 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\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 * @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 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): 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 );\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,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;IAE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;;;;;;;;;;;;;;;;;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 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 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 */\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): 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 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 DumpData(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(() =>\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 DumpData(finalWidth, finalHeight, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\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 * @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 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): 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 );\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/Morph/morphTarget.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class MorphTarget implements IAnimatable {
|
|
|
22
22
|
private _tangents;
|
|
23
23
|
private _uvs;
|
|
24
24
|
private _uv2s;
|
|
25
|
+
private _colors;
|
|
25
26
|
private _influence;
|
|
26
27
|
private _uniqueId;
|
|
27
28
|
/**
|
|
@@ -78,6 +79,7 @@ export declare class MorphTarget implements IAnimatable {
|
|
|
78
79
|
* Gets a boolean defining if the target contains texture coordinates 2 data
|
|
79
80
|
*/
|
|
80
81
|
get hasUV2s(): boolean;
|
|
82
|
+
get hasColors(): boolean;
|
|
81
83
|
/**
|
|
82
84
|
* Gets the number of vertices stored in this target
|
|
83
85
|
*/
|
|
@@ -132,6 +134,16 @@ export declare class MorphTarget implements IAnimatable {
|
|
|
132
134
|
* @returns a FloatArray containing the texture coordinates 2 data (or null if not present)
|
|
133
135
|
*/
|
|
134
136
|
getUV2s(): Nullable<FloatArray>;
|
|
137
|
+
/**
|
|
138
|
+
* Affects color data to this target
|
|
139
|
+
* @param data defines the color data to use
|
|
140
|
+
*/
|
|
141
|
+
setColors(data: Nullable<FloatArray>): void;
|
|
142
|
+
/**
|
|
143
|
+
* Gets the color data stored in this target
|
|
144
|
+
* @returns a FloatArray containing the color data (or null if not present)
|
|
145
|
+
*/
|
|
146
|
+
getColors(): Nullable<FloatArray>;
|
|
135
147
|
/**
|
|
136
148
|
* Clone the current target
|
|
137
149
|
* @returns a new MorphTarget
|
package/Morph/morphTarget.js
CHANGED
|
@@ -57,6 +57,7 @@ export class MorphTarget {
|
|
|
57
57
|
this._tangents = null;
|
|
58
58
|
this._uvs = null;
|
|
59
59
|
this._uv2s = null;
|
|
60
|
+
this._colors = null;
|
|
60
61
|
this._uniqueId = 0;
|
|
61
62
|
/**
|
|
62
63
|
* Observable raised when the influence changes
|
|
@@ -108,6 +109,9 @@ export class MorphTarget {
|
|
|
108
109
|
get hasUV2s() {
|
|
109
110
|
return !!this._uv2s;
|
|
110
111
|
}
|
|
112
|
+
get hasColors() {
|
|
113
|
+
return !!this._colors;
|
|
114
|
+
}
|
|
111
115
|
/**
|
|
112
116
|
* Gets the number of vertices stored in this target
|
|
113
117
|
*/
|
|
@@ -122,7 +126,9 @@ export class MorphTarget {
|
|
|
122
126
|
? this._uvs.length / 2
|
|
123
127
|
: this._uv2s
|
|
124
128
|
? this._uv2s.length / 2
|
|
125
|
-
:
|
|
129
|
+
: this._colors
|
|
130
|
+
? this._colors.length / 4
|
|
131
|
+
: 0;
|
|
126
132
|
}
|
|
127
133
|
/**
|
|
128
134
|
* Affects position data to this target
|
|
@@ -214,6 +220,24 @@ export class MorphTarget {
|
|
|
214
220
|
getUV2s() {
|
|
215
221
|
return this._uv2s;
|
|
216
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Affects color data to this target
|
|
225
|
+
* @param data defines the color data to use
|
|
226
|
+
*/
|
|
227
|
+
setColors(data) {
|
|
228
|
+
const hadColors = this.hasColors;
|
|
229
|
+
this._colors = data;
|
|
230
|
+
if (hadColors !== this.hasColors) {
|
|
231
|
+
this._onDataLayoutChanged.notifyObservers(undefined);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Gets the color data stored in this target
|
|
236
|
+
* @returns a FloatArray containing the color data (or null if not present)
|
|
237
|
+
*/
|
|
238
|
+
getColors() {
|
|
239
|
+
return this._colors;
|
|
240
|
+
}
|
|
217
241
|
/**
|
|
218
242
|
* Clone the current target
|
|
219
243
|
* @returns a new MorphTarget
|
|
@@ -225,6 +249,7 @@ export class MorphTarget {
|
|
|
225
249
|
newOne._tangents = this._tangents;
|
|
226
250
|
newOne._uvs = this._uvs;
|
|
227
251
|
newOne._uv2s = this._uv2s;
|
|
252
|
+
newOne._colors = this._colors;
|
|
228
253
|
return newOne;
|
|
229
254
|
}
|
|
230
255
|
/**
|
|
@@ -251,6 +276,9 @@ export class MorphTarget {
|
|
|
251
276
|
if (this.hasUV2s) {
|
|
252
277
|
serializationObject.uv2s = Array.prototype.slice.call(this.getUV2s());
|
|
253
278
|
}
|
|
279
|
+
if (this.hasColors) {
|
|
280
|
+
serializationObject.colors = Array.prototype.slice.call(this.getColors());
|
|
281
|
+
}
|
|
254
282
|
// Animations
|
|
255
283
|
SerializationHelper.AppendSerializedAnimations(this, serializationObject);
|
|
256
284
|
return serializationObject;
|
|
@@ -287,6 +315,9 @@ export class MorphTarget {
|
|
|
287
315
|
if (serializationObject.uv2s) {
|
|
288
316
|
result.setUV2s(serializationObject.uv2s);
|
|
289
317
|
}
|
|
318
|
+
if (serializationObject.colors) {
|
|
319
|
+
result.setColors(serializationObject.colors);
|
|
320
|
+
}
|
|
290
321
|
// Animations
|
|
291
322
|
if (serializationObject.animations) {
|
|
292
323
|
for (let animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
|
|
@@ -327,6 +358,9 @@ export class MorphTarget {
|
|
|
327
358
|
if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
|
|
328
359
|
result.setUV2s(mesh.getVerticesData(VertexBuffer.UV2Kind));
|
|
329
360
|
}
|
|
361
|
+
if (mesh.isVerticesDataPresent(VertexBuffer.ColorKind)) {
|
|
362
|
+
result.setColors(mesh.getVerticesData(VertexBuffer.ColorKind));
|
|
363
|
+
}
|
|
330
364
|
return result;
|
|
331
365
|
}
|
|
332
366
|
}
|
package/Morph/morphTarget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"morphTarget.js","sourceRoot":"","sources":["../../../../dev/core/src/Morph/morphTarget.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAuBpB;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,SAAiB;QAClC,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE,EAAE,CAAC;YACzC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,QAAQ,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC;QAC/E,CAAC;IACL,CAAC;IAUD;;OAEG;IACH,IAAW,2BAA2B;QAClC,IAAI,CAAC,IAAI,CAAC,4BAA4B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC,MA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,EAAE,CAAC,CAAC;QAEjE,MAAM,CAAC,YAAY,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAEjF,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;YACtD,MAAM,CAAC,UAAU,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;YACvD,MAAM,CAAC,WAAW,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,MAAM,CAAC,MAAM,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,MAAM,CAAC,OAAO,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA7VU;IADN,SAAS,EAAE;uCACM","sourcesContent":["import type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable, FloatArray } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { AnimationPropertiesOverride } from \"../Animations/animationPropertiesOverride\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\n\r\nimport type { Animation } from \"../Animations/animation\";\r\n\r\n/**\r\n * Defines a target to use with MorphTargetManager\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTarget implements IAnimatable {\r\n /**\r\n * Gets or sets the list of animations\r\n */\r\n public animations: Animation[] = [];\r\n\r\n private _scene: Nullable<Scene>;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _tangents: Nullable<FloatArray> = null;\r\n private _uvs: Nullable<FloatArray> = null;\r\n private _uv2s: Nullable<FloatArray> = null;\r\n private _influence: number;\r\n private _uniqueId = 0;\r\n\r\n /**\r\n * Observable raised when the influence changes\r\n */\r\n public onInfluenceChanged = new Observable<boolean>();\r\n\r\n /** @internal */\r\n public _onDataLayoutChanged = new Observable<void>();\r\n\r\n /**\r\n * Gets or sets the influence of this target (ie. its weight in the overall morphing)\r\n */\r\n public get influence(): number {\r\n return this._influence;\r\n }\r\n\r\n public set influence(influence: number) {\r\n if (this._influence === influence) {\r\n return;\r\n }\r\n\r\n const previous = this._influence;\r\n this._influence = influence;\r\n\r\n if (this.onInfluenceChanged.hasObservers()) {\r\n this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the id of the morph Target\r\n */\r\n @serialize()\r\n public id: string;\r\n\r\n private _animationPropertiesOverride: Nullable<AnimationPropertiesOverride> = null;\r\n\r\n /**\r\n * Gets or sets the animation properties override\r\n */\r\n public get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride> {\r\n if (!this._animationPropertiesOverride && this._scene) {\r\n return this._scene.animationPropertiesOverride;\r\n }\r\n return this._animationPropertiesOverride;\r\n }\r\n\r\n public set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>) {\r\n this._animationPropertiesOverride = value;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTarget\r\n * @param name defines the name of the target\r\n * @param influence defines the influence to use\r\n * @param scene defines the scene the morphtarget belongs to\r\n */\r\n public constructor(\r\n /** defines the name of the target */\r\n public name: string,\r\n influence = 0,\r\n scene: Nullable<Scene> = null\r\n ) {\r\n this.id = name;\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this.influence = influence;\r\n\r\n if (this._scene) {\r\n this._uniqueId = this._scene.getUniqueId();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the unique ID of this manager\r\n */\r\n public get uniqueId(): number {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains position data\r\n */\r\n public get hasPositions(): boolean {\r\n return !!this._positions;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains normal data\r\n */\r\n public get hasNormals(): boolean {\r\n return !!this._normals;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains tangent data\r\n */\r\n public get hasTangents(): boolean {\r\n return !!this._tangents;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains texture coordinates data\r\n */\r\n public get hasUVs(): boolean {\r\n return !!this._uvs;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains texture coordinates 2 data\r\n */\r\n public get hasUV2s(): boolean {\r\n return !!this._uv2s;\r\n }\r\n\r\n /**\r\n * Gets the number of vertices stored in this target\r\n */\r\n public get vertexCount(): number {\r\n return this._positions\r\n ? this._positions.length / 3\r\n : this._normals\r\n ? this._normals.length / 3\r\n : this._tangents\r\n ? this._tangents.length / 3\r\n : this._uvs\r\n ? this._uvs.length / 2\r\n : this._uv2s\r\n ? this._uv2s.length / 2\r\n : 0;\r\n }\r\n\r\n /**\r\n * Affects position data to this target\r\n * @param data defines the position data to use\r\n */\r\n public setPositions(data: Nullable<FloatArray>) {\r\n const hadPositions = this.hasPositions;\r\n\r\n this._positions = data;\r\n\r\n if (hadPositions !== this.hasPositions) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the position data stored in this target\r\n * @returns a FloatArray containing the position data (or null if not present)\r\n */\r\n public getPositions(): Nullable<FloatArray> {\r\n return this._positions;\r\n }\r\n\r\n /**\r\n * Affects normal data to this target\r\n * @param data defines the normal data to use\r\n */\r\n public setNormals(data: Nullable<FloatArray>) {\r\n const hadNormals = this.hasNormals;\r\n\r\n this._normals = data;\r\n\r\n if (hadNormals !== this.hasNormals) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the normal data stored in this target\r\n * @returns a FloatArray containing the normal data (or null if not present)\r\n */\r\n public getNormals(): Nullable<FloatArray> {\r\n return this._normals;\r\n }\r\n\r\n /**\r\n * Affects tangent data to this target\r\n * @param data defines the tangent data to use\r\n */\r\n public setTangents(data: Nullable<FloatArray>) {\r\n const hadTangents = this.hasTangents;\r\n\r\n this._tangents = data;\r\n\r\n if (hadTangents !== this.hasTangents) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the tangent data stored in this target\r\n * @returns a FloatArray containing the tangent data (or null if not present)\r\n */\r\n public getTangents(): Nullable<FloatArray> {\r\n return this._tangents;\r\n }\r\n\r\n /**\r\n * Affects texture coordinates data to this target\r\n * @param data defines the texture coordinates data to use\r\n */\r\n public setUVs(data: Nullable<FloatArray>) {\r\n const hadUVs = this.hasUVs;\r\n\r\n this._uvs = data;\r\n\r\n if (hadUVs !== this.hasUVs) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates data stored in this target\r\n * @returns a FloatArray containing the texture coordinates data (or null if not present)\r\n */\r\n public getUVs(): Nullable<FloatArray> {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Affects texture coordinates 2 data to this target\r\n * @param data defines the texture coordinates 2 data to use\r\n */\r\n public setUV2s(data: Nullable<FloatArray>) {\r\n const hadUV2s = this.hasUV2s;\r\n\r\n this._uv2s = data;\r\n\r\n if (hadUV2s !== this.hasUV2s) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates 2 data stored in this target\r\n * @returns a FloatArray containing the texture coordinates 2 data (or null if not present)\r\n */\r\n public getUV2s(): Nullable<FloatArray> {\r\n return this._uv2s;\r\n }\r\n\r\n /**\r\n * Clone the current target\r\n * @returns a new MorphTarget\r\n */\r\n public clone(): MorphTarget {\r\n const newOne = SerializationHelper.Clone(() => new MorphTarget(this.name, this.influence, this._scene), this);\r\n\r\n newOne._positions = this._positions;\r\n newOne._normals = this._normals;\r\n newOne._tangents = this._tangents;\r\n newOne._uvs = this._uvs;\r\n newOne._uv2s = this._uv2s;\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Serializes the current target into a Serialization object\r\n * @returns the serialized object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.influence = this.influence;\r\n\r\n serializationObject.positions = Array.prototype.slice.call(this.getPositions());\r\n if (this.id != null) {\r\n serializationObject.id = this.id;\r\n }\r\n if (this.hasNormals) {\r\n serializationObject.normals = Array.prototype.slice.call(this.getNormals());\r\n }\r\n if (this.hasTangents) {\r\n serializationObject.tangents = Array.prototype.slice.call(this.getTangents());\r\n }\r\n if (this.hasUVs) {\r\n serializationObject.uvs = Array.prototype.slice.call(this.getUVs());\r\n }\r\n if (this.hasUV2s) {\r\n serializationObject.uv2s = Array.prototype.slice.call(this.getUV2s());\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Returns the string \"MorphTarget\"\r\n * @returns \"MorphTarget\"\r\n */\r\n public getClassName(): string {\r\n return \"MorphTarget\";\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new target from serialized data\r\n * @param serializationObject defines the serialized data to use\r\n * @param scene defines the hosting scene\r\n * @returns a new MorphTarget\r\n */\r\n public static Parse(serializationObject: any, scene?: Scene): MorphTarget {\r\n const result = new MorphTarget(serializationObject.name, serializationObject.influence);\r\n\r\n result.setPositions(serializationObject.positions);\r\n\r\n if (serializationObject.id != null) {\r\n result.id = serializationObject.id;\r\n }\r\n if (serializationObject.normals) {\r\n result.setNormals(serializationObject.normals);\r\n }\r\n if (serializationObject.tangents) {\r\n result.setTangents(serializationObject.tangents);\r\n }\r\n if (serializationObject.uvs) {\r\n result.setUVs(serializationObject.uvs);\r\n }\r\n if (serializationObject.uv2s) {\r\n result.setUV2s(serializationObject.uv2s);\r\n }\r\n\r\n // Animations\r\n if (serializationObject.animations) {\r\n for (let animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {\r\n const parsedAnimation = serializationObject.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n result.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n\r\n if (serializationObject.autoAnimate && scene) {\r\n scene.beginAnimation(\r\n result,\r\n serializationObject.autoAnimateFrom,\r\n serializationObject.autoAnimateTo,\r\n serializationObject.autoAnimateLoop,\r\n serializationObject.autoAnimateSpeed || 1.0\r\n );\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a MorphTarget from mesh data\r\n * @param mesh defines the source mesh\r\n * @param name defines the name to use for the new target\r\n * @param influence defines the influence to attach to the target\r\n * @returns a new MorphTarget\r\n */\r\n public static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget {\r\n if (!name) {\r\n name = mesh.name;\r\n }\r\n\r\n const result = new MorphTarget(name, influence, mesh.getScene());\r\n\r\n result.setPositions(<FloatArray>mesh.getVerticesData(VertexBuffer.PositionKind));\r\n\r\n if (mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {\r\n result.setNormals(<FloatArray>mesh.getVerticesData(VertexBuffer.NormalKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.TangentKind)) {\r\n result.setTangents(<FloatArray>mesh.getVerticesData(VertexBuffer.TangentKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {\r\n result.setUVs(<FloatArray>mesh.getVerticesData(VertexBuffer.UVKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {\r\n result.setUV2s(<FloatArray>mesh.getVerticesData(VertexBuffer.UV2Kind));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"morphTarget.js","sourceRoot":"","sources":["../../../../dev/core/src/Morph/morphTarget.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI7C;;;GAGG;AACH,MAAM,OAAO,WAAW;IAwBpB;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,SAAiB;QAClC,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE,EAAE,CAAC;YACzC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,QAAQ,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC;QAC/E,CAAC;IACL,CAAC;IAUD;;OAEG;I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AAI,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;YACvD,MAAM,CAAC,WAAW,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;QACnF,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,MAAM,CAAC,MAAM,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,MAAM,CAAC,OAAO,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,SAAS,CAAa,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAnYU;IADN,SAAS,EAAE;uCACM","sourcesContent":["import type { IAnimatable } from \"../Animations/animatable.interface\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable, FloatArray } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { AnimationPropertiesOverride } from \"../Animations/animationPropertiesOverride\";\r\nimport { serialize } from \"../Misc/decorators\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\n\r\nimport type { Animation } from \"../Animations/animation\";\r\n\r\n/**\r\n * Defines a target to use with MorphTargetManager\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTarget implements IAnimatable {\r\n /**\r\n * Gets or sets the list of animations\r\n */\r\n public animations: Animation[] = [];\r\n\r\n private _scene: Nullable<Scene>;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _tangents: Nullable<FloatArray> = null;\r\n private _uvs: Nullable<FloatArray> = null;\r\n private _uv2s: Nullable<FloatArray> = null;\r\n private _colors: Nullable<FloatArray> = null;\r\n private _influence: number;\r\n private _uniqueId = 0;\r\n\r\n /**\r\n * Observable raised when the influence changes\r\n */\r\n public onInfluenceChanged = new Observable<boolean>();\r\n\r\n /** @internal */\r\n public _onDataLayoutChanged = new Observable<void>();\r\n\r\n /**\r\n * Gets or sets the influence of this target (ie. its weight in the overall morphing)\r\n */\r\n public get influence(): number {\r\n return this._influence;\r\n }\r\n\r\n public set influence(influence: number) {\r\n if (this._influence === influence) {\r\n return;\r\n }\r\n\r\n const previous = this._influence;\r\n this._influence = influence;\r\n\r\n if (this.onInfluenceChanged.hasObservers()) {\r\n this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the id of the morph Target\r\n */\r\n @serialize()\r\n public id: string;\r\n\r\n private _animationPropertiesOverride: Nullable<AnimationPropertiesOverride> = null;\r\n\r\n /**\r\n * Gets or sets the animation properties override\r\n */\r\n public get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride> {\r\n if (!this._animationPropertiesOverride && this._scene) {\r\n return this._scene.animationPropertiesOverride;\r\n }\r\n return this._animationPropertiesOverride;\r\n }\r\n\r\n public set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>) {\r\n this._animationPropertiesOverride = value;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTarget\r\n * @param name defines the name of the target\r\n * @param influence defines the influence to use\r\n * @param scene defines the scene the morphtarget belongs to\r\n */\r\n public constructor(\r\n /** defines the name of the target */\r\n public name: string,\r\n influence = 0,\r\n scene: Nullable<Scene> = null\r\n ) {\r\n this.id = name;\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n this.influence = influence;\r\n\r\n if (this._scene) {\r\n this._uniqueId = this._scene.getUniqueId();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the unique ID of this manager\r\n */\r\n public get uniqueId(): number {\r\n return this._uniqueId;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains position data\r\n */\r\n public get hasPositions(): boolean {\r\n return !!this._positions;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains normal data\r\n */\r\n public get hasNormals(): boolean {\r\n return !!this._normals;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains tangent data\r\n */\r\n public get hasTangents(): boolean {\r\n return !!this._tangents;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains texture coordinates data\r\n */\r\n public get hasUVs(): boolean {\r\n return !!this._uvs;\r\n }\r\n\r\n /**\r\n * Gets a boolean defining if the target contains texture coordinates 2 data\r\n */\r\n public get hasUV2s(): boolean {\r\n return !!this._uv2s;\r\n }\r\n\r\n public get hasColors(): boolean {\r\n return !!this._colors;\r\n }\r\n\r\n /**\r\n * Gets the number of vertices stored in this target\r\n */\r\n public get vertexCount(): number {\r\n return this._positions\r\n ? this._positions.length / 3\r\n : this._normals\r\n ? this._normals.length / 3\r\n : this._tangents\r\n ? this._tangents.length / 3\r\n : this._uvs\r\n ? this._uvs.length / 2\r\n : this._uv2s\r\n ? this._uv2s.length / 2\r\n : this._colors\r\n ? this._colors.length / 4\r\n : 0;\r\n }\r\n\r\n /**\r\n * Affects position data to this target\r\n * @param data defines the position data to use\r\n */\r\n public setPositions(data: Nullable<FloatArray>) {\r\n const hadPositions = this.hasPositions;\r\n\r\n this._positions = data;\r\n\r\n if (hadPositions !== this.hasPositions) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the position data stored in this target\r\n * @returns a FloatArray containing the position data (or null if not present)\r\n */\r\n public getPositions(): Nullable<FloatArray> {\r\n return this._positions;\r\n }\r\n\r\n /**\r\n * Affects normal data to this target\r\n * @param data defines the normal data to use\r\n */\r\n public setNormals(data: Nullable<FloatArray>) {\r\n const hadNormals = this.hasNormals;\r\n\r\n this._normals = data;\r\n\r\n if (hadNormals !== this.hasNormals) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the normal data stored in this target\r\n * @returns a FloatArray containing the normal data (or null if not present)\r\n */\r\n public getNormals(): Nullable<FloatArray> {\r\n return this._normals;\r\n }\r\n\r\n /**\r\n * Affects tangent data to this target\r\n * @param data defines the tangent data to use\r\n */\r\n public setTangents(data: Nullable<FloatArray>) {\r\n const hadTangents = this.hasTangents;\r\n\r\n this._tangents = data;\r\n\r\n if (hadTangents !== this.hasTangents) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the tangent data stored in this target\r\n * @returns a FloatArray containing the tangent data (or null if not present)\r\n */\r\n public getTangents(): Nullable<FloatArray> {\r\n return this._tangents;\r\n }\r\n\r\n /**\r\n * Affects texture coordinates data to this target\r\n * @param data defines the texture coordinates data to use\r\n */\r\n public setUVs(data: Nullable<FloatArray>) {\r\n const hadUVs = this.hasUVs;\r\n\r\n this._uvs = data;\r\n\r\n if (hadUVs !== this.hasUVs) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates data stored in this target\r\n * @returns a FloatArray containing the texture coordinates data (or null if not present)\r\n */\r\n public getUVs(): Nullable<FloatArray> {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Affects texture coordinates 2 data to this target\r\n * @param data defines the texture coordinates 2 data to use\r\n */\r\n public setUV2s(data: Nullable<FloatArray>) {\r\n const hadUV2s = this.hasUV2s;\r\n\r\n this._uv2s = data;\r\n\r\n if (hadUV2s !== this.hasUV2s) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates 2 data stored in this target\r\n * @returns a FloatArray containing the texture coordinates 2 data (or null if not present)\r\n */\r\n public getUV2s(): Nullable<FloatArray> {\r\n return this._uv2s;\r\n }\r\n\r\n /**\r\n * Affects color data to this target\r\n * @param data defines the color data to use\r\n */\r\n public setColors(data: Nullable<FloatArray>) {\r\n const hadColors = this.hasColors;\r\n\r\n this._colors = data;\r\n\r\n if (hadColors !== this.hasColors) {\r\n this._onDataLayoutChanged.notifyObservers(undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color data stored in this target\r\n * @returns a FloatArray containing the color data (or null if not present)\r\n */\r\n public getColors(): Nullable<FloatArray> {\r\n return this._colors;\r\n }\r\n\r\n /**\r\n * Clone the current target\r\n * @returns a new MorphTarget\r\n */\r\n public clone(): MorphTarget {\r\n const newOne = SerializationHelper.Clone(() => new MorphTarget(this.name, this.influence, this._scene), this);\r\n\r\n newOne._positions = this._positions;\r\n newOne._normals = this._normals;\r\n newOne._tangents = this._tangents;\r\n newOne._uvs = this._uvs;\r\n newOne._uv2s = this._uv2s;\r\n newOne._colors = this._colors;\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Serializes the current target into a Serialization object\r\n * @returns the serialized object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.name = this.name;\r\n serializationObject.influence = this.influence;\r\n\r\n serializationObject.positions = Array.prototype.slice.call(this.getPositions());\r\n if (this.id != null) {\r\n serializationObject.id = this.id;\r\n }\r\n if (this.hasNormals) {\r\n serializationObject.normals = Array.prototype.slice.call(this.getNormals());\r\n }\r\n if (this.hasTangents) {\r\n serializationObject.tangents = Array.prototype.slice.call(this.getTangents());\r\n }\r\n if (this.hasUVs) {\r\n serializationObject.uvs = Array.prototype.slice.call(this.getUVs());\r\n }\r\n if (this.hasUV2s) {\r\n serializationObject.uv2s = Array.prototype.slice.call(this.getUV2s());\r\n }\r\n if (this.hasColors) {\r\n serializationObject.colors = Array.prototype.slice.call(this.getColors());\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Returns the string \"MorphTarget\"\r\n * @returns \"MorphTarget\"\r\n */\r\n public getClassName(): string {\r\n return \"MorphTarget\";\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new target from serialized data\r\n * @param serializationObject defines the serialized data to use\r\n * @param scene defines the hosting scene\r\n * @returns a new MorphTarget\r\n */\r\n public static Parse(serializationObject: any, scene?: Scene): MorphTarget {\r\n const result = new MorphTarget(serializationObject.name, serializationObject.influence);\r\n\r\n result.setPositions(serializationObject.positions);\r\n\r\n if (serializationObject.id != null) {\r\n result.id = serializationObject.id;\r\n }\r\n if (serializationObject.normals) {\r\n result.setNormals(serializationObject.normals);\r\n }\r\n if (serializationObject.tangents) {\r\n result.setTangents(serializationObject.tangents);\r\n }\r\n if (serializationObject.uvs) {\r\n result.setUVs(serializationObject.uvs);\r\n }\r\n if (serializationObject.uv2s) {\r\n result.setUV2s(serializationObject.uv2s);\r\n }\r\n if (serializationObject.colors) {\r\n result.setColors(serializationObject.colors);\r\n }\r\n\r\n // Animations\r\n if (serializationObject.animations) {\r\n for (let animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {\r\n const parsedAnimation = serializationObject.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n result.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n\r\n if (serializationObject.autoAnimate && scene) {\r\n scene.beginAnimation(\r\n result,\r\n serializationObject.autoAnimateFrom,\r\n serializationObject.autoAnimateTo,\r\n serializationObject.autoAnimateLoop,\r\n serializationObject.autoAnimateSpeed || 1.0\r\n );\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a MorphTarget from mesh data\r\n * @param mesh defines the source mesh\r\n * @param name defines the name to use for the new target\r\n * @param influence defines the influence to attach to the target\r\n * @returns a new MorphTarget\r\n */\r\n public static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget {\r\n if (!name) {\r\n name = mesh.name;\r\n }\r\n\r\n const result = new MorphTarget(name, influence, mesh.getScene());\r\n\r\n result.setPositions(<FloatArray>mesh.getVerticesData(VertexBuffer.PositionKind));\r\n\r\n if (mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {\r\n result.setNormals(<FloatArray>mesh.getVerticesData(VertexBuffer.NormalKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.TangentKind)) {\r\n result.setTangents(<FloatArray>mesh.getVerticesData(VertexBuffer.TangentKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {\r\n result.setUVs(<FloatArray>mesh.getVerticesData(VertexBuffer.UVKind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {\r\n result.setUV2s(<FloatArray>mesh.getVerticesData(VertexBuffer.UV2Kind));\r\n }\r\n if (mesh.isVerticesDataPresent(VertexBuffer.ColorKind)) {\r\n result.setColors(<FloatArray>mesh.getVerticesData(VertexBuffer.ColorKind));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -24,6 +24,7 @@ export declare class MorphTargetManager implements IDisposable {
|
|
|
24
24
|
private _supportsTangents;
|
|
25
25
|
private _supportsUVs;
|
|
26
26
|
private _supportsUV2s;
|
|
27
|
+
private _supportsColors;
|
|
27
28
|
private _vertexCount;
|
|
28
29
|
private _uniqueId;
|
|
29
30
|
private _tempInfluences;
|
|
@@ -67,6 +68,10 @@ export declare class MorphTargetManager implements IDisposable {
|
|
|
67
68
|
* Gets or sets a boolean indicating if UV2 must be morphed
|
|
68
69
|
*/
|
|
69
70
|
enableUV2Morphing: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Gets or sets a boolean indicating if colors must be morphed
|
|
73
|
+
*/
|
|
74
|
+
enableColorMorphing: boolean;
|
|
70
75
|
/**
|
|
71
76
|
* Sets a boolean indicating that adding new target or updating an existing target will not update the underlying data buffers
|
|
72
77
|
*/
|
|
@@ -116,6 +121,10 @@ export declare class MorphTargetManager implements IDisposable {
|
|
|
116
121
|
* Gets a boolean indicating if this manager supports morphing of texture coordinates 2
|
|
117
122
|
*/
|
|
118
123
|
get supportsUV2s(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Gets a boolean indicating if this manager supports morphing of colors
|
|
126
|
+
*/
|
|
127
|
+
get supportsColors(): boolean;
|
|
119
128
|
/**
|
|
120
129
|
* Gets a boolean indicating if this manager has data for morphing positions
|
|
121
130
|
*/
|
|
@@ -136,6 +145,10 @@ export declare class MorphTargetManager implements IDisposable {
|
|
|
136
145
|
* Gets a boolean indicating if this manager has data for morphing texture coordinates 2
|
|
137
146
|
*/
|
|
138
147
|
get hasUV2s(): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Gets a boolean indicating if this manager has data for morphing colors
|
|
150
|
+
*/
|
|
151
|
+
get hasColors(): boolean;
|
|
139
152
|
/**
|
|
140
153
|
* Gets the number of targets stored in this manager
|
|
141
154
|
*/
|
|
@@ -42,6 +42,7 @@ export class MorphTargetManager {
|
|
|
42
42
|
this._supportsTangents = false;
|
|
43
43
|
this._supportsUVs = false;
|
|
44
44
|
this._supportsUV2s = false;
|
|
45
|
+
this._supportsColors = false;
|
|
45
46
|
this._vertexCount = 0;
|
|
46
47
|
this._uniqueId = 0;
|
|
47
48
|
this._tempInfluences = new Array();
|
|
@@ -81,6 +82,10 @@ export class MorphTargetManager {
|
|
|
81
82
|
* Gets or sets a boolean indicating if UV2 must be morphed
|
|
82
83
|
*/
|
|
83
84
|
this.enableUV2Morphing = true;
|
|
85
|
+
/**
|
|
86
|
+
* Gets or sets a boolean indicating if colors must be morphed
|
|
87
|
+
*/
|
|
88
|
+
this.enableColorMorphing = true;
|
|
84
89
|
this._numMaxInfluencers = 0;
|
|
85
90
|
this._useTextureToStoreTargets = true;
|
|
86
91
|
if (!scene) {
|
|
@@ -156,6 +161,12 @@ export class MorphTargetManager {
|
|
|
156
161
|
get supportsUV2s() {
|
|
157
162
|
return this._supportsUV2s && this.enableUV2Morphing;
|
|
158
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Gets a boolean indicating if this manager supports morphing of colors
|
|
166
|
+
*/
|
|
167
|
+
get supportsColors() {
|
|
168
|
+
return this._supportsColors && this.enableColorMorphing;
|
|
169
|
+
}
|
|
159
170
|
/**
|
|
160
171
|
* Gets a boolean indicating if this manager has data for morphing positions
|
|
161
172
|
*/
|
|
@@ -186,6 +197,12 @@ export class MorphTargetManager {
|
|
|
186
197
|
get hasUV2s() {
|
|
187
198
|
return this._supportsUV2s;
|
|
188
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Gets a boolean indicating if this manager has data for morphing colors
|
|
202
|
+
*/
|
|
203
|
+
get hasColors() {
|
|
204
|
+
return this._supportsColors;
|
|
205
|
+
}
|
|
189
206
|
/**
|
|
190
207
|
* Gets the number of targets stored in this manager
|
|
191
208
|
*/
|
|
@@ -316,6 +333,7 @@ export class MorphTargetManager {
|
|
|
316
333
|
copy.enableTangentMorphing = this.enableTangentMorphing;
|
|
317
334
|
copy.enableUVMorphing = this.enableUVMorphing;
|
|
318
335
|
copy.enableUV2Morphing = this.enableUV2Morphing;
|
|
336
|
+
copy.enableColorMorphing = this.enableColorMorphing;
|
|
319
337
|
return copy;
|
|
320
338
|
}
|
|
321
339
|
/**
|
|
@@ -394,6 +412,7 @@ export class MorphTargetManager {
|
|
|
394
412
|
this._supportsTangents = true;
|
|
395
413
|
this._supportsUVs = true;
|
|
396
414
|
this._supportsUV2s = true;
|
|
415
|
+
this._supportsColors = true;
|
|
397
416
|
this._vertexCount = 0;
|
|
398
417
|
this._targetStoreTexture?.dispose();
|
|
399
418
|
this._targetStoreTexture = null;
|
|
@@ -406,6 +425,7 @@ export class MorphTargetManager {
|
|
|
406
425
|
this._supportsTangents = this._supportsTangents && target.hasTangents;
|
|
407
426
|
this._supportsUVs = this._supportsUVs && target.hasUVs;
|
|
408
427
|
this._supportsUV2s = this._supportsUV2s && target.hasUV2s;
|
|
428
|
+
this._supportsColors = this._supportsColors && target.hasColors;
|
|
409
429
|
const vertexCount = target.vertexCount;
|
|
410
430
|
if (this._vertexCount === 0) {
|
|
411
431
|
this._vertexCount = vertexCount;
|
|
@@ -421,7 +441,8 @@ export class MorphTargetManager {
|
|
|
421
441
|
this._supportsNormals && this._textureVertexStride++;
|
|
422
442
|
this._supportsTangents && this._textureVertexStride++;
|
|
423
443
|
this._supportsUVs && this._textureVertexStride++;
|
|
424
|
-
this.
|
|
444
|
+
this._supportsUV2s && this._textureVertexStride++;
|
|
445
|
+
this._supportsColors && this._textureVertexStride++;
|
|
425
446
|
this._textureWidth = this._vertexCount * this._textureVertexStride || 1;
|
|
426
447
|
this._textureHeight = 1;
|
|
427
448
|
const maxTextureSize = engine.getCaps().maxTextureSize;
|
|
@@ -439,6 +460,7 @@ export class MorphTargetManager {
|
|
|
439
460
|
const uvs = target.getUVs();
|
|
440
461
|
const tangents = target.getTangents();
|
|
441
462
|
const uv2s = target.getUV2s();
|
|
463
|
+
const colors = target.getColors();
|
|
442
464
|
offset = index * this._textureWidth * this._textureHeight * 4;
|
|
443
465
|
for (let vertex = 0; vertex < this._vertexCount; vertex++) {
|
|
444
466
|
if (this._supportsPositions && positions) {
|
|
@@ -469,6 +491,13 @@ export class MorphTargetManager {
|
|
|
469
491
|
data[offset + 1] = uv2s[vertex * 2 + 1];
|
|
470
492
|
offset += 4;
|
|
471
493
|
}
|
|
494
|
+
if (this._supportsColors && colors) {
|
|
495
|
+
data[offset] = colors[vertex * 4];
|
|
496
|
+
data[offset + 1] = colors[vertex * 4 + 1];
|
|
497
|
+
data[offset + 2] = colors[vertex * 4 + 2];
|
|
498
|
+
data[offset + 3] = colors[vertex * 4 + 3];
|
|
499
|
+
offset += 4;
|
|
500
|
+
}
|
|
472
501
|
}
|
|
473
502
|
}
|
|
474
503
|
this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(data, this._textureWidth, this._textureHeight, targetCount, this._scene, false, false, 1, 1);
|