@babylonjs/core 7.40.1 → 7.40.3

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.
Files changed (96) hide show
  1. package/Engines/abstractEngine.js +2 -2
  2. package/Engines/abstractEngine.js.map +1 -1
  3. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +10 -2
  4. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +48 -2
  5. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  6. package/Materials/Node/Blocks/meshAttributeExistsBlock.js +3 -0
  7. package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
  8. package/Materials/Node/nodeMaterial.d.ts +2 -0
  9. package/Materials/Node/nodeMaterial.js +2 -0
  10. package/Materials/Node/nodeMaterial.js.map +1 -1
  11. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  12. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  13. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  14. package/Materials/effect.functions.js +1 -1
  15. package/Materials/effect.functions.js.map +1 -1
  16. package/Materials/materialHelper.functions.js +2 -0
  17. package/Materials/materialHelper.functions.js.map +1 -1
  18. package/Materials/shaderMaterial.js +4 -0
  19. package/Materials/shaderMaterial.js.map +1 -1
  20. package/Materials/standardMaterial.d.ts +1 -0
  21. package/Materials/standardMaterial.js +1 -0
  22. package/Materials/standardMaterial.js.map +1 -1
  23. package/Meshes/Compression/dracoCodec.d.ts +83 -0
  24. package/Meshes/Compression/dracoCodec.js +107 -0
  25. package/Meshes/Compression/dracoCodec.js.map +1 -0
  26. package/Meshes/Compression/dracoCompression.d.ts +17 -63
  27. package/Meshes/Compression/dracoCompression.js +22 -200
  28. package/Meshes/Compression/dracoCompression.js.map +1 -1
  29. package/Meshes/Compression/dracoDecoder.d.ts +103 -0
  30. package/Meshes/Compression/dracoDecoder.js +216 -0
  31. package/Meshes/Compression/dracoDecoder.js.map +1 -0
  32. package/Meshes/Compression/index.d.ts +1 -0
  33. package/Meshes/Compression/index.js +1 -0
  34. package/Meshes/Compression/index.js.map +1 -1
  35. package/Meshes/mesh.js +23 -0
  36. package/Meshes/mesh.js.map +1 -1
  37. package/Misc/screenshotTools.d.ts +3 -3
  38. package/Misc/screenshotTools.js +3 -3
  39. package/Misc/screenshotTools.js.map +1 -1
  40. package/Morph/morphTarget.d.ts +15 -0
  41. package/Morph/morphTarget.js +35 -0
  42. package/Morph/morphTarget.js.map +1 -1
  43. package/Morph/morphTargetManager.d.ts +9 -0
  44. package/Morph/morphTargetManager.js +23 -0
  45. package/Morph/morphTargetManager.js.map +1 -1
  46. package/Shaders/ShadersInclude/morphTargetsVertex.js +7 -1
  47. package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
  48. package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js +3 -0
  49. package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
  50. package/Shaders/ShadersInclude/samplerVertexImplementation.js +1 -1
  51. package/Shaders/ShadersInclude/samplerVertexImplementation.js.map +1 -1
  52. package/Shaders/default.vertex.js +10 -1
  53. package/Shaders/default.vertex.js.map +1 -1
  54. package/Shaders/depth.vertex.js +4 -1
  55. package/Shaders/depth.vertex.js.map +1 -1
  56. package/Shaders/geometry.vertex.js +9 -6
  57. package/Shaders/geometry.vertex.js.map +1 -1
  58. package/Shaders/glowMapGeneration.vertex.js +6 -3
  59. package/Shaders/glowMapGeneration.vertex.js.map +1 -1
  60. package/Shaders/outline.vertex.js +4 -1
  61. package/Shaders/outline.vertex.js.map +1 -1
  62. package/Shaders/pbr.vertex.js +10 -1
  63. package/Shaders/pbr.vertex.js.map +1 -1
  64. package/Shaders/shadowMap.vertex.js +4 -1
  65. package/Shaders/shadowMap.vertex.js.map +1 -1
  66. package/Shaders/volumetricLightScatteringPass.vertex.js +4 -1
  67. package/Shaders/volumetricLightScatteringPass.vertex.js.map +1 -1
  68. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +7 -1
  69. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  70. package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js +3 -0
  71. package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
  72. package/ShadersWGSL/ShadersInclude/samplerVertexImplementation.js +1 -1
  73. package/ShadersWGSL/ShadersInclude/samplerVertexImplementation.js.map +1 -1
  74. package/ShadersWGSL/default.vertex.js +10 -1
  75. package/ShadersWGSL/default.vertex.js.map +1 -1
  76. package/ShadersWGSL/depth.vertex.js +4 -1
  77. package/ShadersWGSL/depth.vertex.js.map +1 -1
  78. package/ShadersWGSL/geometry.vertex.js +9 -6
  79. package/ShadersWGSL/geometry.vertex.js.map +1 -1
  80. package/ShadersWGSL/glowMapGeneration.vertex.js +6 -3
  81. package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -1
  82. package/ShadersWGSL/glowMapMerge.fragment.js +3 -2
  83. package/ShadersWGSL/glowMapMerge.fragment.js.map +1 -1
  84. package/ShadersWGSL/outline.vertex.js +4 -1
  85. package/ShadersWGSL/outline.vertex.js.map +1 -1
  86. package/ShadersWGSL/pbr.vertex.js +10 -1
  87. package/ShadersWGSL/pbr.vertex.js.map +1 -1
  88. package/ShadersWGSL/shadowMap.vertex.js +4 -1
  89. package/ShadersWGSL/shadowMap.vertex.js.map +1 -1
  90. package/XR/features/WebXRNearInteraction.d.ts +4 -0
  91. package/XR/features/WebXRNearInteraction.js +15 -8
  92. package/XR/features/WebXRNearInteraction.js.map +1 -1
  93. package/assets/Draco/draco_encoder.js +38 -0
  94. package/assets/Draco/draco_encoder.wasm +0 -0
  95. package/assets/Draco/draco_encoder_wasm_wrapper.js +96 -0
  96. package/package.json +1 -1
