@babylonjs/core 7.8.0 → 7.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/Behaviors/Meshes/sixDofDragBehavior.js +1 -1
  2. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  3. package/Cameras/Inputs/BaseCameraPointersInput.js +5 -1
  4. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  5. package/Engines/AbstractEngine/abstractEngine.states.d.ts +1 -0
  6. package/Engines/AbstractEngine/abstractEngine.states.js +1 -0
  7. package/Engines/AbstractEngine/abstractEngine.states.js.map +1 -1
  8. package/Engines/{Extensions/engine.views.d.ts → AbstractEngine/abstractEngine.views.d.ts} +1 -2
  9. package/Engines/{Extensions/engine.views.js → AbstractEngine/abstractEngine.views.js} +10 -10
  10. package/Engines/AbstractEngine/abstractEngine.views.js.map +1 -0
  11. package/Engines/AbstractEngine/index.d.ts +1 -0
  12. package/Engines/AbstractEngine/index.js +1 -0
  13. package/Engines/AbstractEngine/index.js.map +1 -1
  14. package/Engines/Extensions/engine.alpha.d.ts +2 -2
  15. package/Engines/Extensions/engine.alpha.js.map +1 -1
  16. package/Engines/Extensions/engine.cubeTexture.d.ts +10 -4
  17. package/Engines/Extensions/engine.cubeTexture.js +10 -0
  18. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  19. package/Engines/Extensions/engine.dynamicBuffer.d.ts +2 -2
  20. package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
  21. package/Engines/Extensions/engine.dynamicTexture.d.ts +2 -2
  22. package/Engines/Extensions/engine.dynamicTexture.js.map +1 -1
  23. package/Engines/Extensions/engine.multiRender.d.ts +2 -2
  24. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  25. package/Engines/Extensions/engine.prefilteredCubeTexture.d.ts +22 -0
  26. package/Engines/Extensions/engine.prefilteredCubeTexture.js +88 -0
  27. package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -0
  28. package/Engines/Extensions/engine.rawTexture.d.ts +2 -63
  29. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  30. package/Engines/Extensions/engine.readTexture.d.ts +2 -2
  31. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  32. package/Engines/Extensions/engine.renderTarget.d.ts +5 -11
  33. package/Engines/Extensions/engine.renderTarget.js +37 -0
  34. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  35. package/Engines/Extensions/engine.renderTargetCube.d.ts +2 -2
  36. package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
  37. package/Engines/Extensions/engine.renderTargetTexture.d.ts +14 -0
  38. package/Engines/Extensions/engine.renderTargetTexture.js +16 -0
  39. package/Engines/Extensions/engine.renderTargetTexture.js.map +1 -0
  40. package/Engines/Extensions/engine.videoTexture.d.ts +2 -2
  41. package/Engines/Extensions/engine.videoTexture.js.map +1 -1
  42. package/Engines/Extensions/index.d.ts +2 -1
  43. package/Engines/Extensions/index.js +2 -1
  44. package/Engines/Extensions/index.js.map +1 -1
  45. package/Engines/WebGPU/Extensions/engine.alpha.d.ts +3 -27
  46. package/Engines/WebGPU/Extensions/engine.alpha.js +1 -0
  47. package/Engines/WebGPU/Extensions/engine.alpha.js.map +1 -1
  48. package/Engines/WebGPU/Extensions/engine.cubeTexture.d.ts +10 -4
  49. package/Engines/WebGPU/Extensions/engine.cubeTexture.js +9 -0
  50. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  51. package/Engines/WebGPU/Extensions/engine.dynamicTexture.d.ts +2 -2
  52. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
  53. package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -2
  54. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  55. package/Engines/WebGPU/Extensions/engine.rawTexture.d.ts +2 -50
  56. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  57. package/Engines/WebGPU/Extensions/engine.readTexture.d.ts +2 -2
  58. package/Engines/WebGPU/Extensions/engine.readTexture.js.map +1 -1
  59. package/Engines/WebGPU/Extensions/engine.renderTarget.d.ts +3 -11
  60. package/Engines/WebGPU/Extensions/engine.renderTarget.js +1 -0
  61. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  62. package/Engines/WebGPU/Extensions/engine.renderTargetCube.d.ts +2 -2
  63. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
  64. package/Engines/WebGPU/Extensions/engine.renderTargetTexture.d.ts +14 -0
  65. package/Engines/WebGPU/Extensions/engine.renderTargetTexture.js +10 -0
  66. package/Engines/WebGPU/Extensions/engine.renderTargetTexture.js.map +1 -0
  67. package/Engines/WebGPU/Extensions/engine.videoTexture.d.ts +2 -2
  68. package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
  69. package/Engines/WebGPU/Extensions/index.d.ts +1 -0
  70. package/Engines/WebGPU/Extensions/index.js +1 -0
  71. package/Engines/WebGPU/Extensions/index.js.map +1 -1
  72. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +4 -0
  73. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +4 -0
  74. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  75. package/Engines/abstractEngine.d.ts +13 -351
  76. package/Engines/abstractEngine.js +90 -5
  77. package/Engines/abstractEngine.js.map +1 -1
  78. package/Engines/engine.d.ts +11 -30
  79. package/Engines/engine.js +0 -69
  80. package/Engines/engine.js.map +1 -1
  81. package/Engines/nativeEngine.d.ts +4 -7
  82. package/Engines/nativeEngine.js +3 -8
  83. package/Engines/nativeEngine.js.map +1 -1
  84. package/Engines/thinEngine.d.ts +7 -18
  85. package/Engines/thinEngine.js +4 -146
  86. package/Engines/thinEngine.js.map +1 -1
  87. package/Engines/webgpuEngine.d.ts +4 -26
  88. package/Engines/webgpuEngine.js +3 -51
  89. package/Engines/webgpuEngine.js.map +1 -1
  90. package/Materials/Node/Blocks/Fragment/TBNBlock.js +14 -7
  91. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  92. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +19 -11
  93. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
  94. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +47 -20
  95. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
  96. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +3 -1
  97. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
  98. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +4 -4
  99. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
  100. package/Materials/Node/Blocks/biPlanarBlock.js +1 -2
  101. package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
  102. package/Materials/Node/Blocks/cloudBlock.js +1 -1
  103. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  104. package/Materials/Node/Blocks/triPlanarBlock.js +1 -1
  105. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  106. package/Materials/Node/nodeMaterialBuildState.d.ts +2 -0
  107. package/Materials/Node/nodeMaterialBuildState.js +7 -0
  108. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  109. package/Materials/Textures/Filtering/hdrFiltering.d.ts +1 -0
  110. package/Materials/Textures/Filtering/hdrFiltering.js +2 -1
  111. package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
  112. package/Materials/Textures/Loaders/basisTextureLoader.d.ts +1 -0
  113. package/Materials/Textures/Loaders/basisTextureLoader.js +1 -0
  114. package/Materials/Textures/Loaders/basisTextureLoader.js.map +1 -1
  115. package/Materials/Textures/Loaders/ddsTextureLoader.d.ts +1 -0
  116. package/Materials/Textures/Loaders/ddsTextureLoader.js +1 -0
  117. package/Materials/Textures/Loaders/ddsTextureLoader.js.map +1 -1
  118. package/Materials/Textures/Loaders/ktxTextureLoader.d.ts +1 -0
  119. package/Materials/Textures/Loaders/ktxTextureLoader.js +1 -0
  120. package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
  121. package/Materials/Textures/baseTexture.d.ts +1 -0
  122. package/Materials/Textures/baseTexture.js +1 -0
  123. package/Materials/Textures/baseTexture.js.map +1 -1
  124. package/Materials/Textures/cubeTexture.d.ts +2 -1
  125. package/Materials/Textures/cubeTexture.js +3 -2
  126. package/Materials/Textures/cubeTexture.js.map +1 -1
  127. package/Materials/Textures/dynamicTexture.d.ts +1 -1
  128. package/Materials/Textures/dynamicTexture.js.map +1 -1
  129. package/Materials/Textures/renderTargetTexture.d.ts +11 -0
  130. package/Materials/Textures/renderTargetTexture.js +10 -0
  131. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  132. package/Materials/effect.d.ts +8 -23
  133. package/Materials/effect.js +2 -25
  134. package/Materials/effect.js.map +1 -1
  135. package/Misc/dds.d.ts +2 -22
  136. package/Misc/dds.js +0 -95
  137. package/Misc/dds.js.map +1 -1
  138. package/Misc/minMaxReducer.d.ts +1 -0
  139. package/Misc/minMaxReducer.js +1 -0
  140. package/Misc/minMaxReducer.js.map +1 -1
  141. package/Misc/screenshotTools.d.ts +1 -0
  142. package/Misc/screenshotTools.js +1 -0
  143. package/Misc/screenshotTools.js.map +1 -1
  144. package/Morph/morphTargetManager.d.ts +6 -0
  145. package/Morph/morphTargetManager.js +13 -0
  146. package/Morph/morphTargetManager.js.map +1 -1
  147. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -0
  148. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  149. package/Physics/v2/Plugins/havokPlugin.d.ts +11 -1
  150. package/Physics/v2/Plugins/havokPlugin.js +25 -1
  151. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  152. package/Physics/v2/physicsAggregate.js +3 -3
  153. package/Physics/v2/physicsAggregate.js.map +1 -1
  154. package/Physics/v2/physicsBody.d.ts +6 -0
  155. package/Physics/v2/physicsBody.js +7 -0
  156. package/Physics/v2/physicsBody.js.map +1 -1
  157. package/PostProcesses/postProcess.d.ts +37 -2
  158. package/PostProcesses/postProcess.js +34 -0
  159. package/PostProcesses/postProcess.js.map +1 -1
  160. package/Rendering/depthPeelingRenderer.d.ts +1 -0
  161. package/Rendering/depthPeelingRenderer.js +1 -0
  162. package/Rendering/depthPeelingRenderer.js.map +1 -1
  163. package/Rendering/geometryBufferRenderer.d.ts +1 -0
  164. package/Rendering/geometryBufferRenderer.js +1 -0
  165. package/Rendering/geometryBufferRenderer.js.map +1 -1
  166. package/Rendering/prePassRenderer.d.ts +1 -0
  167. package/Rendering/prePassRenderer.js +1 -0
  168. package/Rendering/prePassRenderer.js.map +1 -1
  169. package/ShadersWGSL/ShadersInclude/bumpFragment.d.ts +5 -0
  170. package/ShadersWGSL/ShadersInclude/bumpFragment.js +61 -0
  171. package/ShadersWGSL/ShadersInclude/bumpFragment.js.map +1 -0
  172. package/ShadersWGSL/ShadersInclude/bumpFragmentFunctions.d.ts +6 -0
  173. package/ShadersWGSL/ShadersInclude/bumpFragmentFunctions.js +40 -0
  174. package/ShadersWGSL/ShadersInclude/bumpFragmentFunctions.js.map +1 -0
  175. package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.d.ts +5 -0
  176. package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +69 -0
  177. package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -0
  178. package/ShadersWGSL/ShadersInclude/samplerFragmentDeclaration.d.ts +5 -0
  179. package/ShadersWGSL/ShadersInclude/samplerFragmentDeclaration.js +27 -0
  180. package/ShadersWGSL/ShadersInclude/samplerFragmentDeclaration.js.map +1 -0
  181. package/package.json +1 -1
  182. package/Engines/Extensions/engine.views.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/screenshotTools.ts"],"names":[],"mappings":"AAEA,O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G;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 { DumpTools } 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_INT,\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 DumpTools.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 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 DumpTools.DumpData(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n });\r\n }\r\n });\r\n\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\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 if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().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 } 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 * @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): 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 );\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,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlD,OAAO,0CAA0C,CAAC;AAElD,IAAI,gBAAgB,GAAgC,IAAI,CAAC;AAEzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAsB,EACtB,MAAc,EACd,IAA8B,E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;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 { DumpTools } 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\nimport \"../Engines/Extensions/engine.readTexture\";\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_INT,\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 DumpTools.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 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 DumpTools.DumpData(\r\n finalWidth,\r\n finalHeight,\r\n data,\r\n successCallback as (data: string | ArrayBuffer) => void,\r\n mimeType,\r\n fileName,\r\n true,\r\n undefined,\r\n quality\r\n );\r\n texture.dispose();\r\n });\r\n });\r\n }\r\n });\r\n\r\n texture.render(true);\r\n\r\n // re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur\r\n // if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)\r\n scene.incrementRenderId();\r\n scene.resetCachedMaterial();\r\n engine.setSize(originalSize.width, originalSize.height);\r\n camera.getProjectionMatrix(true); // Force cache refresh;\r\n scene.render();\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 if (!fxaaPostProcess.getEffect().isReady()) {\r\n fxaaPostProcess.getEffect().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 } 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 * @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): 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 );\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"]}
