@babylonjs/core 6.38.0 → 6.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/Behaviors/Meshes/sixDofDragBehavior.js +14 -20
  2. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  3. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +9 -9
  4. package/Cameras/Inputs/BaseCameraPointersInput.js +10 -10
  5. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  6. package/Cameras/Inputs/freeCameraMouseInput.d.ts +1 -1
  7. package/Cameras/Inputs/freeCameraMouseInput.js +1 -1
  8. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  9. package/Cameras/VR/vrExperienceHelper.d.ts +2 -2
  10. package/Cameras/VR/vrExperienceHelper.js +2 -2
  11. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  12. package/Culling/Octrees/octree.d.ts +4 -4
  13. package/Culling/Octrees/octree.js +4 -4
  14. package/Culling/Octrees/octree.js.map +1 -1
  15. package/Debug/physicsViewer.d.ts +5 -1
  16. package/Debug/physicsViewer.js +5 -1
  17. package/Debug/physicsViewer.js.map +1 -1
  18. package/Engines/ICanvas.d.ts +60 -0
  19. package/Engines/ICanvas.js.map +1 -1
  20. package/Engines/IPipelineContext.d.ts +3 -3
  21. package/Engines/IPipelineContext.js.map +1 -1
  22. package/Engines/Native/nativePipelineContext.d.ts +4 -5
  23. package/Engines/Native/nativePipelineContext.js +2 -9
  24. package/Engines/Native/nativePipelineContext.js.map +1 -1
  25. package/Engines/Native/nativeRenderTargetWrapper.js +2 -0
  26. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  27. package/Engines/Native/validatedNativeDataStream.d.ts +3 -0
  28. package/Engines/Native/validatedNativeDataStream.js +3 -0
  29. package/Engines/Native/validatedNativeDataStream.js.map +1 -1
  30. package/Engines/WebGL/webGLHardwareTexture.js +1 -0
  31. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  32. package/Engines/WebGL/webGLRenderTargetWrapper.js +1 -0
  33. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  34. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  35. package/Engines/WebGPU/webgpuConstants.d.ts +3 -1
  36. package/Engines/WebGPU/webgpuConstants.js +2 -0
  37. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  38. package/Engines/WebGPU/webgpuTintWASM.d.ts +1 -1
  39. package/Engines/WebGPU/webgpuTintWASM.js +5 -5
  40. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  41. package/Engines/engine.d.ts +11 -45
  42. package/Engines/nativeEngine.d.ts +3 -1
  43. package/Engines/nativeEngine.js +29 -30
  44. package/Engines/nativeEngine.js.map +1 -1
  45. package/Engines/thinEngine.js +2 -2
  46. package/Engines/thinEngine.js.map +1 -1
  47. package/Engines/webgpuEngine.js +0 -1
  48. package/Engines/webgpuEngine.js.map +1 -1
  49. package/FlowGraph/Blocks/Data/Logic/index.d.ts +0 -1
  50. package/FlowGraph/Blocks/Data/Logic/index.js +0 -1
  51. package/FlowGraph/Blocks/Data/Logic/index.js.map +1 -1
  52. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.d.ts +334 -1
  53. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +472 -74
  54. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -1
  55. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +6 -6
  56. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  57. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +3 -0
  58. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  59. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.d.ts +1 -1
  60. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +2 -2
  61. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  62. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +7 -3
  63. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +7 -6
  64. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  65. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.d.ts +14 -0
  66. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js +4 -0
  67. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js.map +1 -1
  68. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +3 -0
  69. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  70. package/FlowGraph/flowGraphConnection.d.ts +16 -0
  71. package/FlowGraph/flowGraphConnection.js.map +1 -1
  72. package/FlowGraph/flowGraphContext.d.ts +14 -0
  73. package/FlowGraph/flowGraphContext.js.map +1 -1
  74. package/FlowGraph/flowGraphInteger.d.ts +62 -0
  75. package/FlowGraph/flowGraphInteger.js +76 -0
  76. package/FlowGraph/flowGraphInteger.js.map +1 -0
  77. package/FlowGraph/flowGraphPathConverterComponent.d.ts +2 -1
  78. package/FlowGraph/flowGraphPathConverterComponent.js +3 -3
  79. package/FlowGraph/flowGraphPathConverterComponent.js.map +1 -1
  80. package/FlowGraph/flowGraphRichTypes.d.ts +2 -0
  81. package/FlowGraph/flowGraphRichTypes.js +5 -0
  82. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  83. package/FlowGraph/serialization.js +8 -1
  84. package/FlowGraph/serialization.js.map +1 -1
  85. package/Gizmos/gizmo.d.ts +4 -1
  86. package/Gizmos/gizmo.js.map +1 -1
  87. package/Inputs/scene.inputManager.js +1 -1
  88. package/Inputs/scene.inputManager.js.map +1 -1
  89. package/Lights/spotLight.js +1 -1
  90. package/Lights/spotLight.js.map +1 -1
  91. package/Loading/sceneLoader.d.ts +9 -0
  92. package/Loading/sceneLoader.js +7 -0
  93. package/Loading/sceneLoader.js.map +1 -1
  94. package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +1 -1
  95. package/Materials/GreasedLine/greasedLineMaterialInterfaces.js.map +1 -1
  96. package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +2 -1
  97. package/Materials/GreasedLine/greasedLinePluginMaterial.js +2 -1
  98. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
  99. package/Materials/Node/Blocks/Dual/index.d.ts +1 -0
  100. package/Materials/Node/Blocks/Dual/index.js +1 -0
  101. package/Materials/Node/Blocks/Dual/index.js.map +1 -1
  102. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +5 -0
  103. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +5 -0
  104. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  105. package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +1 -1
  106. package/Materials/Node/Blocks/Input/prePassTextureBlock.js +1 -1
  107. package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
  108. package/Materials/Node/Blocks/addBlock.js +1 -1
  109. package/Materials/Node/Blocks/addBlock.js.map +1 -1
  110. package/Materials/Node/Blocks/divideBlock.js +1 -1
  111. package/Materials/Node/Blocks/divideBlock.js.map +1 -1
  112. package/Materials/Node/Blocks/multiplyBlock.js +1 -1
  113. package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
  114. package/Materials/Node/Blocks/subtractBlock.js +1 -1
  115. package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
  116. package/Materials/Node/nodeMaterial.d.ts +2 -1
  117. package/Materials/Node/nodeMaterial.js +2 -1
  118. package/Materials/Node/nodeMaterial.js.map +1 -1
  119. package/Materials/PBR/pbrBaseMaterial.d.ts +3 -3
  120. package/Materials/PBR/pbrBaseMaterial.js +3 -3
  121. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  122. package/Materials/PBR/pbrMaterial.d.ts +1 -0
  123. package/Materials/PBR/pbrMaterial.js +2 -1
  124. package/Materials/PBR/pbrMaterial.js.map +1 -1
  125. package/Materials/PBR/pbrMetallicRoughnessMaterial.d.ts +3 -3
  126. package/Materials/PBR/pbrMetallicRoughnessMaterial.js +3 -3
  127. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  128. package/Materials/PBR/pbrSpecularGlossinessMaterial.d.ts +3 -3
  129. package/Materials/PBR/pbrSpecularGlossinessMaterial.js +3 -3
  130. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  131. package/Materials/Textures/Procedurals/noiseProceduralTexture.d.ts +1 -1
  132. package/Materials/Textures/Procedurals/noiseProceduralTexture.js +1 -1
  133. package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
  134. package/Materials/Textures/baseTexture.js +3 -0
  135. package/Materials/Textures/baseTexture.js.map +1 -1
  136. package/Materials/Textures/multiRenderTarget.d.ts +1 -1
  137. package/Materials/Textures/multiRenderTarget.js +1 -1
  138. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  139. package/Materials/Textures/texture.d.ts +4 -1
  140. package/Materials/Textures/texture.js +4 -1
  141. package/Materials/Textures/texture.js.map +1 -1
  142. package/Materials/Textures/thinRenderTargetTexture.d.ts +1 -1
  143. package/Materials/Textures/thinRenderTargetTexture.js +1 -1
  144. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  145. package/Materials/Textures/thinTexture.js +3 -0
  146. package/Materials/Textures/thinTexture.js.map +1 -1
  147. package/Materials/effect.js +2 -1
  148. package/Materials/effect.js.map +1 -1
  149. package/Materials/material.d.ts +1 -1
  150. package/Materials/material.js +2 -2
  151. package/Materials/material.js.map +1 -1
  152. package/Materials/standardMaterial.js +1 -1
  153. package/Materials/standardMaterial.js.map +1 -1
  154. package/Maths/math.like.d.ts +3 -0
  155. package/Maths/math.like.js.map +1 -1
  156. package/Maths/math.polar.d.ts +3 -2
  157. package/Maths/math.polar.js +8 -2
  158. package/Maths/math.polar.js.map +1 -1
  159. package/Maths/math.vector.d.ts +1 -1
  160. package/Maths/math.vector.js +1 -1
  161. package/Maths/math.vector.js.map +1 -1
  162. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +2 -0
  163. package/Meshes/GreasedLine/greasedLineBaseMesh.js +2 -0
  164. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  165. package/Meshes/GreasedLine/greasedLineRibbonMesh.d.ts +2 -0
  166. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +2 -0
  167. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  168. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -1
  169. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +1 -1
  170. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
  171. package/Meshes/geodesicMesh.d.ts +32 -1
  172. package/Meshes/geodesicMesh.js +17 -1
  173. package/Meshes/geodesicMesh.js.map +1 -1
  174. package/Meshes/instancedMesh.d.ts +27 -14
  175. package/Meshes/instancedMesh.js +27 -14
  176. package/Meshes/instancedMesh.js.map +1 -1
  177. package/Meshes/linesMesh.d.ts +3 -3
  178. package/Meshes/linesMesh.js +3 -3
  179. package/Meshes/linesMesh.js.map +1 -1
  180. package/Meshes/transformNode.js +18 -0
  181. package/Meshes/transformNode.js.map +1 -1
  182. package/Misc/HighDynamicRange/hdr.d.ts +1 -0
  183. package/Misc/HighDynamicRange/hdr.js +1 -0
  184. package/Misc/HighDynamicRange/hdr.js.map +1 -1
  185. package/Misc/HighDynamicRange/panoramaToCubemap.d.ts +1 -0
  186. package/Misc/HighDynamicRange/panoramaToCubemap.js +1 -0
  187. package/Misc/HighDynamicRange/panoramaToCubemap.js.map +1 -1
  188. package/Misc/decorators.d.ts +1 -0
  189. package/Misc/decorators.js +1 -0
  190. package/Misc/decorators.js.map +1 -1
  191. package/Misc/greasedLineTools.d.ts +5 -1
  192. package/Misc/greasedLineTools.js +5 -1
  193. package/Misc/greasedLineTools.js.map +1 -1
  194. package/Misc/tools.d.ts +4 -0
  195. package/Misc/tools.js +4 -0
  196. package/Misc/tools.js.map +1 -1
  197. package/Misc/videoRecorder.d.ts +4 -1
  198. package/Misc/videoRecorder.js +7 -5
  199. package/Misc/videoRecorder.js.map +1 -1
  200. package/Misc/webRequest.d.ts +3 -0
  201. package/Misc/webRequest.js +3 -0
  202. package/Misc/webRequest.js.map +1 -1
  203. package/Navigation/INavigationEngine.d.ts +10 -1
  204. package/Navigation/INavigationEngine.js.map +1 -1
  205. package/Navigation/Plugins/recastJSPlugin.d.ts +20 -0
  206. package/Navigation/Plugins/recastJSPlugin.js +43 -8
  207. package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
  208. package/ObjectModel/objectModelInterfaces.d.ts +5 -0
  209. package/ObjectModel/objectModelInterfaces.js.map +1 -1
  210. package/Physics/physicsHelper.d.ts +2 -2
  211. package/Physics/physicsHelper.js +4 -4
  212. package/Physics/physicsHelper.js.map +1 -1
  213. package/Physics/physicsRaycastResult.d.ts +2 -1
  214. package/Physics/physicsRaycastResult.js +2 -1
  215. package/Physics/physicsRaycastResult.js.map +1 -1
  216. package/Physics/v1/physicsImpostor.d.ts +2 -2
  217. package/Physics/v1/physicsImpostor.js +2 -2
  218. package/Physics/v1/physicsImpostor.js.map +1 -1
  219. package/Physics/v2/Plugins/havokPlugin.d.ts +49 -4
  220. package/Physics/v2/Plugins/havokPlugin.js +51 -4
  221. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  222. package/Physics/v2/physicsBody.d.ts +33 -3
  223. package/Physics/v2/physicsBody.js +24 -5
  224. package/Physics/v2/physicsBody.js.map +1 -1
  225. package/Physics/v2/physicsEngine.d.ts +4 -1
  226. package/Physics/v2/physicsEngine.js +4 -1
  227. package/Physics/v2/physicsEngine.js.map +1 -1
  228. package/Physics/v2/ragdoll.js +4 -0
  229. package/Physics/v2/ragdoll.js.map +1 -1
  230. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -1
  231. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +1 -1
  232. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  233. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.d.ts +1 -1
  234. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +1 -1
  235. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  236. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +1 -1
  237. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +1 -1
  238. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  239. package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +1 -1
  240. package/PostProcesses/volumetricLightScatteringPostProcess.js +1 -1
  241. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  242. package/Rendering/GlobalIllumination/giRSMManager.d.ts +2 -1
  243. package/Rendering/GlobalIllumination/giRSMManager.js +5 -2
  244. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  245. package/Rendering/prePassRenderer.d.ts +2 -2
  246. package/Rendering/prePassRenderer.js +2 -2
  247. package/Rendering/prePassRenderer.js.map +1 -1
  248. package/Rendering/reflectiveShadowMap.d.ts +4 -0
  249. package/Rendering/reflectiveShadowMap.js +7 -0
  250. package/Rendering/reflectiveShadowMap.js.map +1 -1
  251. package/Rendering/renderingManager.d.ts +1 -0
  252. package/Rendering/renderingManager.js +1 -0
  253. package/Rendering/renderingManager.js.map +1 -1
  254. package/XR/features/WebXRAbstractFeature.d.ts +4 -0
  255. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  256. package/XR/features/WebXRControllerPointerSelection.js +1 -0
  257. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  258. package/XR/features/WebXRDepthSensing.d.ts +1 -1
  259. package/XR/features/WebXRDepthSensing.js +1 -1
  260. package/XR/features/WebXRDepthSensing.js.map +1 -1
  261. package/XR/features/WebXRSpaceWarp.d.ts +0 -27
  262. package/XR/features/WebXRSpaceWarp.js +0 -27
  263. package/XR/features/WebXRSpaceWarp.js.map +1 -1
  264. package/XR/index.d.ts +1 -0
  265. package/XR/index.js +1 -0
  266. package/XR/index.js.map +1 -1
  267. package/assetContainer.d.ts +1 -1
  268. package/assetContainer.js +1 -1
  269. package/assetContainer.js.map +1 -1
  270. package/node.d.ts +3 -0
  271. package/node.js +3 -0
  272. package/node.js.map +1 -1
  273. package/package.json +1 -1
  274. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.d.ts +0 -60
  275. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js +0 -104
  276. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"octree.js","sourceRoot":"","sources":["../../../../../dev/core/src/Culling/Octrees/octree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAK9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;GAGG;AACH,MAAM,OAAO,MAAM;IAcf;;;;;;OAMG;IACH,YACI,YAAuD,EACvD,gBAAyB;IACzB,qKAAqK;IAC9J,WAAW,CAAC;QAAZ,aAAQ,GAAR,QAAQ,CAAI;QApBvB;;WAEG;QACI,mBAAc,GAAQ,EAAE,CAAC;QAmB5B,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,IAAI,EAAE,CAAC;QAChD,IAAI,CAAC,iBAAiB,GAAG,IAAI,qBAAqB,CAAI,IAAI,CAAC,CAAC;QAC5D,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACtC,CAAC;IAED,U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CAAC,cAAc,CAAC,CAAC;QAElE,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;;AAED;;;;GAIG;AACW,4BAAqB,GAAG,CAAC,KAAmB,EAAE,KAAgC,EAAQ,EAAE;IAClG,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,EAAE,CAAC;IAC7C,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC/F,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC7B;AACL,CAAC,AALkC,CAKjC;AAEF;;;;GAIG;AACW,+BAAwB,GAAG,CAAC,KAAc,EAAE,KAA2B,EAAQ,EAAE;IAC3F,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,EAAE,CAAC;IAC7C,IAAI,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC3E,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC7B;AACL,CAAC,AALqC,CAKpC","sourcesContent":["import type { SmartArray } from \"../../Misc/smartArray\";\r\nimport { SmartArrayNoDuplicate } from \"../../Misc/smartArray\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { SubMesh } from \"../../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\nimport { OctreeBlock } from \"./octreeBlock\";\r\nimport type { Plane } from \"../../Maths/math.plane\";\r\n\r\n/**\r\n * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeOctrees\r\n */\r\nexport class Octree<T> {\r\n /**\r\n * Blocks within the octree containing objects\r\n */\r\n public blocks: Array<OctreeBlock<T>>;\r\n /**\r\n * Content stored in the octree\r\n */\r\n public dynamicContent: T[] = [];\r\n\r\n private _maxBlockCapacity: number;\r\n private _selectionContent: SmartArrayNoDuplicate<T>;\r\n private _creationFunc: (entry: T, block: OctreeBlock<T>) => void;\r\n\r\n /**\r\n * Creates a octree\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeOctrees\r\n * @param creationFunc function to be used to instantiate the octree\r\n * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)\r\n * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)\r\n */\r\n constructor(\r\n creationFunc: (entry: T, block: OctreeBlock<T>) => void,\r\n maxBlockCapacity?: number,\r\n /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */\r\n public maxDepth = 2\r\n ) {\r\n this._maxBlockCapacity = maxBlockCapacity || 64;\r\n this._selectionContent = new SmartArrayNoDuplicate<T>(1024);\r\n this._creationFunc = creationFunc;\r\n }\r\n\r\n // Methods\r\n /**\r\n * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters\r\n * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);\r\n * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);\r\n * @param entries meshes to be added to the octree blocks\r\n */\r\n public update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void {\r\n OctreeBlock._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);\r\n }\r\n\r\n /**\r\n * Adds a mesh to the octree\r\n * @param entry Mesh to add to the octree\r\n */\r\n public addMesh(entry: T): void {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.addEntry(entry);\r\n }\r\n }\r\n\r\n /**\r\n * Remove an element from the octree\r\n * @param entry defines the element to remove\r\n */\r\n public removeMesh(entry: T): void {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.removeEntry(entry);\r\n }\r\n }\r\n\r\n /**\r\n * Selects an array of meshes within the frustum\r\n * @param frustumPlanes The frustum planes to use which will select all meshes within it\r\n * @param allowDuplicate If duplicate objects are allowed in the resulting object array\r\n * @returns array of meshes within the frustum\r\n */\r\n public select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T> {\r\n this._selectionContent.reset();\r\n\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.select(frustumPlanes, this._selectionContent, allowDuplicate);\r\n }\r\n\r\n if (allowDuplicate) {\r\n this._selectionContent.concat(this.dynamicContent);\r\n } else {\r\n this._selectionContent.concatWithNoDuplicate(this.dynamicContent);\r\n }\r\n\r\n return this._selectionContent;\r\n }\r\n\r\n /**\r\n * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array\r\n * @param sphereCenter defines the bounding sphere center\r\n * @param sphereRadius defines the bounding sphere radius\r\n * @param allowDuplicate defines if the selection array can contains duplicated entries\r\n * @returns an array of objects that intersect the sphere\r\n */\r\n public intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T> {\r\n this._selectionContent.reset();\r\n\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);\r\n }\r\n\r\n if (allowDuplicate) {\r\n this._selectionContent.concat(this.dynamicContent);\r\n } else {\r\n this._selectionContent.concatWithNoDuplicate(this.dynamicContent);\r\n }\r\n\r\n return this._selectionContent;\r\n }\r\n\r\n /**\r\n * Test if the octree intersect with the given ray and if yes, then add its content to resulting array\r\n * @param ray defines the ray to test with\r\n * @returns array of intersected objects\r\n */\r\n public intersectsRay(ray: Ray): SmartArray<T> {\r\n this._selectionContent.reset();\r\n\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersectsRay(ray, this._selectionContent);\r\n }\r\n\r\n this._selectionContent.concatWithNoDuplicate(this.dynamicContent);\r\n\r\n return this._selectionContent;\r\n }\r\n\r\n /**\r\n * Adds a mesh into the octree block if it intersects the block\r\n * @param entry\r\n * @param block\r\n */\r\n public static CreationFuncForMeshes = (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>): void => {\r\n const boundingInfo = entry.getBoundingInfo();\r\n if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {\r\n block.entries.push(entry);\r\n }\r\n };\r\n\r\n /**\r\n * Adds a submesh into the octree block if it intersects the block\r\n * @param entry\r\n * @param block\r\n */\r\n public static CreationFuncForSubMeshes = (entry: SubMesh, block: OctreeBlock<SubMesh>): void => {\r\n const boundingInfo = entry.getBoundingInfo();\r\n if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {\r\n block.entries.push(entry);\r\n }\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"octree.js","sourceRoot":"","sources":["../../../../../dev/core/src/Culling/Octrees/octree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAK9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C;;;GAGG;AACH,MAAM,OAAO,MAAM;IAcf;;;;;;OAMG;IACH,YACI,YAAuD,EACvD,gBAAyB;IACzB,qKAAqK;IAC9J,WAAW,CAAC;QAAZ,aAAQ,GAAR,QAAQ,CAAI;QApBvB;;WAEG;QACI,mBAAc,GAAQ,EAAE,CAAC;QAmB5B,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,IAAI,EAAE,CAAC;QAChD,IAAI,CAAC,iBAAiB,GAAG,IAAI,qBAAqB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I,CAAC,iBAAiB,CAAC,CAAC;SACpD;QAED,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAElE,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;;AAED;;;;GAIG;AACW,4BAAqB,GAAG,CAAC,KAAmB,EAAE,KAAgC,EAAQ,EAAE;IAClG,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,EAAE,CAAC;IAC7C,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC/F,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC7B;AACL,CAAC,AALkC,CAKjC;AAEF;;;;GAIG;AACW,+BAAwB,GAAG,CAAC,KAAc,EAAE,KAA2B,EAAQ,EAAE;IAC3F,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,EAAE,CAAC;IAC7C,IAAI,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC3E,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC7B;AACL,CAAC,AALqC,CAKpC","sourcesContent":["import type { SmartArray } from \"../../Misc/smartArray\";\r\nimport { SmartArrayNoDuplicate } from \"../../Misc/smartArray\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { SubMesh } from \"../../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Ray } from \"../../Culling/ray\";\r\nimport { OctreeBlock } from \"./octreeBlock\";\r\nimport type { Plane } from \"../../Maths/math.plane\";\r\n\r\n/**\r\n * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeOctrees\r\n */\r\nexport class Octree<T> {\r\n /**\r\n * Blocks within the octree containing objects\r\n */\r\n public blocks: Array<OctreeBlock<T>>;\r\n /**\r\n * Content stored in the octree\r\n */\r\n public dynamicContent: T[] = [];\r\n\r\n private _maxBlockCapacity: number;\r\n private _selectionContent: SmartArrayNoDuplicate<T>;\r\n private _creationFunc: (entry: T, block: OctreeBlock<T>) => void;\r\n\r\n /**\r\n * Creates a octree\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeOctrees\r\n * @param creationFunc function to be used to instantiate the octree\r\n * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)\r\n * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)\r\n */\r\n constructor(\r\n creationFunc: (entry: T, block: OctreeBlock<T>) => void,\r\n maxBlockCapacity?: number,\r\n /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */\r\n public maxDepth = 2\r\n ) {\r\n this._maxBlockCapacity = maxBlockCapacity || 64;\r\n this._selectionContent = new SmartArrayNoDuplicate<T>(1024);\r\n this._creationFunc = creationFunc;\r\n }\r\n\r\n // Methods\r\n /**\r\n * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters\r\n * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);\r\n * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);\r\n * @param entries meshes to be added to the octree blocks\r\n */\r\n public update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void {\r\n OctreeBlock._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);\r\n }\r\n\r\n /**\r\n * Adds a mesh to the octree\r\n * @param entry Mesh to add to the octree\r\n */\r\n public addMesh(entry: T): void {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.addEntry(entry);\r\n }\r\n }\r\n\r\n /**\r\n * Remove an element from the octree\r\n * @param entry defines the element to remove\r\n */\r\n public removeMesh(entry: T): void {\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.removeEntry(entry);\r\n }\r\n }\r\n\r\n /**\r\n * Selects an array of meshes within the frustum\r\n * @param frustumPlanes The frustum planes to use which will select all meshes within it\r\n * @param allowDuplicate If duplicate objects are allowed in the resulting object array\r\n * @returns array of meshes within the frustum\r\n */\r\n public select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T> {\r\n this._selectionContent.reset();\r\n\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.select(frustumPlanes, this._selectionContent, allowDuplicate);\r\n }\r\n\r\n if (allowDuplicate) {\r\n this._selectionContent.concat(this.dynamicContent);\r\n } else {\r\n this._selectionContent.concatWithNoDuplicate(this.dynamicContent);\r\n }\r\n\r\n return this._selectionContent;\r\n }\r\n\r\n /**\r\n * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array\r\n * @param sphereCenter defines the bounding sphere center\r\n * @param sphereRadius defines the bounding sphere radius\r\n * @param allowDuplicate defines if the selection array can contains duplicated entries\r\n * @returns an array of objects that intersect the sphere\r\n */\r\n public intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T> {\r\n this._selectionContent.reset();\r\n\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);\r\n }\r\n\r\n if (allowDuplicate) {\r\n this._selectionContent.concat(this.dynamicContent);\r\n } else {\r\n this._selectionContent.concatWithNoDuplicate(this.dynamicContent);\r\n }\r\n\r\n return this._selectionContent;\r\n }\r\n\r\n /**\r\n * Test if the octree intersect with the given ray and if yes, then add its content to resulting array\r\n * @param ray defines the ray to test with\r\n * @returns array of intersected objects\r\n */\r\n public intersectsRay(ray: Ray): SmartArray<T> {\r\n this._selectionContent.reset();\r\n\r\n for (let index = 0; index < this.blocks.length; index++) {\r\n const block = this.blocks[index];\r\n block.intersectsRay(ray, this._selectionContent);\r\n }\r\n\r\n this._selectionContent.concatWithNoDuplicate(this.dynamicContent);\r\n\r\n return this._selectionContent;\r\n }\r\n\r\n /**\r\n * Adds a mesh into the octree block if it intersects the block\r\n * @param entry defines the mesh to try to add to the block\r\n * @param block defines the block where the mesh should be added\r\n */\r\n public static CreationFuncForMeshes = (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>): void => {\r\n const boundingInfo = entry.getBoundingInfo();\r\n if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {\r\n block.entries.push(entry);\r\n }\r\n };\r\n\r\n /**\r\n * Adds a submesh into the octree block if it intersects the block\r\n * @param entry defines the submesh to try to add to the block\r\n * @param block defines the block where the submesh should be added\r\n */\r\n public static CreationFuncForSubMeshes = (entry: SubMesh, block: OctreeBlock<SubMesh>): void => {\r\n const boundingInfo = entry.getBoundingInfo();\r\n if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {\r\n block.entries.push(entry);\r\n }\r\n };\r\n}\r\n"]}
