@babylonjs/core 5.45.2 → 5.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (563) hide show
  1. package/Actions/actionManager.js +6 -1
  2. package/Actions/actionManager.js.map +1 -1
  3. package/Actions/condition.js +23 -23
  4. package/Actions/condition.js.map +1 -1
  5. package/Animations/animatable.js +48 -48
  6. package/Animations/animatable.js.map +1 -1
  7. package/Animations/animation.js +53 -53
  8. package/Animations/animation.js.map +1 -1
  9. package/Animations/animationGroup.js +53 -53
  10. package/Animations/animationGroup.js.map +1 -1
  11. package/Animations/runtimeAnimation.js +36 -36
  12. package/Animations/runtimeAnimation.js.map +1 -1
  13. package/Audio/audioEngine.js +14 -14
  14. package/Audio/audioEngine.js.map +1 -1
  15. package/Audio/audioSceneComponent.js +14 -14
  16. package/Audio/audioSceneComponent.js.map +1 -1
  17. package/Audio/sound.js +47 -47
  18. package/Audio/sound.js.map +1 -1
  19. package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +1 -1
  20. package/Behaviors/Meshes/fadeInOutBehavior.js +11 -11
  21. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  22. package/Behaviors/Meshes/pointerDragBehavior.js +34 -34
  23. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  24. package/Bones/bone.js +15 -15
  25. package/Bones/bone.js.map +1 -1
  26. package/Bones/boneIKController.js +9 -9
  27. package/Bones/boneIKController.js.map +1 -1
  28. package/Bones/boneLookController.js +50 -50
  29. package/Bones/boneLookController.js.map +1 -1
  30. package/Bones/skeleton.js +35 -35
  31. package/Bones/skeleton.js.map +1 -1
  32. package/Buffers/buffer.js +14 -14
  33. package/Buffers/buffer.js.map +1 -1
  34. package/Buffers/dataBuffer.js +6 -6
  35. package/Buffers/dataBuffer.js.map +1 -1
  36. package/Cameras/Inputs/freeCameraDeviceOrientationInput.js +42 -42
  37. package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
  38. package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js +18 -18
  39. package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
  40. package/Cameras/VR/vrExperienceHelper.js +178 -178
  41. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  42. package/Cameras/arcRotateCamera.js +176 -176
  43. package/Cameras/arcRotateCamera.js.map +1 -1
  44. package/Cameras/camera.js +90 -90
  45. package/Cameras/camera.js.map +1 -1
  46. package/Cameras/flyCamera.js +82 -82
  47. package/Cameras/flyCamera.js.map +1 -1
  48. package/Cameras/freeCamera.js +54 -54
  49. package/Cameras/freeCamera.js.map +1 -1
  50. package/Compute/computeShader.js +12 -12
  51. package/Compute/computeShader.js.map +1 -1
  52. package/Culling/ray.d.ts +1 -1
  53. package/Debug/axesViewer.js +12 -12
  54. package/Debug/axesViewer.js.map +1 -1
  55. package/Debug/debugLayer.js +21 -21
  56. package/Debug/debugLayer.js.map +1 -1
  57. package/Debug/directionalLightFrustumViewer.js +20 -20
  58. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  59. package/Debug/physicsViewer.js +3 -3
  60. package/Debug/physicsViewer.js.map +1 -1
  61. package/Debug/rayHelper.js +10 -10
  62. package/Debug/rayHelper.js.map +1 -1
  63. package/Debug/skeletonViewer.js +81 -81
  64. package/Debug/skeletonViewer.js.map +1 -1
  65. package/DeviceInput/InputDevices/deviceSource.d.ts +1 -1
  66. package/DeviceInput/InputDevices/deviceSourceManager.js +31 -31
  67. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  68. package/DeviceInput/InputDevices/deviceTypes.d.ts +1 -1
  69. package/DeviceInput/eventFactory.d.ts +1 -1
  70. package/DeviceInput/eventFactory.js +4 -4
  71. package/DeviceInput/eventFactory.js.map +1 -1
  72. package/DeviceInput/internalDeviceSourceManager.d.ts +2 -2
  73. package/DeviceInput/webDeviceInputSystem.js +2 -2
  74. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  75. package/Engines/Extensions/engine.computeShader.d.ts +3 -3
  76. package/Engines/Extensions/engine.multiRender.js +1 -1
  77. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  78. package/Engines/Extensions/engine.query.d.ts +1 -1
  79. package/Engines/Extensions/engine.renderTarget.d.ts +1 -1
  80. package/Engines/Extensions/engine.renderTarget.js +1 -1
  81. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  82. package/Engines/Native/nativeDataStream.d.ts +1 -1
  83. package/Engines/Native/nativeHardwareTexture.js +3 -3
  84. package/Engines/Native/nativeHardwareTexture.js.map +1 -1
  85. package/Engines/Native/nativeInterfaces.d.ts +5 -5
  86. package/Engines/Native/nativePipelineContext.js +7 -7
  87. package/Engines/Native/nativePipelineContext.js.map +1 -1
  88. package/Engines/Native/nativeRenderTargetWrapper.js +6 -6
  89. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  90. package/Engines/Processors/shaderCodeInliner.js +4 -4
  91. package/Engines/Processors/shaderCodeInliner.js.map +1 -1
  92. package/Engines/Processors/shaderProcessingOptions.d.ts +1 -1
  93. package/Engines/WebGL/webGLHardwareTexture.js +3 -3
  94. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  95. package/Engines/WebGPU/webgpuBufferManager.js +3 -3
  96. package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
  97. package/Engines/WebGPU/webgpuCacheBindGroups.js +6 -6
  98. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  99. package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js +5 -5
  100. package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js.map +1 -1
  101. package/Engines/WebGPU/webgpuClearQuad.js +11 -11
  102. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  103. package/Engines/WebGPU/webgpuComputeContext.js +7 -7
  104. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  105. package/Engines/WebGPU/webgpuComputePipelineContext.js +4 -4
  106. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  107. package/Engines/WebGPU/webgpuDrawContext.js +7 -7
  108. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  109. package/Engines/WebGPU/webgpuHardwareTexture.js +9 -9
  110. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  111. package/Engines/WebGPU/webgpuMaterialContext.js +5 -5
  112. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  113. package/Engines/WebGPU/webgpuOcclusionQuery.js +10 -10
  114. package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
  115. package/Engines/WebGPU/webgpuPipelineContext.js +6 -6
  116. package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
  117. package/Engines/WebGPU/webgpuQuerySet.js +3 -3
  118. package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
  119. package/Engines/WebGPU/webgpuShaderProcessingContext.js +3 -3
  120. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  121. package/Engines/WebGPU/webgpuTextureHelper.js +3 -3
  122. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  123. package/Engines/WebGPU/webgpuTimestampQuery.js +3 -3
  124. package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
  125. package/Engines/engine.js +134 -134
  126. package/Engines/engine.js.map +1 -1
  127. package/Engines/nativeEngine.js +6 -6
  128. package/Engines/nativeEngine.js.map +1 -1
  129. package/Engines/nullEngine.js +25 -25
  130. package/Engines/nullEngine.js.map +1 -1
  131. package/Engines/renderTargetWrapper.js +25 -25
  132. package/Engines/renderTargetWrapper.js.map +1 -1
  133. package/Engines/thinEngine.js +243 -243
  134. package/Engines/thinEngine.js.map +1 -1
  135. package/Engines/webgpuEngine.js +132 -132
  136. package/Engines/webgpuEngine.js.map +1 -1
  137. package/Events/keyboardEvents.js +10 -10
  138. package/Events/keyboardEvents.js.map +1 -1
  139. package/Events/pointerEvents.js +10 -10
  140. package/Events/pointerEvents.js.map +1 -1
  141. package/Gamepads/Controllers/poseEnabledController.js +9 -9
  142. package/Gamepads/Controllers/poseEnabledController.js.map +1 -1
  143. package/Gamepads/Controllers/webVRController.js +13 -13
  144. package/Gamepads/Controllers/webVRController.js.map +1 -1
  145. package/Gamepads/gamepad.js +20 -20
  146. package/Gamepads/gamepad.js.map +1 -1
  147. package/Gizmos/axisDragGizmo.js +45 -45
  148. package/Gizmos/axisDragGizmo.js.map +1 -1
  149. package/Gizmos/axisScaleGizmo.js +12 -12
  150. package/Gizmos/axisScaleGizmo.js.map +1 -1
  151. package/Gizmos/boundingBoxGizmo.js +74 -74
  152. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  153. package/Gizmos/gizmo.js +34 -34
  154. package/Gizmos/gizmo.js.map +1 -1
  155. package/Gizmos/gizmoManager.js +40 -40
  156. package/Gizmos/gizmoManager.js.map +1 -1
  157. package/Gizmos/planeDragGizmo.js +23 -23
  158. package/Gizmos/planeDragGizmo.js.map +1 -1
  159. package/Gizmos/planeRotationGizmo.js +12 -12
  160. package/Gizmos/planeRotationGizmo.js.map +1 -1
  161. package/Gizmos/positionGizmo.js +40 -40
  162. package/Gizmos/positionGizmo.js.map +1 -1
  163. package/Gizmos/rotationGizmo.js +47 -47
  164. package/Gizmos/rotationGizmo.js.map +1 -1
  165. package/Gizmos/scaleGizmo.js +41 -41
  166. package/Gizmos/scaleGizmo.js.map +1 -1
  167. package/Helpers/environmentHelper.js +18 -18
  168. package/Helpers/environmentHelper.js.map +1 -1
  169. package/Helpers/textureDome.js +96 -96
  170. package/Helpers/textureDome.js.map +1 -1
  171. package/IAccessibilityTag.d.ts +2 -2
  172. package/Inputs/scene.inputManager.d.ts +4 -3
  173. package/Inputs/scene.inputManager.js +12 -11
  174. package/Inputs/scene.inputManager.js.map +1 -1
  175. package/Instrumentation/engineInstrumentation.js +21 -21
  176. package/Instrumentation/engineInstrumentation.js.map +1 -1
  177. package/Instrumentation/sceneInstrumentation.js +90 -90
  178. package/Instrumentation/sceneInstrumentation.js.map +1 -1
  179. package/Layers/effectLayer.js +48 -48
  180. package/Layers/effectLayer.js.map +1 -1
  181. package/Layers/glowLayer.js +32 -32
  182. package/Layers/glowLayer.js.map +1 -1
  183. package/Layers/highlightLayer.js +26 -26
  184. package/Layers/highlightLayer.js.map +1 -1
  185. package/Layers/layer.js +40 -40
  186. package/Layers/layer.js.map +1 -1
  187. package/LensFlares/lensFlare.js +15 -15
  188. package/LensFlares/lensFlare.js.map +1 -1
  189. package/LensFlares/lensFlareSystem.js +4 -4
  190. package/LensFlares/lensFlareSystem.js.map +1 -1
  191. package/Lights/Shadows/cascadedShadowGenerator.js +18 -18
  192. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  193. package/Lights/Shadows/shadowGenerator.js +115 -115
  194. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  195. package/Lights/directionalLight.js +31 -31
  196. package/Lights/directionalLight.js.map +1 -1
  197. package/Lights/light.js +72 -72
  198. package/Lights/light.js.map +1 -1
  199. package/Lights/pointLight.js +18 -18
  200. package/Lights/pointLight.js.map +1 -1
  201. package/Lights/spotLight.js +30 -30
  202. package/Lights/spotLight.js.map +1 -1
  203. package/Loading/sceneLoader.d.ts +1 -1
  204. package/Materials/Background/backgroundMaterial.js +124 -124
  205. package/Materials/Background/backgroundMaterial.js.map +1 -1
  206. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +8 -8
  207. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  208. package/Materials/Node/Blocks/Dual/lightBlock.js +14 -14
  209. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  210. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +9 -9
  211. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  212. package/Materials/Node/Blocks/Dual/textureBlock.js +26 -26
  213. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  214. package/Materials/Node/Blocks/Input/inputBlock.js +34 -34
  215. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  216. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +14 -14
  217. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  218. package/Materials/Node/Blocks/PBR/reflectionBlock.js +16 -16
  219. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  220. package/Materials/Node/Blocks/customBlock.js +7 -7
  221. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  222. package/Materials/Node/Blocks/gradientBlock.js +13 -13
  223. package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
  224. package/Materials/Node/Blocks/triPlanarBlock.js +30 -30
  225. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  226. package/Materials/Node/nodeMaterial.d.ts +1 -1
  227. package/Materials/Node/nodeMaterial.js +60 -60
  228. package/Materials/Node/nodeMaterial.js.map +1 -1
  229. package/Materials/Node/nodeMaterialBlock.js +35 -35
  230. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  231. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +50 -50
  232. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  233. package/Materials/PBR/pbrAnisotropicConfiguration.js +5 -5
  234. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  235. package/Materials/PBR/pbrBRDFConfiguration.js +4 -4
  236. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  237. package/Materials/PBR/pbrBaseMaterial.js +53 -55
  238. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  239. package/Materials/PBR/pbrBaseSimpleMaterial.js +17 -17
  240. package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
  241. package/Materials/PBR/pbrClearCoatConfiguration.js +5 -5
  242. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  243. package/Materials/PBR/pbrIridescenceConfiguration.js +5 -5
  244. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  245. package/Materials/PBR/pbrMaterial.js +209 -209
  246. package/Materials/PBR/pbrMaterial.js.map +1 -1
  247. package/Materials/PBR/pbrSheenConfiguration.js +5 -5
  248. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  249. package/Materials/PBR/pbrSpecularGlossinessMaterial.js +6 -6
  250. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  251. package/Materials/PBR/pbrSubSurfaceConfiguration.js +51 -51
  252. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  253. package/Materials/Textures/baseTexture.js +99 -99
  254. package/Materials/Textures/baseTexture.js.map +1 -1
  255. package/Materials/Textures/cubeTexture.js +61 -61
  256. package/Materials/Textures/cubeTexture.js.map +1 -1
  257. package/Materials/Textures/externalTexture.js +16 -16
  258. package/Materials/Textures/externalTexture.js.map +1 -1
  259. package/Materials/Textures/hdrCubeTexture.js +44 -44
  260. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  261. package/Materials/Textures/internalTexture.js +31 -31
  262. package/Materials/Textures/internalTexture.js.map +1 -1
  263. package/Materials/Textures/mirrorTexture.js +73 -73
  264. package/Materials/Textures/mirrorTexture.js.map +1 -1
  265. package/Materials/Textures/multiRenderTarget.js +47 -47
  266. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  267. package/Materials/Textures/rawTexture2DArray.js +6 -6
  268. package/Materials/Textures/rawTexture2DArray.js.map +1 -1
  269. package/Materials/Textures/renderTargetTexture.js +142 -142
  270. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  271. package/Materials/Textures/texture.d.ts +1 -1
  272. package/Materials/Textures/texture.js +26 -26
  273. package/Materials/Textures/texture.js.map +1 -1
  274. package/Materials/Textures/textureCreationOptions.d.ts +1 -1
  275. package/Materials/Textures/textureSampler.js +20 -20
  276. package/Materials/Textures/textureSampler.js.map +1 -1
  277. package/Materials/Textures/thinRenderTargetTexture.js +6 -6
  278. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  279. package/Materials/Textures/thinTexture.js +39 -39
  280. package/Materials/Textures/thinTexture.js.map +1 -1
  281. package/Materials/Textures/videoTexture.js +41 -41
  282. package/Materials/Textures/videoTexture.js.map +1 -1
  283. package/Materials/drawWrapper.js +6 -6
  284. package/Materials/drawWrapper.js.map +1 -1
  285. package/Materials/effect.js +18 -18
  286. package/Materials/effect.js.map +1 -1
  287. package/Materials/effectRenderer.js +9 -9
  288. package/Materials/effectRenderer.js.map +1 -1
  289. package/Materials/fresnelParameters.d.ts +2 -2
  290. package/Materials/fresnelParameters.js +13 -13
  291. package/Materials/fresnelParameters.js.map +1 -1
  292. package/Materials/material.detailMapConfiguration.js +5 -5
  293. package/Materials/material.detailMapConfiguration.js.map +1 -1
  294. package/Materials/material.js +223 -223
  295. package/Materials/material.js.map +1 -1
  296. package/Materials/materialPluginBase.js +5 -5
  297. package/Materials/materialPluginBase.js.map +1 -1
  298. package/Materials/materialPluginEvent.d.ts +14 -14
  299. package/Materials/materialPluginManager.d.ts +1 -1
  300. package/Materials/multiMaterial.js +16 -16
  301. package/Materials/multiMaterial.js.map +1 -1
  302. package/Materials/shadowDepthWrapper.js +14 -14
  303. package/Materials/shadowDepthWrapper.js.map +1 -1
  304. package/Materials/standardMaterial.js +100 -100
  305. package/Materials/standardMaterial.js.map +1 -1
  306. package/Materials/uniformBufferEffectCommonAccessor.js +3 -3
  307. package/Materials/uniformBufferEffectCommonAccessor.js.map +1 -1
  308. package/Maths/math.functions.js +2 -0
  309. package/Maths/math.functions.js.map +1 -1
  310. package/Maths/math.path.js +11 -11
  311. package/Maths/math.path.js.map +1 -1
  312. package/Maths/math.vector.d.ts +27 -7
  313. package/Maths/math.vector.js +75 -48
  314. package/Maths/math.vector.js.map +1 -1
  315. package/Meshes/Builders/goldbergBuilder.d.ts +2 -2
  316. package/Meshes/Compression/dracoCompression.js +23 -23
  317. package/Meshes/Compression/dracoCompression.js.map +1 -1
  318. package/Meshes/Compression/meshoptCompression.js +9 -9
  319. package/Meshes/Compression/meshoptCompression.js.map +1 -1
  320. package/Meshes/abstractMesh.js +179 -179
  321. package/Meshes/abstractMesh.js.map +1 -1
  322. package/Meshes/geometry.js +32 -32
  323. package/Meshes/geometry.js.map +1 -1
  324. package/Meshes/goldbergMesh.d.ts +1 -1
  325. package/Meshes/linesMesh.js +3 -3
  326. package/Meshes/linesMesh.js.map +1 -1
  327. package/Meshes/mesh.js +166 -166
  328. package/Meshes/mesh.js.map +1 -1
  329. package/Meshes/mesh.vertexData.js.map +1 -1
  330. package/Meshes/polygonMesh.js +5 -5
  331. package/Meshes/polygonMesh.js.map +1 -1
  332. package/Meshes/subMesh.js +59 -59
  333. package/Meshes/subMesh.js.map +1 -1
  334. package/Meshes/transformNode.js +52 -52
  335. package/Meshes/transformNode.js.map +1 -1
  336. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.d.ts +1 -1
  337. package/Misc/PerformanceViewer/performanceViewerCollector.js +12 -12
  338. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  339. package/Misc/arrayTools.d.ts +1 -1
  340. package/Misc/copyTextureToTexture.js +3 -3
  341. package/Misc/copyTextureToTexture.js.map +1 -1
  342. package/Misc/coroutine.d.ts +5 -5
  343. package/Misc/deferred.js +9 -9
  344. package/Misc/deferred.js.map +1 -1
  345. package/Misc/depthReducer.js +7 -7
  346. package/Misc/depthReducer.js.map +1 -1
  347. package/Misc/environmentTextureTools.d.ts +1 -1
  348. package/Misc/error.d.ts +1 -1
  349. package/Misc/fileTools.d.ts +5 -5
  350. package/Misc/filesInput.js +6 -6
  351. package/Misc/filesInput.js.map +1 -1
  352. package/Misc/khronosTextureContainer2.js +9 -9
  353. package/Misc/khronosTextureContainer2.js.map +1 -1
  354. package/Misc/observable.js +12 -12
  355. package/Misc/observable.js.map +1 -1
  356. package/Misc/perfCounter.js +16 -16
  357. package/Misc/perfCounter.js.map +1 -1
  358. package/Misc/sceneOptimizer.js +76 -76
  359. package/Misc/sceneOptimizer.js.map +1 -1
  360. package/Misc/stringDictionary.d.ts +1 -1
  361. package/Misc/trajectoryClassifier.js +67 -67
  362. package/Misc/trajectoryClassifier.js.map +1 -1
  363. package/Misc/videoRecorder.js +15 -15
  364. package/Misc/videoRecorder.js.map +1 -1
  365. package/Misc/virtualJoystick.js +12 -12
  366. package/Misc/virtualJoystick.js.map +1 -1
  367. package/Morph/morphTarget.js +28 -28
  368. package/Morph/morphTarget.js.map +1 -1
  369. package/Morph/morphTargetManager.js +18 -18
  370. package/Morph/morphTargetManager.js.map +1 -1
  371. package/Offline/database.js +12 -12
  372. package/Offline/database.js.map +1 -1
  373. package/Particles/EmitterTypes/coneParticleEmitter.js +25 -25
  374. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  375. package/Particles/EmitterTypes/meshParticleEmitter.js +20 -20
  376. package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
  377. package/Particles/baseParticleSystem.js +232 -232
  378. package/Particles/baseParticleSystem.js.map +1 -1
  379. package/Particles/cloudPoint.js +9 -9
  380. package/Particles/cloudPoint.js.map +1 -1
  381. package/Particles/gpuParticleSystem.js +123 -123
  382. package/Particles/gpuParticleSystem.js.map +1 -1
  383. package/Particles/particleSystem.js +102 -102
  384. package/Particles/particleSystem.js.map +1 -1
  385. package/Particles/particleSystemComponent.js +5 -0
  386. package/Particles/particleSystemComponent.js.map +1 -1
  387. package/Particles/pointsCloudSystem.js +18 -18
  388. package/Particles/pointsCloudSystem.js.map +1 -1
  389. package/Particles/solidParticle.js +23 -23
  390. package/Particles/solidParticle.js.map +1 -1
  391. package/Physics/index.d.ts +1 -0
  392. package/Physics/index.js +1 -0
  393. package/Physics/index.js.map +1 -1
  394. package/Physics/v1/physicsEngine.js +14 -14
  395. package/Physics/v1/physicsEngine.js.map +1 -1
  396. package/Physics/v1/physicsImpostor.js +149 -149
  397. package/Physics/v1/physicsImpostor.js.map +1 -1
  398. package/Physics/v2/IPhysicsEnginePlugin.d.ts +6 -8
  399. package/Physics/v2/IPhysicsEnginePlugin.js +1 -0
  400. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  401. package/Physics/v2/physicsBody.d.ts +10 -1
  402. package/Physics/v2/physicsBody.js +13 -1
  403. package/Physics/v2/physicsBody.js.map +1 -1
  404. package/Physics/v2/physicsConstraint.d.ts +139 -66
  405. package/Physics/v2/physicsConstraint.js +145 -78
  406. package/Physics/v2/physicsConstraint.js.map +1 -1
  407. package/Physics/v2/physicsEngine.js +14 -14
  408. package/Physics/v2/physicsEngine.js.map +1 -1
  409. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +137 -129
  410. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  411. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +68 -68
  412. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  413. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +6 -6
  414. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  415. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +226 -225
  416. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  417. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +10 -10
  418. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  419. package/PostProcesses/anaglyphPostProcess.js +7 -7
  420. package/PostProcesses/anaglyphPostProcess.js.map +1 -1
  421. package/PostProcesses/blackAndWhitePostProcess.js +7 -7
  422. package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
  423. package/PostProcesses/bloomEffect.js +28 -28
  424. package/PostProcesses/bloomEffect.js.map +1 -1
  425. package/PostProcesses/bloomMergePostProcess.js +7 -7
  426. package/PostProcesses/bloomMergePostProcess.js.map +1 -1
  427. package/PostProcesses/blurPostProcess.js +32 -32
  428. package/PostProcesses/blurPostProcess.js.map +1 -1
  429. package/PostProcesses/chromaticAberrationPostProcess.js +7 -7
  430. package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
  431. package/PostProcesses/circleOfConfusionPostProcess.js +7 -7
  432. package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
  433. package/PostProcesses/colorCorrectionPostProcess.js +7 -7
  434. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  435. package/PostProcesses/convolutionPostProcess.js +7 -7
  436. package/PostProcesses/convolutionPostProcess.js.map +1 -1
  437. package/PostProcesses/depthOfFieldBlurPostProcess.js +7 -7
  438. package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
  439. package/PostProcesses/depthOfFieldEffect.js +36 -36
  440. package/PostProcesses/depthOfFieldEffect.js.map +1 -1
  441. package/PostProcesses/depthOfFieldMergePostProcess.js +7 -7
  442. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  443. package/PostProcesses/extractHighlightsPostProcess.js +7 -7
  444. package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
  445. package/PostProcesses/filterPostProcess.js +7 -7
  446. package/PostProcesses/filterPostProcess.js.map +1 -1
  447. package/PostProcesses/grainPostProcess.js +7 -7
  448. package/PostProcesses/grainPostProcess.js.map +1 -1
  449. package/PostProcesses/imageProcessingPostProcess.js +42 -42
  450. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  451. package/PostProcesses/motionBlurPostProcess.js +41 -41
  452. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  453. package/PostProcesses/passPostProcess.js +15 -15
  454. package/PostProcesses/passPostProcess.js.map +1 -1
  455. package/PostProcesses/postProcess.d.ts +2 -2
  456. package/PostProcesses/postProcess.js +123 -123
  457. package/PostProcesses/postProcess.js.map +1 -1
  458. package/PostProcesses/refractionPostProcess.js +21 -21
  459. package/PostProcesses/refractionPostProcess.js.map +1 -1
  460. package/PostProcesses/screenSpaceCurvaturePostProcess.js +7 -7
  461. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  462. package/PostProcesses/screenSpaceReflectionPostProcess.js +19 -19
  463. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  464. package/PostProcesses/sharpenPostProcess.js +7 -7
  465. package/PostProcesses/sharpenPostProcess.js.map +1 -1
  466. package/PostProcesses/stereoscopicInterlacePostProcess.js +14 -14
  467. package/PostProcesses/stereoscopicInterlacePostProcess.js.map +1 -1
  468. package/PostProcesses/tonemapPostProcess.js +7 -7
  469. package/PostProcesses/tonemapPostProcess.js.map +1 -1
  470. package/PostProcesses/volumetricLightScatteringPostProcess.js +11 -11
  471. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  472. package/PostProcesses/vrDistortionCorrectionPostProcess.js +7 -7
  473. package/PostProcesses/vrDistortionCorrectionPostProcess.js.map +1 -1
  474. package/Rendering/depthPeelingRenderer.js +36 -36
  475. package/Rendering/depthPeelingRenderer.js.map +1 -1
  476. package/Rendering/depthRenderer.js +8 -8
  477. package/Rendering/depthRenderer.js.map +1 -1
  478. package/Rendering/edgesRenderer.js +34 -34
  479. package/Rendering/edgesRenderer.js.map +1 -1
  480. package/Rendering/fluidRenderer/fluidRenderer.js +8 -8
  481. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  482. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +3 -3
  483. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -1
  484. package/Rendering/fluidRenderer/fluidRenderingObject.js +22 -19
  485. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  486. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +12 -12
  487. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
  488. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +18 -18
  489. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
  490. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +71 -68
  491. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
  492. package/Rendering/fluidRenderer/fluidRenderingTextures.js +29 -29
  493. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
  494. package/Rendering/geometryBufferRenderer.js +173 -168
  495. package/Rendering/geometryBufferRenderer.js.map +1 -1
  496. package/Rendering/prePassRenderer.js +51 -51
  497. package/Rendering/prePassRenderer.js.map +1 -1
  498. package/Rendering/renderingGroup.js +25 -25
  499. package/Rendering/renderingGroup.js.map +1 -1
  500. package/Rendering/renderingManager.js +21 -21
  501. package/Rendering/renderingManager.js.map +1 -1
  502. package/Rendering/subSurfaceConfiguration.js +18 -18
  503. package/Rendering/subSurfaceConfiguration.js.map +1 -1
  504. package/Rendering/utilityLayerRenderer.js +76 -76
  505. package/Rendering/utilityLayerRenderer.js.map +1 -1
  506. package/Shaders/ShadersInclude/pbrBlockSubSurface.js +1 -1
  507. package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
  508. package/Shaders/fluidRenderingParticleDepth.fragment.js +5 -1
  509. package/Shaders/fluidRenderingParticleDepth.fragment.js.map +1 -1
  510. package/Shaders/fluidRenderingRender.fragment.js +7 -2
  511. package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
  512. package/Shaders/geometry.fragment.d.ts +2 -0
  513. package/Shaders/geometry.fragment.js +5 -1
  514. package/Shaders/geometry.fragment.js.map +1 -1
  515. package/Shaders/geometry.vertex.d.ts +2 -0
  516. package/Shaders/geometry.vertex.js +8 -4
  517. package/Shaders/geometry.vertex.js.map +1 -1
  518. package/Sprites/sprite.js +16 -16
  519. package/Sprites/sprite.js.map +1 -1
  520. package/Sprites/spriteManager.js +81 -81
  521. package/Sprites/spriteManager.js.map +1 -1
  522. package/Sprites/spriteMap.js +32 -32
  523. package/Sprites/spriteMap.js.map +1 -1
  524. package/Sprites/spriteRenderer.js +6 -6
  525. package/Sprites/spriteRenderer.js.map +1 -1
  526. package/Sprites/thinSprite.js +22 -22
  527. package/Sprites/thinSprite.js.map +1 -1
  528. package/States/stencilStateComposer.js +10 -10
  529. package/States/stencilStateComposer.js.map +1 -1
  530. package/XR/features/WebXRAnchorSystem.js +7 -7
  531. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  532. package/XR/features/WebXRControllerMovement.d.ts +3 -3
  533. package/XR/features/WebXRControllerMovement.js +97 -97
  534. package/XR/features/WebXRControllerMovement.js.map +1 -1
  535. package/XR/features/WebXRControllerPhysics.js +24 -24
  536. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  537. package/XR/features/WebXRControllerTeleportation.js +26 -26
  538. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  539. package/XR/features/WebXRDOMOverlay.d.ts +1 -1
  540. package/XR/features/WebXRFeaturePointSystem.js +6 -6
  541. package/XR/features/WebXRFeaturePointSystem.js.map +1 -1
  542. package/XR/features/WebXRHandTracking.d.ts +1 -1
  543. package/XR/features/WebXRHandTracking.js +95 -95
  544. package/XR/features/WebXRHandTracking.js.map +1 -1
  545. package/XR/features/WebXRWalkingLocomotion.js +21 -21
  546. package/XR/features/WebXRWalkingLocomotion.js.map +1 -1
  547. package/XR/motionController/webXRAbstractMotionController.d.ts +3 -3
  548. package/XR/motionController/webXRMotionControllerManager.d.ts +1 -1
  549. package/XR/native/nativeXRFrame.js +3 -3
  550. package/XR/native/nativeXRFrame.js.map +1 -1
  551. package/XR/webXRFeaturesManager.d.ts +1 -1
  552. package/XR/webXRLayerWrapper.d.ts +2 -2
  553. package/XR/webXRLayerWrapper.js +17 -17
  554. package/XR/webXRLayerWrapper.js.map +1 -1
  555. package/abstractScene.d.ts +2 -2
  556. package/node.d.ts +1 -1
  557. package/node.js +71 -71
  558. package/node.js.map +1 -1
  559. package/package.json +1 -1
  560. package/scene.js +777 -777
  561. package/scene.js.map +1 -1
  562. package/sceneComponent.d.ts +12 -12
  563. package/types.d.ts +11 -11
