@babylonjs/core 6.41.0 → 6.41.2

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 (650) hide show
  1. package/Animations/animatable.js +1 -2
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/animation.js +4 -6
  4. package/Animations/animation.js.map +1 -1
  5. package/Animations/animationGroup.js +3 -3
  6. package/Animations/animationGroup.js.map +1 -1
  7. package/Animations/runtimeAnimation.js +1 -1
  8. package/Animations/runtimeAnimation.js.map +1 -1
  9. package/Audio/audioEngine.js +3 -5
  10. package/Audio/audioEngine.js.map +1 -1
  11. package/Audio/audioSceneComponent.js +1 -2
  12. package/Audio/audioSceneComponent.js.map +1 -1
  13. package/Audio/sound.js +48 -74
  14. package/Audio/sound.js.map +1 -1
  15. package/Audio/soundTrack.js +6 -12
  16. package/Audio/soundTrack.js.map +1 -1
  17. package/BakedVertexAnimation/bakedVertexAnimationManager.js +1 -2
  18. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  19. package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
  20. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  21. package/Behaviors/Meshes/fadeInOutBehavior.js +2 -4
  22. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  23. package/Behaviors/Meshes/followBehavior.js +1 -2
  24. package/Behaviors/Meshes/followBehavior.js.map +1 -1
  25. package/Behaviors/Meshes/handConstraintBehavior.js +2 -2
  26. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  27. package/Bones/bone.js +4 -6
  28. package/Bones/bone.js.map +1 -1
  29. package/Bones/skeleton.js +2 -3
  30. package/Bones/skeleton.js.map +1 -1
  31. package/Buffers/buffer.align.js +5 -8
  32. package/Buffers/buffer.align.js.map +1 -1
  33. package/Buffers/buffer.js +6 -8
  34. package/Buffers/buffer.js.map +1 -1
  35. package/Cameras/Inputs/BaseCameraPointersInput.js +3 -4
  36. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  37. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +3 -5
  38. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  39. package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
  40. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  41. package/Cameras/Inputs/freeCameraMouseInput.js +2 -2
  42. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  43. package/Cameras/arcRotateCamera.js +1 -2
  44. package/Cameras/arcRotateCamera.js.map +1 -1
  45. package/Cameras/camera.d.ts +5 -0
  46. package/Cameras/camera.js +18 -11
  47. package/Cameras/camera.js.map +1 -1
  48. package/Collisions/pickingInfo.js +1 -1
  49. package/Collisions/pickingInfo.js.map +1 -1
  50. package/Compute/computeEffect.js +5 -8
  51. package/Compute/computeEffect.js.map +1 -1
  52. package/Compute/computeShader.js +12 -9
  53. package/Compute/computeShader.js.map +1 -1
  54. package/Culling/Octrees/octreeSceneComponent.js +1 -2
  55. package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
  56. package/Culling/boundingBox.js +2 -3
  57. package/Culling/boundingBox.js.map +1 -1
  58. package/Culling/ray.d.ts +6 -1
  59. package/Culling/ray.js +9 -4
  60. package/Culling/ray.js.map +1 -1
  61. package/Debug/debugLayer.js +4 -1
  62. package/Debug/debugLayer.js.map +1 -1
  63. package/Debug/directionalLightFrustumViewer.js +7 -9
  64. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  65. package/Debug/physicsViewer.js +5 -7
  66. package/Debug/physicsViewer.js.map +1 -1
  67. package/Debug/rayHelper.js +1 -2
  68. package/Debug/rayHelper.js.map +1 -1
  69. package/Debug/skeletonViewer.js +26 -31
  70. package/Debug/skeletonViewer.js.map +1 -1
  71. package/Decorators/nodeDecorator.js +1 -1
  72. package/Decorators/nodeDecorator.js.map +1 -1
  73. package/DeviceInput/InputDevices/deviceSourceManager.js +3 -5
  74. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  75. package/DeviceInput/eventFactory.js +1 -1
  76. package/DeviceInput/eventFactory.js.map +1 -1
  77. package/DeviceInput/internalDeviceSourceManager.js +1 -2
  78. package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
  79. package/DeviceInput/webDeviceInputSystem.js +9 -12
  80. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  81. package/Engines/Extensions/engine.cubeTexture.js +6 -1
  82. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  83. package/Engines/Extensions/engine.multiRender.js +3 -4
  84. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  85. package/Engines/Extensions/engine.rawTexture.js +4 -4
  86. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  87. package/Engines/Extensions/engine.readTexture.js +2 -3
  88. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  89. package/Engines/Extensions/engine.renderTarget.js +9 -5
  90. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  91. package/Engines/Extensions/engine.renderTargetCube.js +9 -1
  92. package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
  93. package/Engines/Extensions/engine.views.js +1 -2
  94. package/Engines/Extensions/engine.views.js.map +1 -1
  95. package/Engines/Processors/shaderCodeNode.js +6 -7
  96. package/Engines/Processors/shaderCodeNode.js.map +1 -1
  97. package/Engines/Processors/shaderProcessor.js +6 -11
  98. package/Engines/Processors/shaderProcessor.js.map +1 -1
  99. package/Engines/WebGL/webGLHardwareTexture.js +1 -2
  100. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  101. package/Engines/WebGL/webGLRenderTargetWrapper.js +3 -5
  102. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  103. package/Engines/WebGPU/Extensions/engine.cubeTexture.js +9 -2
  104. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  105. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +1 -2
  106. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
  107. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -6
  108. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  109. package/Engines/WebGPU/Extensions/engine.query.js +2 -4
  110. package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
  111. package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -4
  112. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  113. package/Engines/WebGPU/Extensions/engine.renderTarget.js +11 -5
  114. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  115. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js +11 -3
  116. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
  117. package/Engines/WebGPU/Extensions/engine.storageBuffer.js +2 -3
  118. package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
  119. package/Engines/WebGPU/Extensions/engine.textureSampler.js +1 -2
  120. package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
  121. package/Engines/WebGPU/Extensions/engine.videoTexture.js +1 -2
  122. package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
  123. package/Engines/WebGPU/webgpuBufferManager.js +1 -1
  124. package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
  125. package/Engines/WebGPU/webgpuCacheBindGroups.js +6 -7
  126. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  127. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +15 -20
  128. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  129. package/Engines/WebGPU/webgpuCacheSampler.js +10 -5
  130. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  131. package/Engines/WebGPU/webgpuClearQuad.js +2 -3
  132. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  133. package/Engines/WebGPU/webgpuComputePipelineContext.js +1 -2
  134. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  135. package/Engines/WebGPU/webgpuDepthCullingState.js +2 -2
  136. package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
  137. package/Engines/WebGPU/webgpuDrawContext.js +1 -2
  138. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  139. package/Engines/WebGPU/webgpuHardwareTexture.js +4 -6
  140. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  141. package/Engines/WebGPU/webgpuMaterialContext.js +2 -3
  142. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  143. package/Engines/WebGPU/webgpuOcclusionQuery.js +3 -5
  144. package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
  145. package/Engines/WebGPU/webgpuPipelineContext.js +2 -4
  146. package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
  147. package/Engines/WebGPU/webgpuQuerySet.js +1 -1
  148. package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
  149. package/Engines/WebGPU/webgpuShaderProcessingContext.js +2 -4
  150. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  151. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -4
  152. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  153. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +5 -4
  154. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  155. package/Engines/WebGPU/webgpuStencilStateComposer.js +1 -2
  156. package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
  157. package/Engines/WebGPU/webgpuTextureManager.js +40 -43
  158. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  159. package/Engines/WebGPU/webgpuTimestampQuery.js +12 -7
  160. package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
  161. package/Engines/WebGPU/webgpuTintWASM.js +4 -1
  162. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  163. package/Engines/engine.js +4 -7
  164. package/Engines/engine.js.map +1 -1
  165. package/Engines/nativeEngine.js +16 -22
  166. package/Engines/nativeEngine.js.map +1 -1
  167. package/Engines/nullEngine.js +9 -1
  168. package/Engines/nullEngine.js.map +1 -1
  169. package/Engines/renderTargetWrapper.js +11 -16
  170. package/Engines/renderTargetWrapper.js.map +1 -1
  171. package/Engines/thinEngine.js +32 -44
  172. package/Engines/thinEngine.js.map +1 -1
  173. package/Engines/webgpuEngine.js +77 -95
  174. package/Engines/webgpuEngine.js.map +1 -1
  175. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +2 -3
  176. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  177. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +3 -6
  178. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  179. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +1 -2
  180. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
  181. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +1 -2
  182. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
  183. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +2 -4
  184. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
  185. package/FlowGraph/flowGraph.js +1 -2
  186. package/FlowGraph/flowGraph.js.map +1 -1
  187. package/FlowGraph/flowGraphBlock.js +2 -4
  188. package/FlowGraph/flowGraphBlock.js.map +1 -1
  189. package/FlowGraph/flowGraphContext.js +1 -2
  190. package/FlowGraph/flowGraphContext.js.map +1 -1
  191. package/FlowGraph/flowGraphCoordinator.js +4 -7
  192. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  193. package/FlowGraph/flowGraphSignalConnection.js +1 -2
  194. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  195. package/FlowGraph/serialization.js +2 -3
  196. package/FlowGraph/serialization.js.map +1 -1
  197. package/Gamepads/gamepadManager.js +1 -1
  198. package/Gamepads/gamepadManager.js.map +1 -1
  199. package/Gizmos/axisDragGizmo.js +2 -4
  200. package/Gizmos/axisDragGizmo.js.map +1 -1
  201. package/Gizmos/axisScaleGizmo.js +5 -8
  202. package/Gizmos/axisScaleGizmo.js.map +1 -1
  203. package/Gizmos/boundingBoxGizmo.js +1 -1
  204. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  205. package/Gizmos/cameraGizmo.js +2 -3
  206. package/Gizmos/cameraGizmo.js.map +1 -1
  207. package/Gizmos/gizmo.js +4 -7
  208. package/Gizmos/gizmo.js.map +1 -1
  209. package/Gizmos/gizmoManager.js +3 -4
  210. package/Gizmos/gizmoManager.js.map +1 -1
  211. package/Gizmos/planeDragGizmo.js +2 -4
  212. package/Gizmos/planeDragGizmo.js.map +1 -1
  213. package/Gizmos/planeRotationGizmo.js +2 -4
  214. package/Gizmos/planeRotationGizmo.js.map +1 -1
  215. package/Helpers/environmentHelper.js +8 -2
  216. package/Helpers/environmentHelper.js.map +1 -1
  217. package/Helpers/videoDome.js +1 -2
  218. package/Helpers/videoDome.js.map +1 -1
  219. package/Inputs/scene.inputManager.js +8 -10
  220. package/Inputs/scene.inputManager.js.map +1 -1
  221. package/Layers/effectLayer.js +16 -10
  222. package/Layers/effectLayer.js.map +1 -1
  223. package/Layers/glowLayer.js +16 -6
  224. package/Layers/glowLayer.js.map +1 -1
  225. package/Layers/highlightLayer.js +12 -3
  226. package/Layers/highlightLayer.js.map +1 -1
  227. package/Layers/layer.js +1 -2
  228. package/Layers/layer.js.map +1 -1
  229. package/LensFlares/lensFlareSystem.js +1 -2
  230. package/LensFlares/lensFlareSystem.js.map +1 -1
  231. package/Lights/Shadows/cascadedShadowGenerator.js +21 -25
  232. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  233. package/Lights/Shadows/shadowGenerator.js +18 -21
  234. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  235. package/Lights/light.js +2 -4
  236. package/Lights/light.js.map +1 -1
  237. package/Lights/shadowLight.js +1 -1
  238. package/Lights/shadowLight.js.map +1 -1
  239. package/Loading/Plugins/babylonFileLoader.js +1 -2
  240. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  241. package/Loading/sceneLoader.js +1 -1
  242. package/Loading/sceneLoader.js.map +1 -1
  243. package/Materials/GreasedLine/greasedLinePluginMaterial.js +26 -32
  244. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
  245. package/Materials/GreasedLine/greasedLineSimpleMaterial.js +22 -27
  246. package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
  247. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +6 -7
  248. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
  249. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +1 -2
  250. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  251. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +1 -2
  252. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  253. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +1 -1
  254. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  255. package/Materials/Node/Blocks/Dual/textureBlock.js +10 -16
  256. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  257. package/Materials/Node/Blocks/Fragment/TBNBlock.js +2 -3
  258. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  259. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -2
  260. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  261. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +2 -4
  262. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  263. package/Materials/Node/Blocks/Input/inputBlock.js +1 -2
  264. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  265. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +24 -26
  266. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  267. package/Materials/Node/Blocks/PBR/iridescenceBlock.js +3 -3
  268. package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
  269. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +45 -49
  270. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  271. package/Materials/Node/Blocks/PBR/reflectionBlock.js +1 -2
  272. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  273. package/Materials/Node/Blocks/PBR/refractionBlock.js +1 -2
  274. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  275. package/Materials/Node/Blocks/PBR/sheenBlock.js +13 -13
  276. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  277. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +27 -28
  278. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  279. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
  280. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  281. package/Materials/Node/Blocks/Vertex/instancesBlock.js +2 -2
  282. package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
  283. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +43 -33
  284. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  285. package/Materials/Node/Blocks/biPlanarBlock.js +1 -2
  286. package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
  287. package/Materials/Node/Blocks/cloudBlock.js +2 -3
  288. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  289. package/Materials/Node/Blocks/colorMergerBlock.js +4 -5
  290. package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
  291. package/Materials/Node/Blocks/customBlock.js +4 -6
  292. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  293. package/Materials/Node/Blocks/meshAttributeExistsBlock.js +2 -4
  294. package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
  295. package/Materials/Node/Blocks/triPlanarBlock.js +14 -23
  296. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  297. package/Materials/Node/Blocks/vectorMergerBlock.js +4 -5
  298. package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
  299. package/Materials/Node/nodeMaterial.js +16 -11
  300. package/Materials/Node/nodeMaterial.js.map +1 -1
  301. package/Materials/Node/nodeMaterialBlock.js +3 -4
  302. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  303. package/Materials/Node/nodeMaterialBuildState.js +1 -1
  304. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  305. package/Materials/PBR/pbrBaseMaterial.js +25 -28
  306. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  307. package/Materials/PBR/pbrClearCoatConfiguration.js +6 -9
  308. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  309. package/Materials/PBR/pbrIridescenceConfiguration.js +4 -7
  310. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  311. package/Materials/PBR/pbrSheenConfiguration.js +4 -7
  312. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  313. package/Materials/Textures/Loaders/envTextureLoader.js +2 -2
  314. package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
  315. package/Materials/Textures/Packer/packer.js +13 -14
  316. package/Materials/Textures/Packer/packer.js.map +1 -1
  317. package/Materials/Textures/Procedurals/noiseProceduralTexture.js +1 -2
  318. package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
  319. package/Materials/Textures/Procedurals/proceduralTexture.js +19 -11
  320. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  321. package/Materials/Textures/baseTexture.js +2 -4
  322. package/Materials/Textures/baseTexture.js.map +1 -1
  323. package/Materials/Textures/cubeTexture.js +7 -13
  324. package/Materials/Textures/cubeTexture.js.map +1 -1
  325. package/Materials/Textures/dynamicTexture.js +1 -2
  326. package/Materials/Textures/dynamicTexture.js.map +1 -1
  327. package/Materials/Textures/hdrCubeTexture.js +2 -4
  328. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  329. package/Materials/Textures/htmlElementTexture.js +5 -3
  330. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  331. package/Materials/Textures/internalTexture.js +3 -5
  332. package/Materials/Textures/internalTexture.js.map +1 -1
  333. package/Materials/Textures/mirrorTexture.js +3 -6
  334. package/Materials/Textures/mirrorTexture.js.map +1 -1
  335. package/Materials/Textures/multiRenderTarget.js +5 -8
  336. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  337. package/Materials/Textures/rawTexture.js +1 -1
  338. package/Materials/Textures/rawTexture.js.map +1 -1
  339. package/Materials/Textures/renderTargetTexture.js +22 -34
  340. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  341. package/Materials/Textures/texture.js +16 -21
  342. package/Materials/Textures/texture.js.map +1 -1
  343. package/Materials/Textures/thinRenderTargetTexture.js +2 -4
  344. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  345. package/Materials/Textures/thinTexture.js +1 -1
  346. package/Materials/Textures/thinTexture.js.map +1 -1
  347. package/Materials/Textures/videoTexture.js +12 -10
  348. package/Materials/Textures/videoTexture.js.map +1 -1
  349. package/Materials/clipPlaneMaterialHelper.js +18 -21
  350. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  351. package/Materials/drawWrapper.js +2 -4
  352. package/Materials/drawWrapper.js.map +1 -1
  353. package/Materials/effect.d.ts +4 -0
  354. package/Materials/effect.js +18 -18
  355. package/Materials/effect.js.map +1 -1
  356. package/Materials/effectRenderer.js +2 -3
  357. package/Materials/effectRenderer.js.map +1 -1
  358. package/Materials/material.decalMapConfiguration.js +3 -3
  359. package/Materials/material.decalMapConfiguration.js.map +1 -1
  360. package/Materials/material.detailMapConfiguration.js +1 -2
  361. package/Materials/material.detailMapConfiguration.js.map +1 -1
  362. package/Materials/material.js +7 -4
  363. package/Materials/material.js.map +1 -1
  364. package/Materials/materialDefines.js +5 -6
  365. package/Materials/materialDefines.js.map +1 -1
  366. package/Materials/materialHelper.d.ts +1 -1
  367. package/Materials/materialHelper.js +3 -4
  368. package/Materials/materialHelper.js.map +1 -1
  369. package/Materials/materialPluginManager.js +3 -5
  370. package/Materials/materialPluginManager.js.map +1 -1
  371. package/Materials/meshDebugPluginMaterial.js +13 -14
  372. package/Materials/meshDebugPluginMaterial.js.map +1 -1
  373. package/Materials/multiMaterial.js +1 -2
  374. package/Materials/multiMaterial.js.map +1 -1
  375. package/Materials/shaderMaterial.d.ts +1 -1
  376. package/Materials/shaderMaterial.js +64 -32
  377. package/Materials/shaderMaterial.js.map +1 -1
  378. package/Materials/shadowDepthWrapper.js +24 -23
  379. package/Materials/shadowDepthWrapper.js.map +1 -1
  380. package/Materials/standardMaterial.js +10 -12
  381. package/Materials/standardMaterial.js.map +1 -1
  382. package/Materials/uniformBuffer.js +1 -1
  383. package/Materials/uniformBuffer.js.map +1 -1
  384. package/Maths/math.vector.js +1 -2
  385. package/Maths/math.vector.js.map +1 -1
  386. package/Meshes/Builders/decalBuilder.js +26 -29
  387. package/Meshes/Builders/decalBuilder.js.map +1 -1
  388. package/Meshes/Builders/greasedLineBuilder.js +16 -16
  389. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  390. package/Meshes/Builders/groundBuilder.d.ts +5 -1
  391. package/Meshes/Builders/groundBuilder.js +13 -2
  392. package/Meshes/Builders/groundBuilder.js.map +1 -1
  393. package/Meshes/Builders/textBuilder.js +2 -3
  394. package/Meshes/Builders/textBuilder.js.map +1 -1
  395. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +9 -1
  396. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +141 -12
  397. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  398. package/Meshes/GreasedLine/greasedLineBaseMesh.js +8 -11
  399. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  400. package/Meshes/GreasedLine/greasedLineMesh.js +3 -5
  401. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  402. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +13 -18
  403. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  404. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +1 -2
  405. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  406. package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +18 -18
  407. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +18 -18
  408. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
  409. package/Meshes/Node/nodeGeometry.js +6 -3
  410. package/Meshes/Node/nodeGeometry.js.map +1 -1
  411. package/Meshes/Node/nodeGeometryBlock.js +1 -1
  412. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  413. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +1 -2
  414. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  415. package/Meshes/Node/nodeGeometryBuildState.js +1 -2
  416. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  417. package/Meshes/abstractMesh.js +6 -10
  418. package/Meshes/abstractMesh.js.map +1 -1
  419. package/Meshes/csg.js +1 -2
  420. package/Meshes/csg.js.map +1 -1
  421. package/Meshes/geometry.js +1 -1
  422. package/Meshes/geometry.js.map +1 -1
  423. package/Meshes/instancedMesh.js +5 -10
  424. package/Meshes/instancedMesh.js.map +1 -1
  425. package/Meshes/mesh.js +13 -22
  426. package/Meshes/mesh.js.map +1 -1
  427. package/Meshes/mesh.vertexData.js +3 -4
  428. package/Meshes/mesh.vertexData.js.map +1 -1
  429. package/Meshes/meshUVSpaceRenderer.js +18 -15
  430. package/Meshes/meshUVSpaceRenderer.js.map +1 -1
  431. package/Meshes/subMesh.js +8 -14
  432. package/Meshes/subMesh.js.map +1 -1
  433. package/Meshes/thinInstanceMesh.js +12 -18
  434. package/Meshes/thinInstanceMesh.js.map +1 -1
  435. package/Meshes/trailMesh.js +2 -3
  436. package/Meshes/trailMesh.js.map +1 -1
  437. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -2
  438. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  439. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +9 -14
  440. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  441. package/Misc/PerformanceViewer/performanceViewerCollector.js +2 -3
  442. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  443. package/Misc/arrayTools.js +1 -1
  444. package/Misc/arrayTools.js.map +1 -1
  445. package/Misc/basis.js +2 -3
  446. package/Misc/basis.js.map +1 -1
  447. package/Misc/dataStorage.js +1 -1
  448. package/Misc/dataStorage.js.map +1 -1
  449. package/Misc/deepCopier.js +1 -1
  450. package/Misc/deepCopier.js.map +1 -1
  451. package/Misc/environmentTextureTools.js +3 -4
  452. package/Misc/environmentTextureTools.js.map +1 -1
  453. package/Misc/equirectangularCapture.js +2 -3
  454. package/Misc/equirectangularCapture.js.map +1 -1
  455. package/Misc/fileTools.js +4 -4
  456. package/Misc/fileTools.js.map +1 -1
  457. package/Misc/greasedLineTools.js +3 -5
  458. package/Misc/greasedLineTools.js.map +1 -1
  459. package/Misc/logger.js +1 -2
  460. package/Misc/logger.js.map +1 -1
  461. package/Misc/minMaxReducer.js +2 -3
  462. package/Misc/minMaxReducer.js.map +1 -1
  463. package/Misc/pressureObserverWrapper.js +5 -8
  464. package/Misc/pressureObserverWrapper.js.map +1 -1
  465. package/Misc/sceneRecorder.js +1 -1
  466. package/Misc/sceneRecorder.js.map +1 -1
  467. package/Misc/screenshotTools.js +1 -1
  468. package/Misc/screenshotTools.js.map +1 -1
  469. package/Misc/textureTools.js +5 -5
  470. package/Misc/textureTools.js.map +1 -1
  471. package/Misc/timer.js +3 -5
  472. package/Misc/timer.js.map +1 -1
  473. package/Misc/tools.d.ts +3 -2
  474. package/Misc/tools.js +6 -5
  475. package/Misc/tools.js.map +1 -1
  476. package/Misc/trajectoryClassifier.js +3 -3
  477. package/Misc/trajectoryClassifier.js.map +1 -1
  478. package/Misc/videoRecorder.js +6 -4
  479. package/Misc/videoRecorder.js.map +1 -1
  480. package/Misc/virtualJoystick.js +4 -1
  481. package/Misc/virtualJoystick.js.map +1 -1
  482. package/Morph/morphTargetManager.js +1 -2
  483. package/Morph/morphTargetManager.js.map +1 -1
  484. package/Particles/EmitterTypes/meshParticleEmitter.js +1 -2
  485. package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
  486. package/Particles/baseParticleSystem.d.ts +4 -0
  487. package/Particles/baseParticleSystem.js +4 -0
  488. package/Particles/baseParticleSystem.js.map +1 -1
  489. package/Particles/computeShaderParticleSystem.js +3 -6
  490. package/Particles/computeShaderParticleSystem.js.map +1 -1
  491. package/Particles/gpuParticleSystem.d.ts +2 -2
  492. package/Particles/gpuParticleSystem.js +30 -20
  493. package/Particles/gpuParticleSystem.js.map +1 -1
  494. package/Particles/particleSystem.d.ts +3 -2
  495. package/Particles/particleSystem.js +33 -30
  496. package/Particles/particleSystem.js.map +1 -1
  497. package/Particles/particleSystemComponent.js +2 -3
  498. package/Particles/particleSystemComponent.js.map +1 -1
  499. package/Particles/pointsCloudSystem.js +5 -8
  500. package/Particles/pointsCloudSystem.js.map +1 -1
  501. package/Particles/solidParticleSystem.js +5 -7
  502. package/Particles/solidParticleSystem.js.map +1 -1
  503. package/Particles/webgl2ParticleSystem.js +1 -2
  504. package/Particles/webgl2ParticleSystem.js.map +1 -1
  505. package/Physics/castingResult.js +1 -1
  506. package/Physics/castingResult.js.map +1 -1
  507. package/Physics/joinedPhysicsEngineComponent.js +2 -2
  508. package/Physics/joinedPhysicsEngineComponent.js.map +1 -1
  509. package/Physics/physicsHelper.js +19 -21
  510. package/Physics/physicsHelper.js.map +1 -1
  511. package/Physics/v2/IPhysicsEnginePlugin.d.ts +20 -0
  512. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  513. package/Physics/v2/Plugins/havokPlugin.js +48 -35
  514. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  515. package/Physics/v2/physicsAggregate.js +10 -12
  516. package/Physics/v2/physicsAggregate.js.map +1 -1
  517. package/Physics/v2/physicsBody.js +2 -4
  518. package/Physics/v2/physicsBody.js.map +1 -1
  519. package/Physics/v2/physicsShape.js +1 -2
  520. package/Physics/v2/physicsShape.js.map +1 -1
  521. package/Physics/v2/ragdoll.js +6 -8
  522. package/Physics/v2/ragdoll.js.map +1 -1
  523. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +6 -8
  524. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  525. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +14 -22
  526. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  527. package/PostProcesses/colorCorrectionPostProcess.js +1 -1
  528. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  529. package/PostProcesses/postProcess.js +28 -34
  530. package/PostProcesses/postProcess.js.map +1 -1
  531. package/PostProcesses/postProcessManager.js +4 -6
  532. package/PostProcesses/postProcessManager.js.map +1 -1
  533. package/PostProcesses/screenSpaceReflectionPostProcess.js +2 -2
  534. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  535. package/PostProcesses/volumetricLightScatteringPostProcess.js +4 -7
  536. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  537. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +1 -1
  538. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  539. package/Probes/reflectionProbe.js +2 -4
  540. package/Probes/reflectionProbe.js.map +1 -1
  541. package/Rendering/GlobalIllumination/giRSMManager.js +22 -19
  542. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  543. package/Rendering/boundingBoxRenderer.js +2 -3
  544. package/Rendering/boundingBoxRenderer.js.map +1 -1
  545. package/Rendering/depthPeelingRenderer.js +2 -4
  546. package/Rendering/depthPeelingRenderer.js.map +1 -1
  547. package/Rendering/depthPeelingSceneComponent.js +2 -4
  548. package/Rendering/depthPeelingSceneComponent.js.map +1 -1
  549. package/Rendering/depthRenderer.js +10 -13
  550. package/Rendering/depthRenderer.js.map +1 -1
  551. package/Rendering/edgesRenderer.js +8 -11
  552. package/Rendering/edgesRenderer.js.map +1 -1
  553. package/Rendering/fluidRenderer/fluidRenderer.js +6 -11
  554. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  555. package/Rendering/fluidRenderer/fluidRenderingObject.js +3 -5
  556. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  557. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +2 -4
  558. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
  559. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +30 -36
  560. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
  561. package/Rendering/fluidRenderer/fluidRenderingTextures.js +5 -7
  562. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
  563. package/Rendering/geometryBufferRenderer.js +3 -2
  564. package/Rendering/geometryBufferRenderer.js.map +1 -1
  565. package/Rendering/outlineRenderer.js +5 -4
  566. package/Rendering/outlineRenderer.js.map +1 -1
  567. package/Rendering/prePassRenderer.js +3 -6
  568. package/Rendering/prePassRenderer.js.map +1 -1
  569. package/Rendering/reflectiveShadowMap.d.ts +1 -0
  570. package/Rendering/reflectiveShadowMap.js +5 -5
  571. package/Rendering/reflectiveShadowMap.js.map +1 -1
  572. package/Shaders/color.fragment.d.ts +2 -0
  573. package/Shaders/color.fragment.js +4 -0
  574. package/Shaders/color.fragment.js.map +1 -1
  575. package/Shaders/color.vertex.d.ts +2 -0
  576. package/Shaders/color.vertex.js +7 -0
  577. package/Shaders/color.vertex.js.map +1 -1
  578. package/Shaders/gpuRenderParticles.fragment.d.ts +2 -0
  579. package/Shaders/gpuRenderParticles.fragment.js +4 -0
  580. package/Shaders/gpuRenderParticles.fragment.js.map +1 -1
  581. package/Shaders/gpuRenderParticles.vertex.d.ts +2 -0
  582. package/Shaders/gpuRenderParticles.vertex.js +5 -1
  583. package/Shaders/gpuRenderParticles.vertex.js.map +1 -1
  584. package/Shaders/particles.fragment.d.ts +2 -0
  585. package/Shaders/particles.fragment.js +4 -0
  586. package/Shaders/particles.fragment.js.map +1 -1
  587. package/Shaders/particles.vertex.d.ts +2 -0
  588. package/Shaders/particles.vertex.js +5 -1
  589. package/Shaders/particles.vertex.js.map +1 -1
  590. package/Sprites/spriteManager.js +1 -2
  591. package/Sprites/spriteManager.js.map +1 -1
  592. package/Sprites/spriteRenderer.js +5 -7
  593. package/Sprites/spriteRenderer.js.map +1 -1
  594. package/States/stencilStateComposer.js +2 -4
  595. package/States/stencilStateComposer.js.map +1 -1
  596. package/XR/features/WebXRAbstractFeature.js +6 -2
  597. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  598. package/XR/features/WebXRAnchorSystem.js +1 -2
  599. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  600. package/XR/features/WebXRControllerMovement.js +6 -7
  601. package/XR/features/WebXRControllerMovement.js.map +1 -1
  602. package/XR/features/WebXRControllerPhysics.js +17 -10
  603. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  604. package/XR/features/WebXRControllerPointerSelection.js +1 -2
  605. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  606. package/XR/features/WebXRControllerTeleportation.d.ts +1 -0
  607. package/XR/features/WebXRControllerTeleportation.js +6 -3
  608. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  609. package/XR/features/WebXRDepthSensing.js +3 -5
  610. package/XR/features/WebXRDepthSensing.js.map +1 -1
  611. package/XR/features/WebXRHandTracking.d.ts +1 -0
  612. package/XR/features/WebXRHandTracking.js +31 -28
  613. package/XR/features/WebXRHandTracking.js.map +1 -1
  614. package/XR/features/WebXRLayers.js +9 -11
  615. package/XR/features/WebXRLayers.js.map +1 -1
  616. package/XR/features/WebXRLightEstimation.js +3 -6
  617. package/XR/features/WebXRLightEstimation.js.map +1 -1
  618. package/XR/features/WebXRMeshDetector.js +2 -4
  619. package/XR/features/WebXRMeshDetector.js.map +1 -1
  620. package/XR/features/WebXRNearInteraction.js +21 -18
  621. package/XR/features/WebXRNearInteraction.js.map +1 -1
  622. package/XR/features/WebXRPlaneDetector.js +1 -2
  623. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  624. package/XR/features/WebXRRawCameraAccess.js +2 -3
  625. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  626. package/XR/features/WebXRSpaceWarp.js +1 -1
  627. package/XR/features/WebXRSpaceWarp.js.map +1 -1
  628. package/XR/motionController/webXRAbstractMotionController.js +4 -1
  629. package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
  630. package/XR/native/nativeXRFrame.js +1 -2
  631. package/XR/native/nativeXRFrame.js.map +1 -1
  632. package/XR/webXRCamera.js +1 -2
  633. package/XR/webXRCamera.js.map +1 -1
  634. package/XR/webXRDefaultExperience.js +28 -6
  635. package/XR/webXRDefaultExperience.js.map +1 -1
  636. package/XR/webXRExperienceHelper.js +5 -7
  637. package/XR/webXRExperienceHelper.js.map +1 -1
  638. package/XR/webXRFeaturesManager.js +4 -1
  639. package/XR/webXRFeaturesManager.js.map +1 -1
  640. package/XR/webXRInput.js +6 -1
  641. package/XR/webXRInput.js.map +1 -1
  642. package/XR/webXRInputSource.js +1 -2
  643. package/XR/webXRInputSource.js.map +1 -1
  644. package/XR/webXRSessionManager.js +16 -29
  645. package/XR/webXRSessionManager.js.map +1 -1
  646. package/assetContainer.js +4 -1
  647. package/assetContainer.js.map +1 -1
  648. package/package.json +1 -1
  649. package/scene.js +18 -17
  650. package/scene.js.map +1 -1