@@ -110,7 +110,7 @@ export declare class PhysicsViewer {
110
110
  showBody(body: PhysicsBody): Nullable<AbstractMesh>;
111
111
  /**
112
112
  * Shows a debug box corresponding to the inertia of a given body
113
- * @param body
113
+ * @param body the physics body used to get the inertia
114
114
  */
115
115
  showInertia(body: PhysicsBody): Nullable<AbstractMesh>;
116
116
  /**
@@ -139,6 +139,10 @@ export declare class PhysicsViewer {
139
139
  * This is useful for hiding a body from the physics engine without deleting it.
140
140
  */
141
141
  hideBody(body: Nullable<PhysicsBody>): void;
142
+ /**
143
+ * Hides a body's inertia from the viewer utility layer
144
+ * @param body the body to hide
145
+ */
142
146
  hideInertia(body: Nullable<PhysicsBody>): void;
143
147
  /**
144
148
  * Hide a physics constraint from the viewer utility layer
@@ -278,7 +278,7 @@ export class PhysicsViewer {
278
278
  }
279
279
  /**
280
280
  * Shows a debug box corresponding to the inertia of a given body
281
- * @param body
281
+ * @param body the physics body used to get the inertia
282
282
  */
283
283
  showInertia(body) {
284
284
  if (!this._scene) {
@@ -415,6 +415,10 @@ export class PhysicsViewer {
415
415
  this._scene.unregisterBeforeRender(this._renderFunction);
416
416
  }
417
417
  }
418
+ /**
419
+ * Hides a body's inertia from the viewer utility layer
420
+ * @param body the body to hide
421
+ */
418
422
  hideInertia(body) {
419
423
  if (!body || !this._scene || !this._utilityLayer) {
420
424
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"physicsViewer.js","sourceRoot":"","sources":["../../../../dev/core/src/Debug/physicsViewer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,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a,CAAC,OAAO,EAAE,CAAC;SAChC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;SACnC;QACD,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;SACrC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SACjC;QAED,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QAEjC,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC7B;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { Matrix, Quaternion, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from \"../Physics/v1/IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsMassProperties } from \"../Physics/v2/IPhysicsEnginePlugin\";\r\nimport { PhysicsImpostor } from \"../Physics/v1/physicsImpostor\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport type { ICreateCapsuleOptions } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { CreateCapsule } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { PhysicsBody } from \"../Physics/v2/physicsBody\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport { MeshBuilder } from \"../Meshes/meshBuilder\";\r\nimport type { PhysicsConstraint } from \"../Physics/v2/physicsConstraint\";\r\nimport { AxesViewer } from \"./axesViewer\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\n\r\n/**\r\n * Used to show the physics impostor around the specific mesh\r\n */\r\nexport class PhysicsViewer {\r\n /** @internal */\r\n protected _impostors: Array<Nullable<PhysicsImpostor>> = [];\r\n /** @internal */\r\n protected _meshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _bodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _constraints: Array<Nullable<PhysicsConstraint>> = [];\r\n /** @internal */\r\n protected _bodyMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _inertiaMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _constraintMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n /** @internal */\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _numConstraints = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _constraintRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\r\n\r\n private _debugBoxMesh: Mesh;\r\n private _debugSphereMesh: Mesh;\r\n private _debugCapsuleMesh: Mesh;\r\n private _debugCylinderMesh: Mesh;\r\n private _debugMaterial: StandardMaterial;\r\n private _debugInertiaMaterial: StandardMaterial;\r\n private _debugMeshMeshes = new Array<Mesh>();\r\n\r\n private _constraintAxesSize = 0.4;\r\n\r\n /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(scene?: Scene) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n const physicEngine = this._scene.getPhysicsEngine();\r\n\r\n if (physicEngine) {\r\n this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();\r\n }\r\n\r\n this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This code is useful for synchronizing the debug meshes of the physics engine with the physics impostor and mesh.\r\n * It checks if the impostor is disposed and if the plugin version is 1, then it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes are up to date with the physics engine.\r\n */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\r\n if (plugin?.getPluginVersion() === 1) {\r\n this._updateDebugMeshesV1();\r\n } else {\r\n this._updateDebugMeshesV2();\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This method is useful for synchronizing the debug meshes with the physics impostors.\r\n * It iterates through the impostors and meshes, and if the plugin version is 1, it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes accurately reflect the physics impostors, which is important for debugging the physics engine.\r\n */\r\n protected _updateDebugMeshesV1(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV1;\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n const impostor = this._impostors[i];\r\n\r\n if (!impostor) {\r\n continue;\r\n }\r\n\r\n if (impostor.isDisposed) {\r\n this.hideImpostor(this._impostors[i--]);\r\n } else {\r\n if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n continue;\r\n }\r\n const mesh = this._meshes[i];\r\n\r\n if (mesh && plugin) {\r\n plugin.syncMeshWithImpostor(mesh, impostor);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine for V2 plugin.\r\n *\r\n * This method is useful for synchronizing the debug meshes of the physics engine with the current state of the bodies.\r\n * It iterates through the bodies array and updates the debug meshes with the current transform of each body.\r\n * This ensures that the debug meshes accurately reflect the current state of the physics engine.\r\n */\r\n protected _updateDebugMeshesV2(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV2;\r\n for (let i = 0; i < this._numBodies; i++) {\r\n const body = this._bodies[i];\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n const body = this._inertiaBodies[i];\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\r\n }\r\n }\r\n\r\n protected _updateDebugInertia(body: PhysicsBody, inertiaMesh: AbstractMesh): void {\r\n const inertiaMatrixRef = Matrix.Identity();\r\n const transformMatrixRef = Matrix.Identity();\r\n const finalMatrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const inertiaAsMesh = inertiaMesh as Mesh;\r\n const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData!;\r\n const bodyTransformMatrixData = (body.transformNode as Mesh)._thinInstanceDataStorage.matrixData!;\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, transformMatrixRef);\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, finalMatrixRef);\r\n finalMatrixRef.copyToArray(inertiaMeshMatrixData, i * 16);\r\n }\r\n inertiaAsMesh.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n body.transformNode.rotationQuaternion?.toRotationMatrix(transformMatrixRef);\r\n transformMatrixRef.setTranslation(body.transformNode.position);\r\n if (body.transformNode.parent) {\r\n const parentTransform = body.transformNode.parent.computeWorldMatrix(true);\r\n transformMatrixRef.multiplyToRef(parentTransform, transformMatrixRef);\r\n }\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);\r\n inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraints() {\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n const constraint = this._constraints[i];\r\n const mesh = this._constraintMeshes[i];\r\n if (constraint && mesh) {\r\n this._updateDebugConstraint(constraint, mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given a scaling vector, make all of its components\r\n * 1, preserving the sign\r\n * @param scaling\r\n */\r\n protected _makeScalingUnitInPlace(scaling: Vector3) {\r\n if (Math.abs(scaling.x - 1) > Epsilon) {\r\n scaling.x = 1 * Math.sign(scaling.x);\r\n }\r\n if (Math.abs(scaling.y - 1) > Epsilon) {\r\n scaling.y = 1 * Math.sign(scaling.y);\r\n }\r\n if (Math.abs(scaling.z - 1) > Epsilon) {\r\n scaling.z = 1 * Math.sign(scaling.z);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh: AbstractMesh) {\r\n if (!constraint._initOptions) {\r\n return;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return;\r\n }\r\n\r\n parentingMesh.getDescendants(true).forEach((parentConstraintMesh) => {\r\n // Get the parent transform\r\n const parentCoordSystemNode = parentConstraintMesh.getDescendants(true)[0] as TransformNode;\r\n const childCoordSystemNode = parentConstraintMesh.getDescendants(true)[1] as TransformNode;\r\n\r\n const { parentBody, parentBodyIndex } = parentCoordSystemNode.metadata;\r\n const { childBody, childBodyIndex } = childCoordSystemNode.metadata;\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n this._makeScalingUnitInPlace(parentCoordSystemNode.scaling);\r\n\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n this._makeScalingUnitInPlace(childCoordSystemNode.scaling);\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = parentCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n parentTransformNode.position.copyFrom(pivotA);\r\n\r\n const childTransformNode = childCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n childTransformNode.position.copyFrom(pivotB);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]),\r\n parentTransformNode.rotationQuaternion!\r\n );\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]),\r\n childTransformNode.rotationQuaternion!\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Renders a specified physic impostor\r\n * @param impostor defines the impostor to render\r\n * @param targetMesh defines the mesh represented by the impostor\r\n * @returns the new debug mesh used to render the impostor\r\n */\r\n public showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugMesh(impostor, targetMesh);\r\n\r\n if (debugMesh) {\r\n this._impostors[this._numMeshes] = impostor;\r\n this._meshes[this._numMeshes] = debugMesh;\r\n\r\n if (this._numMeshes === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numMeshes++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics body.\r\n * @param body The physics body to show.\r\n * @returns The debug mesh, or null if the body is already shown.\r\n *\r\n * This function is useful for visualizing the physics body in the scene.\r\n * It creates a debug mesh for the given body and adds it to the scene.\r\n * It also registers a before render function to update the debug mesh position and rotation.\r\n */\r\n public showBody(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugBodyMesh(body);\r\n\r\n if (debugMesh) {\r\n this._bodies[this._numBodies] = body;\r\n this._bodyMeshes[this._numBodies] = debugMesh;\r\n\r\n if (this._numBodies === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug box corresponding to the inertia of a given body\r\n * @param body\r\n */\r\n public showInertia(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugInertiaMesh(body);\r\n if (debugMesh) {\r\n this._inertiaBodies[this._numInertiaBodies] = body;\r\n this._inertiaMeshes[this._numInertiaBodies] = debugMesh;\r\n\r\n if (this._numInertiaBodies === 0) {\r\n this._inertiaRenderFunction = () => this._updateInertiaMeshes();\r\n this._scene.registerBeforeRender(this._inertiaRenderFunction);\r\n }\r\n\r\n this._numInertiaBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics constraint.\r\n * @param constraint the physics constraint to show\r\n * @returns the debug mesh, or null if the constraint is already shown\r\n */\r\n public showConstraint(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] == constraint) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugConstraintMesh(constraint);\r\n if (debugMesh) {\r\n this._constraints[this._numConstraints] = constraint;\r\n this._constraintMeshes[this._numConstraints] = debugMesh;\r\n\r\n if (this._numConstraints === 0) {\r\n this._constraintRenderFunction = () => this._updateDebugConstraints();\r\n this._scene.registerBeforeRender(this._constraintRenderFunction);\r\n }\r\n\r\n this._numConstraints++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Hides an impostor from the scene.\r\n * @param impostor - The impostor to hide.\r\n *\r\n * This method is useful for hiding an impostor from the scene. It removes the\r\n * impostor from the utility layer scene, disposes the mesh, and removes the\r\n * impostor from the list of impostors. If the impostor is the last one in the\r\n * list, it also unregisters the render function.\r\n */\r\n public hideImpostor(impostor: Nullable<PhysicsImpostor>) {\r\n if (!impostor || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n const mesh = this._meshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n const index = this._debugMeshMeshes.indexOf(mesh as Mesh);\r\n if (index > -1) {\r\n this._debugMeshMeshes.splice(index, 1);\r\n }\r\n\r\n this._numMeshes--;\r\n if (this._numMeshes > 0) {\r\n this._meshes[i] = this._meshes[this._numMeshes];\r\n this._impostors[i] = this._impostors[this._numMeshes];\r\n this._meshes[this._numMeshes] = null;\r\n this._impostors[this._numMeshes] = null;\r\n } else {\r\n this._meshes[0] = null;\r\n this._impostors[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numMeshes === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body from the physics engine.\r\n * @param body - The body to hide.\r\n *\r\n * This function is useful for hiding a body from the physics engine.\r\n * It removes the body from the utility layer scene and disposes the mesh associated with it.\r\n * It also unregisters the render function if the number of bodies is 0.\r\n * This is useful for hiding a body from the physics engine without deleting it.\r\n */\r\n public hideBody(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] === body) {\r\n const mesh = this._bodyMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._numBodies--;\r\n if (this._numBodies > 0) {\r\n this._bodyMeshes[i] = this._bodyMeshes[this._numBodies];\r\n this._bodies[i] = this._bodies[this._numBodies];\r\n this._bodyMeshes[this._numBodies] = null;\r\n this._bodies[this._numBodies] = null;\r\n } else {\r\n this._bodyMeshes[0] = null;\r\n this._bodies[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n public hideInertia(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] === body) {\r\n const mesh = this._inertiaMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._inertiaBodies.splice(i, 1);\r\n this._inertiaMeshes.splice(i, 1);\r\n\r\n this._numInertiaBodies--;\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numInertiaBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._inertiaRenderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hide a physics constraint from the viewer utility layer\r\n * @param constraint the constraint to hide\r\n */\r\n public hideConstraint(constraint: Nullable<PhysicsConstraint>) {\r\n if (!constraint || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] === constraint) {\r\n const mesh = this._constraintMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._constraints.splice(i, 1);\r\n this._constraintMeshes.splice(i, 1);\r\n\r\n this._numConstraints--;\r\n\r\n if (this._numConstraints > 0) {\r\n this._constraints[i] = this._constraints[this._numConstraints];\r\n this._constraintMeshes[i] = this._constraintMeshes[this._numConstraints];\r\n this._constraints[this._numConstraints] = null;\r\n this._constraintMeshes[this._numConstraints] = null;\r\n } else {\r\n this._constraints[0] = null;\r\n this._constraintMeshes[0] = null;\r\n }\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numConstraints === 0) {\r\n this._scene.unregisterBeforeRender(this._constraintRenderFunction);\r\n }\r\n }\r\n\r\n private _getDebugMaterial(scene: Scene): Material {\r\n if (!this._debugMaterial) {\r\n this._debugMaterial = new StandardMaterial(\"\", scene);\r\n this._debugMaterial.wireframe = true;\r\n this._debugMaterial.emissiveColor = Color3.White();\r\n this._debugMaterial.disableLighting = true;\r\n }\r\n\r\n return this._debugMaterial;\r\n }\r\n\r\n private _getDebugInertiaMaterial(scene: Scene): Material {\r\n if (!this._debugInertiaMaterial) {\r\n this._debugInertiaMaterial = new StandardMaterial(\"\", scene);\r\n this._debugInertiaMaterial.disableLighting = true;\r\n this._debugInertiaMaterial.alpha = 0.0;\r\n }\r\n\r\n return this._debugInertiaMaterial;\r\n }\r\n\r\n private _getDebugBoxMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugBoxMesh) {\r\n this._debugBoxMesh = CreateBox(\"physicsBodyBoxViewMesh\", { size: 1 }, scene);\r\n this._debugBoxMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugBoxMesh.material = this._getDebugMaterial(scene);\r\n this._debugBoxMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugBoxMesh.createInstance(\"physicsBodyBoxViewInstance\");\r\n }\r\n\r\n private _getDebugSphereMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugSphereMesh) {\r\n this._debugSphereMesh = CreateSphere(\"physicsBodySphereViewMesh\", { diameter: 1 }, scene);\r\n this._debugSphereMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugSphereMesh.material = this._getDebugMaterial(scene);\r\n this._debugSphereMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugSphereMesh.createInstance(\"physicsBodySphereViewInstance\");\r\n }\r\n\r\n private _getDebugCapsuleMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCapsuleMesh) {\r\n this._debugCapsuleMesh = CreateCapsule(\"physicsBodyCapsuleViewMesh\", { height: 1 } as ICreateCapsuleOptions, scene);\r\n this._debugCapsuleMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCapsuleMesh.material = this._getDebugMaterial(scene);\r\n this._debugCapsuleMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCapsuleMesh.createInstance(\"physicsBodyCapsuleViewInstance\");\r\n }\r\n\r\n private _getDebugCylinderMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCylinderMesh) {\r\n this._debugCylinderMesh = CreateCylinder(\"physicsBodyCylinderViewMesh\", { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);\r\n this._debugCylinderMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCylinderMesh.material = this._getDebugMaterial(scene);\r\n this._debugCylinderMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCylinderMesh.createInstance(\"physicsBodyCylinderViewInstance\");\r\n }\r\n\r\n private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {\r\n const wireframeOver = new Mesh(mesh.name, scene, null, mesh);\r\n wireframeOver.setParent(mesh);\r\n wireframeOver.position = Vector3.Zero();\r\n wireframeOver.material = this._getDebugMaterial(scene);\r\n\r\n this._debugMeshMeshes.push(wireframeOver);\r\n\r\n return wireframeOver;\r\n }\r\n\r\n private _getDebugMesh(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n // Only create child impostor debug meshes when evaluating the parent\r\n if (targetMesh && targetMesh.parent && (targetMesh.parent as Mesh).physicsImpostor) {\r\n return null;\r\n }\r\n\r\n let mesh: Nullable<AbstractMesh> = null;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n if (!impostor.physicsBody) {\r\n Logger.Warn(\"Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor.\");\r\n return null;\r\n }\r\n switch (impostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n impostor.getBoxSizeToRef(mesh.scaling);\r\n break;\r\n case PhysicsImpostor.SphereImpostor: {\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n const radius = impostor.getRadius();\r\n mesh.scaling.x = radius * 2;\r\n mesh.scaling.y = radius * 2;\r\n mesh.scaling.z = radius * 2;\r\n break;\r\n }\r\n case PhysicsImpostor.CapsuleImpostor: {\r\n mesh = this._getDebugCapsuleMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * 2 * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * 2 * impostor.object.scaling.z;\r\n break;\r\n }\r\n case PhysicsImpostor.MeshImpostor:\r\n if (targetMesh) {\r\n mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);\r\n }\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n if (targetMesh) {\r\n // Handle compound impostors\r\n const childMeshes = targetMesh.getChildMeshes().filter((c) => {\r\n return c.physicsImpostor ? 1 : 0;\r\n });\r\n childMeshes.forEach((m) => {\r\n if (m.physicsImpostor && m.getClassName() === \"Mesh\") {\r\n const boundingInfo = m.getBoundingInfo();\r\n const min = boundingInfo.boundingBox.minimum;\r\n const max = boundingInfo.boundingBox.maximum;\r\n switch (m.physicsImpostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n mesh.position.copyFrom(min);\r\n mesh.position.addInPlace(max);\r\n mesh.position.scaleInPlace(0.5);\r\n break;\r\n case PhysicsImpostor.SphereImpostor:\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n break;\r\n case PhysicsImpostor.CylinderImpostor:\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n break;\r\n default:\r\n mesh = null;\r\n break;\r\n }\r\n if (mesh) {\r\n mesh.scaling.x = max.x - min.x;\r\n mesh.scaling.y = max.y - min.y;\r\n mesh.scaling.z = max.z - min.z;\r\n mesh.parent = m;\r\n }\r\n }\r\n });\r\n } else {\r\n Logger.Warn(\"No target mesh parameter provided for NoImpostor. Skipping.\");\r\n }\r\n mesh = null;\r\n break;\r\n case PhysicsImpostor.CylinderImpostor: {\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * impostor.object.scaling.z;\r\n break;\r\n }\r\n }\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a debug mesh for a given physics body\r\n * @param body The physics body to create the debug mesh for\r\n * @returns The created debug mesh or null if the utility layer is not available\r\n *\r\n * This code is useful for creating a debug mesh for a given physics body.\r\n * It creates a Mesh object with a VertexData object containing the positions and indices\r\n * of the geometry of the body. The mesh is then assigned a debug material from the utility layer scene.\r\n * This allows for visualizing the physics body in the scene.\r\n */\r\n private _getDebugBodyMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n const mesh = new Mesh(\"custom\", utilityLayerScene);\r\n const vertexData = new VertexData();\r\n const geometry = body.getGeometry() as any;\r\n vertexData.positions = geometry.positions;\r\n vertexData.indices = geometry.indices;\r\n vertexData.applyToMesh(mesh);\r\n if (body._pluginDataInstances) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n mesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16);\r\n }\r\n mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\r\n }\r\n\r\n private _getMeshDebugInertiaMatrixToRef(massProps: PhysicsMassProperties, matrix: Matrix) {\r\n const orientation = massProps.inertiaOrientation ?? Quaternion.Identity();\r\n const inertiaLocal = massProps.inertia ?? Vector3.Zero();\r\n const center = massProps.centerOfMass ?? Vector3.Zero();\r\n\r\n const betaSqrd = (inertiaLocal.x - inertiaLocal.y + inertiaLocal.z) * 6;\r\n const beta = Math.sqrt(Math.max(betaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const gammaSqrd = inertiaLocal.x * 12 - betaSqrd;\r\n const gamma = Math.sqrt(Math.max(gammaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const alphaSqrd = inertiaLocal.z * 12 - betaSqrd;\r\n const alpha = Math.sqrt(Math.max(alphaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const extents = TmpVectors.Vector3[0];\r\n extents.set(alpha, beta, gamma);\r\n\r\n const scaling = Matrix.ScalingToRef(extents.x, extents.y, extents.z, TmpVectors.Matrix[0]);\r\n const rotation = orientation.toRotationMatrix(TmpVectors.Matrix[1]);\r\n const translation = Matrix.TranslationToRef(center.x, center.y, center.z, TmpVectors.Matrix[2]);\r\n\r\n scaling.multiplyToRef(rotation, matrix);\r\n matrix.multiplyToRef(translation, matrix);\r\n\r\n return matrix;\r\n }\r\n\r\n private _getDebugInertiaMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n // The base inertia mesh is going to be a 1x1 cube that's scaled and rotated according to the inertia\r\n const inertiaBoxMesh = MeshBuilder.CreateBox(\"custom\", { size: 1 }, utilityLayerScene);\r\n const matrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n for (let i = 0; i < body._pluginDataInstances.length; ++i) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.copyToArray(instanceBuffer, i * 16);\r\n }\r\n inertiaBoxMesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16);\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.decomposeToTransformNode(inertiaBoxMesh);\r\n }\r\n inertiaBoxMesh.enableEdgesRendering();\r\n inertiaBoxMesh.edgesWidth = 2.0;\r\n inertiaBoxMesh.edgesColor = new Color4(1, 0, 1, 1);\r\n inertiaBoxMesh.material = this._getDebugInertiaMaterial(utilityLayerScene);\r\n\r\n return inertiaBoxMesh;\r\n }\r\n\r\n private _getTransformFromBodyToRef(body: PhysicsBody, matrix: Matrix, instanceIndex?: number) {\r\n const tnode = body.transformNode;\r\n if (instanceIndex && instanceIndex >= 0) {\r\n return Matrix.FromArrayToRef((tnode as Mesh)._thinInstanceDataStorage.matrixData!, instanceIndex, matrix);\r\n } else {\r\n return matrix.copyFrom(tnode.getWorldMatrix());\r\n }\r\n }\r\n\r\n private _getDebugConstraintMesh(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n if (!constraint._initOptions) {\r\n return null;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return null;\r\n }\r\n\r\n // Create a mesh to parent all the constraint debug meshes to\r\n const parentingMesh = new Mesh(\"parentingDebugConstraint\", utilityLayerScene);\r\n\r\n // First, get a reference to all physic bodies that are using this constraint\r\n const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();\r\n\r\n for (const bodyPairInfo of bodiesUsingConstraint) {\r\n // Create a mesh to keep the pair of constraint axes\r\n const parentOfPair = new TransformNode(\"parentOfPair\", utilityLayerScene);\r\n parentOfPair.parent = parentingMesh;\r\n\r\n const { parentBody, parentBodyIndex, childBody, childBodyIndex } = bodyPairInfo;\r\n // Get the parent transform\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n const parentCoordSystemNode = new TransformNode(\"parentCoordSystem\", utilityLayerScene);\r\n // parentCoordSystemNode.parent = parentingMesh;\r\n parentCoordSystemNode.parent = parentOfPair;\r\n // Save parent and index here to be able to get the transform on update\r\n parentCoordSystemNode.metadata = { parentBody, parentBodyIndex };\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n\r\n const childCoordSystemNode = new TransformNode(\"childCoordSystem\", utilityLayerScene);\r\n // childCoordSystemNode.parent = parentingMesh;\r\n childCoordSystemNode.parent = parentOfPair;\r\n // Save child and index here to be able to get the transform on update\r\n childCoordSystemNode.metadata = { childBody, childBodyIndex };\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n const rotTransformParent = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisA, perpAxisA, axisA.cross(perpAxisA), TmpVectors.Matrix[0]));\r\n const rotTransformChild = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisB, perpAxisB, axisB.cross(perpAxisB), TmpVectors.Matrix[0]));\r\n\r\n const translateTransformParent = pivotA;\r\n const translateTransformChild = pivotB;\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = new TransformNode(\"constraint_parent\", utilityLayerScene);\r\n parentTransformNode.position.copyFrom(translateTransformParent);\r\n parentTransformNode.rotationQuaternion = rotTransformParent;\r\n parentTransformNode.parent = parentCoordSystemNode;\r\n\r\n const childTransformNode = new TransformNode(\"constraint_child\", utilityLayerScene);\r\n childTransformNode.parent = childCoordSystemNode;\r\n childTransformNode.position.copyFrom(translateTransformChild);\r\n childTransformNode.rotationQuaternion = rotTransformChild;\r\n\r\n // Create axes for the constraint\r\n const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n parentAxes.xAxis.parent = parentTransformNode;\r\n parentAxes.yAxis.parent = parentTransformNode;\r\n parentAxes.zAxis.parent = parentTransformNode;\r\n\r\n const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n childAxes.xAxis.parent = childTransformNode;\r\n childAxes.yAxis.parent = childTransformNode;\r\n childAxes.zAxis.parent = childTransformNode;\r\n }\r\n\r\n return parentingMesh;\r\n }\r\n\r\n /**\r\n * Clean up physics debug display\r\n */\r\n public dispose() {\r\n // impostors\r\n for (let index = this._numMeshes - 1; index >= 0; index--) {\r\n this.hideImpostor(this._impostors[0]);\r\n }\r\n // bodies\r\n for (let index = this._numBodies - 1; index >= 0; index--) {\r\n this.hideBody(this._bodies[0]);\r\n }\r\n // inertia\r\n for (let index = this._numInertiaBodies - 1; index >= 0; index--) {\r\n this.hideInertia(this._inertiaBodies[0]);\r\n }\r\n\r\n if (this._debugBoxMesh) {\r\n this._debugBoxMesh.dispose();\r\n }\r\n if (this._debugSphereMesh) {\r\n this._debugSphereMesh.dispose();\r\n }\r\n if (this._debugCylinderMesh) {\r\n this._debugCylinderMesh.dispose();\r\n }\r\n if (this._debugMaterial) {\r\n this._debugMaterial.dispose();\r\n }\r\n\r\n this._impostors.length = 0;\r\n this._scene = null;\r\n this._physicsEnginePlugin = null;\r\n\r\n if (this._utilityLayer) {\r\n this._utilityLayer.dispose();\r\n this._utilityLayer = null;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsViewer.js","sourceRoot":"","sources":["../../../../dev/core/src/Debug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CAAC,aAAa,GAAG,IAAI,CAAC;SAC7B;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { Matrix, Quaternion, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from \"../Physics/v1/IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsMassProperties } from \"../Physics/v2/IPhysicsEnginePlugin\";\r\nimport { PhysicsImpostor } from \"../Physics/v1/physicsImpostor\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport type { ICreateCapsuleOptions } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { CreateCapsule } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { PhysicsBody } from \"../Physics/v2/physicsBody\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport { MeshBuilder } from \"../Meshes/meshBuilder\";\r\nimport type { PhysicsConstraint } from \"../Physics/v2/physicsConstraint\";\r\nimport { AxesViewer } from \"./axesViewer\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\n\r\n/**\r\n * Used to show the physics impostor around the specific mesh\r\n */\r\nexport class PhysicsViewer {\r\n /** @internal */\r\n protected _impostors: Array<Nullable<PhysicsImpostor>> = [];\r\n /** @internal */\r\n protected _meshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _bodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _constraints: Array<Nullable<PhysicsConstraint>> = [];\r\n /** @internal */\r\n protected _bodyMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _inertiaMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _constraintMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n /** @internal */\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _numConstraints = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _constraintRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\r\n\r\n private _debugBoxMesh: Mesh;\r\n private _debugSphereMesh: Mesh;\r\n private _debugCapsuleMesh: Mesh;\r\n private _debugCylinderMesh: Mesh;\r\n private _debugMaterial: StandardMaterial;\r\n private _debugInertiaMaterial: StandardMaterial;\r\n private _debugMeshMeshes = new Array<Mesh>();\r\n\r\n private _constraintAxesSize = 0.4;\r\n\r\n /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(scene?: Scene) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n const physicEngine = this._scene.getPhysicsEngine();\r\n\r\n if (physicEngine) {\r\n this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();\r\n }\r\n\r\n this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This code is useful for synchronizing the debug meshes of the physics engine with the physics impostor and mesh.\r\n * It checks if the impostor is disposed and if the plugin version is 1, then it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes are up to date with the physics engine.\r\n */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\r\n if (plugin?.getPluginVersion() === 1) {\r\n this._updateDebugMeshesV1();\r\n } else {\r\n this._updateDebugMeshesV2();\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This method is useful for synchronizing the debug meshes with the physics impostors.\r\n * It iterates through the impostors and meshes, and if the plugin version is 1, it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes accurately reflect the physics impostors, which is important for debugging the physics engine.\r\n */\r\n protected _updateDebugMeshesV1(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV1;\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n const impostor = this._impostors[i];\r\n\r\n if (!impostor) {\r\n continue;\r\n }\r\n\r\n if (impostor.isDisposed) {\r\n this.hideImpostor(this._impostors[i--]);\r\n } else {\r\n if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n continue;\r\n }\r\n const mesh = this._meshes[i];\r\n\r\n if (mesh && plugin) {\r\n plugin.syncMeshWithImpostor(mesh, impostor);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine for V2 plugin.\r\n *\r\n * This method is useful for synchronizing the debug meshes of the physics engine with the current state of the bodies.\r\n * It iterates through the bodies array and updates the debug meshes with the current transform of each body.\r\n * This ensures that the debug meshes accurately reflect the current state of the physics engine.\r\n */\r\n protected _updateDebugMeshesV2(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV2;\r\n for (let i = 0; i < this._numBodies; i++) {\r\n const body = this._bodies[i];\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n const body = this._inertiaBodies[i];\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\r\n }\r\n }\r\n\r\n protected _updateDebugInertia(body: PhysicsBody, inertiaMesh: AbstractMesh): void {\r\n const inertiaMatrixRef = Matrix.Identity();\r\n const transformMatrixRef = Matrix.Identity();\r\n const finalMatrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const inertiaAsMesh = inertiaMesh as Mesh;\r\n const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData!;\r\n const bodyTransformMatrixData = (body.transformNode as Mesh)._thinInstanceDataStorage.matrixData!;\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, transformMatrixRef);\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, finalMatrixRef);\r\n finalMatrixRef.copyToArray(inertiaMeshMatrixData, i * 16);\r\n }\r\n inertiaAsMesh.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n body.transformNode.rotationQuaternion?.toRotationMatrix(transformMatrixRef);\r\n transformMatrixRef.setTranslation(body.transformNode.position);\r\n if (body.transformNode.parent) {\r\n const parentTransform = body.transformNode.parent.computeWorldMatrix(true);\r\n transformMatrixRef.multiplyToRef(parentTransform, transformMatrixRef);\r\n }\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);\r\n inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraints() {\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n const constraint = this._constraints[i];\r\n const mesh = this._constraintMeshes[i];\r\n if (constraint && mesh) {\r\n this._updateDebugConstraint(constraint, mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given a scaling vector, make all of its components\r\n * 1, preserving the sign\r\n * @param scaling\r\n */\r\n protected _makeScalingUnitInPlace(scaling: Vector3) {\r\n if (Math.abs(scaling.x - 1) > Epsilon) {\r\n scaling.x = 1 * Math.sign(scaling.x);\r\n }\r\n if (Math.abs(scaling.y - 1) > Epsilon) {\r\n scaling.y = 1 * Math.sign(scaling.y);\r\n }\r\n if (Math.abs(scaling.z - 1) > Epsilon) {\r\n scaling.z = 1 * Math.sign(scaling.z);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh: AbstractMesh) {\r\n if (!constraint._initOptions) {\r\n return;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return;\r\n }\r\n\r\n parentingMesh.getDescendants(true).forEach((parentConstraintMesh) => {\r\n // Get the parent transform\r\n const parentCoordSystemNode = parentConstraintMesh.getDescendants(true)[0] as TransformNode;\r\n const childCoordSystemNode = parentConstraintMesh.getDescendants(true)[1] as TransformNode;\r\n\r\n const { parentBody, parentBodyIndex } = parentCoordSystemNode.metadata;\r\n const { childBody, childBodyIndex } = childCoordSystemNode.metadata;\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n this._makeScalingUnitInPlace(parentCoordSystemNode.scaling);\r\n\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n this._makeScalingUnitInPlace(childCoordSystemNode.scaling);\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = parentCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n parentTransformNode.position.copyFrom(pivotA);\r\n\r\n const childTransformNode = childCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n childTransformNode.position.copyFrom(pivotB);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]),\r\n parentTransformNode.rotationQuaternion!\r\n );\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]),\r\n childTransformNode.rotationQuaternion!\r\n );\r\n });\r\n }\r\n\r\n /**\r\n * Renders a specified physic impostor\r\n * @param impostor defines the impostor to render\r\n * @param targetMesh defines the mesh represented by the impostor\r\n * @returns the new debug mesh used to render the impostor\r\n */\r\n public showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugMesh(impostor, targetMesh);\r\n\r\n if (debugMesh) {\r\n this._impostors[this._numMeshes] = impostor;\r\n this._meshes[this._numMeshes] = debugMesh;\r\n\r\n if (this._numMeshes === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numMeshes++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics body.\r\n * @param body The physics body to show.\r\n * @returns The debug mesh, or null if the body is already shown.\r\n *\r\n * This function is useful for visualizing the physics body in the scene.\r\n * It creates a debug mesh for the given body and adds it to the scene.\r\n * It also registers a before render function to update the debug mesh position and rotation.\r\n */\r\n public showBody(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugBodyMesh(body);\r\n\r\n if (debugMesh) {\r\n this._bodies[this._numBodies] = body;\r\n this._bodyMeshes[this._numBodies] = debugMesh;\r\n\r\n if (this._numBodies === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug box corresponding to the inertia of a given body\r\n * @param body the physics body used to get the inertia\r\n */\r\n public showInertia(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugInertiaMesh(body);\r\n if (debugMesh) {\r\n this._inertiaBodies[this._numInertiaBodies] = body;\r\n this._inertiaMeshes[this._numInertiaBodies] = debugMesh;\r\n\r\n if (this._numInertiaBodies === 0) {\r\n this._inertiaRenderFunction = () => this._updateInertiaMeshes();\r\n this._scene.registerBeforeRender(this._inertiaRenderFunction);\r\n }\r\n\r\n this._numInertiaBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics constraint.\r\n * @param constraint the physics constraint to show\r\n * @returns the debug mesh, or null if the constraint is already shown\r\n */\r\n public showConstraint(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] == constraint) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugConstraintMesh(constraint);\r\n if (debugMesh) {\r\n this._constraints[this._numConstraints] = constraint;\r\n this._constraintMeshes[this._numConstraints] = debugMesh;\r\n\r\n if (this._numConstraints === 0) {\r\n this._constraintRenderFunction = () => this._updateDebugConstraints();\r\n this._scene.registerBeforeRender(this._constraintRenderFunction);\r\n }\r\n\r\n this._numConstraints++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Hides an impostor from the scene.\r\n * @param impostor - The impostor to hide.\r\n *\r\n * This method is useful for hiding an impostor from the scene. It removes the\r\n * impostor from the utility layer scene, disposes the mesh, and removes the\r\n * impostor from the list of impostors. If the impostor is the last one in the\r\n * list, it also unregisters the render function.\r\n */\r\n public hideImpostor(impostor: Nullable<PhysicsImpostor>) {\r\n if (!impostor || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n const mesh = this._meshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n const index = this._debugMeshMeshes.indexOf(mesh as Mesh);\r\n if (index > -1) {\r\n this._debugMeshMeshes.splice(index, 1);\r\n }\r\n\r\n this._numMeshes--;\r\n if (this._numMeshes > 0) {\r\n this._meshes[i] = this._meshes[this._numMeshes];\r\n this._impostors[i] = this._impostors[this._numMeshes];\r\n this._meshes[this._numMeshes] = null;\r\n this._impostors[this._numMeshes] = null;\r\n } else {\r\n this._meshes[0] = null;\r\n this._impostors[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numMeshes === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body from the physics engine.\r\n * @param body - The body to hide.\r\n *\r\n * This function is useful for hiding a body from the physics engine.\r\n * It removes the body from the utility layer scene and disposes the mesh associated with it.\r\n * It also unregisters the render function if the number of bodies is 0.\r\n * This is useful for hiding a body from the physics engine without deleting it.\r\n */\r\n public hideBody(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] === body) {\r\n const mesh = this._bodyMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._numBodies--;\r\n if (this._numBodies > 0) {\r\n this._bodyMeshes[i] = this._bodyMeshes[this._numBodies];\r\n this._bodies[i] = this._bodies[this._numBodies];\r\n this._bodyMeshes[this._numBodies] = null;\r\n this._bodies[this._numBodies] = null;\r\n } else {\r\n this._bodyMeshes[0] = null;\r\n this._bodies[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body's inertia from the viewer utility layer\r\n * @param body the body to hide\r\n */\r\n public hideInertia(body: Nullable<PhysicsBody>) {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] === body) {\r\n const mesh = this._inertiaMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._inertiaBodies.splice(i, 1);\r\n this._inertiaMeshes.splice(i, 1);\r\n\r\n this._numInertiaBodies--;\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numInertiaBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._inertiaRenderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hide a physics constraint from the viewer utility layer\r\n * @param constraint the constraint to hide\r\n */\r\n public hideConstraint(constraint: Nullable<PhysicsConstraint>) {\r\n if (!constraint || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] === constraint) {\r\n const mesh = this._constraintMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._constraints.splice(i, 1);\r\n this._constraintMeshes.splice(i, 1);\r\n\r\n this._numConstraints--;\r\n\r\n if (this._numConstraints > 0) {\r\n this._constraints[i] = this._constraints[this._numConstraints];\r\n this._constraintMeshes[i] = this._constraintMeshes[this._numConstraints];\r\n this._constraints[this._numConstraints] = null;\r\n this._constraintMeshes[this._numConstraints] = null;\r\n } else {\r\n this._constraints[0] = null;\r\n this._constraintMeshes[0] = null;\r\n }\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numConstraints === 0) {\r\n this._scene.unregisterBeforeRender(this._constraintRenderFunction);\r\n }\r\n }\r\n\r\n private _getDebugMaterial(scene: Scene): Material {\r\n if (!this._debugMaterial) {\r\n this._debugMaterial = new StandardMaterial(\"\", scene);\r\n this._debugMaterial.wireframe = true;\r\n this._debugMaterial.emissiveColor = Color3.White();\r\n this._debugMaterial.disableLighting = true;\r\n }\r\n\r\n return this._debugMaterial;\r\n }\r\n\r\n private _getDebugInertiaMaterial(scene: Scene): Material {\r\n if (!this._debugInertiaMaterial) {\r\n this._debugInertiaMaterial = new StandardMaterial(\"\", scene);\r\n this._debugInertiaMaterial.disableLighting = true;\r\n this._debugInertiaMaterial.alpha = 0.0;\r\n }\r\n\r\n return this._debugInertiaMaterial;\r\n }\r\n\r\n private _getDebugBoxMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugBoxMesh) {\r\n this._debugBoxMesh = CreateBox(\"physicsBodyBoxViewMesh\", { size: 1 }, scene);\r\n this._debugBoxMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugBoxMesh.material = this._getDebugMaterial(scene);\r\n this._debugBoxMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugBoxMesh.createInstance(\"physicsBodyBoxViewInstance\");\r\n }\r\n\r\n private _getDebugSphereMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugSphereMesh) {\r\n this._debugSphereMesh = CreateSphere(\"physicsBodySphereViewMesh\", { diameter: 1 }, scene);\r\n this._debugSphereMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugSphereMesh.material = this._getDebugMaterial(scene);\r\n this._debugSphereMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugSphereMesh.createInstance(\"physicsBodySphereViewInstance\");\r\n }\r\n\r\n private _getDebugCapsuleMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCapsuleMesh) {\r\n this._debugCapsuleMesh = CreateCapsule(\"physicsBodyCapsuleViewMesh\", { height: 1 } as ICreateCapsuleOptions, scene);\r\n this._debugCapsuleMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCapsuleMesh.material = this._getDebugMaterial(scene);\r\n this._debugCapsuleMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCapsuleMesh.createInstance(\"physicsBodyCapsuleViewInstance\");\r\n }\r\n\r\n private _getDebugCylinderMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCylinderMesh) {\r\n this._debugCylinderMesh = CreateCylinder(\"physicsBodyCylinderViewMesh\", { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);\r\n this._debugCylinderMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCylinderMesh.material = this._getDebugMaterial(scene);\r\n this._debugCylinderMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCylinderMesh.createInstance(\"physicsBodyCylinderViewInstance\");\r\n }\r\n\r\n private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {\r\n const wireframeOver = new Mesh(mesh.name, scene, null, mesh);\r\n wireframeOver.setParent(mesh);\r\n wireframeOver.position = Vector3.Zero();\r\n wireframeOver.material = this._getDebugMaterial(scene);\r\n\r\n this._debugMeshMeshes.push(wireframeOver);\r\n\r\n return wireframeOver;\r\n }\r\n\r\n private _getDebugMesh(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n // Only create child impostor debug meshes when evaluating the parent\r\n if (targetMesh && targetMesh.parent && (targetMesh.parent as Mesh).physicsImpostor) {\r\n return null;\r\n }\r\n\r\n let mesh: Nullable<AbstractMesh> = null;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n if (!impostor.physicsBody) {\r\n Logger.Warn(\"Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor.\");\r\n return null;\r\n }\r\n switch (impostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n impostor.getBoxSizeToRef(mesh.scaling);\r\n break;\r\n case PhysicsImpostor.SphereImpostor: {\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n const radius = impostor.getRadius();\r\n mesh.scaling.x = radius * 2;\r\n mesh.scaling.y = radius * 2;\r\n mesh.scaling.z = radius * 2;\r\n break;\r\n }\r\n case PhysicsImpostor.CapsuleImpostor: {\r\n mesh = this._getDebugCapsuleMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * 2 * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * 2 * impostor.object.scaling.z;\r\n break;\r\n }\r\n case PhysicsImpostor.MeshImpostor:\r\n if (targetMesh) {\r\n mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);\r\n }\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n if (targetMesh) {\r\n // Handle compound impostors\r\n const childMeshes = targetMesh.getChildMeshes().filter((c) => {\r\n return c.physicsImpostor ? 1 : 0;\r\n });\r\n childMeshes.forEach((m) => {\r\n if (m.physicsImpostor && m.getClassName() === \"Mesh\") {\r\n const boundingInfo = m.getBoundingInfo();\r\n const min = boundingInfo.boundingBox.minimum;\r\n const max = boundingInfo.boundingBox.maximum;\r\n switch (m.physicsImpostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n mesh.position.copyFrom(min);\r\n mesh.position.addInPlace(max);\r\n mesh.position.scaleInPlace(0.5);\r\n break;\r\n case PhysicsImpostor.SphereImpostor:\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n break;\r\n case PhysicsImpostor.CylinderImpostor:\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n break;\r\n default:\r\n mesh = null;\r\n break;\r\n }\r\n if (mesh) {\r\n mesh.scaling.x = max.x - min.x;\r\n mesh.scaling.y = max.y - min.y;\r\n mesh.scaling.z = max.z - min.z;\r\n mesh.parent = m;\r\n }\r\n }\r\n });\r\n } else {\r\n Logger.Warn(\"No target mesh parameter provided for NoImpostor. Skipping.\");\r\n }\r\n mesh = null;\r\n break;\r\n case PhysicsImpostor.CylinderImpostor: {\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * impostor.object.scaling.z;\r\n break;\r\n }\r\n }\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a debug mesh for a given physics body\r\n * @param body The physics body to create the debug mesh for\r\n * @returns The created debug mesh or null if the utility layer is not available\r\n *\r\n * This code is useful for creating a debug mesh for a given physics body.\r\n * It creates a Mesh object with a VertexData object containing the positions and indices\r\n * of the geometry of the body. The mesh is then assigned a debug material from the utility layer scene.\r\n * This allows for visualizing the physics body in the scene.\r\n */\r\n private _getDebugBodyMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n const mesh = new Mesh(\"custom\", utilityLayerScene);\r\n const vertexData = new VertexData();\r\n const geometry = body.getGeometry() as any;\r\n vertexData.positions = geometry.positions;\r\n vertexData.indices = geometry.indices;\r\n vertexData.applyToMesh(mesh);\r\n if (body._pluginDataInstances) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n mesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16);\r\n }\r\n mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\r\n }\r\n\r\n private _getMeshDebugInertiaMatrixToRef(massProps: PhysicsMassProperties, matrix: Matrix) {\r\n const orientation = massProps.inertiaOrientation ?? Quaternion.Identity();\r\n const inertiaLocal = massProps.inertia ?? Vector3.Zero();\r\n const center = massProps.centerOfMass ?? Vector3.Zero();\r\n\r\n const betaSqrd = (inertiaLocal.x - inertiaLocal.y + inertiaLocal.z) * 6;\r\n const beta = Math.sqrt(Math.max(betaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const gammaSqrd = inertiaLocal.x * 12 - betaSqrd;\r\n const gamma = Math.sqrt(Math.max(gammaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const alphaSqrd = inertiaLocal.z * 12 - betaSqrd;\r\n const alpha = Math.sqrt(Math.max(alphaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const extents = TmpVectors.Vector3[0];\r\n extents.set(alpha, beta, gamma);\r\n\r\n const scaling = Matrix.ScalingToRef(extents.x, extents.y, extents.z, TmpVectors.Matrix[0]);\r\n const rotation = orientation.toRotationMatrix(TmpVectors.Matrix[1]);\r\n const translation = Matrix.TranslationToRef(center.x, center.y, center.z, TmpVectors.Matrix[2]);\r\n\r\n scaling.multiplyToRef(rotation, matrix);\r\n matrix.multiplyToRef(translation, matrix);\r\n\r\n return matrix;\r\n }\r\n\r\n private _getDebugInertiaMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n // The base inertia mesh is going to be a 1x1 cube that's scaled and rotated according to the inertia\r\n const inertiaBoxMesh = MeshBuilder.CreateBox(\"custom\", { size: 1 }, utilityLayerScene);\r\n const matrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n for (let i = 0; i < body._pluginDataInstances.length; ++i) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.copyToArray(instanceBuffer, i * 16);\r\n }\r\n inertiaBoxMesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16);\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.decomposeToTransformNode(inertiaBoxMesh);\r\n }\r\n inertiaBoxMesh.enableEdgesRendering();\r\n inertiaBoxMesh.edgesWidth = 2.0;\r\n inertiaBoxMesh.edgesColor = new Color4(1, 0, 1, 1);\r\n inertiaBoxMesh.material = this._getDebugInertiaMaterial(utilityLayerScene);\r\n\r\n return inertiaBoxMesh;\r\n }\r\n\r\n private _getTransformFromBodyToRef(body: PhysicsBody, matrix: Matrix, instanceIndex?: number) {\r\n const tnode = body.transformNode;\r\n if (instanceIndex && instanceIndex >= 0) {\r\n return Matrix.FromArrayToRef((tnode as Mesh)._thinInstanceDataStorage.matrixData!, instanceIndex, matrix);\r\n } else {\r\n return matrix.copyFrom(tnode.getWorldMatrix());\r\n }\r\n }\r\n\r\n private _getDebugConstraintMesh(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n if (!constraint._initOptions) {\r\n return null;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return null;\r\n }\r\n\r\n // Create a mesh to parent all the constraint debug meshes to\r\n const parentingMesh = new Mesh(\"parentingDebugConstraint\", utilityLayerScene);\r\n\r\n // First, get a reference to all physic bodies that are using this constraint\r\n const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();\r\n\r\n for (const bodyPairInfo of bodiesUsingConstraint) {\r\n // Create a mesh to keep the pair of constraint axes\r\n const parentOfPair = new TransformNode(\"parentOfPair\", utilityLayerScene);\r\n parentOfPair.parent = parentingMesh;\r\n\r\n const { parentBody, parentBodyIndex, childBody, childBodyIndex } = bodyPairInfo;\r\n // Get the parent transform\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n const parentCoordSystemNode = new TransformNode(\"parentCoordSystem\", utilityLayerScene);\r\n // parentCoordSystemNode.parent = parentingMesh;\r\n parentCoordSystemNode.parent = parentOfPair;\r\n // Save parent and index here to be able to get the transform on update\r\n parentCoordSystemNode.metadata = { parentBody, parentBodyIndex };\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n\r\n const childCoordSystemNode = new TransformNode(\"childCoordSystem\", utilityLayerScene);\r\n // childCoordSystemNode.parent = parentingMesh;\r\n childCoordSystemNode.parent = parentOfPair;\r\n // Save child and index here to be able to get the transform on update\r\n childCoordSystemNode.metadata = { childBody, childBodyIndex };\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n const rotTransformParent = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisA, perpAxisA, axisA.cross(perpAxisA), TmpVectors.Matrix[0]));\r\n const rotTransformChild = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisB, perpAxisB, axisB.cross(perpAxisB), TmpVectors.Matrix[0]));\r\n\r\n const translateTransformParent = pivotA;\r\n const translateTransformChild = pivotB;\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = new TransformNode(\"constraint_parent\", utilityLayerScene);\r\n parentTransformNode.position.copyFrom(translateTransformParent);\r\n parentTransformNode.rotationQuaternion = rotTransformParent;\r\n parentTransformNode.parent = parentCoordSystemNode;\r\n\r\n const childTransformNode = new TransformNode(\"constraint_child\", utilityLayerScene);\r\n childTransformNode.parent = childCoordSystemNode;\r\n childTransformNode.position.copyFrom(translateTransformChild);\r\n childTransformNode.rotationQuaternion = rotTransformChild;\r\n\r\n // Create axes for the constraint\r\n const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n parentAxes.xAxis.parent = parentTransformNode;\r\n parentAxes.yAxis.parent = parentTransformNode;\r\n parentAxes.zAxis.parent = parentTransformNode;\r\n\r\n const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n childAxes.xAxis.parent = childTransformNode;\r\n childAxes.yAxis.parent = childTransformNode;\r\n childAxes.zAxis.parent = childTransformNode;\r\n }\r\n\r\n return parentingMesh;\r\n }\r\n\r\n /**\r\n * Clean up physics debug display\r\n */\r\n public dispose() {\r\n // impostors\r\n for (let index = this._numMeshes - 1; index >= 0; index--) {\r\n this.hideImpostor(this._impostors[0]);\r\n }\r\n // bodies\r\n for (let index = this._numBodies - 1; index >= 0; index--) {\r\n this.hideBody(this._bodies[0]);\r\n }\r\n // inertia\r\n for (let index = this._numInertiaBodies - 1; index >= 0; index--) {\r\n this.hideInertia(this._inertiaBodies[0]);\r\n }\r\n\r\n if (this._debugBoxMesh) {\r\n this._debugBoxMesh.dispose();\r\n }\r\n if (this._debugSphereMesh) {\r\n this._debugSphereMesh.dispose();\r\n }\r\n if (this._debugCylinderMesh) {\r\n this._debugCylinderMesh.dispose();\r\n }\r\n if (this._debugMaterial) {\r\n this._debugMaterial.dispose();\r\n }\r\n\r\n this._impostors.length = 0;\r\n this._scene = null;\r\n this._physicsEnginePlugin = null;\r\n\r\n if (this._utilityLayer) {\r\n this._utilityLayer.dispose();\r\n this._utilityLayer = null;\r\n }\r\n }\r\n}\r\n"]}
@@ -117,29 +117,89 @@ export interface DOMMatrix {
117
117
  * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.
118
118
  */
119
119
  a: number;
120
+ /**
121
+ * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.
122
+ */
120
123
  b: number;
124
+ /**
125
+ * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.
126
+ */
121
127
  c: number;
128
+ /**
129
+ * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.
130
+ */
122
131
  d: number;
132
+ /**
133
+ * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.
134
+ */
123
135
  e: number;
136
+ /**
137
+ * The following double-precision floating-point values represent the components of a matrix which are required in order to perform 2D rotations and translations.
138
+ */
124
139
  f: number;
125
140
  /**
126
141
  * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
127
142
  */
128
143
  m11: number;
144
+ /**
145
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
146
+ */
129
147
  m12: number;
148
+ /**
149
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
150
+ */
130
151
  m13: number;
152
+ /**
153
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
154
+ */
131
155
  m14: number;
156
+ /**
157
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
158
+ */
132
159
  m21: number;
160
+ /**
161
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
162
+ */
133
163
  m22: number;
164
+ /**
165
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
166
+ */
134
167
  m23: number;
168
+ /**
169
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
170
+ */
135
171
  m24: number;
172
+ /**
173
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
174
+ */
136
175
  m31: number;
176
+ /**
177
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
178
+ */
137
179
  m32: number;
180
+ /**
181
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
182
+ */
138
183
  m33: number;
184
+ /**
185
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
186
+ */
139
187
  m34: number;
188
+ /**
189
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
190
+ */
140
191
  m41: number;
192
+ /**
193
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
194
+ */
141
195
  m42: number;
196
+ /**
197
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
198
+ */
142
199
  m43: number;
200
+ /**
201
+ * The following are double-precision floating-point values representing each component of a 4×4 matrix, where m11 through m14 are the first column, m21 through m24 are the second column, and so forth.
202
+ */
143
203
  m44: number;
144
204
  }
145
205
  /**