@@ -34,240 +34,307 @@ export class PhysicsConstraint {
34
34
  throw new Error("No Physics Plugin available.");
35
35
  }
36
36
  this._physicsPlugin = physicsPlugin;
37
- this._physicsPlugin.initConstraint(this, type, options);
37
+ this._options = options;
38
+ this._type = type;
38
39
  }
39
40
  /**
40
- * Sets the parent body of this body.
41
- * @param body - The parent body to set.
41
+ * Gets the type of the constraint.
42
42
  *
43
- * This method is useful for setting the parent body of a physics body in a physics engine.
44
- * This allows the engine to accurately simulate the motion of the body in relation to its parent body.
45
- * For example, if the parent body is a planet, the engine can accurately simulate the motion of the body in relation to the planet's gravity.
46
- */
47
- setParentBody(body) {
48
- this._physicsPlugin.setParentBody(this, body);
49
- }
50
- /**
51
- * Retrieves the parent body of the current physics constraint.
52
- *
53
- * @returns The parent body of the current physics constraint, or `undefined` if the
54
- * current constraint does not have a parent body.
55
- */
56
- getParentBody() {
57
- return this._physicsPlugin.getParentBody(this);
58
- }
59
- /**
60
- * Sets the child body of the current body.
61
- *
62
- * @param body - The child body to set.
43
+ * @returns The type of the constraint.
63
44
  *
64
- * This method is useful for setting the child body of the current body in a physics engine.
65
- * This allows for the creation of complex structures of bodies that interact with each other in a realistic way.
66
45
  */