@@ -22,7 +22,6 @@ export class PhysicsAggregate {
22
22
  * The type of the physics aggregate
23
23
  */
24
24
  type, _options = { mass: 0 }, _scene) {
25
- var _a;
26
25
  this.transformNode = transformNode;
27
26
  this.type = type;
28
27
  this._options = _options;
@@ -49,7 +48,7 @@ export class PhysicsAggregate {
49
48
  this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;
50
49
  this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;
51
50
  const motionType = this._options.mass === 0 ? PhysicsMotionType.STATIC : PhysicsMotionType.DYNAMIC;
52
- const startAsleep = (_a = this._options.startAsleep) !== null && _a !== void 0 ? _a : false;
51
+ const startAsleep = this._options.startAsleep ?? false;
53
52
  this.body = new PhysicsBody(transformNode, motionType, startAsleep, this._scene);
54
53
  this._addSizeOptions();
55
54
  if (type.getClassName && type.getClassName() === "PhysicsShape") {
@@ -79,10 +78,9 @@ export class PhysicsAggregate {
79
78
  }
80
79
  }
81
80
  _hasVertices(node) {
82
- return (node === null || node === void 0 ? void 0 : node.getTotalVertices()) > 0;
81
+ return node?.getTotalVertices() > 0;
83
82
  }
84
83
  _addSizeOptions() {
85
- var _a, _b, _c, _d, _e, _f, _g, _h;
86
84
  this.transformNode.computeWorldMatrix(true);
87
85
  const bb = this._getObjectBoundingBox();
88
86
  const extents = TmpVectors.Vector3[0];
@@ -115,17 +113,17 @@ export class PhysicsAggregate {
115
113
  case PhysicsShapeType.CAPSULE:
116
114
  {
117
115
  const capRadius = extents.x / 2;
118
- this._options.radius = (_a = this._options.radius) !== null && _a !== void 0 ? _a : capRadius;
119
- this._options.pointA = (_b = this._options.pointA) !== null && _b !== void 0 ? _b : new Vector3(0, min.y + capRadius, 0);
120
- this._options.pointB = (_c = this._options.pointB) !== null && _c !== void 0 ? _c : new Vector3(0, min.y + extents.y - capRadius, 0);
116
+ this._options.radius = this._options.radius ?? capRadius;
117
+ this._options.pointA = this._options.pointA ?? new Vector3(0, min.y + capRadius, 0);
118
+ this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y - capRadius, 0);
121
119
  }
122
120
  break;
123
121
  case PhysicsShapeType.CYLINDER:
124
122
  {
125
123
  const capRadius = extents.x / 2;
126
- this._options.radius = (_d = this._options.radius) !== null && _d !== void 0 ? _d : capRadius;
127
- this._options.pointA = (_e = this._options.pointA) !== null && _e !== void 0 ? _e : new Vector3(0, min.y, 0);
128
- this._options.pointB = (_f = this._options.pointB) !== null && _f !== void 0 ? _f : new Vector3(0, min.y + extents.y, 0);
124
+ this._options.radius = this._options.radius ?? capRadius;
125
+ this._options.pointA = this._options.pointA ?? new Vector3(0, min.y, 0);
126
+ this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y, 0);
129
127
  }
130
128
  break;
131
129
  case PhysicsShapeType.MESH:
@@ -138,8 +136,8 @@ export class PhysicsAggregate {
138
136
  }
139
137
  break;
140
138
  case PhysicsShapeType.BOX:
141
- this._options.extents = (_g = this._options.extents) !== null && _g !== void 0 ? _g : new Vector3(extents.x, extents.y, extents.z);
142
- this._options.rotation = (_h = this._options.rotation) !== null && _h !== void 0 ? _h : Quaternion.Identity();
139
+ this._options.extents = this._options.extents ?? new Vector3(extents.x, extents.y, extents.z);
140
+ this._options.rotation = this._options.rotation ?? Quaternion.Identity();
143
141
  break;
144
142
  }
145
143
  }