@@ -127,6 +127,12 @@ export declare class MorphTargetManager implements IDisposable {
127
127
  * @returns the requested target
128
128
  */
129
129
  getTarget(index: number): MorphTarget;
130
+ /**
131
+ * Gets the first target with the specified name
132
+ * @param name defines the name to check
133
+ * @returns the requested target
134
+ */
135
+ getTargetByName(name: string): Nullable<MorphTarget>;
130
136
  /**
131
137
  * Add a new target to this manager
132
138
  * @param target defines the target to add
@@ -180,6 +180,19 @@ export class MorphTargetManager {
180
180
  getTarget(index) {
181
181
  return this._targets[index];
182
182
  }
183
+ /**
184
+ * Gets the first target with the specified name
185
+ * @param name defines the name to check
186
+ * @returns the requested target
187
+ */
188
+ getTargetByName(name) {
189
+ for (const target of this._targets) {
190
+ if (target.name === name) {
191
+ return target;
192
+ }
193
+ }
194
+ return null;
195
+ }
183
196
  /**
184
197
  * Add a new target to this manager
185
198
  * @param target defines the target to add
@@ -1 +1 @@
1
- {"version":3,"file":"morphTargetManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Morph/morphTargetManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAoD3B;;OAEG;IACH,IAAW,gBAAgB,CAAC,KAAc;QACtC,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,aAAa,EAAE,CAAC;SACxB;aAAM;YACH,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,IA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;AAhhBD,wFAAwF;AAC1E,uCAAoB,GAAG,IAAI,AAAP,CAAQ;AAE1C,qHAAqH;AACvG,6DAA0C,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { MorphTarget } from \"./morphTarget\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { RawTexture2DArray } from \"../Materials/Textures/rawTexture2DArray\";\r\nimport type { AbstractScene } from \"../abstractScene\";\r\n/**\r\n * This class is used to deform meshes using morphing between different targets\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTargetManager implements IDisposable {\r\n /** Enable storing morph target data into textures when set to true (true by default) */\r\n public static EnableTextureStorage = true;\r\n\r\n /** Maximum number of active morph targets supported in the \"vertex attribute\" mode (i.e., not the \"texture\" mode) */\r\n public static MaxActiveMorphTargetsInVertexAttributeMode = 8;\r\n\r\n private _targets = new Array<MorphTarget>();\r\n private _targetInfluenceChangedObservers = new Array<Nullable<Observer<boolean>>>();\r\n private _targetDataLayoutChangedObservers = new Array<Nullable<Observer<void>>>();\r\n private _activeTargets = new SmartArray<MorphTarget>(16);\r\n private _scene: Nullable<Scene>;\r\n private _influences: Float32Array;\r\n private _morphTargetTextureIndices: Float32Array;\r\n private _supportsNormals = false;\r\n private _supportsTangents = false;\r\n private _supportsUVs = false;\r\n private _vertexCount = 0;\r\n private _textureVertexStride = 0;\r\n private _textureWidth = 0;\r\n private _textureHeight = 1;\r\n private _uniqueId = 0;\r\n private _tempInfluences = new Array<number>();\r\n private _canUseTextureForTargets = false;\r\n private _blockCounter = 0;\r\n\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n /** @internal */\r\n public _targetStoreTexture: Nullable<RawTexture2DArray>;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if influencers must be optimized (eg. recompiling the shader if less influencers are used)\r\n */\r\n public optimizeInfluencers = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if normals must be morphed\r\n */\r\n public enableNormalMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if tangents must be morphed\r\n */\r\n public enableTangentMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if UV must be morphed\r\n */\r\n public enableUVMorphing = true;\r\n\r\n /**\r\n * Sets a boolean indicating that adding new target or updating an existing target will not update the underlying data buffers\r\n */\r\n public set areUpdatesFrozen(block: boolean) {\r\n if (block) {\r\n this._blockCounter++;\r\n } else {\r\n this._blockCounter--;\r\n if (this._blockCounter <= 0) {\r\n this._blockCounter = 0;\r\n\r\n this._syncActiveTargets(true);\r\n }\r\n }\r\n }\r\n\r\n public get areUpdatesFrozen() {\r\n return this._blockCounter > 0;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTargetManager\r\n * @param scene defines the current scene\r\n */\r\n public constructor(scene: Nullable<Scene> = null) {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n this._scene = scene;\r\n\r\n if (this._scene) {\r\n this._scene.addMorphTargetManager(this);\r\n\r\n this._uniqueId = this._scene.getUniqueId();\r\n\r\n const engineCaps = this._scene.getEngine().getCaps();\r\n this._canUseTextureForTargets =\r\n engineCaps.canUseGLVertexID && engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0 && engineCaps.texture2DArrayMaxLayerCount > 1;\r\n }\r\n }\r\n\r\n private _numMaxInfluencers = 0;\r\n\r\n /**\r\n * Gets or sets the maximum number of influencers (targets) (default value: 0).\r\n * Setting a value for this property can lead to a smoother experience, as only one shader will be compiled, which will use this value as the maximum number of influencers.\r\n * If you leave the value at 0 (default), a new shader will be compiled every time the number of active influencers changes. This can cause problems, as compiling a shader takes time.\r\n * If you assign a non-zero value to this property, you need to ensure that this value is greater than the maximum number of (active) influencers you'll need for this morph manager.\r\n * Otherwise, the number of active influencers will be truncated at the value you set for this property, which can lead to unexpected results.\r\n * Note that this property has no effect if \"useTextureToStoreTargets\" is false.\r\n */\r\n public get numMaxInfluencers(): number {\r\n return this._numMaxInfluencers;\r\n }\r\n\r\n public set numMaxInfluencers(value: number) {\r\n if (this._numMaxInfluencers === value) {\r\n return;\r\n }\r\n\r\n this._numMaxInfluencers = value;\r\n this._syncActiveTargets(true);\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 the number of vertices handled by this manager\r\n */\r\n public get vertexCount(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of normals\r\n */\r\n public get supportsNormals(): boolean {\r\n return this._supportsNormals && this.enableNormalMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of tangents\r\n */\r\n public get supportsTangents(): boolean {\r\n return this._supportsTangents && this.enableTangentMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of texture coordinates\r\n */\r\n public get supportsUVs(): boolean {\r\n return this._supportsUVs && this.enableUVMorphing;\r\n }\r\n\r\n /**\r\n * Gets the number of targets stored in this manager\r\n */\r\n public get numTargets(): number {\r\n return this._targets.length;\r\n }\r\n\r\n /**\r\n * Gets the number of influencers (ie. the number of targets with influences > 0)\r\n */\r\n public get numInfluencers(): number {\r\n return this._activeTargets.length;\r\n }\r\n\r\n /**\r\n * Gets the list of influences (one per target)\r\n */\r\n public get influences(): Float32Array {\r\n return this._influences;\r\n }\r\n\r\n private _useTextureToStoreTargets = true;\r\n /**\r\n * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).\r\n * Please note that this option is not available if the hardware does not support it\r\n */\r\n public get useTextureToStoreTargets(): boolean {\r\n return this._useTextureToStoreTargets;\r\n }\r\n\r\n public set useTextureToStoreTargets(value: boolean) {\r\n this._useTextureToStoreTargets = value;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)\r\n */\r\n public get isUsingTextureForTargets() {\r\n return (\r\n MorphTargetManager.EnableTextureStorage &&\r\n this.useTextureToStoreTargets &&\r\n this._canUseTextureForTargets &&\r\n !this._scene?.getEngine().getCaps().disableMorphTargetTexture\r\n );\r\n }\r\n\r\n /**\r\n * Gets the active target at specified index. An active target is a target with an influence > 0\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getActiveTarget(index: number): MorphTarget {\r\n return this._activeTargets.data[index];\r\n }\r\n\r\n /**\r\n * Gets the target at specified index\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getTarget(index: number): MorphTarget {\r\n return this._targets[index];\r\n }\r\n\r\n /**\r\n * Add a new target to this manager\r\n * @param target defines the target to add\r\n */\r\n public addTarget(target: MorphTarget): void {\r\n this._targets.push(target);\r\n this._targetInfluenceChangedObservers.push(\r\n target.onInfluenceChanged.add((needUpdate) => {\r\n this._syncActiveTargets(needUpdate);\r\n })\r\n );\r\n this._targetDataLayoutChangedObservers.push(\r\n target._onDataLayoutChanged.add(() => {\r\n this._syncActiveTargets(true);\r\n })\r\n );\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n /**\r\n * Removes a target from the manager\r\n * @param target defines the target to remove\r\n */\r\n public removeTarget(target: MorphTarget): void {\r\n const index = this._targets.indexOf(target);\r\n if (index >= 0) {\r\n this._targets.splice(index, 1);\r\n\r\n target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);\r\n target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n if (this._scene) {\r\n this._scene.stopAnimation(target);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _bind(effect: Effect) {\r\n effect.setFloat3(\"morphTargetTextureInfo\", this._textureVertexStride, this._textureWidth, this._textureHeight);\r\n effect.setFloatArray(\"morphTargetTextureIndices\", this._morphTargetTextureIndices);\r\n effect.setTexture(\"morphTargets\", this._targetStoreTexture);\r\n effect.setInt(\"morphTargetCount\", this.numInfluencers);\r\n }\r\n\r\n /**\r\n * Clone the current manager\r\n * @returns a new MorphTargetManager\r\n */\r\n public clone(): MorphTargetManager {\r\n const copy = new MorphTargetManager(this._scene);\r\n\r\n for (const target of this._targets) {\r\n copy.addTarget(target.clone());\r\n }\r\n\r\n copy.enableNormalMorphing = this.enableNormalMorphing;\r\n copy.enableTangentMorphing = this.enableTangentMorphing;\r\n copy.enableUVMorphing = this.enableUVMorphing;\r\n\r\n return copy;\r\n }\r\n\r\n /**\r\n * Serializes the current manager 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.id = this.uniqueId;\r\n\r\n serializationObject.targets = [];\r\n for (const target of this._targets) {\r\n serializationObject.targets.push(target.serialize());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n private _syncActiveTargets(needUpdate: boolean): void {\r\n if (this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n let influenceCount = 0;\r\n this._activeTargets.reset();\r\n this._supportsNormals = true;\r\n this._supportsTangents = true;\r\n this._supportsUVs = true;\r\n this._vertexCount = 0;\r\n\r\n if (this._scene && this._targets.length > this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount) {\r\n this.useTextureToStoreTargets = false;\r\n }\r\n\r\n if (!this._morphTargetTextureIndices || this._morphTargetTextureIndices.length !== this._targets.length) {\r\n this._morphTargetTextureIndices = new Float32Array(this._targets.length);\r\n }\r\n\r\n let targetIndex = -1;\r\n for (const target of this._targets) {\r\n targetIndex++;\r\n if (target.influence === 0 && this.optimizeInfluencers) {\r\n continue;\r\n }\r\n\r\n if (this._activeTargets.length >= MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode && !this.isUsingTextureForTargets) {\r\n break;\r\n }\r\n\r\n this._activeTargets.push(target);\r\n this._morphTargetTextureIndices[influenceCount] = targetIndex;\r\n this._tempInfluences[influenceCount++] = target.influence;\r\n\r\n this._supportsNormals = this._supportsNormals && target.hasNormals;\r\n this._supportsTangents = this._supportsTangents && target.hasTangents;\r\n this._supportsUVs = this._supportsUVs && target.hasUVs;\r\n\r\n const positions = target.getPositions();\r\n if (positions) {\r\n const vertexCount = positions.length / 3;\r\n if (this._vertexCount === 0) {\r\n this._vertexCount = vertexCount;\r\n } else if (this._vertexCount !== vertexCount) {\r\n Logger.Error(\"Incompatible target. Targets must all have the same vertices count.\");\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (this._morphTargetTextureIndices.length !== influenceCount) {\r\n this._morphTargetTextureIndices = this._morphTargetTextureIndices.slice(0, influenceCount);\r\n }\r\n\r\n if (!this._influences || this._influences.length !== influenceCount) {\r\n this._influences = new Float32Array(influenceCount);\r\n }\r\n\r\n for (let index = 0; index < influenceCount; index++) {\r\n this._influences[index] = this._tempInfluences[index];\r\n }\r\n\r\n if (needUpdate) {\r\n this.synchronize();\r\n }\r\n }\r\n\r\n /**\r\n * Synchronize the targets with all the meshes using this morph target manager\r\n */\r\n public synchronize(): void {\r\n if (!this._scene || this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n if (this.isUsingTextureForTargets && (this._vertexCount || this.numMaxInfluencers > 0)) {\r\n this._textureVertexStride = 1;\r\n\r\n if (this._supportsNormals) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsTangents) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsUVs) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n this._textureWidth = this._vertexCount * this._textureVertexStride || 1;\r\n this._textureHeight = 1;\r\n\r\n const maxTextureSize = this._scene.getEngine().getCaps().maxTextureSize;\r\n if (this._textureWidth > maxTextureSize) {\r\n this._textureHeight = Math.ceil(this._textureWidth / maxTextureSize);\r\n this._textureWidth = maxTextureSize;\r\n }\r\n\r\n let mustUpdateTexture = true;\r\n if (this._targetStoreTexture) {\r\n const textureSize = this._targetStoreTexture.getSize();\r\n if (textureSize.width === this._textureWidth && textureSize.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length) {\r\n mustUpdateTexture = false;\r\n }\r\n }\r\n\r\n if (mustUpdateTexture) {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n const targetCount = this._targets.length;\r\n const data = new Float32Array(targetCount * this._textureWidth * this._textureHeight * 4);\r\n\r\n let offset = 0;\r\n for (let index = 0; index < targetCount; index++) {\r\n const target = this._targets[index];\r\n\r\n const positions = target.getPositions();\r\n const normals = target.getNormals();\r\n const uvs = target.getUVs();\r\n const tangents = target.getTangents();\r\n\r\n if (!positions) {\r\n if (index === 0) {\r\n Logger.Error(\"Invalid morph target. Target must have positions.\");\r\n }\r\n return;\r\n }\r\n\r\n offset = index * this._textureWidth * this._textureHeight * 4;\r\n for (let vertex = 0; vertex < this._vertexCount; vertex++) {\r\n data[offset] = positions[vertex * 3];\r\n data[offset + 1] = positions[vertex * 3 + 1];\r\n data[offset + 2] = positions[vertex * 3 + 2];\r\n\r\n offset += 4;\r\n\r\n if (this._supportsNormals && normals) {\r\n data[offset] = normals[vertex * 3];\r\n data[offset + 1] = normals[vertex * 3 + 1];\r\n data[offset + 2] = normals[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsUVs && uvs) {\r\n data[offset] = uvs[vertex * 2];\r\n data[offset + 1] = uvs[vertex * 2 + 1];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsTangents && tangents) {\r\n data[offset] = tangents[vertex * 3];\r\n data[offset + 1] = tangents[vertex * 3 + 1];\r\n data[offset + 2] = tangents[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n }\r\n }\r\n\r\n this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(\r\n data,\r\n this._textureWidth,\r\n this._textureHeight,\r\n targetCount,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_FLOAT\r\n );\r\n }\r\n }\r\n\r\n // Flag meshes as dirty to resync with the active targets\r\n for (const mesh of this._scene.meshes) {\r\n if ((<any>mesh).morphTargetManager === this) {\r\n (<Mesh>mesh)._syncGeometryWithMorphTargetManager();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose() {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n this._targetStoreTexture = null;\r\n\r\n // Remove from scene\r\n if (this._scene) {\r\n this._scene.removeMorphTargetManager(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.morphTargetManagers.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.morphTargetManagers.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n for (const morph of this._targets) {\r\n this._scene.stopAnimation(morph);\r\n }\r\n }\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new MorphTargetManager from serialized data\r\n * @param serializationObject defines the serialized data\r\n * @param scene defines the hosting scene\r\n * @returns the new MorphTargetManager\r\n */\r\n public static Parse(serializationObject: any, scene: Scene): MorphTargetManager {\r\n const result = new MorphTargetManager(scene);\r\n\r\n result._uniqueId = serializationObject.id;\r\n\r\n for (const targetData of serializationObject.targets) {\r\n result.addTarget(MorphTarget.Parse(targetData, scene));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"morphTargetManager.js","sourceRoot":"","sources":["../../../../dev/core/src/Morph/morphTargetManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,C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AAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBAC9D;gBACD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;aAChC;YAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aACpC;SACJ;IACL,CAAC;IAED,UAAU;IAEV;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,mBAAwB,EAAE,KAAY;QACtD,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE7C,MAAM,CAAC,SAAS,GAAG,mBAAmB,CAAC,EAAE,CAAC;QAE1C,KAAK,MAAM,UAAU,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAClD,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;SAC1D;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;;AA/hBD,wFAAwF;AAC1E,uCAAoB,GAAG,IAAI,AAAP,CAAQ;AAE1C,qHAAqH;AACvG,6DAA0C,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { MorphTarget } from \"./morphTarget\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { RawTexture2DArray } from \"../Materials/Textures/rawTexture2DArray\";\r\nimport type { AbstractScene } from \"../abstractScene\";\r\n/**\r\n * This class is used to deform meshes using morphing between different targets\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets\r\n */\r\nexport class MorphTargetManager implements IDisposable {\r\n /** Enable storing morph target data into textures when set to true (true by default) */\r\n public static EnableTextureStorage = true;\r\n\r\n /** Maximum number of active morph targets supported in the \"vertex attribute\" mode (i.e., not the \"texture\" mode) */\r\n public static MaxActiveMorphTargetsInVertexAttributeMode = 8;\r\n\r\n private _targets = new Array<MorphTarget>();\r\n private _targetInfluenceChangedObservers = new Array<Nullable<Observer<boolean>>>();\r\n private _targetDataLayoutChangedObservers = new Array<Nullable<Observer<void>>>();\r\n private _activeTargets = new SmartArray<MorphTarget>(16);\r\n private _scene: Nullable<Scene>;\r\n private _influences: Float32Array;\r\n private _morphTargetTextureIndices: Float32Array;\r\n private _supportsNormals = false;\r\n private _supportsTangents = false;\r\n private _supportsUVs = false;\r\n private _vertexCount = 0;\r\n private _textureVertexStride = 0;\r\n private _textureWidth = 0;\r\n private _textureHeight = 1;\r\n private _uniqueId = 0;\r\n private _tempInfluences = new Array<number>();\r\n private _canUseTextureForTargets = false;\r\n private _blockCounter = 0;\r\n\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n /** @internal */\r\n public _targetStoreTexture: Nullable<RawTexture2DArray>;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if influencers must be optimized (eg. recompiling the shader if less influencers are used)\r\n */\r\n public optimizeInfluencers = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if normals must be morphed\r\n */\r\n public enableNormalMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if tangents must be morphed\r\n */\r\n public enableTangentMorphing = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if UV must be morphed\r\n */\r\n public enableUVMorphing = true;\r\n\r\n /**\r\n * Sets a boolean indicating that adding new target or updating an existing target will not update the underlying data buffers\r\n */\r\n public set areUpdatesFrozen(block: boolean) {\r\n if (block) {\r\n this._blockCounter++;\r\n } else {\r\n this._blockCounter--;\r\n if (this._blockCounter <= 0) {\r\n this._blockCounter = 0;\r\n\r\n this._syncActiveTargets(true);\r\n }\r\n }\r\n }\r\n\r\n public get areUpdatesFrozen() {\r\n return this._blockCounter > 0;\r\n }\r\n\r\n /**\r\n * Creates a new MorphTargetManager\r\n * @param scene defines the current scene\r\n */\r\n public constructor(scene: Nullable<Scene> = null) {\r\n if (!scene) {\r\n scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n this._scene = scene;\r\n\r\n if (this._scene) {\r\n this._scene.addMorphTargetManager(this);\r\n\r\n this._uniqueId = this._scene.getUniqueId();\r\n\r\n const engineCaps = this._scene.getEngine().getCaps();\r\n this._canUseTextureForTargets =\r\n engineCaps.canUseGLVertexID && engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0 && engineCaps.texture2DArrayMaxLayerCount > 1;\r\n }\r\n }\r\n\r\n private _numMaxInfluencers = 0;\r\n\r\n /**\r\n * Gets or sets the maximum number of influencers (targets) (default value: 0).\r\n * Setting a value for this property can lead to a smoother experience, as only one shader will be compiled, which will use this value as the maximum number of influencers.\r\n * If you leave the value at 0 (default), a new shader will be compiled every time the number of active influencers changes. This can cause problems, as compiling a shader takes time.\r\n * If you assign a non-zero value to this property, you need to ensure that this value is greater than the maximum number of (active) influencers you'll need for this morph manager.\r\n * Otherwise, the number of active influencers will be truncated at the value you set for this property, which can lead to unexpected results.\r\n * Note that this property has no effect if \"useTextureToStoreTargets\" is false.\r\n */\r\n public get numMaxInfluencers(): number {\r\n return this._numMaxInfluencers;\r\n }\r\n\r\n public set numMaxInfluencers(value: number) {\r\n if (this._numMaxInfluencers === value) {\r\n return;\r\n }\r\n\r\n this._numMaxInfluencers = value;\r\n this._syncActiveTargets(true);\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 the number of vertices handled by this manager\r\n */\r\n public get vertexCount(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of normals\r\n */\r\n public get supportsNormals(): boolean {\r\n return this._supportsNormals && this.enableNormalMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of tangents\r\n */\r\n public get supportsTangents(): boolean {\r\n return this._supportsTangents && this.enableTangentMorphing;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if this manager supports morphing of texture coordinates\r\n */\r\n public get supportsUVs(): boolean {\r\n return this._supportsUVs && this.enableUVMorphing;\r\n }\r\n\r\n /**\r\n * Gets the number of targets stored in this manager\r\n */\r\n public get numTargets(): number {\r\n return this._targets.length;\r\n }\r\n\r\n /**\r\n * Gets the number of influencers (ie. the number of targets with influences > 0)\r\n */\r\n public get numInfluencers(): number {\r\n return this._activeTargets.length;\r\n }\r\n\r\n /**\r\n * Gets the list of influences (one per target)\r\n */\r\n public get influences(): Float32Array {\r\n return this._influences;\r\n }\r\n\r\n private _useTextureToStoreTargets = true;\r\n /**\r\n * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).\r\n * Please note that this option is not available if the hardware does not support it\r\n */\r\n public get useTextureToStoreTargets(): boolean {\r\n return this._useTextureToStoreTargets;\r\n }\r\n\r\n public set useTextureToStoreTargets(value: boolean) {\r\n this._useTextureToStoreTargets = value;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)\r\n */\r\n public get isUsingTextureForTargets() {\r\n return (\r\n MorphTargetManager.EnableTextureStorage &&\r\n this.useTextureToStoreTargets &&\r\n this._canUseTextureForTargets &&\r\n !this._scene?.getEngine().getCaps().disableMorphTargetTexture\r\n );\r\n }\r\n\r\n /**\r\n * Gets the active target at specified index. An active target is a target with an influence > 0\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getActiveTarget(index: number): MorphTarget {\r\n return this._activeTargets.data[index];\r\n }\r\n\r\n /**\r\n * Gets the target at specified index\r\n * @param index defines the index to check\r\n * @returns the requested target\r\n */\r\n public getTarget(index: number): MorphTarget {\r\n return this._targets[index];\r\n }\r\n\r\n /**\r\n * Gets the first target with the specified name\r\n * @param name defines the name to check\r\n * @returns the requested target\r\n */\r\n public getTargetByName(name: string): Nullable<MorphTarget> {\r\n for (const target of this._targets) {\r\n if (target.name === name) {\r\n return target;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Add a new target to this manager\r\n * @param target defines the target to add\r\n */\r\n public addTarget(target: MorphTarget): void {\r\n this._targets.push(target);\r\n this._targetInfluenceChangedObservers.push(\r\n target.onInfluenceChanged.add((needUpdate) => {\r\n this._syncActiveTargets(needUpdate);\r\n })\r\n );\r\n this._targetDataLayoutChangedObservers.push(\r\n target._onDataLayoutChanged.add(() => {\r\n this._syncActiveTargets(true);\r\n })\r\n );\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n /**\r\n * Removes a target from the manager\r\n * @param target defines the target to remove\r\n */\r\n public removeTarget(target: MorphTarget): void {\r\n const index = this._targets.indexOf(target);\r\n if (index >= 0) {\r\n this._targets.splice(index, 1);\r\n\r\n target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);\r\n target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);\r\n this._syncActiveTargets(true);\r\n }\r\n\r\n if (this._scene) {\r\n this._scene.stopAnimation(target);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _bind(effect: Effect) {\r\n effect.setFloat3(\"morphTargetTextureInfo\", this._textureVertexStride, this._textureWidth, this._textureHeight);\r\n effect.setFloatArray(\"morphTargetTextureIndices\", this._morphTargetTextureIndices);\r\n effect.setTexture(\"morphTargets\", this._targetStoreTexture);\r\n effect.setInt(\"morphTargetCount\", this.numInfluencers);\r\n }\r\n\r\n /**\r\n * Clone the current manager\r\n * @returns a new MorphTargetManager\r\n */\r\n public clone(): MorphTargetManager {\r\n const copy = new MorphTargetManager(this._scene);\r\n\r\n for (const target of this._targets) {\r\n copy.addTarget(target.clone());\r\n }\r\n\r\n copy.enableNormalMorphing = this.enableNormalMorphing;\r\n copy.enableTangentMorphing = this.enableTangentMorphing;\r\n copy.enableUVMorphing = this.enableUVMorphing;\r\n\r\n return copy;\r\n }\r\n\r\n /**\r\n * Serializes the current manager 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.id = this.uniqueId;\r\n\r\n serializationObject.targets = [];\r\n for (const target of this._targets) {\r\n serializationObject.targets.push(target.serialize());\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n private _syncActiveTargets(needUpdate: boolean): void {\r\n if (this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n let influenceCount = 0;\r\n this._activeTargets.reset();\r\n this._supportsNormals = true;\r\n this._supportsTangents = true;\r\n this._supportsUVs = true;\r\n this._vertexCount = 0;\r\n\r\n if (this._scene && this._targets.length > this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount) {\r\n this.useTextureToStoreTargets = false;\r\n }\r\n\r\n if (!this._morphTargetTextureIndices || this._morphTargetTextureIndices.length !== this._targets.length) {\r\n this._morphTargetTextureIndices = new Float32Array(this._targets.length);\r\n }\r\n\r\n let targetIndex = -1;\r\n for (const target of this._targets) {\r\n targetIndex++;\r\n if (target.influence === 0 && this.optimizeInfluencers) {\r\n continue;\r\n }\r\n\r\n if (this._activeTargets.length >= MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode && !this.isUsingTextureForTargets) {\r\n break;\r\n }\r\n\r\n this._activeTargets.push(target);\r\n this._morphTargetTextureIndices[influenceCount] = targetIndex;\r\n this._tempInfluences[influenceCount++] = target.influence;\r\n\r\n this._supportsNormals = this._supportsNormals && target.hasNormals;\r\n this._supportsTangents = this._supportsTangents && target.hasTangents;\r\n this._supportsUVs = this._supportsUVs && target.hasUVs;\r\n\r\n const positions = target.getPositions();\r\n if (positions) {\r\n const vertexCount = positions.length / 3;\r\n if (this._vertexCount === 0) {\r\n this._vertexCount = vertexCount;\r\n } else if (this._vertexCount !== vertexCount) {\r\n Logger.Error(\"Incompatible target. Targets must all have the same vertices count.\");\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (this._morphTargetTextureIndices.length !== influenceCount) {\r\n this._morphTargetTextureIndices = this._morphTargetTextureIndices.slice(0, influenceCount);\r\n }\r\n\r\n if (!this._influences || this._influences.length !== influenceCount) {\r\n this._influences = new Float32Array(influenceCount);\r\n }\r\n\r\n for (let index = 0; index < influenceCount; index++) {\r\n this._influences[index] = this._tempInfluences[index];\r\n }\r\n\r\n if (needUpdate) {\r\n this.synchronize();\r\n }\r\n }\r\n\r\n /**\r\n * Synchronize the targets with all the meshes using this morph target manager\r\n */\r\n public synchronize(): void {\r\n if (!this._scene || this.areUpdatesFrozen) {\r\n return;\r\n }\r\n\r\n if (this.isUsingTextureForTargets && (this._vertexCount || this.numMaxInfluencers > 0)) {\r\n this._textureVertexStride = 1;\r\n\r\n if (this._supportsNormals) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsTangents) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n if (this._supportsUVs) {\r\n this._textureVertexStride++;\r\n }\r\n\r\n this._textureWidth = this._vertexCount * this._textureVertexStride || 1;\r\n this._textureHeight = 1;\r\n\r\n const maxTextureSize = this._scene.getEngine().getCaps().maxTextureSize;\r\n if (this._textureWidth > maxTextureSize) {\r\n this._textureHeight = Math.ceil(this._textureWidth / maxTextureSize);\r\n this._textureWidth = maxTextureSize;\r\n }\r\n\r\n let mustUpdateTexture = true;\r\n if (this._targetStoreTexture) {\r\n const textureSize = this._targetStoreTexture.getSize();\r\n if (textureSize.width === this._textureWidth && textureSize.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length) {\r\n mustUpdateTexture = false;\r\n }\r\n }\r\n\r\n if (mustUpdateTexture) {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n const targetCount = this._targets.length;\r\n const data = new Float32Array(targetCount * this._textureWidth * this._textureHeight * 4);\r\n\r\n let offset = 0;\r\n for (let index = 0; index < targetCount; index++) {\r\n const target = this._targets[index];\r\n\r\n const positions = target.getPositions();\r\n const normals = target.getNormals();\r\n const uvs = target.getUVs();\r\n const tangents = target.getTangents();\r\n\r\n if (!positions) {\r\n if (index === 0) {\r\n Logger.Error(\"Invalid morph target. Target must have positions.\");\r\n }\r\n return;\r\n }\r\n\r\n offset = index * this._textureWidth * this._textureHeight * 4;\r\n for (let vertex = 0; vertex < this._vertexCount; vertex++) {\r\n data[offset] = positions[vertex * 3];\r\n data[offset + 1] = positions[vertex * 3 + 1];\r\n data[offset + 2] = positions[vertex * 3 + 2];\r\n\r\n offset += 4;\r\n\r\n if (this._supportsNormals && normals) {\r\n data[offset] = normals[vertex * 3];\r\n data[offset + 1] = normals[vertex * 3 + 1];\r\n data[offset + 2] = normals[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsUVs && uvs) {\r\n data[offset] = uvs[vertex * 2];\r\n data[offset + 1] = uvs[vertex * 2 + 1];\r\n offset += 4;\r\n }\r\n\r\n if (this._supportsTangents && tangents) {\r\n data[offset] = tangents[vertex * 3];\r\n data[offset + 1] = tangents[vertex * 3 + 1];\r\n data[offset + 2] = tangents[vertex * 3 + 2];\r\n offset += 4;\r\n }\r\n }\r\n }\r\n\r\n this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(\r\n data,\r\n this._textureWidth,\r\n this._textureHeight,\r\n targetCount,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_FLOAT\r\n );\r\n }\r\n }\r\n\r\n // Flag meshes as dirty to resync with the active targets\r\n for (const mesh of this._scene.meshes) {\r\n if ((<any>mesh).morphTargetManager === this) {\r\n (<Mesh>mesh)._syncGeometryWithMorphTargetManager();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose() {\r\n if (this._targetStoreTexture) {\r\n this._targetStoreTexture.dispose();\r\n }\r\n\r\n this._targetStoreTexture = null;\r\n\r\n // Remove from scene\r\n if (this._scene) {\r\n this._scene.removeMorphTargetManager(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.morphTargetManagers.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.morphTargetManagers.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n for (const morph of this._targets) {\r\n this._scene.stopAnimation(morph);\r\n }\r\n }\r\n }\r\n\r\n // Statics\r\n\r\n /**\r\n * Creates a new MorphTargetManager from serialized data\r\n * @param serializationObject defines the serialized data\r\n * @param scene defines the hosting scene\r\n * @returns the new MorphTargetManager\r\n */\r\n public static Parse(serializationObject: any, scene: Scene): MorphTargetManager {\r\n const result = new MorphTargetManager(scene);\r\n\r\n result._uniqueId = serializationObject.id;\r\n\r\n for (const targetData of serializationObject.targets) {\r\n result.addTarget(MorphTarget.Parse(targetData, scene));\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
@@ -376,6 +376,7 @@ export interface IPhysicsEnginePluginV2 {
376
376
  removeChild(shape: PhysicsShape, childIndex: number): void;
377
377
  getNumChildren(shape: PhysicsShape): number;
378
378
  getBoundingBox(shape: PhysicsShape): BoundingBox;
379
+ getBodyBoundingBox(body: PhysicsBody): BoundingBox;
379
380
  disposeShape(shape: PhysicsShape): void;
380
381
  setTrigger(shape: PhysicsShape, isTrigger: boolean): void;
381
382
  initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;
@@ -1 +1 @@
1
- {"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAYA,6CAA6C;AAC7C,MAAM,CAAN,IAAY,8BAaX;AAbD,WAAY,8BAA8B;IACtC;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AAC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ACvC,+DAA2C,CAAA;IAC3C,6DAAyC,CAAA;IACzC,uDAAmC,CAAA;IACnC,qDAAiC,CAAA;AACrC,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AA6MD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAChC,yGAAqB,CAAA;IACrB,yFAAa,CAAA;IACb,6FAAe,CAAA;AACnB,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { IRaycastQuery, PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\nexport enum PhysicsEventType {\r\n COLLISION_STARTED = \"COLLISION_STARTED\",\r\n COLLISION_CONTINUED = \"COLLISION_CONTINUED\",\r\n COLLISION_FINISHED = \"COLLISION_FINISHED\",\r\n TRIGGER_ENTERED = \"TRIGGER_ENTERED\",\r\n TRIGGER_EXITED = \"TRIGGER_EXITED\",\r\n}\r\n\r\n/**\r\n * Base collision object\r\n */\r\nexport interface IBasePhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * Event type\r\n */\r\n type: PhysicsEventType;\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent extends IBasePhysicsCollisionEvent {\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n /**\r\n * The size of the heightfield in the X axis\r\n */\r\n heightFieldSizeX?: number;\r\n /**\r\n * The size of the heightfield in the Z axis\r\n */\r\n heightFieldSizeZ?: number;\r\n /**\r\n * The number of samples along the X axis\r\n */\r\n numHeightFieldSamplesX?: number;\r\n /**\r\n * The number of samples along the Z axis\r\n */\r\n numHeightFieldSamplesZ?: number;\r\n /**\r\n * The data for the heightfield\r\n */\r\n heightFieldData?: Float32Array;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/**\r\n * Controls the body sleep mode.\r\n */\r\nexport enum PhysicsActivationControl {\r\n SIMULATION_CONTROLLED,\r\n ALWAYS_ACTIVE,\r\n ALWAYS_INACTIVE,\r\n}\r\n\r\n/**\r\n * Represents a pair of bodies connected by a constraint.\r\n */\r\nexport type ConstrainedBodyPair = { parentBody: PhysicsBody; parentBodyIndex: number; childBody: PhysicsBody; childBodyIndex: number };\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n /**\r\n * Collision ended observable\r\n */\r\n onCollisionEndedObservable: Observable<IBasePhysicsCollisionEvent>;\r\n /**\r\n * Trigger observable\r\n */\r\n onTriggerCollisionObservable: Observable<IBasePhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyAngularImpulse(body: PhysicsBody, angularImpulse: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): {};\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n setCollisionEndedCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n getCollisionEndedObservable(body: PhysicsBody, instanceIndex?: number): Observable<IBasePhysicsCollisionEvent>;\r\n setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;\r\n getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;\r\n setTargetTransform(body: PhysicsBody, position: Vector3, rotation: Quaternion, instanceIndex?: number): void;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n getMaterial(shape: PhysicsShape): PhysicsMaterial;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n setTrigger(shape: PhysicsShape, isTrigger: boolean): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode>;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType>;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAYA,6CAA6C;AAC7C,MAAM,CAAN,IAAY,8BAaX;AAbD,WAAY,8BAA8B;IACtC;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AACV,CAAC,EAbW,8BAA8B,KAA9B,8BAA8B,QAazC;AAED,2GAA2G;AAC3G,MAAM,CAAN,IAAY,qBAqCX;AArCD,WAAY,qBAAqB;IAC7B;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;IACH,yEAAQ,CAAA;IACR;;;OAGG;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B;IACzB,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAChC,yGAAqB,CAAA;IACrB,yFAAa,CAAA;IACb,6FAAe,CAAA;AACnB,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { IRaycastQuery, PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\nexport enum PhysicsEventType {\r\n COLLISION_STARTED = \"COLLISION_STARTED\",\r\n COLLISION_CONTINUED = \"COLLISION_CONTINUED\",\r\n COLLISION_FINISHED = \"COLLISION_FINISHED\",\r\n TRIGGER_ENTERED = \"TRIGGER_ENTERED\",\r\n TRIGGER_EXITED = \"TRIGGER_EXITED\",\r\n}\r\n\r\n/**\r\n * Base collision object\r\n */\r\nexport interface IBasePhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * Event type\r\n */\r\n type: PhysicsEventType;\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent extends IBasePhysicsCollisionEvent {\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n /**\r\n * The size of the heightfield in the X axis\r\n */\r\n heightFieldSizeX?: number;\r\n /**\r\n * The size of the heightfield in the Z axis\r\n */\r\n heightFieldSizeZ?: number;\r\n /**\r\n * The number of samples along the X axis\r\n */\r\n numHeightFieldSamplesX?: number;\r\n /**\r\n * The number of samples along the Z axis\r\n */\r\n numHeightFieldSamplesZ?: number;\r\n /**\r\n * The data for the heightfield\r\n */\r\n heightFieldData?: Float32Array;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/**\r\n * Controls the body sleep mode.\r\n */\r\nexport enum PhysicsActivationControl {\r\n SIMULATION_CONTROLLED,\r\n ALWAYS_ACTIVE,\r\n ALWAYS_INACTIVE,\r\n}\r\n\r\n/**\r\n * Represents a pair of bodies connected by a constraint.\r\n */\r\nexport type ConstrainedBodyPair = { parentBody: PhysicsBody; parentBodyIndex: number; childBody: PhysicsBody; childBodyIndex: number };\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n /**\r\n * Collision ended observable\r\n */\r\n onCollisionEndedObservable: Observable<IBasePhysicsCollisionEvent>;\r\n /**\r\n * Trigger observable\r\n */\r\n onTriggerCollisionObservable: Observable<IBasePhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyAngularImpulse(body: PhysicsBody, angularImpulse: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): {};\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n setCollisionEndedCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n getCollisionEndedObservable(body: PhysicsBody, instanceIndex?: number): Observable<IBasePhysicsCollisionEvent>;\r\n setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;\r\n getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;\r\n setTargetTransform(body: PhysicsBody, position: Vector3, rotation: Quaternion, instanceIndex?: number): void;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n getMaterial(shape: PhysicsShape): PhysicsMaterial;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n getBodyBoundingBox(body: PhysicsBody): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n setTrigger(shape: PhysicsShape, isTrigger: boolean): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode>;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType>;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
@@ -6,7 +6,7 @@ import type { PhysicsBody } from "../physicsBody";
6
6
  import type { PhysicsConstraint } from "../physicsConstraint";
7
7
  import type { PhysicsMaterial } from "../physicsMaterial";
8
8
  import { PhysicsShape } from "../physicsShape";
9
- import type { BoundingBox } from "../../../Culling/boundingBox";
9
+ import { BoundingBox } from "../../../Culling/boundingBox";
10
10
  import type { TransformNode } from "../../../Meshes/transformNode";
11
11
  import { Mesh } from "../../../Meshes/mesh";
12
12
  import { Observable } from "../../../Misc/observable";
@@ -549,6 +549,16 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
549
549
  * for collision detection and other physics calculations.
550
550
  */
551
551
  getBoundingBox(_shape: PhysicsShape): BoundingBox;
552
+ /**
553
+ * Calculates the world bounding box of a given physics body.
554
+ *
555
+ * @param body - The physics body to calculate the bounding box for.
556
+ * @returns The calculated bounding box.
557
+ *
558
+ * This method is useful for physics engines as it allows to calculate the
559
+ * boundaries of a given body.
560
+ */
561
+ getBodyBoundingBox(body: PhysicsBody): BoundingBox;
552
562
  /**
553
563
  * Gets the geometry of a physics body.
554
564
  *
@@ -3,6 +3,7 @@ import { PhysicsShapeType, PhysicsConstraintType, PhysicsMotionType, PhysicsCons
3
3
  import { Logger } from "../../../Misc/logger.js";
4
4
  import { PhysicsMaterialCombineMode } from "../physicsMaterial.js";
5
5
  import { PhysicsShape } from "../physicsShape.js";
6
+ import { BoundingBox } from "../../../Culling/boundingBox.js";
6
7
  import { Mesh } from "../../../Meshes/mesh.js";
7
8
  import { InstancedMesh } from "../../../Meshes/instancedMesh.js";
8
9
  import { VertexBuffer } from "../../../Buffers/buffer.js";
@@ -1294,7 +1295,30 @@ export class HavokPlugin {
1294
1295
  * for collision detection and other physics calculations.
1295
1296
  */
1296
1297
  getBoundingBox(_shape) {
1297
- return {};
1298
+ // get local AABB
1299
+ const aabb = this._hknp.HP_Shape_GetBoundingBox(_shape._pluginData, [
1300
+ [0, 0, 0],
1301
+ [0, 0, 0, 1],
1302
+ ])[1];
1303
+ TmpVectors.Vector3[0].set(aabb[0][0], aabb[0][1], aabb[0][2]); // min
1304
+ TmpVectors.Vector3[1].set(aabb[1][0], aabb[1][1], aabb[1][2]); // max
1305
+ const boundingbox = new BoundingBox(TmpVectors.Vector3[0], TmpVectors.Vector3[1], Matrix.IdentityReadOnly);
1306
+ return boundingbox;
1307
+ }
1308
+ /**
1309
+ * Calculates the world bounding box of a given physics body.
1310
+ *
1311
+ * @param body - The physics body to calculate the bounding box for.
1312
+ * @returns The calculated bounding box.
1313
+ *
1314
+ * This method is useful for physics engines as it allows to calculate the
1315
+ * boundaries of a given body.
1316
+ */
1317
+ getBodyBoundingBox(body) {
1318
+ // get local AABB
1319
+ const aabb = this.getBoundingBox(body.shape);
1320
+ const boundingbox = new BoundingBox(aabb.minimum, aabb.maximum, body.transformNode.getWorldMatrix());
1321
+ return boundingbox;
1298
1322
  }
1299
1323
  /**
1300
1324
  * Gets the geometry of a physics body.