67
- setChildBody(body) {
68
- this._physicsPlugin.setChildBody(this, body);
46
+ getType() {
47
+ return this._type;
69
48
  }
70
49
  /**
71
- * Retrieves the child body of the current physics constraint.
50
+ * Retrieves the options of the physics constraint.
72
51
  *
73
- * @returns The child body of the current physics constraint, or `undefined` if no
74
- * child body is present.
75
- */
76
- getChildBody() {
77
- return this._physicsPlugin.getChildBody(this);
78
- }
79
- /**
80
- *
81
- * @param pivot +
82
- * @param axisX
83
- * @param axisY
84
- */
85
- setAnchorInParent(pivot, axisX, axisY) {
86
- this._physicsPlugin.setAnchorInParent(this, pivot, axisX, axisY);
87
- }
88
- /**
52
+ * @returns The physics constraint parameters.
89
53
  *
90
- * @param pivot
91
- * @param axisX
92
- * @param axisY
93
54
  */
94
- setAnchorInChild(pivot, axisX, axisY) {
95
- this._physicsPlugin.setAnchorInChild(this, pivot, axisX, axisY);
55
+ getOptions() {
56
+ return this._options;
96
57
  }
97
58
  /**
98
- *
99
- * @param isEnabled
59
+ * Enable/disable the constraint
60
+ * @param isEnabled value for the constraint
100
61
  */
101
62
  setEnabled(isEnabled) {
102
63
  this._physicsPlugin.setEnabled(this, isEnabled);
103
64
  }
104
65
  /**
105
66
  *
106
- * @returns
67
+ * @returns true if constraint is enabled
107
68
  */
108
69
  getEnabled() {
109
70
  return this._physicsPlugin.getEnabled(this);
110
71
  }
111
72
  /**
73
+ * Enables or disables collisions for the physics engine.
74
+ *
75
+ * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.
112
76
  *
113
- * @param isEnabled
114
77
  */
115
78
  setCollisionsEnabled(isEnabled) {
116
79
  this._physicsPlugin.setCollisionsEnabled(this, isEnabled);
117
80
  }
118
81
  /**
82
+ * Gets whether collisions are enabled for this physics object.
83
+ *
84
+ * @returns `true` if collisions are enabled, `false` otherwise.
119
85
  *
120
- * @returns
121
86
  */
122
87
  getCollisionsEnabled() {
123
88
  return this._physicsPlugin.getCollisionsEnabled(this);
124
89
  }
125
90
  /**
91
+ * Sets the friction of the given axis of the physics engine.
92
+ * @param axis - The axis of the physics engine to set the friction for.
93
+ * @param friction - The friction to set for the given axis.
126
94
  *
127
- * @param axis
128
- * @param friction
129
95
  */
130
96
  setAxisFriction(axis, friction) {
131
97
  this._physicsPlugin.setAxisFriction(this, axis, friction);
132
98
  }
133
99
  /**
100
+ * Gets the friction of the given axis of the physics engine.
101
+ * @param axis - The axis of the physics engine.
102
+ * @returns The friction of the given axis.
134
103
  *
135
- * @param axis
136
- * @returns
137
104
  */
138
105
  getAxisFriction(axis) {
139
106
  return this._physicsPlugin.getAxisFriction(this, axis);
140
107
  }
141
108
  /**
109
+ * Sets the limit mode for the given axis of the constraint.
110
+ * @param axis The axis to set the limit mode for.
111
+ * @param limitMode The limit mode to set.
142
112
  *
143
- * @param axis
144
- * @param limitMode
113
+ * This method is useful for setting the limit mode for a given axis of the constraint. This is important for
114
+ * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,
115
+ * the engine can be configured to either stop the motion of the objects, or to allow them to continue
116
+ * moving beyond the constraint.
145
117
  */
146
118
  setAxisMode(axis, limitMode) {
147
119
  this._physicsPlugin.setAxisMode(this, axis, limitMode);
148
120
  }
149
121
  /**
122
+ * Gets the limit mode of the given axis of the constraint.
123
+ *
124
+ * @param axis - The axis of the constraint.
125
+ * @returns The limit mode of the given axis.
150
126
  *
151
- * @param axis
152
127
  */
153
128
  getAxisMode(axis) {
154
129
  return this._physicsPlugin.getAxisMode(this, axis);
155
130
  }
156
131
  /**
132
+ * Sets the minimum limit of a given axis of a constraint.
133
+ * @param axis - The axis of the constraint.
134
+ * @param minLimit - The minimum limit of the axis.
157
135
  *
158
136
  */
159
137
  setAxisMinLimit(axis, minLimit) {
160
138
  this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);
161
139
  }
162
140
  /**
141
+ * Gets the minimum limit of the given axis of the physics engine.
142
+ * @param axis - The axis of the physics engine.
143
+ * @returns The minimum limit of the given axis.
163
144
  *
164
145
  */
165
146
  getAxisMinLimit(axis) {
166
147
  return this._physicsPlugin.getAxisMinLimit(this, axis);
167
148
  }
168
149
  /**
150
+ * Sets the maximum limit of the given axis for the physics engine.
151
+ * @param axis - The axis to set the limit for.
152
+ * @param limit - The maximum limit of the axis.
169
153
  *
154
+ * This method is useful for setting the maximum limit of the given axis for the physics engine,
155
+ * which can be used to control the movement of the physics object. This helps to ensure that the
156
+ * physics object does not move beyond the given limit.
170
157
  */
171
158
  setAxisMaxLimit(axis, limit) {
172
159
  this._physicsPlugin.setAxisMaxLimit(this, axis, limit);
173
160
  }
174
161
  /**
162
+ * Gets the maximum limit of the given axis of the physics engine.
163
+ * @param axis - The axis of the physics engine.
164
+ * @returns The maximum limit of the given axis.
175
165
  *
176
166
  */
177
167
  getAxisMaxLimit(axis) {
178
168
  return this._physicsPlugin.getAxisMaxLimit(this, axis);
179
169
  }
180
170
  /**
171
+ * Sets the motor type of the given axis of the constraint.
172
+ * @param axis - The axis of the constraint.
173
+ * @param motorType - The type of motor to use.
174
+ * @returns void
181
175
  *
182
176
  */
183
177
  setAxisMotorType(axis, motorType) {
184
178
  this._physicsPlugin.setAxisMotorType(this, axis, motorType);
185
179
  }
186
180
  /**
181
+ * Gets the motor type of the specified axis of the constraint.
182
+ *
183
+ * @param axis - The axis of the constraint.
184
+ * @returns The motor type of the specified axis.
187
185
  *
188
186
  */
189
187
  getAxisMotorType(axis) {
190
188
  return this._physicsPlugin.getAxisMotorType(this, axis);
191
189
  }
192
190
  /**
191
+ * Sets the target velocity of the motor associated with the given axis of the constraint.
192
+ * @param axis - The axis of the constraint.
193
+ * @param target - The target velocity of the motor.
193
194
  *
195
+ * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.
194
196
  */
195
197
  setAxisMotorTarget(axis, target) {
196
198
  this._physicsPlugin.setAxisMotorTarget(this, axis, target);
197
199
  }
198
200
  /**
201
+ * Gets the target velocity of the motor associated to the given constraint axis.
202
+ * @param axis - The constraint axis associated to the motor.
203
+ * @returns The target velocity of the motor.
199
204
  *
200
205
  */
201
206
  getAxisMotorTarget(axis) {
202
207
  return this._physicsPlugin.getAxisMotorTarget(this, axis);
203
208
  }
204
209
  /**
210
+ * Sets the maximum force of the motor of the given axis of the constraint.
211
+ * @param axis - The axis of the constraint.
212
+ * @param maxForce - The maximum force of the motor.
205
213
  *
206
214
  */
207
215
  setAxisMotorMaxForce(axis, maxForce) {
208
216
  this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);
209
217
  }