@@ -1 +1 @@
1
- {"version":3,"file":"physicsAggregate.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,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ACpC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,yBAAyB,EAAE;YAChC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;SACxB;IACL,CAAC;CACJ","sourcesContent":["import { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { PhysicsShape } from \"./physicsShape\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { PhysicsMotionType, PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Node } from \"../../node\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * The interface for the physics aggregate parameters\r\n */\r\nexport interface PhysicsAggregateParameters {\r\n /**\r\n * The mass of the physics aggregate\r\n */\r\n mass: number;\r\n\r\n /**\r\n * The friction of the physics aggregate\r\n */\r\n friction?: number;\r\n\r\n /**\r\n * The coefficient of restitution of the physics aggregate\r\n */\r\n restitution?: number;\r\n\r\n /**\r\n * Radius for sphere, cylinder and capsule\r\n */\r\n radius?: number;\r\n\r\n /**\r\n * Starting point for cylinder/capsule\r\n */\r\n pointA?: Vector3;\r\n\r\n /**\r\n * Ending point for cylinder/capsule\r\n */\r\n pointB?: Vector3;\r\n\r\n /**\r\n * Extents for box\r\n */\r\n extents?: Vector3;\r\n\r\n /**\r\n * Orientation for box\r\n */\r\n rotation?: Quaternion;\r\n\r\n /**\r\n * mesh local center\r\n */\r\n center?: Vector3;\r\n\r\n /**\r\n * mesh object. Used for mesh and convex hull aggregates.\r\n */\r\n mesh?: Mesh;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n startAsleep?: boolean;\r\n\r\n /**\r\n * If true, mark the created shape as a trigger shape\r\n */\r\n isTriggerShape?: boolean;\r\n}\r\n/**\r\n * Helper class to create and interact with a PhysicsAggregate.\r\n * This is a transition object that works like Physics Plugin V1 Impostors.\r\n * This helper instanciate all mandatory physics objects to get a body/shape and material.\r\n * It's less efficient that handling body and shapes independently but for prototyping or\r\n * a small numbers of physics objects, it's good enough.\r\n */\r\nexport class PhysicsAggregate {\r\n /**\r\n * The body that is associated with this aggregate\r\n */\r\n public body: PhysicsBody;\r\n\r\n /**\r\n * The shape that is associated with this aggregate\r\n */\r\n public shape: PhysicsShape;\r\n\r\n /**\r\n * The material that is associated with this aggregate\r\n */\r\n public material: PhysicsMaterial;\r\n\r\n private _disposeShapeWhenDisposed = true;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics aggregate\r\n */\r\n public transformNode: TransformNode,\r\n /**\r\n * The type of the physics aggregate\r\n */\r\n public type: PhysicsShapeType | PhysicsShape,\r\n private _options: PhysicsAggregateParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.transformNode) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n const m = transformNode as Mesh;\r\n if (this.transformNode.parent && this._options.mass !== 0 && m.hasThinInstances) {\r\n Logger.Warn(\r\n \"A physics body has been created for an object which has a parent and thin instances. Babylon physics currently works in local space so unexpected issues may occur.\"\r\n );\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && transformNode.getScene) {\r\n this._scene = transformNode.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n\r\n const motionType = this._options.mass === 0 ? PhysicsMotionType.STATIC : PhysicsMotionType.DYNAMIC;\r\n const startAsleep = this._options.startAsleep ?? false;\r\n this.body = new PhysicsBody(transformNode, motionType, startAsleep, this._scene);\r\n this._addSizeOptions();\r\n if ((type as any).getClassName && (type as any).getClassName() === \"PhysicsShape\") {\r\n this.shape = type as PhysicsShape;\r\n this._disposeShapeWhenDisposed = false;\r\n } else {\r\n this.shape = new PhysicsShape({ type: type as PhysicsShapeType, parameters: this._options as any }, this._scene);\r\n }\r\n\r\n if (this._options.isTriggerShape) {\r\n this.shape.isTrigger = true;\r\n }\r\n\r\n this.material = { friction: this._options.friction, restitution: this._options.restitution };\r\n this.body.shape = this.shape;\r\n this.shape.material = this.material;\r\n\r\n this.body.setMassProperties({ mass: this._options.mass });\r\n\r\n this._nodeDisposeObserver = this.transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n private _getObjectBoundingBox() {\r\n if ((this.transformNode as AbstractMesh).getRawBoundingInfo) {\r\n return (this.transformNode as AbstractMesh).getRawBoundingInfo().boundingBox;\r\n } else {\r\n return new BoundingBox(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));\r\n }\r\n }\r\n\r\n private _hasVertices(node: TransformNode): boolean {\r\n return (node as any)?.getTotalVertices() > 0;\r\n }\r\n\r\n private _addSizeOptions(): void {\r\n this.transformNode.computeWorldMatrix(true);\r\n const bb = this._getObjectBoundingBox();\r\n const extents = TmpVectors.Vector3[0];\r\n extents.copyFrom(bb.extendSize);\r\n extents.scaleInPlace(2);\r\n extents.multiplyInPlace(this.transformNode.scaling);\r\n // In case we had any negative scaling, we need to take the absolute value of the extents.\r\n extents.x = Math.abs(extents.x);\r\n extents.y = Math.abs(extents.y);\r\n extents.z = Math.abs(extents.z);\r\n\r\n const min = TmpVectors.Vector3[1];\r\n min.copyFrom(bb.minimum);\r\n min.multiplyInPlace(this.transformNode.scaling);\r\n\r\n if (!this._options.center) {\r\n const center = new Vector3();\r\n center.copyFrom(bb.center);\r\n center.multiplyInPlace(this.transformNode.scaling);\r\n this._options.center = center;\r\n }\r\n\r\n switch (this.type) {\r\n case PhysicsShapeType.SPHERE:\r\n if (!this._options.radius && Scalar.WithinEpsilon(extents.x, extents.y, 0.0001) && Scalar.WithinEpsilon(extents.x, extents.z, 0.0001)) {\r\n this._options.radius = extents.x / 2;\r\n } else if (!this._options.radius) {\r\n Logger.Warn(\"Non uniform scaling is unsupported for sphere shapes. Setting the radius to the biggest bounding box extent.\");\r\n this._options.radius = Math.max(extents.x, extents.y, extents.z) / 2;\r\n }\r\n break;\r\n case PhysicsShapeType.CAPSULE:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y + capRadius, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y - capRadius, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.CYLINDER:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.MESH:\r\n case PhysicsShapeType.CONVEX_HULL:\r\n if (!this._options.mesh && this._hasVertices(this.transformNode)) {\r\n this._options.mesh = this.transformNode as Mesh;\r\n } else if (!this._options.mesh || !this._hasVertices(this._options.mesh)) {\r\n throw new Error(\r\n \"No valid mesh was provided for mesh or convex hull shape parameter. Please provide a mesh with valid geometry (number of vertices greater than 0).\"\r\n );\r\n }\r\n break;\r\n case PhysicsShapeType.BOX:\r\n this._options.extents = this._options.extents ?? new Vector3(extents.x, extents.y, extents.z);\r\n this._options.rotation = this._options.rotation ?? Quaternion.Identity();\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Releases the body, shape and material\r\n */\r\n public dispose(): void {\r\n if (this._nodeDisposeObserver) {\r\n this.body.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this.body.dispose();\r\n if (this._disposeShapeWhenDisposed) {\r\n this.shape.dispose();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsAggregate.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM7E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAkExD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAoBzB;IACI;;OAEG;IACI,aAA4B;IACnC;;OAEG;IACI,IAAqC,EACpC,WAAuC,EAAE,IAAI,EAAE,CAAC,EAAE,EAClD,MAAc;QANf,kBAAa,GAAb,aAAa,CAAe;QAI5B,SAAI,GAAJ,IAAI,CAAiC;QACpC,aAAQ,GAAR,QAAQ,CAA0C;QAClD,WAAM,GAAN,MAAM,CAAQ;QAdlB,8BAAyB,GAAG,IAAI,CAAC;QAgBrC,eAAe;QACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACrB,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;YACvE,OAAO;SACV;QACD,MAAM,CAAC,GAAG,aAAqB,CAAC;QA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AQ,CAAC,OAAO,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC9F,IAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACzE,MAAM;SACb;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC3B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAC9E,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;SACpC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,yBAAyB,EAAE;YAChC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;SACxB;IACL,CAAC;CACJ","sourcesContent":["import { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { PhysicsShape } from \"./physicsShape\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Quaternion, TmpVectors, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { PhysicsMotionType, PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Node } from \"../../node\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * The interface for the physics aggregate parameters\r\n */\r\nexport interface PhysicsAggregateParameters {\r\n /**\r\n * The mass of the physics aggregate\r\n */\r\n mass: number;\r\n\r\n /**\r\n * The friction of the physics aggregate\r\n */\r\n friction?: number;\r\n\r\n /**\r\n * The coefficient of restitution of the physics aggregate\r\n */\r\n restitution?: number;\r\n\r\n /**\r\n * Radius for sphere, cylinder and capsule\r\n */\r\n radius?: number;\r\n\r\n /**\r\n * Starting point for cylinder/capsule\r\n */\r\n pointA?: Vector3;\r\n\r\n /**\r\n * Ending point for cylinder/capsule\r\n */\r\n pointB?: Vector3;\r\n\r\n /**\r\n * Extents for box\r\n */\r\n extents?: Vector3;\r\n\r\n /**\r\n * Orientation for box\r\n */\r\n rotation?: Quaternion;\r\n\r\n /**\r\n * mesh local center\r\n */\r\n center?: Vector3;\r\n\r\n /**\r\n * mesh object. Used for mesh and convex hull aggregates.\r\n */\r\n mesh?: Mesh;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n startAsleep?: boolean;\r\n\r\n /**\r\n * If true, mark the created shape as a trigger shape\r\n */\r\n isTriggerShape?: boolean;\r\n}\r\n/**\r\n * Helper class to create and interact with a PhysicsAggregate.\r\n * This is a transition object that works like Physics Plugin V1 Impostors.\r\n * This helper instanciate all mandatory physics objects to get a body/shape and material.\r\n * It's less efficient that handling body and shapes independently but for prototyping or\r\n * a small numbers of physics objects, it's good enough.\r\n */\r\nexport class PhysicsAggregate {\r\n /**\r\n * The body that is associated with this aggregate\r\n */\r\n public body: PhysicsBody;\r\n\r\n /**\r\n * The shape that is associated with this aggregate\r\n */\r\n public shape: PhysicsShape;\r\n\r\n /**\r\n * The material that is associated with this aggregate\r\n */\r\n public material: PhysicsMaterial;\r\n\r\n private _disposeShapeWhenDisposed = true;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics aggregate\r\n */\r\n public transformNode: TransformNode,\r\n /**\r\n * The type of the physics aggregate\r\n */\r\n public type: PhysicsShapeType | PhysicsShape,\r\n private _options: PhysicsAggregateParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.transformNode) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n const m = transformNode as Mesh;\r\n if (this.transformNode.parent && this._options.mass !== 0 && m.hasThinInstances) {\r\n Logger.Warn(\r\n \"A physics body has been created for an object which has a parent and thin instances. Babylon physics currently works in local space so unexpected issues may occur.\"\r\n );\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && transformNode.getScene) {\r\n this._scene = transformNode.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n\r\n const motionType = this._options.mass === 0 ? PhysicsMotionType.STATIC : PhysicsMotionType.DYNAMIC;\r\n const startAsleep = this._options.startAsleep ?? false;\r\n this.body = new PhysicsBody(transformNode, motionType, startAsleep, this._scene);\r\n this._addSizeOptions();\r\n if ((type as any).getClassName && (type as any).getClassName() === \"PhysicsShape\") {\r\n this.shape = type as PhysicsShape;\r\n this._disposeShapeWhenDisposed = false;\r\n } else {\r\n this.shape = new PhysicsShape({ type: type as PhysicsShapeType, parameters: this._options as any }, this._scene);\r\n }\r\n\r\n if (this._options.isTriggerShape) {\r\n this.shape.isTrigger = true;\r\n }\r\n\r\n this.material = { friction: this._options.friction, restitution: this._options.restitution };\r\n this.body.shape = this.shape;\r\n this.shape.material = this.material;\r\n\r\n this.body.setMassProperties({ mass: this._options.mass });\r\n\r\n this._nodeDisposeObserver = this.transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n private _getObjectBoundingBox() {\r\n if ((this.transformNode as AbstractMesh).getRawBoundingInfo) {\r\n return (this.transformNode as AbstractMesh).getRawBoundingInfo().boundingBox;\r\n } else {\r\n return new BoundingBox(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));\r\n }\r\n }\r\n\r\n private _hasVertices(node: TransformNode): boolean {\r\n return (node as any)?.getTotalVertices() > 0;\r\n }\r\n\r\n private _addSizeOptions(): void {\r\n this.transformNode.computeWorldMatrix(true);\r\n const bb = this._getObjectBoundingBox();\r\n const extents = TmpVectors.Vector3[0];\r\n extents.copyFrom(bb.extendSize);\r\n extents.scaleInPlace(2);\r\n extents.multiplyInPlace(this.transformNode.scaling);\r\n // In case we had any negative scaling, we need to take the absolute value of the extents.\r\n extents.x = Math.abs(extents.x);\r\n extents.y = Math.abs(extents.y);\r\n extents.z = Math.abs(extents.z);\r\n\r\n const min = TmpVectors.Vector3[1];\r\n min.copyFrom(bb.minimum);\r\n min.multiplyInPlace(this.transformNode.scaling);\r\n\r\n if (!this._options.center) {\r\n const center = new Vector3();\r\n center.copyFrom(bb.center);\r\n center.multiplyInPlace(this.transformNode.scaling);\r\n this._options.center = center;\r\n }\r\n\r\n switch (this.type) {\r\n case PhysicsShapeType.SPHERE:\r\n if (!this._options.radius && Scalar.WithinEpsilon(extents.x, extents.y, 0.0001) && Scalar.WithinEpsilon(extents.x, extents.z, 0.0001)) {\r\n this._options.radius = extents.x / 2;\r\n } else if (!this._options.radius) {\r\n Logger.Warn(\"Non uniform scaling is unsupported for sphere shapes. Setting the radius to the biggest bounding box extent.\");\r\n this._options.radius = Math.max(extents.x, extents.y, extents.z) / 2;\r\n }\r\n break;\r\n case PhysicsShapeType.CAPSULE:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y + capRadius, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y - capRadius, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.CYLINDER:\r\n {\r\n const capRadius = extents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, min.y, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, min.y + extents.y, 0);\r\n }\r\n break;\r\n case PhysicsShapeType.MESH:\r\n case PhysicsShapeType.CONVEX_HULL:\r\n if (!this._options.mesh && this._hasVertices(this.transformNode)) {\r\n this._options.mesh = this.transformNode as Mesh;\r\n } else if (!this._options.mesh || !this._hasVertices(this._options.mesh)) {\r\n throw new Error(\r\n \"No valid mesh was provided for mesh or convex hull shape parameter. Please provide a mesh with valid geometry (number of vertices greater than 0).\"\r\n );\r\n }\r\n break;\r\n case PhysicsShapeType.BOX:\r\n this._options.extents = this._options.extents ?? new Vector3(extents.x, extents.y, extents.z);\r\n this._options.rotation = this._options.rotation ?? Quaternion.Identity();\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Releases the body, shape and material\r\n */\r\n public dispose(): void {\r\n if (this._nodeDisposeObserver) {\r\n this.body.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this.body.dispose();\r\n if (this._disposeShapeWhenDisposed) {\r\n this.shape.dispose();\r\n }\r\n }\r\n}\r\n"]}
@@ -434,8 +434,7 @@ export class PhysicsBody {
434
434
  * @returns geometric center of the associated mesh
435
435
  */
436
436
  getObjectCenterWorldToRef(ref, instanceIndex) {
437
- var _a;
438
- if (((_a = this._pluginDataInstances) === null || _a === void 0 ? void 0 : _a.length) > 0) {
437
+ if (this._pluginDataInstances?.length > 0) {
439
438
  const index = instanceIndex || 0;
440
439
  const matrixData = this.transformNode._thinInstanceDataStorage.matrixData;
441
440
  if (matrixData) {
@@ -505,8 +504,7 @@ export class PhysicsBody {
505
504
  * @param callback the callback to execute
506
505
  */
507
506
  iterateOverAllInstances(callback) {
508
- var _a;
509
- if (((_a = this._pluginDataInstances) === null || _a === void 0 ? void 0 : _a.length) > 0) {
507
+ if (this._pluginDataInstances?.length > 0) {
510
508
  for (let i = 0; i < this._pluginDataInstances.length; i++) {
511
509
  callback(this, i);
512
510
  }
@@ -1 +1 @@
1
- {"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1E,OAAO,EAAE,KAAK,EAAE,iCAA6B;AAO7C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAgDpB;;;;;;;;;;;;;OAaG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,YAAqB,EAAE,KAAY;QA7D5G;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;WAEG;QACK,wBAAmB,GAAY,KAAK,CAAC;QAC7C;;WAEG;QACK,6BAAwB,GAAY,KAAK,CAAC;QAKlD;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QASvB,gBAAW,GAAG,KAAK,CAAC;QAEpB,WAAM,GAA2B,IAAI,CAAC;QAmB1C,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAC9D,IAAI,CAAC,aAAa,CAAC,kBAA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Ac,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _motionType: PhysicsMotionType;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n this._motionType = motionType;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._motionType;\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @returns\r\n */\r\n public getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"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AC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _motionType: PhysicsMotionType;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n this._motionType = motionType;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._motionType;\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @returns\r\n */\r\n public getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
@@ -20,7 +20,6 @@ export class PhysicsShape {
20
20
  * If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.
21
21
  */
22
22
  constructor(options, scene) {
23
- var _a;
24
23
  /**
25
24
  * V2 Physics plugin private data for single shape
26
25
  */
@@ -48,7 +47,7 @@ export class PhysicsShape {
48
47
  }
49
48
  else if (options.type !== undefined && options.type !== null) {
50
49
  this._type = options.type;
51
- const parameters = (_a = options.parameters) !== null && _a !== void 0 ? _a : {};
50
+ const parameters = options.parameters ?? {};
52
51
  this._physicsPlugin.initShape(this, options.type, parameters);
53
52
  }
54
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsShape.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAuBlF;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAkBrB;;;;;;;;;;;;OAYG;IACH,YAAY,OAA2B,EAAE,KAAY;;QA9BrD;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAU5B,eAAU,GAAY,KAAK,CAAC;QAE5B,gBAAW,GAAG,KAAK,CAAC;QAgBxB,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAE9D,IAAI,OAA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AE,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,YAAY;IACnD;;;OAGG;IACH,YAAY,KAAY;QACpB,KAAK,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACJ","sourcesContent":["import type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { Matrix, Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\n\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Options for creating a physics shape\r\n */\r\nexport interface PhysicShapeOptions {\r\n /**\r\n * The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n */\r\n type?: PhysicsShapeType;\r\n /**\r\n * The parameters of the shape. Varies depending of the shape type.\r\n */\r\n parameters?: PhysicsShapeParameters;\r\n /**\r\n * Reference to an already existing physics shape in the plugin.\r\n */\r\n pluginData?: any;\r\n}\r\n\r\n/**\r\n * PhysicsShape class.\r\n * This class is useful for creating a physics shape that can be used in a physics engine.\r\n * A Physic Shape determine how collision are computed. It must be attached to a body.\r\n */\r\nexport class PhysicsShape {\r\n /**\r\n * V2 Physics plugin private data for single shape\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n private _type: PhysicsShapeType;\r\n\r\n private _material: PhysicsMaterial;\r\n\r\n private _isTrigger: boolean = false;\r\n\r\n private _isDisposed = false;\r\n\r\n /**\r\n * Constructs a new physics shape.\r\n * @param options The options for the physics shape. These are:\r\n * * type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n * * parameters: The parameters of the shape.\r\n * * pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side.\r\n * You need to specify either type or pluginData.\r\n * @param scene The scene the shape belongs to.\r\n *\r\n * This code is useful for creating a new physics shape with the given type, options, and scene.\r\n * It also checks that the physics engine and plugin version are correct.\r\n * If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.\r\n */\r\n constructor(options: PhysicShapeOptions, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n\r\n if (options.pluginData !== undefined && options.pluginData !== null) {\r\n this._pluginData = options.pluginData;\r\n this._type = this._physicsPlugin.getShapeType(this);\r\n } else if (options.type !== undefined && options.type !== null) {\r\n this._type = options.type;\r\n const parameters = options.parameters ?? {};\r\n this._physicsPlugin.initShape(this, options.type, parameters);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsShape\".\r\n * @returns \"PhysicsShape\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsShape\";\r\n }\r\n\r\n /**\r\n * Returns the type of the physics shape.\r\n * @returns The type of the physics shape.\r\n */\r\n public get type(): PhysicsShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Set the membership mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which the shape is a member. This is used in combination\r\n * with the collide mask to determine if this shape should collide with\r\n * another.\r\n *\r\n * @param membershipMask Bitfield of categories of this shape.\r\n */\r\n public set filterMembershipMask(membershipMask: number) {\r\n this._physicsPlugin.setShapeFilterMembershipMask(this, membershipMask);\r\n }\r\n\r\n /**\r\n * Get the membership mask of a shape.\r\n * @returns Bitmask of categories which this shape is a member of.\r\n */\r\n public get filterMembershipMask(): number {\r\n return this._physicsPlugin.getShapeFilterMembershipMask(this);\r\n }\r\n\r\n /**\r\n * Sets the collide mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which this shape collides with. Given two shapes,\r\n * the engine will check if the collide mask and membership overlap:\r\n * shapeA.filterMembershipMask & shapeB.filterCollideMask\r\n *\r\n * If this value is zero (i.e. shapeB only collides with categories\r\n * which shapeA is _not_ a member of) then the shapes will not collide.\r\n *\r\n * Note, the engine will also perform the same test with shapeA and\r\n * shapeB swapped; the shapes will not collide if either shape has\r\n * a collideMask which prevents collision with the other shape.\r\n *\r\n * @param collideMask Bitmask of categories this shape should collide with\r\n */\r\n public set filterCollideMask(collideMask: number) {\r\n this._physicsPlugin.setShapeFilterCollideMask(this, collideMask);\r\n }\r\n\r\n /**\r\n *\r\n * @returns Bitmask of categories that this shape should collide with\r\n */\r\n public get filterCollideMask(): number {\r\n return this._physicsPlugin.getShapeFilterCollideMask(this);\r\n }\r\n /**\r\n *\r\n * @param material\r\n */\r\n public set material(material: PhysicsMaterial) {\r\n this._physicsPlugin.setMaterial(this, material);\r\n this._material = material;\r\n }\r\n\r\n /**\r\n * Returns the material of the physics shape.\r\n * @returns The material of the physics shape.\r\n */\r\n public get material(): PhysicsMaterial {\r\n if (!this._material) {\r\n this._material = this._physicsPlugin.getMaterial(this);\r\n }\r\n return this._material;\r\n }\r\n\r\n /**\r\n * Sets the density of the physics shape.\r\n * @param density The density of the physics shape.\r\n */\r\n public set density(density: number) {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n * Returns the density of the physics shape.\r\n * @returns The density of the physics shape.\r\n */\r\n public get density(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n * Utility to add a child shape to this container,\r\n * automatically computing the relative transform between\r\n * the container shape and the child instance.\r\n *\r\n * @param parentTransform The transform node associated with this shape\r\n * @param newChild The new PhysicsShape to add\r\n * @param childTransform The transform node associated with the child shape\r\n */\r\n public addChildFromParent(parentTransform: TransformNode, newChild: PhysicsShape, childTransform: TransformNode): void {\r\n const childToWorld = childTransform.computeWorldMatrix(true);\r\n const parentToWorld = parentTransform.computeWorldMatrix(true);\r\n const childToParent = TmpVectors.Matrix[0];\r\n childToWorld.multiplyToRef(Matrix.Invert(parentToWorld), childToParent);\r\n const translation = TmpVectors.Vector3[0];\r\n const rotation = TmpVectors.Quaternion[0];\r\n const scale = TmpVectors.Vector3[1];\r\n childToParent.decompose(scale, rotation, translation);\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Adds a child shape to a container with an optional transform\r\n * @param newChild The new PhysicsShape to add\r\n * @param translation Optional position of the child shape relative to this shape\r\n * @param rotation Optional rotation of the child shape relative to this shape\r\n * @param scale Optional scale of the child shape relative to this shape\r\n */\r\n public addChild(newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void {\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Removes a child shape from this shape.\r\n * @param childIndex The index of the child shape to remove\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n * Returns the number of children of a physics shape.\r\n * @returns The number of children of a physics shape.\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics shape.\r\n * @returns The bounding box of the physics shape.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n public set isTrigger(isTrigger: boolean) {\r\n if (this._isTrigger === isTrigger) {\r\n return;\r\n }\r\n this._isTrigger = isTrigger;\r\n this._physicsPlugin.setTrigger(this, isTrigger);\r\n }\r\n\r\n public get isTrigger(): boolean {\r\n return this._isTrigger;\r\n }\r\n\r\n /**\r\n * Dispose the shape and release its associated resources.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n this._physicsPlugin.disposeShape(this);\r\n this._isDisposed = true;\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a sphere shape\r\n */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /**\r\n * Constructor for the Sphere Shape\r\n * @param center local center of the sphere\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate sphere from the mesh.\r\n * @param mesh node from which to derive the sphere shape\r\n * @returns PhysicsShapeSphere\r\n */\r\n static FromMesh(mesh: AbstractMesh) {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingSphere.center;\r\n const he = bounds.boundingBox.extendSize;\r\n const radius = Math.max(he.x, he.y, he.z);\r\n return new PhysicsShapeSphere(centerLocal, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a capsule shape\r\n */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the capsule segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate capsule from the mesh. Note, this is\r\n * not the optimal bounding capsule.\r\n * @param mesh Node from which to derive a cylinder shape\r\n * @returns Physics Shape Capsule\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCapsule {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y - radius, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCapsule(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a cylinder shape\r\n */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the cylinder segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate cylinder from the mesh. Note, this is\r\n * not the optimal bounding cylinder.\r\n * @param mesh Node from which to derive a cylinder shape\r\n * @returns Physics Shape Cylinder\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCylinder {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCylinder(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a box shape\r\n */\r\nexport class PhysicsShapeBox extends PhysicsShape {\r\n /**\r\n *\r\n * @param center local center of the box\r\n * @param rotation local orientation\r\n * @param extents size of the box in each direction\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super({ type: PhysicsShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeBox\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeBox {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingBox.center;\r\n const extents = bounds.boundingBox.extendSize.scale(2.0); //<todo.eoin extendSize seems to really be half-extents?\r\n return new PhysicsShapeBox(centerLocal, Quaternion.Identity(), extents, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a convex hull shape\r\n */\r\nexport class PhysicsShapeConvexHull extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh to be used as topology infos for the convex hull\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a mesh shape\r\n */\r\nexport class PhysicsShapeMesh extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh topology that will be used to create the shape\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.MESH, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * A shape container holds a variable number of shapes. Use AddChild to append to newly created parent container.\r\n */\r\nexport class PhysicsShapeContainer extends PhysicsShape {\r\n /**\r\n * Constructor of the Shape container\r\n * @param scene scene to attach to\r\n */\r\n constructor(scene: Scene) {\r\n super({ type: PhysicsShapeType.CONTAINER, parameters: {} }, scene);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsShape.js","sourceRoot":"","sources":["../../../../../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import type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport { PhysicsShapeType } from \"./IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePluginV2, PhysicsShapeParameters } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { Matrix, Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\n\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Options for creating a physics shape\r\n */\r\nexport interface PhysicShapeOptions {\r\n /**\r\n * The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n */\r\n type?: PhysicsShapeType;\r\n /**\r\n * The parameters of the shape. Varies depending of the shape type.\r\n */\r\n parameters?: PhysicsShapeParameters;\r\n /**\r\n * Reference to an already existing physics shape in the plugin.\r\n */\r\n pluginData?: any;\r\n}\r\n\r\n/**\r\n * PhysicsShape class.\r\n * This class is useful for creating a physics shape that can be used in a physics engine.\r\n * A Physic Shape determine how collision are computed. It must be attached to a body.\r\n */\r\nexport class PhysicsShape {\r\n /**\r\n * V2 Physics plugin private data for single shape\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n private _type: PhysicsShapeType;\r\n\r\n private _material: PhysicsMaterial;\r\n\r\n private _isTrigger: boolean = false;\r\n\r\n private _isDisposed = false;\r\n\r\n /**\r\n * Constructs a new physics shape.\r\n * @param options The options for the physics shape. These are:\r\n * * type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER\r\n * * parameters: The parameters of the shape.\r\n * * pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side.\r\n * You need to specify either type or pluginData.\r\n * @param scene The scene the shape belongs to.\r\n *\r\n * This code is useful for creating a new physics shape with the given type, options, and scene.\r\n * It also checks that the physics engine and plugin version are correct.\r\n * If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.\r\n */\r\n constructor(options: PhysicShapeOptions, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n\r\n if (options.pluginData !== undefined && options.pluginData !== null) {\r\n this._pluginData = options.pluginData;\r\n this._type = this._physicsPlugin.getShapeType(this);\r\n } else if (options.type !== undefined && options.type !== null) {\r\n this._type = options.type;\r\n const parameters = options.parameters ?? {};\r\n this._physicsPlugin.initShape(this, options.type, parameters);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsShape\".\r\n * @returns \"PhysicsShape\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsShape\";\r\n }\r\n\r\n /**\r\n * Returns the type of the physics shape.\r\n * @returns The type of the physics shape.\r\n */\r\n public get type(): PhysicsShapeType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Set the membership mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which the shape is a member. This is used in combination\r\n * with the collide mask to determine if this shape should collide with\r\n * another.\r\n *\r\n * @param membershipMask Bitfield of categories of this shape.\r\n */\r\n public set filterMembershipMask(membershipMask: number) {\r\n this._physicsPlugin.setShapeFilterMembershipMask(this, membershipMask);\r\n }\r\n\r\n /**\r\n * Get the membership mask of a shape.\r\n * @returns Bitmask of categories which this shape is a member of.\r\n */\r\n public get filterMembershipMask(): number {\r\n return this._physicsPlugin.getShapeFilterMembershipMask(this);\r\n }\r\n\r\n /**\r\n * Sets the collide mask of a shape. This is a bitfield of arbitrary\r\n * \"categories\" to which this shape collides with. Given two shapes,\r\n * the engine will check if the collide mask and membership overlap:\r\n * shapeA.filterMembershipMask & shapeB.filterCollideMask\r\n *\r\n * If this value is zero (i.e. shapeB only collides with categories\r\n * which shapeA is _not_ a member of) then the shapes will not collide.\r\n *\r\n * Note, the engine will also perform the same test with shapeA and\r\n * shapeB swapped; the shapes will not collide if either shape has\r\n * a collideMask which prevents collision with the other shape.\r\n *\r\n * @param collideMask Bitmask of categories this shape should collide with\r\n */\r\n public set filterCollideMask(collideMask: number) {\r\n this._physicsPlugin.setShapeFilterCollideMask(this, collideMask);\r\n }\r\n\r\n /**\r\n *\r\n * @returns Bitmask of categories that this shape should collide with\r\n */\r\n public get filterCollideMask(): number {\r\n return this._physicsPlugin.getShapeFilterCollideMask(this);\r\n }\r\n /**\r\n *\r\n * @param material\r\n */\r\n public set material(material: PhysicsMaterial) {\r\n this._physicsPlugin.setMaterial(this, material);\r\n this._material = material;\r\n }\r\n\r\n /**\r\n * Returns the material of the physics shape.\r\n * @returns The material of the physics shape.\r\n */\r\n public get material(): PhysicsMaterial {\r\n if (!this._material) {\r\n this._material = this._physicsPlugin.getMaterial(this);\r\n }\r\n return this._material;\r\n }\r\n\r\n /**\r\n * Sets the density of the physics shape.\r\n * @param density The density of the physics shape.\r\n */\r\n public set density(density: number) {\r\n this._physicsPlugin.setDensity(this, density);\r\n }\r\n\r\n /**\r\n * Returns the density of the physics shape.\r\n * @returns The density of the physics shape.\r\n */\r\n public get density(): number {\r\n return this._physicsPlugin.getDensity(this);\r\n }\r\n\r\n /**\r\n * Utility to add a child shape to this container,\r\n * automatically computing the relative transform between\r\n * the container shape and the child instance.\r\n *\r\n * @param parentTransform The transform node associated with this shape\r\n * @param newChild The new PhysicsShape to add\r\n * @param childTransform The transform node associated with the child shape\r\n */\r\n public addChildFromParent(parentTransform: TransformNode, newChild: PhysicsShape, childTransform: TransformNode): void {\r\n const childToWorld = childTransform.computeWorldMatrix(true);\r\n const parentToWorld = parentTransform.computeWorldMatrix(true);\r\n const childToParent = TmpVectors.Matrix[0];\r\n childToWorld.multiplyToRef(Matrix.Invert(parentToWorld), childToParent);\r\n const translation = TmpVectors.Vector3[0];\r\n const rotation = TmpVectors.Quaternion[0];\r\n const scale = TmpVectors.Vector3[1];\r\n childToParent.decompose(scale, rotation, translation);\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Adds a child shape to a container with an optional transform\r\n * @param newChild The new PhysicsShape to add\r\n * @param translation Optional position of the child shape relative to this shape\r\n * @param rotation Optional rotation of the child shape relative to this shape\r\n * @param scale Optional scale of the child shape relative to this shape\r\n */\r\n public addChild(newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void {\r\n this._physicsPlugin.addChild(this, newChild, translation, rotation, scale);\r\n }\r\n\r\n /**\r\n * Removes a child shape from this shape.\r\n * @param childIndex The index of the child shape to remove\r\n */\r\n public removeChild(childIndex: number): void {\r\n this._physicsPlugin.removeChild(this, childIndex);\r\n }\r\n\r\n /**\r\n * Returns the number of children of a physics shape.\r\n * @returns The number of children of a physics shape.\r\n */\r\n public getNumChildren(): number {\r\n return this._physicsPlugin.getNumChildren(this);\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics shape.\r\n * @returns The bounding box of the physics shape.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBoundingBox(this);\r\n }\r\n\r\n public set isTrigger(isTrigger: boolean) {\r\n if (this._isTrigger === isTrigger) {\r\n return;\r\n }\r\n this._isTrigger = isTrigger;\r\n this._physicsPlugin.setTrigger(this, isTrigger);\r\n }\r\n\r\n public get isTrigger(): boolean {\r\n return this._isTrigger;\r\n }\r\n\r\n /**\r\n * Dispose the shape and release its associated resources.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n this._physicsPlugin.disposeShape(this);\r\n this._isDisposed = true;\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a sphere shape\r\n */\r\nexport class PhysicsShapeSphere extends PhysicsShape {\r\n /**\r\n * Constructor for the Sphere Shape\r\n * @param center local center of the sphere\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.SPHERE, parameters: { center: center, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate sphere from the mesh.\r\n * @param mesh node from which to derive the sphere shape\r\n * @returns PhysicsShapeSphere\r\n */\r\n static FromMesh(mesh: AbstractMesh) {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingSphere.center;\r\n const he = bounds.boundingBox.extendSize;\r\n const radius = Math.max(he.x, he.y, he.z);\r\n return new PhysicsShapeSphere(centerLocal, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a capsule shape\r\n */\r\nexport class PhysicsShapeCapsule extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the capsule segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CAPSULE, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate capsule from the mesh. Note, this is\r\n * not the optimal bounding capsule.\r\n * @param mesh Node from which to derive a cylinder shape\r\n * @returns Physics Shape Capsule\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCapsule {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y - radius, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCapsule(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a cylinder shape\r\n */\r\nexport class PhysicsShapeCylinder extends PhysicsShape {\r\n /**\r\n *\r\n * @param pointA Starting point that defines the cylinder segment\r\n * @param pointB ending point of that same segment\r\n * @param radius radius\r\n * @param scene scene to attach to\r\n */\r\n constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene) {\r\n super({ type: PhysicsShapeType.CYLINDER, parameters: { pointA: pointA, pointB: pointB, radius: radius } }, scene);\r\n }\r\n\r\n /**\r\n * Derive an approximate cylinder from the mesh. Note, this is\r\n * not the optimal bounding cylinder.\r\n * @param mesh Node from which to derive a cylinder shape\r\n * @returns Physics Shape Cylinder\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeCylinder {\r\n const boundsLocal = mesh.getBoundingInfo();\r\n const radius = boundsLocal.boundingBox.extendSize.x;\r\n const pointFromCenter = new Vector3(0, boundsLocal.boundingBox.extendSize.y, 0);\r\n const pointA = boundsLocal.boundingBox.center.add(pointFromCenter);\r\n const pointB = boundsLocal.boundingBox.center.subtract(pointFromCenter);\r\n return new PhysicsShapeCylinder(pointA, pointB, radius, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a box shape\r\n */\r\nexport class PhysicsShapeBox extends PhysicsShape {\r\n /**\r\n *\r\n * @param center local center of the box\r\n * @param rotation local orientation\r\n * @param extents size of the box in each direction\r\n * @param scene scene to attach to\r\n */\r\n constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene) {\r\n super({ type: PhysicsShapeType.BOX, parameters: { center: center, rotation: rotation, extents: extents } }, scene);\r\n }\r\n\r\n /**\r\n *\r\n * @param mesh\r\n * @returns PhysicsShapeBox\r\n */\r\n static FromMesh(mesh: AbstractMesh): PhysicsShapeBox {\r\n const bounds = mesh.getBoundingInfo();\r\n const centerLocal = bounds.boundingBox.center;\r\n const extents = bounds.boundingBox.extendSize.scale(2.0); //<todo.eoin extendSize seems to really be half-extents?\r\n return new PhysicsShapeBox(centerLocal, Quaternion.Identity(), extents, mesh.getScene());\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a convex hull shape\r\n */\r\nexport class PhysicsShapeConvexHull extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh to be used as topology infos for the convex hull\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.CONVEX_HULL, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Helper object to create a mesh shape\r\n */\r\nexport class PhysicsShapeMesh extends PhysicsShape {\r\n /**\r\n *\r\n * @param mesh the mesh topology that will be used to create the shape\r\n * @param scene scene to attach to\r\n */\r\n constructor(mesh: Mesh, scene: Scene) {\r\n super({ type: PhysicsShapeType.MESH, parameters: { mesh: mesh } }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * A shape container holds a variable number of shapes. Use AddChild to append to newly created parent container.\r\n */\r\nexport class PhysicsShapeContainer extends PhysicsShape {\r\n /**\r\n * Constructor of the Shape container\r\n * @param scene scene to attach to\r\n */\r\n constructor(scene: Scene) {\r\n super({ type: PhysicsShapeType.CONTAINER, parameters: {} }, scene);\r\n }\r\n}\r\n"]}
@@ -52,7 +52,6 @@ export class Ragdoll {
52
52
  this._boneOffsetAxis = Axis.Y;
53
53
  }
54
54
  _createColliders() {
55
- var _a, _b, _c;
56
55
  this._mesh.computeWorldMatrix();
57
56
  const config = this._config;
58
57
  for (let i = 0; i < config.length; i++) {
@@ -69,9 +68,9 @@ export class Ragdoll {
69
68
  height: this._config[i].height,
70
69
  size: this._config[i].size,
71
70
  };
72
- currentRagdollBoneProperties.width = (_a = currentRagdollBoneProperties.width) !== null && _a !== void 0 ? _a : currentRagdollBoneProperties.size;
73
- currentRagdollBoneProperties.depth = (_b = currentRagdollBoneProperties.depth) !== null && _b !== void 0 ? _b : currentRagdollBoneProperties.size;
74
- currentRagdollBoneProperties.height = (_c = currentRagdollBoneProperties.height) !== null && _c !== void 0 ? _c : currentRagdollBoneProperties.size;
71
+ currentRagdollBoneProperties.width = currentRagdollBoneProperties.width ?? currentRagdollBoneProperties.size;
72
+ currentRagdollBoneProperties.depth = currentRagdollBoneProperties.depth ?? currentRagdollBoneProperties.size;
73
+ currentRagdollBoneProperties.height = currentRagdollBoneProperties.height ?? currentRagdollBoneProperties.size;
75
74
  const transform = new TransformNode(boneNames[ii] + "_transform", this._scene);
76
75
  // Define the rest of the box properties.
77
76
  currentRagdollBoneProperties.joint = config[i].joint !== undefined ? config[i].joint : this._defaultJoint;
@@ -160,10 +159,9 @@ export class Ragdoll {
160
159
  }
161
160
  }
162
161
  _addImpostorRotationToBone(boneIndex) {
163
- var _a, _b, _c;
164
- const qmesh = (_a = this._mesh.rotationQuaternion) !== null && _a !== void 0 ? _a : Quaternion.FromEulerAngles(this._mesh.rotation.x, this._mesh.rotation.y, this._mesh.rotation.z);
162
+ const qmesh = this._mesh.rotationQuaternion ?? Quaternion.FromEulerAngles(this._mesh.rotation.x, this._mesh.rotation.y, this._mesh.rotation.z);
165
163
  const qbind = this._initialRotation[boneIndex];
166
- const qphys = (_c = (_b = this._aggregates[boneIndex].body) === null || _b === void 0 ? void 0 : _b.transformNode) === null || _c === void 0 ? void 0 : _c.rotationQuaternion;
164
+ const qphys = this._aggregates[boneIndex].body?.transformNode?.rotationQuaternion;
167
165
  // TmpVectors.Quaternion[1] = mesh.rotation * this._initialRotation[boneIndex]
168
166
  // TmpVectors.Quaternion[0] = body.rotation * TmpVectors.Quaternion[1]
169
167
  qmesh.multiplyToRef(qbind, TmpVectors.Quaternion[1]);
@@ -191,7 +189,7 @@ export class Ragdoll {
191
189
  if (nearestParent != null && this._boneNames.includes(nearestParent.name)) {
192
190
  break;
193
191
  }
194
- nearestParent = nearestParent === null || nearestParent === void 0 ? void 0 : nearestParent.getParent();
192
+ nearestParent = nearestParent?.getParent();
195
193
  } while (nearestParent != null);
196
194
  return nearestParent;
197
195
  }