@@ -39,7 +39,8 @@ export declare function CreateScreenshot(engine: AbstractEngine, camera: Camera,
39
39
  */
40
40
  export declare function CreateScreenshotAsync(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, quality?: number): Promise<string>;
41
41
  /**
42
- * Captures 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)
42
+ * 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)
43
+ * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.
43
44
  * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
44
45
  * @param engine defines the rendering engine
45
46
  * @param camera defines the source camera
@@ -48,8 +49,7 @@ export declare function CreateScreenshotAsync(engine: AbstractEngine, camera: Ca
48
49
  * @param mimeType defines the MIME type of the screenshot image (default: image/png).
49
50
  * Check your browser for supported MIME types
50
51
  * @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.
51
- * @returns screenshot as a string of base64-encoded characters. This string can be assigned
52
- * to the src parameter of an <img> to display it
52
+ * @returns promise that resolves once the screenshot is taken
53
53
  */
54
54
  export declare function CreateScreenshotWithResizeAsync(engine: AbstractEngine, camera: Camera, width: number, height: number, mimeType?: string, quality?: number): Promise<void>;
55
55
  /**
@@ -110,7 +110,8 @@ export function CreateScreenshotAsync(engine, camera, size, mimeType = "image/pn
110
110
  });
111
111
  }
112
112
  /**
113
- * Captures 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)
113
+ * 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)
114
+ * If screenshot image data is needed, use {@link CreateScreenshotAsync} instead.
114
115
  * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/renderToPNG
115
116
  * @param engine defines the rendering engine
116
117
  * @param camera defines the source camera
@@ -119,8 +120,7 @@ export function CreateScreenshotAsync(engine, camera, size, mimeType = "image/pn
119
120
  * @param mimeType defines the MIME type of the screenshot image (default: image/png).
120
121
  * Check your browser for supported MIME types
121
122
  * @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.
122
- * @returns screenshot as a string of base64-encoded characters. This string can be assigned
123
- * to the src parameter of an <img> to display it
123
+ * @returns promise that resolves once the screenshot is taken
124
124
  */
125
125
  export function CreateScreenshotWithResizeAsync(engine, camera, width, height, mimeType = "image/png", quality) {
126
126
  return new Promise((resolve) => {
@@ -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;AAIlD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB,OAAgB;IAEhB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEnE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,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AeG;IACH,qBAAqB;IAErB;;;;;;;;;;;;OAYG;IACH,+BAA+B;IAE/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iCAAiC;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sCAAsC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\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\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 */\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): 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 if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\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 } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (screenshotCanvas) {\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\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\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 * @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(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType = \"image/png\", quality?: number): 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 );\r\n });\r\n}\r\n\r\n/**\r\n * Captures 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 * @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\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 * @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 CreateScreenshotWithResizeAsync(engine: AbstractEngine, camera: Camera, width: number, height: number, mimeType = \"image/png\", quality?: number): 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 );\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 const originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };\r\n engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions\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 if (texture.isReadyForRendering() && camera.isReady(true)) {\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 texture.render(true);\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n } else {\r\n setTimeout(renderWhenReady, 16);\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\r\n * @param camera\r\n * @param size\r\n * @private\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\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 */\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\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 * @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 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 * @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\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 * @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 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;AAIlD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,EAC9B,eAAwC,EACxC,QAAQ,GAAG,WAAW,EACtB,aAAa,GAAG,KAAK,EACrB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,CAAC,EAAE,WAAW,EAAE,WAAW,GAAG,CAAC,EAAE,CAAC;AAC9G,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B;;;;;;;;;;;;;;;;;OAiBG;IACH,gBAAgB;IAEhB;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB;IAErB;;;;;;;;;;;;OAYG;IACH,+BAA+B;IAE/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,iCAAiC;IAEjC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,sCAAsC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC1C,KAAK,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACpD,KAAK,CAAC,iCAAiC,GAAG,iCAAiC,CAAC;IAC5E,KAAK,CAAC,sCAAsC,GAAG,sCAAsC,CAAC;AAC1F,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { FxaaPostProcess } from \"../PostProcesses/fxaaPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Logger } from \"./logger\";\r\nimport { Tools } from \"./tools\";\r\nimport type { IScreenshotSize } from \"./interfaces/screenshotSize\";\r\nimport { DumpData } from \"./dumpTools\";\r\nimport type { Nullable } from \"../types\";\r\nimport { ApplyPostProcess } from \"./textureTools\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\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\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 */\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): 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 if (!screenshotCanvas) {\r\n screenshotCanvas = document.createElement(\"canvas\");\r\n }\r\n\r\n screenshotCanvas.width = width;\r\n screenshotCanvas.height = height;\r\n\r\n const renderContext = screenshotCanvas.getContext(\"2d\");\r\n\r\n const ratio = engine.getRenderWidth() / engine.getRenderHeight();\r\n let newWidth = width;\r\n let newHeight = newWidth / ratio;\r\n if (newHeight > height) {\r\n newHeight = height;\r\n newWidth = newHeight * ratio;\r\n }\r\n\r\n const offsetX = Math.max(0, width - newWidth) / 2;\r\n const offsetY = Math.max(0, height - newHeight) / 2;\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 } else {\r\n engine.onEndFrameObservable.addOnce(() => {\r\n const renderingCanvas = engine.getRenderingCanvas();\r\n if (renderContext && renderingCanvas) {\r\n renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);\r\n }\r\n\r\n if (screenshotCanvas) {\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\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\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 * @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(engine: AbstractEngine, camera: Camera, size: IScreenshotSize | number, mimeType = \"image/png\", quality?: number): 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 );\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\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 * @returns promise that resolves once the screenshot is taken\r\n */\r\nexport function CreateScreenshotWithResizeAsync(engine: AbstractEngine, camera: Camera, width: number, height: number, mimeType = \"image/png\", quality?: number): 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 );\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 const originalSize = { width: engine.getRenderWidth(), height: engine.getRenderHeight() };\r\n engine.setSize(width, height); // we need this call to trigger onResizeObservable with the screenshot width/height on all the subsystems that are observing this event and that needs to (re)create some resources with the right dimensions\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 if (texture.isReadyForRendering() && camera.isReady(true)) {\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 texture.render(true);\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n } else {\r\n setTimeout(renderWhenReady, 16);\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\r\n * @param camera\r\n * @param size\r\n * @private\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\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 */\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\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 * @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 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 * @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\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 * @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 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"]}
@@ -21,6 +21,7 @@ export declare class MorphTarget implements IAnimatable {
21
21
  private _normals;
22
22
  private _tangents;
23
23
  private _uvs;
24
+ private _uv2s;
24
25
  private _influence;
25
26
  private _uniqueId;
26
27
  /**
@@ -73,6 +74,10 @@ export declare class MorphTarget implements IAnimatable {
73
74
  * Gets a boolean defining if the target contains texture coordinates data
74
75
  */
75
76
  get hasUVs(): boolean;
77
+ /**
78
+ * Gets a boolean defining if the target contains texture coordinates 2 data
79
+ */
80
+ get hasUV2s(): boolean;
76
81
  /**
77
82
  * Affects position data to this target
78
83
  * @param data defines the position data to use
@@ -113,6 +118,16 @@ export declare class MorphTarget implements IAnimatable {
113
118
  * @returns a FloatArray containing the texture coordinates data (or null if not present)
114
119
  */
115
120
  getUVs(): Nullable<FloatArray>;
121
+ /**
122
+ * Affects texture coordinates 2 data to this target
123
+ * @param data defines the texture coordinates 2 data to use
124
+ */
125
+ setUV2s(data: Nullable<FloatArray>): void;
126
+ /**
127
+ * Gets the texture coordinates 2 data stored in this target
128
+ * @returns a FloatArray containing the texture coordinates 2 data (or null if not present)
129
+ */
130
+ getUV2s(): Nullable<FloatArray>;
116
131
  /**
117
132
  * Clone the current target
118
133
  * @returns a new MorphTarget
@@ -56,6 +56,7 @@ export class MorphTarget {
56
56
  this._normals = null;
57
57
  this._tangents = null;
58
58
  this._uvs = null;
59
+ this._uv2s = null;
59
60
  this._uniqueId = 0;
60
61
  /**
61
62
  * Observable raised when the influence changes
@@ -101,6 +102,12 @@ export class MorphTarget {
101
102
  get hasUVs() {
102
103
  return !!this._uvs;
103
104
  }
105
+ /**
106
+ * Gets a boolean defining if the target contains texture coordinates 2 data
107
+ */
108
+ get hasUV2s() {
109
+ return !!this._uv2s;
110
+ }
104
111
  /**
105
112
  * Affects position data to this target
106
113
  * @param data defines the position data to use
@@ -173,6 +180,24 @@ export class MorphTarget {
173
180
  getUVs() {
174
181
  return this._uvs;
175
182
  }
183
+ /**
184
+ * Affects texture coordinates 2 data to this target
185
+ * @param data defines the texture coordinates 2 data to use
186
+ */
187
+ setUV2s(data) {
188
+ const hadUV2s = this.hasUV2s;
189
+ this._uv2s = data;
190
+ if (hadUV2s !== this.hasUV2s) {
191
+ this._onDataLayoutChanged.notifyObservers(undefined);
192
+ }
193
+ }
194
+ /**
195
+ * Gets the texture coordinates 2 data stored in this target
196
+ * @returns a FloatArray containing the texture coordinates 2 data (or null if not present)
197
+ */
198
+ getUV2s() {
199
+ return this._uv2s;
200
+ }
176
201
  /**
177
202
  * Clone the current target
178
203
  * @returns a new MorphTarget
@@ -183,6 +208,7 @@ export class MorphTarget {
183
208
  newOne._normals = this._normals;
184
209
  newOne._tangents = this._tangents;
185
210
  newOne._uvs = this._uvs;
211
+ newOne._uv2s = this._uv2s;
186
212
  return newOne;
187
213
  }
188
214
  /**
@@ -206,6 +232,9 @@ export class MorphTarget {
206
232
  if (this.hasUVs) {
207
233
  serializationObject.uvs = Array.prototype.slice.call(this.getUVs());
208
234
  }
235
+ if (this.hasUV2s) {
236
+ serializationObject.uv2s = Array.prototype.slice.call(this.getUV2s());
237
+ }
209
238
  // Animations
210
239
  SerializationHelper.AppendSerializedAnimations(this, serializationObject);
211
240
  return serializationObject;
@@ -239,6 +268,9 @@ export class MorphTarget {
239
268
  if (serializationObject.uvs) {
240
269
  result.setUVs(serializationObject.uvs);
241
270
  }
271
+ if (serializationObject.uv2s) {
272
+ result.setUV2s(serializationObject.uv2s);
273
+ }
242
274
  // Animations
243
275
  if (serializationObject.animations) {
244
276
  for (let animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
@@ -276,6 +308,9 @@ export class MorphTarget {
276
308
  if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
277
309
  result.setUVs(mesh.getVerticesData(VertexBuffer.UVKind));
278
310
  }
311
+ if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
312
+ result.setUV2s(mesh.getVerticesData(VertexBuffer.UV2Kind));
313
+ }
279
314
  return result;
280
315
  }
281
316
  }
@@ -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;IAsBpB;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IA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,eAAe,EACnC,mBAAmB,CAAC,aAAa,EACjC,mBAAmB,CAAC,eAAe,EACnC,mBAAmB,CAAC,gBAAgB,IAAI,GAAG,CAC9C,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAkB,EAAE,IAAa,EAAE,SAAkB;QACxE,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,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;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AArSU;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 _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 * 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 * 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\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\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\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\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,MAA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AI,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,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;AA5UU;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 * 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"]}
@@ -22,6 +22,7 @@ export declare class MorphTargetManager implements IDisposable {
22
22
  private _supportsNormals;
23
23
  private _supportsTangents;
24
24
  private _supportsUVs;
25
+ private _supportsUV2s;
25
26
  private _vertexCount;
26
27
  private _uniqueId;
27
28
  private _tempInfluences;
@@ -55,6 +56,10 @@ export declare class MorphTargetManager implements IDisposable {
55
56
  * Gets or sets a boolean indicating if UV must be morphed
56
57
  */
57
58
  enableUVMorphing: boolean;
59
+ /**
60
+ * Gets or sets a boolean indicating if UV2 must be morphed
61
+ */
62
+ enableUV2Morphing: boolean;
58
63
  /**
59
64
  * Sets a boolean indicating that adding new target or updating an existing target will not update the underlying data buffers
60
65
  */
@@ -96,6 +101,10 @@ export declare class MorphTargetManager implements IDisposable {
96
101
  * Gets a boolean indicating if this manager supports morphing of texture coordinates
97
102
  */
98
103
  get supportsUVs(): boolean;
104
+ /**
105
+ * Gets a boolean indicating if this manager supports morphing of texture coordinates 2
106
+ */
107
+ get supportsUV2s(): boolean;
99
108
  /**
100
109
  * Gets the number of targets stored in this manager
101
110
  */
@@ -39,6 +39,7 @@ export class MorphTargetManager {
39
39
  this._supportsNormals = false;
40
40
  this._supportsTangents = false;
41
41
  this._supportsUVs = false;
42
+ this._supportsUV2s = false;
42
43
  this._vertexCount = 0;
43
44
  this._uniqueId = 0;
44
45
  this._tempInfluences = new Array();
@@ -68,6 +69,10 @@ export class MorphTargetManager {
68
69
  * Gets or sets a boolean indicating if UV must be morphed
69
70
  */
70
71
  this.enableUVMorphing = true;
72
+ /**
73
+ * Gets or sets a boolean indicating if UV2 must be morphed
74
+ */
75
+ this.enableUV2Morphing = true;
71
76
  this._numMaxInfluencers = 0;
72
77
  this._useTextureToStoreTargets = true;
73
78
  if (!scene) {
@@ -130,6 +135,12 @@ export class MorphTargetManager {
130
135
  get supportsUVs() {
131
136
  return this._supportsUVs && this.enableUVMorphing;
132
137
  }
138
+ /**
139
+ * Gets a boolean indicating if this manager supports morphing of texture coordinates 2
140
+ */
141
+ get supportsUV2s() {
142
+ return this._supportsUV2s && this.enableUV2Morphing;
143
+ }
133
144
  /**
134
145
  * Gets the number of targets stored in this manager
135
146
  */
@@ -247,6 +258,7 @@ export class MorphTargetManager {
247
258
  copy.enableNormalMorphing = this.enableNormalMorphing;
248
259
  copy.enableTangentMorphing = this.enableTangentMorphing;
249
260
  copy.enableUVMorphing = this.enableUVMorphing;
261
+ copy.enableUV2Morphing = this.enableUV2Morphing;
250
262
  return copy;
251
263
  }
252
264
  /**
@@ -271,6 +283,7 @@ export class MorphTargetManager {
271
283
  this._supportsNormals = true;
272
284
  this._supportsTangents = true;
273
285
  this._supportsUVs = true;
286
+ this._supportsUV2s = true;
274
287
  this._vertexCount = 0;
275
288
  if (this._scene && this._targets.length > this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount) {
276
289
  this.useTextureToStoreTargets = false;
@@ -293,6 +306,7 @@ export class MorphTargetManager {
293
306
  this._supportsNormals = this._supportsNormals && target.hasNormals;
294
307
  this._supportsTangents = this._supportsTangents && target.hasTangents;
295
308
  this._supportsUVs = this._supportsUVs && target.hasUVs;
309
+ this._supportsUV2s = this._supportsUV2s && target.hasUV2s;
296
310
  const positions = target.getPositions();
297
311
  if (positions) {
298
312
  const vertexCount = positions.length / 3;
@@ -336,6 +350,9 @@ export class MorphTargetManager {
336
350
  if (this._supportsUVs) {
337
351
  this._textureVertexStride++;
338
352
  }
353
+ if (this.supportsUV2s) {
354
+ this._textureVertexStride++;
355
+ }
339
356
  this._textureWidth = this._vertexCount * this._textureVertexStride || 1;
340
357
  this._textureHeight = 1;
341
358
  const maxTextureSize = this._scene.getEngine().getCaps().maxTextureSize;
@@ -363,6 +380,7 @@ export class MorphTargetManager {
363
380
  const normals = target.getNormals();
364
381
  const uvs = target.getUVs();
365
382
  const tangents = target.getTangents();
383
+ const uv2s = target.getUV2s();
366
384
  if (!positions) {
367
385
  if (index === 0) {
368
386
  Logger.Error("Invalid morph target. Target must have positions.");
@@ -392,6 +410,11 @@ export class MorphTargetManager {
392
410
  data[offset + 2] = tangents[vertex * 3 + 2];
393
411
  offset += 4;
394
412
  }
413
+ if (this._supportsUV2s && uv2s) {
414
+ data[offset] = uv2s[vertex * 2];
415
+ data[offset + 1] = uv2s[vertex * 2 + 1];
416
+ offset += 4;
417
+ }
395
418
  }
396
419
  }
397
420
  this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(data, this._textureWidth, this._textureHeight, targetCount, this._scene, false, false, 1, 1);