210
218
  /**
219
+ * Gets the maximum force of the motor of the given axis of the constraint.
220
+ * @param axis - The axis of the constraint.
221
+ * @returns The maximum force of the motor.
211
222
  *
212
223
  */
213
224
  getAxisMotorMaxForce(axis) {
214
225
  return this._physicsPlugin.getAxisMotorMaxForce(this, axis);
215
226
  }
216
227
  /**
228
+ * Disposes the constraint from the physics engine.
217
229
  *
230
+ * 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.
218
231
  */
219
232
  dispose() {
220
233
  this._physicsPlugin.disposeConstraint(this);
221
234
  }
222
235
  }
223
236
  /**
237
+ * Represents a Ball and Socket Constraint, used to simulate a joint
224
238
  *
239
+ * @param pivotA - The first pivot, defined locally in the first body frame
240
+ * @param pivotB - The second pivot, defined locally in the second body frame
241
+ * @param axisA - The axis of the first body
242
+ * @param axisB - The axis of the second body
243
+ * @param scene - The scene the constraint is applied to
244
+ * @returns The Ball and Socket Constraint
245
+ *
246
+ * This class is useful for simulating a joint between two bodies in a physics engine.
247
+ * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.
225
248
  */
226
- /** @internal */
227
- export class PhysicsConstraintBallAndSocket extends PhysicsConstraint {
228
- /** @internal */
249
+ export class BallAndSocketConstraint extends PhysicsConstraint {
229
250
  constructor(pivotA, pivotB, axisA, axisB, scene) {
230
251
  super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
231
252
  }
232
253
  }
233
254
  /**
255
+ * Creates a distance constraint.
256
+ * @param maxDistance distance between bodies
257
+ * @param scene The scene the constraint belongs to
258
+ * @returns DistanceConstraint
234
259
  *
260
+ * This code is useful for creating a distance constraint in a physics engine.
261
+ * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.
262
+ * The scene is used to add the constraint to the physics engine.
235
263
  */
236
- /** @internal */
237
- export class PhysicsConstraintDistance extends PhysicsConstraint {
238
- /** @internal */
239
- constructor(pivotA, pivotB, axisA, axisB, scene) {
240
- super(ConstraintType.DISTANCE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
264
+ export class DistanceConstraint extends PhysicsConstraint {
265
+ constructor(maxDistance, scene) {
266
+ super(ConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);
241
267
  }
242
268
  }
243
269
  /**
270
+ * Creates a HingeConstraint, which is a type of PhysicsConstraint.
244
271
  *
272
+ * @param pivotA - The first pivot point, in world space.
273
+ * @param pivotB - The second pivot point, in world space.
274
+ * @param scene - The scene the constraint is used in.
275
+ * @returns The new HingeConstraint.
276
+ *
277
+ * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.
278
+ * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.
245
279
  */
246
- /** @internal */
247
- export class PhysicsConstraintHinge extends PhysicsConstraint {
248
- /** @internal */
280
+ export class HingeConstraint extends PhysicsConstraint {
249
281
  constructor(pivotA, pivotB, axisA, axisB, scene) {
250
282
  super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
251
283
  }
252
284
  }
253
285
  /**
286
+ * Creates a SliderConstraint, which is a type of PhysicsConstraint.
287
+ *
288
+ * @param pivotA - The first pivot of the constraint, in world space.
289
+ * @param pivotB - The second pivot of the constraint, in world space.
290
+ * @param axisA - The first axis of the constraint, in world space.
291
+ * @param axisB - The second axis of the constraint, in world space.
292
+ * @param scene - The scene the constraint belongs to.
293
+ * @returns The created SliderConstraint.
254
294
  *
295
+ * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.
296
+ * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.
297
+ * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.
255
298
  */
256
- /** @internal */
257
- export class PhysicsConstraintSlider extends PhysicsConstraint {
258
- /** @internal */
299
+ export class SliderConstraint extends PhysicsConstraint {
259
300
  constructor(pivotA, pivotB, axisA, axisB, scene) {
260
301
  super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
261
302
  }
262
303
  }
263
304
  /**
305
+ * Creates a LockConstraint, which is a type of PhysicsConstraint.
264
306
  *
307
+ * @param pivotA - The first pivot of the constraint in local space.
308
+ * @param pivotB - The second pivot of the constraint in local space.
309
+ * @param axisA - The first axis of the constraint in local space.
310
+ * @param axisB - The second axis of the constraint in local space.
311
+ * @param scene - The scene the constraint belongs to.
312
+ * @returns The created LockConstraint.
313
+ *
314
+ * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.
315
+ * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.
265
316
  */
266
- /** @internal */
267
- export class PhysicsConstraintLock extends PhysicsConstraint {
268
- /** @internal */
317
+ export class LockConstraint extends PhysicsConstraint {
269
318
  constructor(pivotA, pivotB, axisA, axisB, scene) {
270
319
  super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
271
320
  }
272
321
  }
322
+ /**
323
+ * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.
324
+ *
325
+ * @param pivotA - The first pivot of the constraint in local space.
326
+ * @param pivotB - The second pivot of the constraint in local space.
327
+ * @param axisA - The first axis of the constraint in local space.
328
+ * @param axisB - The second axis of the constraint in local space.
329
+ * @param scene - The scene the constraint belongs to.
330
+ * @returns The created LockConstraint.
331
+ *
332
+ * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.
333
+ * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.
334
+ */
335
+ export class PrismaticConstraint extends PhysicsConstraint {
336
+ constructor(pivotA, pivotB, axisA, axisB, scene) {
337
+ super(ConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
338
+ }
339
+ }
273
340
  //# sourceMappingURL=physicsConstraint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAU1B;;;;;;;;OAQG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QAlBpF;;WAEG;Q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AC,CAAC;IACvG,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,uBAAwB,SAAQ,iBAAiB;IAC1D,gBAAgB;IAChB,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACxG,CAAC;CACJ;AAED;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IACxD,gBAAgB;IAChB,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACtG,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\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 protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, 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\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._physicsPlugin.initConstraint(this, type, options);\r\n }\r\n\r\n /**\r\n * Sets the parent body of this body.\r\n * @param body - The parent body to set.\r\n *\r\n * This method is useful for setting the parent body of a physics body in a physics engine.\r\n * This allows the engine to accurately simulate the motion of the body in relation to its parent body.\r\n * For example, if the parent body is a planet, the engine can accurately simulate the motion of the body in relation to the planet's gravity.\r\n */\r\n public setParentBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setParentBody(this, body);\r\n }\r\n\r\n /**\r\n * Retrieves the parent body of the current physics constraint.\r\n *\r\n * @returns The parent body of the current physics constraint, or `undefined` if the\r\n * current constraint does not have a parent body.\r\n */\r\n public getParentBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getParentBody(this);\r\n }\r\n\r\n /**\r\n * Sets the child body of the current body.\r\n *\r\n * @param body - The child body to set.\r\n *\r\n * This method is useful for setting the child body of the current body in a physics engine.\r\n * This allows for the creation of complex structures of bodies that interact with each other in a realistic way.\r\n */\r\n public setChildBody(body: PhysicsBody): void {\r\n this._physicsPlugin.setChildBody(this, body);\r\n }\r\n\r\n /**\r\n * Retrieves the child body of the current physics constraint.\r\n *\r\n * @returns The child body of the current physics constraint, or `undefined` if no\r\n * child body is present.\r\n */\r\n public getChildBody(): PhysicsBody | undefined {\r\n return this._physicsPlugin.getChildBody(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot +\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInParent(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInParent(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param pivot\r\n * @param axisX\r\n * @param axisY\r\n */\r\n public setAnchorInChild(pivot: Vector3, axisX: Vector3, axisY: Vector3): void {\r\n this._physicsPlugin.setAnchorInChild(this, pivot, axisX, axisY);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param isEnabled\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param friction\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @returns\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n * @param axis\r\n * @param limitMode\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n /**\r\n *\r\n * @param axis\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintBallAndSocket extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintDistance extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintHinge extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintSlider extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsConstraintLock extends PhysicsConstraint {\r\n /** @internal */\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAY1B;;;;;;;;OAQG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QApBpF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAkBhC,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;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAC9D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACI,UAAU;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,SAAkB;QAChC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACpD,C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Y,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACtG,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAC3G,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\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 protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: ConstraintType;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, 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\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._options = options;\r\n this._type = type;\r\n }\r\n\r\n /**\r\n * Gets the type of the constraint.\r\n *\r\n * @returns The type of the constraint.\r\n *\r\n */\r\n public getType(): ConstraintType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Retrieves the options of the physics constraint.\r\n *\r\n * @returns The physics constraint parameters.\r\n *\r\n */\r\n public getOptions(): PhysicsConstraintParameters {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Enable/disable the constraint\r\n * @param isEnabled value for the constraint\r\n */\r\n public setEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if constraint is enabled\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the physics engine.\r\n *\r\n * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for this physics object.\r\n *\r\n * @returns `true` if collisions are enabled, `false` otherwise.\r\n *\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine to set the friction for.\r\n * @param friction - The friction to set for the given axis.\r\n *\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The friction of the given axis.\r\n *\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the limit mode for the given axis of the constraint.\r\n * @param axis The axis to set the limit mode for.\r\n * @param limitMode The limit mode to set.\r\n *\r\n * This method is useful for setting the limit mode for a given axis of the constraint. This is important for\r\n * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,\r\n * the engine can be configured to either stop the motion of the objects, or to allow them to continue\r\n * moving beyond the constraint.\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n\r\n /**\r\n * Gets the limit mode of the given axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The limit mode of the given axis.\r\n *\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of a given axis of a constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param minLimit - The minimum limit of the axis.\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The minimum limit of the given axis.\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis for the physics engine.\r\n * @param axis - The axis to set the limit for.\r\n * @param limit - The maximum limit of the axis.\r\n *\r\n * This method is useful for setting the maximum limit of the given axis for the physics engine,\r\n * which can be used to control the movement of the physics object. This helps to ensure that the\r\n * physics object does not move beyond the given limit.\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The maximum limit of the given axis.\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param motorType - The type of motor to use.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The motor type of the specified axis.\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the target velocity of the motor associated with the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param target - The target velocity of the motor.\r\n *\r\n * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n * Gets the target velocity of the motor associated to the given constraint axis.\r\n * @param axis - The constraint axis associated to the motor.\r\n * @returns The target velocity of the motor.\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param maxForce - The maximum force of the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @returns The maximum force of the motor.\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n * Disposes the constraint 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(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Ball and Socket Constraint, used to simulate a joint\r\n *\r\n * @param pivotA - The first pivot, defined locally in the first body frame\r\n * @param pivotB - The second pivot, defined locally in the second body frame\r\n * @param axisA - The axis of the first body\r\n * @param axisB - The axis of the second body\r\n * @param scene - The scene the constraint is applied to\r\n * @returns The Ball and Socket Constraint\r\n *\r\n * This class is useful for simulating a joint between two bodies in a physics engine.\r\n * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.\r\n */\r\nexport class BallAndSocketConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a distance constraint.\r\n * @param maxDistance distance between bodies\r\n * @param scene The scene the constraint belongs to\r\n * @returns DistanceConstraint\r\n *\r\n * This code is useful for creating a distance constraint in a physics engine.\r\n * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.\r\n * The scene is used to add the constraint to the physics engine.\r\n */\r\nexport class DistanceConstraint extends PhysicsConstraint {\r\n constructor(maxDistance: number, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a HingeConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot point, in world space.\r\n * @param pivotB - The second pivot point, in world space.\r\n * @param scene - The scene the constraint is used in.\r\n * @returns The new HingeConstraint.\r\n *\r\n * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.\r\n * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.\r\n */\r\nexport class HingeConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SliderConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint, in world space.\r\n * @param pivotB - The second pivot of the constraint, in world space.\r\n * @param axisA - The first axis of the constraint, in world space.\r\n * @param axisB - The second axis of the constraint, in world space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SliderConstraint.\r\n *\r\n * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.\r\n * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.\r\n * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.\r\n */\r\nexport class SliderConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a LockConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.\r\n */\r\nexport class LockConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.\r\n */\r\nexport class PrismaticConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
@@ -7,20 +7,6 @@ import { _WarnImport } from "../../Misc/devTools.js";
7
7
  */
8
8
  /** @internal */
9
9
  export class PhysicsEngine {
10
- /**
11
- * Creates a new Physics Engine
12
- * @param gravity defines the gravity vector used by the simulation
13
- * @param _physicsPlugin defines the plugin to use (CannonJS by default)
14
- */
15
- constructor(gravity, _physicsPlugin = PhysicsEngine.DefaultPluginFactory()) {
16
- this._physicsPlugin = _physicsPlugin;
17
- /** @internal */
18
- this._physicsBodies = [];
19
- this._subTimeStep = 0;
20
- gravity = gravity || new Vector3(0, -9.807, 0);
21
- this.setGravity(gravity);
22
- this.setTimeStep();
23
- }
24
10
  /**
25
11
  *
26
12
  * @returns physics plugin version
@@ -35,6 +21,20 @@ export class PhysicsEngine {
35
21
  static DefaultPluginFactory() {
36
22
  throw _WarnImport("");
37
23
  }
24
+ /**
25
+ * Creates a new Physics Engine
26
+ * @param gravity defines the gravity vector used by the simulation
27
+ * @param _physicsPlugin defines the plugin to use (CannonJS by default)
28
+ */
29
+ constructor(gravity, _physicsPlugin = PhysicsEngine.DefaultPluginFactory()) {
30
+ this._physicsPlugin = _physicsPlugin;
31
+ /** @internal */
32
+ this._physicsBodies = [];
33
+ this._subTimeStep = 0;
34
+ gravity = gravity || new Vector3(0, -9.807, 0);
35
+ this.setGravity(gravity);
36
+ this.setTimeStep();
37
+ }
38
38
  /**
39
39
  * Sets the gravity vector used by the simulation
40
40
  * @param gravity defines the gravity vector to use
@@ -1 +1 @@
1
- {"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,gBAAgB;AAChB,MAAM,OAAO,aAAa;IA0BtB;;;;OAIG;IACH,YAAY,OAA0B,EAAU,iBAAyC,aAAa,CAAC,oBAAoB,EAAE;QAA7E,mBAAc,GAAd,cAAc,CAA+D;QA9B7H,gBAAgB;QACR,mBAAc,G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KAAK,GAAG,GAAG,EAAE;YACb,KAAK,GAAG,GAAG,CAAC;SACf;aAAM,IAAI,KAAK,IAAI,CAAC,EAAE;YACnB,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC;SACtB;QAED,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,WAAwB;QACnC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IACD;;OAEG;IACI,UAAU,CAAC,WAAwB;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACZ,mBAAmB,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC5D;IACL,CAAC;IACD;;;OAGG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n //private _uniqueIdCounter = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(gravity: Nullable<Vector3>, private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n * Add a body as an active component of this engine\r\n * @param body\r\n */\r\n public addBody(physicsBody: PhysicsBody): void {\r\n this._physicsBodies.push(physicsBody);\r\n }\r\n /**\r\n * Removes a particular body from this engine\r\n */\r\n public removeBody(physicsBody: PhysicsBody): void {\r\n const index = this._physicsBodies.indexOf(physicsBody);\r\n if (index > -1) {\r\n /*const removed =*/ this._physicsBodies.splice(index, 1);\r\n }\r\n }\r\n /**\r\n * Returns an array of bodies added to this engine\r\n\r\n */\r\n public getBodies(): Array<PhysicsBody> {\r\n return this._physicsBodies;\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePluginV2 {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n this._physicsPlugin.raycast(from, to, result);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n const result = new PhysicsRaycastResult();\r\n this._physicsPlugin.raycast(from, to, result);\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,gBAAgB;AAChB,MAAM,OAAO,aAAa;IAWtB;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAC9B,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,YAAY,OAA0B,EAAU,iBAAyC,aAAa,CAAC,oBAAoB,EAAE;QAA7E,mBAAc,GAAd,cAAc,CAA+D;QA9B7H,gBAAgB;QACR,mBAAc,GAAuB,EAAE,CAAC;QACx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AC,CAAC;IAChE,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,WAAwB;QACnC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1C,CAAC;IACD;;OAEG;IACI,UAAU,CAAC,WAAwB;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACvD,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACZ,mBAAmB,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC5D;IACL,CAAC;IACD;;;OAGG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,MAA4B;QACxE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW;QACrC,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n/** @internal */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n //private _uniqueIdCounter = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(gravity: Nullable<Vector3>, private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n * Add a body as an active component of this engine\r\n * @param body\r\n */\r\n public addBody(physicsBody: PhysicsBody): void {\r\n this._physicsBodies.push(physicsBody);\r\n }\r\n /**\r\n * Removes a particular body from this engine\r\n */\r\n public removeBody(physicsBody: PhysicsBody): void {\r\n const index = this._physicsBodies.indexOf(physicsBody);\r\n if (index > -1) {\r\n /*const removed =*/ this._physicsBodies.splice(index, 1);\r\n }\r\n }\r\n /**\r\n * Returns an array of bodies added to this engine\r\n\r\n */\r\n public getBodies(): Array<PhysicsBody> {\r\n return this._physicsBodies;\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePluginV2 {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n this._physicsPlugin.raycast(from, to, result);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n const result = new PhysicsRaycastResult();\r\n this._physicsPlugin.raycast(from, to, result);\r\n return result;\r\n }\r\n}\r\n"]}