@babylonjs/core 5.35.0 → 5.36.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 (250) hide show
  1. package/Audio/sound.d.ts +5 -0
  2. package/Audio/sound.js +7 -0
  3. package/Audio/sound.js.map +1 -1
  4. package/Debug/physicsViewer.d.ts +4 -3
  5. package/Debug/physicsViewer.js +2 -2
  6. package/Debug/physicsViewer.js.map +1 -1
  7. package/Engines/Extensions/engine.renderTarget.js +15 -15
  8. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  9. package/Engines/Extensions/engine.renderTargetCube.d.ts +1 -1
  10. package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
  11. package/Engines/Extensions/engine.views.d.ts +4 -0
  12. package/Engines/Extensions/engine.views.js +61 -42
  13. package/Engines/Extensions/engine.views.js.map +1 -1
  14. package/Engines/Native/nativeHardwareTexture.d.ts +14 -0
  15. package/Engines/Native/nativeHardwareTexture.js +24 -0
  16. package/Engines/Native/nativeHardwareTexture.js.map +1 -0
  17. package/Engines/Native/nativeInterfaces.d.ts +22 -15
  18. package/Engines/Native/nativeInterfaces.js.map +1 -1
  19. package/Engines/Native/nativePipelineContext.d.ts +252 -0
  20. package/Engines/Native/nativePipelineContext.js +502 -0
  21. package/Engines/Native/nativePipelineContext.js.map +1 -0
  22. package/Engines/Native/nativeRenderTargetWrapper.d.ts +16 -0
  23. package/Engines/Native/nativeRenderTargetWrapper.js +33 -0
  24. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -0
  25. package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -3
  26. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  27. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
  28. package/Engines/engine.d.ts +1 -0
  29. package/Engines/engine.js +24 -18
  30. package/Engines/engine.js.map +1 -1
  31. package/Engines/nativeEngine.d.ts +18 -17
  32. package/Engines/nativeEngine.js +100 -598
  33. package/Engines/nativeEngine.js.map +1 -1
  34. package/Engines/nullEngine.d.ts +1 -1
  35. package/Engines/nullEngine.js.map +1 -1
  36. package/Engines/thinEngine.d.ts +1 -1
  37. package/Engines/thinEngine.js +41 -38
  38. package/Engines/thinEngine.js.map +1 -1
  39. package/Engines/webgpuEngine.js.map +1 -1
  40. package/Gizmos/planeRotationGizmo.js +3 -1
  41. package/Gizmos/planeRotationGizmo.js.map +1 -1
  42. package/Inputs/scene.inputManager.js +4 -4
  43. package/Inputs/scene.inputManager.js.map +1 -1
  44. package/Loading/Plugins/babylonFileLoader.js +3 -3
  45. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  46. package/Materials/Node/Blocks/Dual/textureBlock.js +1 -1
  47. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  48. package/Materials/Node/nodeMaterial.d.ts +19 -1
  49. package/Materials/Node/nodeMaterial.js +30 -0
  50. package/Materials/Node/nodeMaterial.js.map +1 -1
  51. package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +2 -8
  52. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  53. package/Materials/Textures/baseTexture.d.ts +2 -1
  54. package/Materials/Textures/baseTexture.js +3 -2
  55. package/Materials/Textures/baseTexture.js.map +1 -1
  56. package/Materials/Textures/internalTexture.d.ts +2 -0
  57. package/Materials/Textures/internalTexture.js +4 -0
  58. package/Materials/Textures/internalTexture.js.map +1 -1
  59. package/Materials/Textures/mirrorTexture.js +0 -2
  60. package/Materials/Textures/mirrorTexture.js.map +1 -1
  61. package/Materials/Textures/renderTargetTexture.d.ts +53 -3
  62. package/Materials/Textures/renderTargetTexture.js +25 -25
  63. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  64. package/Materials/Textures/texture.d.ts +2 -0
  65. package/Materials/Textures/texture.js +35 -7
  66. package/Materials/Textures/texture.js.map +1 -1
  67. package/Materials/Textures/textureCreationOptions.d.ts +4 -1
  68. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  69. package/Materials/material.js +1 -1
  70. package/Materials/material.js.map +1 -1
  71. package/Meshes/abstractMesh.d.ts +4 -4
  72. package/Meshes/abstractMesh.js +4 -4
  73. package/Meshes/abstractMesh.js.map +1 -1
  74. package/Meshes/mesh.d.ts +2 -2
  75. package/Meshes/mesh.js +1 -1
  76. package/Meshes/mesh.js.map +1 -1
  77. package/Misc/copyTextureToTexture.d.ts +9 -2
  78. package/Misc/copyTextureToTexture.js +23 -1
  79. package/Misc/copyTextureToTexture.js.map +1 -1
  80. package/Particles/IParticleSystem.d.ts +15 -1
  81. package/Particles/IParticleSystem.js.map +1 -1
  82. package/Particles/gpuParticleSystem.d.ts +24 -2
  83. package/Particles/gpuParticleSystem.js +98 -43
  84. package/Particles/gpuParticleSystem.js.map +1 -1
  85. package/Particles/particleSystem.d.ts +6 -1
  86. package/Particles/particleSystem.js +7 -2
  87. package/Particles/particleSystem.js.map +1 -1
  88. package/Physics/IPhysicsEngine.d.ts +8 -108
  89. package/Physics/IPhysicsEngine.js.map +1 -1
  90. package/Physics/Plugins/ammoJSPlugin.d.ts +1 -389
  91. package/Physics/Plugins/ammoJSPlugin.js +2 -1414
  92. package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
  93. package/Physics/Plugins/cannonJSPlugin.d.ts +1 -75
  94. package/Physics/Plugins/cannonJSPlugin.js +2 -664
  95. package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
  96. package/Physics/Plugins/oimoJSPlugin.d.ts +1 -59
  97. package/Physics/Plugins/oimoJSPlugin.js +2 -432
  98. package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
  99. package/Physics/index.d.ts +3 -6
  100. package/Physics/index.js +3 -6
  101. package/Physics/index.js.map +1 -1
  102. package/Physics/physicsEngine.d.ts +1 -135
  103. package/Physics/physicsEngine.js +2 -221
  104. package/Physics/physicsEngine.js.map +1 -1
  105. package/Physics/physicsEngineComponent.d.ts +7 -42
  106. package/Physics/physicsEngineComponent.js +11 -71
  107. package/Physics/physicsEngineComponent.js.map +1 -1
  108. package/Physics/physicsHelper.d.ts +1 -411
  109. package/Physics/physicsHelper.js +2 -708
  110. package/Physics/physicsHelper.js.map +1 -1
  111. package/Physics/physicsImpostor.d.ts +1 -640
  112. package/Physics/physicsImpostor.js +2 -1004
  113. package/Physics/physicsImpostor.js.map +1 -1
  114. package/Physics/physicsJoint.d.ts +1 -275
  115. package/Physics/physicsJoint.js +2 -222
  116. package/Physics/physicsJoint.js.map +1 -1
  117. package/Physics/v1/IPhysicsEnginePlugin.d.ts +73 -0
  118. package/Physics/v1/IPhysicsEnginePlugin.js +2 -0
  119. package/Physics/v1/IPhysicsEnginePlugin.js.map +1 -0
  120. package/Physics/v1/Plugins/ammoJSPlugin.d.ts +401 -0
  121. package/Physics/v1/Plugins/ammoJSPlugin.js +1431 -0
  122. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -0
  123. package/Physics/v1/Plugins/cannonJSPlugin.d.ts +87 -0
  124. package/Physics/v1/Plugins/cannonJSPlugin.js +683 -0
  125. package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -0
  126. package/Physics/{Plugins → v1/Plugins}/index.d.ts +0 -0
  127. package/Physics/{Plugins → v1/Plugins}/index.js +0 -0
  128. package/Physics/v1/Plugins/index.js.map +1 -0
  129. package/Physics/v1/Plugins/oimoJSPlugin.d.ts +71 -0
  130. package/Physics/v1/Plugins/oimoJSPlugin.js +450 -0
  131. package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -0
  132. package/Physics/v1/index.d.ts +7 -0
  133. package/Physics/v1/index.js +9 -0
  134. package/Physics/v1/index.js.map +1 -0
  135. package/Physics/v1/physicsEngine.d.ts +147 -0
  136. package/Physics/v1/physicsEngine.js +237 -0
  137. package/Physics/v1/physicsEngine.js.map +1 -0
  138. package/Physics/v1/physicsEngineComponent.d.ts +45 -0
  139. package/Physics/v1/physicsEngineComponent.js +70 -0
  140. package/Physics/v1/physicsEngineComponent.js.map +1 -0
  141. package/Physics/v1/physicsHelper.d.ts +411 -0
  142. package/Physics/v1/physicsHelper.js +709 -0
  143. package/Physics/v1/physicsHelper.js.map +1 -0
  144. package/Physics/v1/physicsImpostor.d.ts +636 -0
  145. package/Physics/v1/physicsImpostor.js +1001 -0
  146. package/Physics/v1/physicsImpostor.js.map +1 -0
  147. package/Physics/v1/physicsJoint.d.ts +275 -0
  148. package/Physics/v1/physicsJoint.js +223 -0
  149. package/Physics/v1/physicsJoint.js.map +1 -0
  150. package/Physics/v2/IPhysicsEnginePlugin.d.ts +170 -0
  151. package/Physics/v2/IPhysicsEnginePlugin.js +47 -0
  152. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -0
  153. package/Physics/v2/Plugins/index.d.ts +0 -0
  154. package/Physics/v2/Plugins/index.js +2 -0
  155. package/Physics/v2/Plugins/index.js.map +1 -0
  156. package/Physics/v2/index.d.ts +6 -0
  157. package/Physics/v2/index.js +8 -0
  158. package/Physics/v2/index.js.map +1 -0
  159. package/Physics/v2/physicsAggregate.d.ts +114 -0
  160. package/Physics/v2/physicsAggregate.js +46 -0
  161. package/Physics/v2/physicsAggregate.js.map +1 -0
  162. package/Physics/v2/physicsBody.d.ts +109 -0
  163. package/Physics/v2/physicsBody.js +158 -0
  164. package/Physics/v2/physicsBody.js.map +1 -0
  165. package/Physics/v2/physicsConstraint.d.ts +184 -0
  166. package/Physics/v2/physicsConstraint.js +257 -0
  167. package/Physics/v2/physicsConstraint.js.map +1 -0
  168. package/Physics/v2/physicsEngine.d.ts +103 -0
  169. package/Physics/v2/physicsEngine.js +146 -0
  170. package/Physics/v2/physicsEngine.js.map +1 -0
  171. package/Physics/v2/physicsEngineComponent.d.ts +31 -0
  172. package/Physics/v2/physicsEngineComponent.js +50 -0
  173. package/Physics/v2/physicsEngineComponent.js.map +1 -0
  174. package/Physics/v2/physicsMaterial.d.ts +45 -0
  175. package/Physics/v2/physicsMaterial.js +67 -0
  176. package/Physics/v2/physicsMaterial.js.map +1 -0
  177. package/Physics/v2/physicsShape.d.ts +182 -0
  178. package/Physics/v2/physicsShape.js +229 -0
  179. package/Physics/v2/physicsShape.js.map +1 -0
  180. package/PostProcesses/postProcess.d.ts +3 -1
  181. package/PostProcesses/postProcess.js +4 -1
  182. package/PostProcesses/postProcess.js.map +1 -1
  183. package/Rendering/fluidRenderer/fluidRenderer.d.ts +153 -0
  184. package/Rendering/fluidRenderer/fluidRenderer.js +410 -0
  185. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -0
  186. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.d.ts +13 -0
  187. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +31 -0
  188. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -0
  189. package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +81 -0
  190. package/Rendering/fluidRenderer/fluidRenderingObject.js +180 -0
  191. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -0
  192. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.d.ts +63 -0
  193. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +130 -0
  194. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -0
  195. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +64 -0
  196. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +104 -0
  197. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -0
  198. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +234 -0
  199. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +690 -0
  200. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -0
  201. package/Rendering/fluidRenderer/fluidRenderingTextures.d.ts +56 -0
  202. package/Rendering/fluidRenderer/fluidRenderingTextures.js +261 -0
  203. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -0
  204. package/Rendering/fluidRenderer/index.d.ts +5 -0
  205. package/Rendering/fluidRenderer/index.js +6 -0
  206. package/Rendering/fluidRenderer/index.js.map +1 -0
  207. package/Rendering/index.d.ts +1 -0
  208. package/Rendering/index.js +2 -0
  209. package/Rendering/index.js.map +1 -1
  210. package/Shaders/copyTextureToTexture.fragment.js +4 -1
  211. package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
  212. package/Shaders/fluidRenderingBilateralBlur.fragment.d.ts +5 -0
  213. package/Shaders/fluidRenderingBilateralBlur.fragment.js +9 -0
  214. package/Shaders/fluidRenderingBilateralBlur.fragment.js.map +1 -0
  215. package/Shaders/fluidRenderingParticleDepth.fragment.d.ts +5 -0
  216. package/Shaders/fluidRenderingParticleDepth.fragment.js +17 -0
  217. package/Shaders/fluidRenderingParticleDepth.fragment.js.map +1 -0
  218. package/Shaders/fluidRenderingParticleDepth.vertex.d.ts +5 -0
  219. package/Shaders/fluidRenderingParticleDepth.vertex.js +13 -0
  220. package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -0
  221. package/Shaders/fluidRenderingParticleDiffuse.fragment.d.ts +5 -0
  222. package/Shaders/fluidRenderingParticleDiffuse.fragment.js +9 -0
  223. package/Shaders/fluidRenderingParticleDiffuse.fragment.js.map +1 -0
  224. package/Shaders/fluidRenderingParticleDiffuse.vertex.d.ts +5 -0
  225. package/Shaders/fluidRenderingParticleDiffuse.vertex.js +4 -0
  226. package/Shaders/fluidRenderingParticleDiffuse.vertex.js.map +1 -0
  227. package/Shaders/fluidRenderingParticleThickness.fragment.d.ts +5 -0
  228. package/Shaders/fluidRenderingParticleThickness.fragment.js +9 -0
  229. package/Shaders/fluidRenderingParticleThickness.fragment.js.map +1 -0
  230. package/Shaders/fluidRenderingParticleThickness.vertex.d.ts +5 -0
  231. package/Shaders/fluidRenderingParticleThickness.vertex.js +9 -0
  232. package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -0
  233. package/Shaders/fluidRenderingRender.fragment.d.ts +5 -0
  234. package/Shaders/fluidRenderingRender.fragment.js +46 -0
  235. package/Shaders/fluidRenderingRender.fragment.js.map +1 -0
  236. package/Shaders/fluidRenderingStandardBlur.fragment.d.ts +5 -0
  237. package/Shaders/fluidRenderingStandardBlur.fragment.js +9 -0
  238. package/Shaders/fluidRenderingStandardBlur.fragment.js.map +1 -0
  239. package/XR/features/WebXRControllerPhysics.d.ts +1 -1
  240. package/XR/features/WebXRControllerPhysics.js +1 -1
  241. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  242. package/XR/features/WebXRHandTracking.js +1 -1
  243. package/XR/features/WebXRHandTracking.js.map +1 -1
  244. package/package.json +1 -1
  245. package/scene.js +6 -1
  246. package/scene.js.map +1 -1
  247. package/sceneComponent.d.ts +3 -0
  248. package/sceneComponent.js +3 -0
  249. package/sceneComponent.js.map +1 -1
  250. package/Physics/Plugins/index.js.map +0 -1
@@ -1,10 +1,9 @@
1
1
  import { Logger } from "../Misc/logger.js";
2
2
  import { Observable } from "../Misc/observable.js";
3
- import { AbstractMesh } from "../Meshes/abstractMesh.js";
4
3
  import { SceneComponentConstants } from "../sceneComponent.js";
5
4
  import { Scene } from "../scene.js";
6
- import { PhysicsEngine } from "./physicsEngine.js";
7
- import { PhysicsJoint } from "./physicsJoint.js";
5
+ import { PhysicsEngine as PhysicsEngineV1 } from "./v1/physicsEngine.js";
6
+ import { PhysicsEngine as PhysicsEngineV2 } from "./v2/physicsEngine.js";
8
7
  /**
9
8
  * Gets the current physics engine
10
9
  * @returns a IPhysicsEngine or null if none attached
@@ -29,7 +28,15 @@ Scene.prototype.enablePhysics = function (gravity = null, plugin) {
29
28
  this._addComponent(component);
30
29
  }
31
30
  try {
32
- this._physicsEngine = new PhysicsEngine(gravity, plugin);
31
+ if ((plugin === null || plugin === void 0 ? void 0 : plugin.getPluginVersion()) === 1) {
32
+ this._physicsEngine = new PhysicsEngineV1(gravity, plugin);
33
+ }
34
+ else if ((plugin === null || plugin === void 0 ? void 0 : plugin.getPluginVersion()) === 2) {
35
+ this._physicsEngine = new PhysicsEngineV2(gravity, plugin);
36
+ }
37
+ else {
38
+ throw new Error("Unsupported Physics plugin version.");
39
+ }
33
40
  this._physicsTimeAccumulator = 0;
34
41
  return true;
35
42
  }
@@ -88,73 +95,6 @@ Scene.prototype._advancePhysicsEngineStep = function (step) {
88
95
  }
89
96
  }
90
97
  };
91
- Object.defineProperty(AbstractMesh.prototype, "physicsImpostor", {
92
- get: function () {
93
- return this._physicsImpostor;
94
- },
95
- set: function (value) {
96
- if (this._physicsImpostor === value) {
97
- return;
98
- }
99
- if (this._disposePhysicsObserver) {
100
- this.onDisposeObservable.remove(this._disposePhysicsObserver);
101
- }
102
- this._physicsImpostor = value;
103
- if (value) {
104
- this._disposePhysicsObserver = this.onDisposeObservable.add(() => {
105
- // Physics
106
- if (this.physicsImpostor) {
107
- this.physicsImpostor.dispose( /*!doNotRecurse*/);
108
- this.physicsImpostor = null;
109
- }
110
- });
111
- }
112
- },
113
- enumerable: true,
114
- configurable: true,
115
- });
116
- /**
117
- * Gets the current physics impostor
118
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics
119
- * @returns a physics impostor or null
120
- */
121
- AbstractMesh.prototype.getPhysicsImpostor = function () {
122
- return this.physicsImpostor;
123
- };
124
- /**
125
- * Apply a physic impulse to the mesh
126
- * @param force defines the force to apply
127
- * @param contactPoint defines where to apply the force
128
- * @returns the current mesh
129
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
130
- */
131
- AbstractMesh.prototype.applyImpulse = function (force, contactPoint) {
132
- if (!this.physicsImpostor) {
133
- return this;
134
- }
135
- this.physicsImpostor.applyImpulse(force, contactPoint);
136
- return this;
137
- };
138
- /**
139
- * Creates a physic joint between two meshes
140
- * @param otherMesh defines the other mesh to use
141
- * @param pivot1 defines the pivot to use on this mesh
142
- * @param pivot2 defines the pivot to use on the other mesh
143
- * @param options defines additional options (can be plugin dependent)
144
- * @returns the current mesh
145
- * @see https://www.babylonjs-playground.com/#0BS5U0#0
146
- */
147
- AbstractMesh.prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
148
- if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
149
- return this;
150
- }
151
- this.physicsImpostor.createJoint(otherMesh.physicsImpostor, PhysicsJoint.HingeJoint, {
152
- mainPivot: pivot1,
153
- connectedPivot: pivot2,
154
- nativeParams: options,
155
- });
156
- return this;
157
- };
158
98
  /**
159
99
  * Defines the physics engine scene component responsible to manage a physics engine
160
100
  */
@@ -1 +1 @@
1
- {"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../lts/core/generated/Physics/physicsEngineComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAoD9C;;;GAGG;AACH,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG;IAC/B,OAAO,IAAI,CAAC,cAAc,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;;GAKG;AACH,KAAK,CAAC,SAAS,CAAC,aAAa,GAAG,UAAU,UAA6B,IAAI,EAAE,MAA6B;IACtG,IAAI,IAAI,CAAC,cAAc,EAAE;QACrB,OAAO,IAAI,CAAC;KACf;IAED,sCAAsC;IACtC,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,kBAAkB,CAAgC,CAAC;IAC9G,IAAI,CAAC,SAAS,EAAE;QACZ,SAAS,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,C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AAC;QAE9D,gEAAgE;QAChE,IAAI,CAAC,KAAK,CAAC,yBAAyB,GAAG,GAAG,EAAE;YACxC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;gBAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC;aACzD;YAED,OAAO,MAAM,GAAG,IAAI,CAAC;QACzB,CAAC,CAAC;IACN,CAAC;IAED;;OAEG;IACI,QAAQ,KAAU,CAAC;IAE1B;;;OAGG;IACI,OAAO;QACV,mCAAmC;IACvC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAE5C,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;SACrC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { ISceneComponent } from \"../sceneComponent\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { Scene } from \"../scene\";\r\nimport type { Node } from \"../node\";\r\n\r\nimport type { IPhysicsEngine, IPhysicsEnginePlugin } from \"./IPhysicsEngine\";\r\nimport { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { PhysicsImpostor } from \"./physicsImpostor\";\r\nimport { PhysicsJoint } from \"./physicsJoint\";\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @internal (Backing field) */\r\n _physicsEngine: Nullable<IPhysicsEngine>;\r\n /** @internal */\r\n _physicsTimeAccumulator: number;\r\n\r\n /**\r\n * Gets the current physics engine\r\n * @returns a IPhysicsEngine or null if none attached\r\n */\r\n getPhysicsEngine(): Nullable<IPhysicsEngine>;\r\n\r\n /**\r\n * Enables physics to the current scene\r\n * @param gravity defines the scene's gravity for the physics engine. defaults to real earth gravity : (0, -9.81, 0)\r\n * @param plugin defines the physics engine to be used. defaults to CannonJS.\r\n * @returns a boolean indicating if the physics engine was initialized\r\n */\r\n enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;\r\n\r\n /**\r\n * Disables and disposes the physics engine associated with the scene\r\n */\r\n disablePhysicsEngine(): void;\r\n\r\n /**\r\n * Gets a boolean indicating if there is an active physics engine\r\n * @returns a boolean indicating if there is an active physics engine\r\n */\r\n isPhysicsEnabled(): boolean;\r\n\r\n /**\r\n * Deletes a physics compound impostor\r\n * @param compound defines the compound to delete\r\n */\r\n deleteCompoundImpostor(compound: any): void;\r\n\r\n /**\r\n * An event triggered when physic simulation is about to be run\r\n */\r\n onBeforePhysicsObservable: Observable<Scene>;\r\n\r\n /**\r\n * An event triggered when physic simulation has been done\r\n */\r\n onAfterPhysicsObservable: Observable<Scene>;\r\n }\r\n}\r\n\r\n/**\r\n * Gets the current physics engine\r\n * @returns a IPhysicsEngine or null if none attached\r\n */\r\nScene.prototype.getPhysicsEngine = function (): Nullable<IPhysicsEngine> {\r\n return this._physicsEngine;\r\n};\r\n\r\n/**\r\n * Enables physics to the current scene\r\n * @param gravity defines the scene's gravity for the physics engine\r\n * @param plugin defines the physics engine to be used. defaults to CannonJS.\r\n * @returns a boolean indicating if the physics engine was initialized\r\n */\r\nScene.prototype.enablePhysics = function (gravity: Nullable<Vector3> = null, plugin?: IPhysicsEnginePlugin): boolean {\r\n if (this._physicsEngine) {\r\n return true;\r\n }\r\n\r\n // Register the component to the scene\r\n let component = this._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE) as PhysicsEngineSceneComponent;\r\n if (!component) {\r\n component = new PhysicsEngineSceneComponent(this);\r\n this._addComponent(component);\r\n }\r\n\r\n try {\r\n this._physicsEngine = new PhysicsEngine(gravity, plugin);\r\n this._physicsTimeAccumulator = 0;\r\n return true;\r\n } catch (e) {\r\n Logger.Error(e.message);\r\n return false;\r\n }\r\n};\r\n\r\n/**\r\n * Disables and disposes the physics engine associated with the scene\r\n */\r\nScene.prototype.disablePhysicsEngine = function (): void {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._physicsEngine.dispose();\r\n this._physicsEngine = null;\r\n};\r\n\r\n/**\r\n * Gets a boolean indicating if there is an active physics engine\r\n * @returns a boolean indicating if there is an active physics engine\r\n */\r\nScene.prototype.isPhysicsEnabled = function (): boolean {\r\n return this._physicsEngine !== undefined;\r\n};\r\n\r\n/**\r\n * Deletes a physics compound impostor\r\n * @param compound defines the compound to delete\r\n */\r\nScene.prototype.deleteCompoundImpostor = function (compound: any): void {\r\n const mesh: AbstractMesh = compound.parts[0].mesh;\r\n\r\n if (mesh.physicsImpostor) {\r\n mesh.physicsImpostor.dispose(/*true*/);\r\n mesh.physicsImpostor = null;\r\n }\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nScene.prototype._advancePhysicsEngineStep = function (step: number) {\r\n if (this._physicsEngine) {\r\n const subTime = this._physicsEngine.getSubTimeStep();\r\n if (subTime > 0) {\r\n this._physicsTimeAccumulator += step;\r\n while (this._physicsTimeAccumulator > subTime) {\r\n this.onBeforePhysicsObservable.notifyObservers(this);\r\n this._physicsEngine._step(subTime / 1000);\r\n this.onAfterPhysicsObservable.notifyObservers(this);\r\n this._physicsTimeAccumulator -= subTime;\r\n }\r\n } else {\r\n this.onBeforePhysicsObservable.notifyObservers(this);\r\n this._physicsEngine._step(step / 1000);\r\n this.onAfterPhysicsObservable.notifyObservers(this);\r\n }\r\n }\r\n};\r\n\r\ndeclare module \"../Meshes/abstractMesh\" {\r\n export interface AbstractMesh {\r\n /** @internal */\r\n _physicsImpostor: Nullable<PhysicsImpostor>;\r\n\r\n /**\r\n * Gets or sets impostor used for physic simulation\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics\r\n */\r\n physicsImpostor: Nullable<PhysicsImpostor>;\r\n\r\n /**\r\n * Gets the current physics impostor\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics\r\n * @returns a physics impostor or null\r\n */\r\n getPhysicsImpostor(): Nullable<PhysicsImpostor>;\r\n\r\n /** Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\n applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;\r\n\r\n /**\r\n * Creates a physic joint between two meshes\r\n * @param otherMesh defines the other mesh to use\r\n * @param pivot1 defines the pivot to use on this mesh\r\n * @param pivot2 defines the pivot to use on the other mesh\r\n * @param options defines additional options (can be plugin dependent)\r\n * @returns the current mesh\r\n * @see https://www.babylonjs-playground.com/#0BS5U0#0\r\n */\r\n setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;\r\n\r\n /** @internal */\r\n _disposePhysicsObserver: Nullable<Observer<Node>>;\r\n }\r\n}\r\n\r\nObject.defineProperty(AbstractMesh.prototype, \"physicsImpostor\", {\r\n get: function (this: AbstractMesh) {\r\n return this._physicsImpostor;\r\n },\r\n set: function (this: AbstractMesh, value: Nullable<PhysicsImpostor>) {\r\n if (this._physicsImpostor === value) {\r\n return;\r\n }\r\n if (this._disposePhysicsObserver) {\r\n this.onDisposeObservable.remove(this._disposePhysicsObserver);\r\n }\r\n\r\n this._physicsImpostor = value;\r\n\r\n if (value) {\r\n this._disposePhysicsObserver = this.onDisposeObservable.add(() => {\r\n // Physics\r\n if (this.physicsImpostor) {\r\n this.physicsImpostor.dispose(/*!doNotRecurse*/);\r\n this.physicsImpostor = null;\r\n }\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Gets the current physics impostor\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics\r\n * @returns a physics impostor or null\r\n */\r\nAbstractMesh.prototype.getPhysicsImpostor = function (): Nullable<PhysicsImpostor> {\r\n return this.physicsImpostor;\r\n};\r\n\r\n/**\r\n * Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nAbstractMesh.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): AbstractMesh {\r\n if (!this.physicsImpostor) {\r\n return this;\r\n }\r\n this.physicsImpostor.applyImpulse(force, contactPoint);\r\n return this;\r\n};\r\n\r\n/**\r\n * Creates a physic joint between two meshes\r\n * @param otherMesh defines the other mesh to use\r\n * @param pivot1 defines the pivot to use on this mesh\r\n * @param pivot2 defines the pivot to use on the other mesh\r\n * @param options defines additional options (can be plugin dependent)\r\n * @returns the current mesh\r\n * @see https://www.babylonjs-playground.com/#0BS5U0#0\r\n */\r\nAbstractMesh.prototype.setPhysicsLinkWith = function (otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh {\r\n if (!this.physicsImpostor || !otherMesh.physicsImpostor) {\r\n return this;\r\n }\r\n this.physicsImpostor.createJoint(otherMesh.physicsImpostor, PhysicsJoint.HingeJoint, {\r\n mainPivot: pivot1,\r\n connectedPivot: pivot2,\r\n nativeParams: options,\r\n });\r\n return this;\r\n};\r\n\r\n/**\r\n * Defines the physics engine scene component responsible to manage a physics engine\r\n */\r\nexport class PhysicsEngineSceneComponent implements ISceneComponent {\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_PHYSICSENGINE;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Creates a new instance of the component for the given scene\r\n * @param scene Defines the scene to register the component in\r\n */\r\n constructor(scene: Scene) {\r\n this.scene = scene;\r\n this.scene.onBeforePhysicsObservable = new Observable<Scene>();\r\n this.scene.onAfterPhysicsObservable = new Observable<Scene>();\r\n\r\n // Replace the function used to get the deterministic frame time\r\n this.scene.getDeterministicFrameTime = () => {\r\n if (this.scene._physicsEngine) {\r\n return this.scene._physicsEngine.getTimeStep() * 1000;\r\n }\r\n\r\n return 1000.0 / 60.0;\r\n };\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {}\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n // Nothing to do for this component\r\n }\r\n\r\n /**\r\n * Disposes the component and the associated resources\r\n */\r\n public dispose(): void {\r\n this.scene.onBeforePhysicsObservable.clear();\r\n this.scene.onAfterPhysicsObservable.clear();\r\n\r\n if (this.scene._physicsEngine) {\r\n this.scene.disablePhysicsEngine();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../lts/core/generated/Physics/physicsEngineComponent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAuDtE;;;GAGG;AACH,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG;IAC/B,OAAO,IAAI,CAAC,cAAc,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;;GAKG;AACH,KAAK,CAAC,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AM,OAAO,2BAA2B;IAWpC;;;OAGG;IACH,YAAY,KAAY;QAdxB;;WAEG;QACa,SAAI,GAAG,uBAAuB,CAAC,kBAAkB,CAAC;QAY9D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,yBAAyB,GAAG,IAAI,UAAU,EAAS,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,wBAAwB,GAAG,IAAI,UAAU,EAAS,CAAC;QAE9D,gEAAgE;QAChE,IAAI,CAAC,KAAK,CAAC,yBAAyB,GAAG,GAAG,EAAE;YACxC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;gBAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC;aACzD;YAED,OAAO,MAAM,GAAG,IAAI,CAAC;QACzB,CAAC,CAAC;IACN,CAAC;IAED;;OAEG;IACI,QAAQ,KAAU,CAAC;IAE1B;;;OAGG;IACI,OAAO;QACV,mCAAmC;IACvC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAE5C,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;SACrC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { ISceneComponent } from \"../sceneComponent\";\r\nimport { SceneComponentConstants } from \"../sceneComponent\";\r\nimport { Scene } from \"../scene\";\r\nimport type { IPhysicsEngine } from \"./IPhysicsEngine\";\r\nimport type { IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from \"./v1/IPhysicsEnginePlugin\";\r\nimport type { IPhysicsEnginePlugin as IPhysicsEnginePluginV2 } from \"./v2/IPhysicsEnginePlugin\";\r\nimport { PhysicsEngine as PhysicsEngineV1 } from \"./v1/physicsEngine\";\r\nimport { PhysicsEngine as PhysicsEngineV2 } from \"./v2/physicsEngine\";\r\n\r\ndeclare module \"../scene\" {\r\n /**\r\n *\r\n */\r\n export interface Scene {\r\n /** @internal (Backing field) */\r\n _physicsEngine: Nullable<IPhysicsEngine>;\r\n /** @internal */\r\n _physicsTimeAccumulator: number;\r\n\r\n /**\r\n * Gets the current physics engine\r\n * @returns a IPhysicsEngine or null if none attached\r\n */\r\n getPhysicsEngine(): Nullable<IPhysicsEngine>;\r\n\r\n /**\r\n * Enables physics to the current scene\r\n * @param gravity defines the scene's gravity for the physics engine. defaults to real earth gravity : (0, -9.81, 0)\r\n * @param plugin defines the physics engine to be used. defaults to CannonJS.\r\n * @returns a boolean indicating if the physics engine was initialized\r\n */\r\n enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2): boolean;\r\n\r\n /**\r\n * Disables and disposes the physics engine associated with the scene\r\n */\r\n disablePhysicsEngine(): void;\r\n\r\n /**\r\n * Gets a boolean indicating if there is an active physics engine\r\n * @returns a boolean indicating if there is an active physics engine\r\n */\r\n isPhysicsEnabled(): boolean;\r\n\r\n /**\r\n * Deletes a physics compound impostor\r\n * @param compound defines the compound to delete\r\n */\r\n deleteCompoundImpostor(compound: any): void;\r\n\r\n /**\r\n * An event triggered when physic simulation is about to be run\r\n */\r\n onBeforePhysicsObservable: Observable<Scene>;\r\n\r\n /**\r\n * An event triggered when physic simulation has been done\r\n */\r\n onAfterPhysicsObservable: Observable<Scene>;\r\n }\r\n}\r\n\r\n/**\r\n * Gets the current physics engine\r\n * @returns a IPhysicsEngine or null if none attached\r\n */\r\nScene.prototype.getPhysicsEngine = function (): Nullable<IPhysicsEngine> {\r\n return this._physicsEngine;\r\n};\r\n\r\n/**\r\n * Enables physics to the current scene\r\n * @param gravity defines the scene's gravity for the physics engine\r\n * @param plugin defines the physics engine to be used. defaults to CannonJS.\r\n * @returns a boolean indicating if the physics engine was initialized\r\n */\r\nScene.prototype.enablePhysics = function (gravity: Nullable<Vector3> = null, plugin?: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2): boolean {\r\n if (this._physicsEngine) {\r\n return true;\r\n }\r\n\r\n // Register the component to the scene\r\n let component = this._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE) as PhysicsEngineSceneComponent;\r\n if (!component) {\r\n component = new PhysicsEngineSceneComponent(this);\r\n this._addComponent(component);\r\n }\r\n\r\n try {\r\n if (plugin?.getPluginVersion() === 1) {\r\n this._physicsEngine = new PhysicsEngineV1(gravity, plugin as IPhysicsEnginePluginV1);\r\n } else if (plugin?.getPluginVersion() === 2) {\r\n this._physicsEngine = new PhysicsEngineV2(gravity, plugin as IPhysicsEnginePluginV2);\r\n } else {\r\n throw new Error(\"Unsupported Physics plugin version.\");\r\n }\r\n this._physicsTimeAccumulator = 0;\r\n return true;\r\n } catch (e) {\r\n Logger.Error(e.message);\r\n return false;\r\n }\r\n};\r\n\r\n/**\r\n * Disables and disposes the physics engine associated with the scene\r\n */\r\nScene.prototype.disablePhysicsEngine = function (): void {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._physicsEngine.dispose();\r\n this._physicsEngine = null;\r\n};\r\n\r\n/**\r\n * Gets a boolean indicating if there is an active physics engine\r\n * @returns a boolean indicating if there is an active physics engine\r\n */\r\nScene.prototype.isPhysicsEnabled = function (): boolean {\r\n return this._physicsEngine !== undefined;\r\n};\r\n\r\n/**\r\n * Deletes a physics compound impostor\r\n * @param compound defines the compound to delete\r\n */\r\nScene.prototype.deleteCompoundImpostor = function (compound: any): void {\r\n const mesh: AbstractMesh = compound.parts[0].mesh;\r\n\r\n if (mesh.physicsImpostor) {\r\n mesh.physicsImpostor.dispose(/*true*/);\r\n mesh.physicsImpostor = null;\r\n }\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nScene.prototype._advancePhysicsEngineStep = function (step: number) {\r\n if (this._physicsEngine) {\r\n const subTime = this._physicsEngine.getSubTimeStep();\r\n if (subTime > 0) {\r\n this._physicsTimeAccumulator += step;\r\n while (this._physicsTimeAccumulator > subTime) {\r\n this.onBeforePhysicsObservable.notifyObservers(this);\r\n this._physicsEngine._step(subTime / 1000);\r\n this.onAfterPhysicsObservable.notifyObservers(this);\r\n this._physicsTimeAccumulator -= subTime;\r\n }\r\n } else {\r\n this.onBeforePhysicsObservable.notifyObservers(this);\r\n this._physicsEngine._step(step / 1000);\r\n this.onAfterPhysicsObservable.notifyObservers(this);\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Defines the physics engine scene component responsible to manage a physics engine\r\n */\r\nexport class PhysicsEngineSceneComponent implements ISceneComponent {\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_PHYSICSENGINE;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Creates a new instance of the component for the given scene\r\n * @param scene Defines the scene to register the component in\r\n */\r\n constructor(scene: Scene) {\r\n this.scene = scene;\r\n this.scene.onBeforePhysicsObservable = new Observable<Scene>();\r\n this.scene.onAfterPhysicsObservable = new Observable<Scene>();\r\n\r\n // Replace the function used to get the deterministic frame time\r\n this.scene.getDeterministicFrameTime = () => {\r\n if (this.scene._physicsEngine) {\r\n return this.scene._physicsEngine.getTimeStep() * 1000;\r\n }\r\n\r\n return 1000.0 / 60.0;\r\n };\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {}\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n // Nothing to do for this component\r\n }\r\n\r\n /**\r\n * Disposes the component and the associated resources\r\n */\r\n public dispose(): void {\r\n this.scene.onBeforePhysicsObservable.clear();\r\n this.scene.onAfterPhysicsObservable.clear();\r\n\r\n if (this.scene._physicsEngine) {\r\n this.scene.disablePhysicsEngine();\r\n }\r\n }\r\n}\r\n"]}
@@ -1,411 +1 @@
1
- import type { Nullable } from "../types";
2
- import { Vector3 } from "../Maths/math.vector";
3
- import type { Mesh } from "../Meshes/mesh";
4
- import type { Scene } from "../scene";
5
- import type { PhysicsImpostor } from "./physicsImpostor";
6
- /**
7
- * A helper for physics simulations
8
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
9
- */
10
- export declare class PhysicsHelper {
11
- private _scene;
12
- private _physicsEngine;
13
- /**
14
- * Initializes the Physics helper
15
- * @param scene Babylon.js scene
16
- */
17
- constructor(scene: Scene);
18
- /**
19
- * Applies a radial explosion impulse
20
- * @param origin the origin of the explosion
21
- * @param radiusOrEventOptions the radius or the options of radial explosion
22
- * @param strength the explosion strength
23
- * @param falloff possible options: Constant & Linear. Defaults to Constant
24
- * @returns A physics radial explosion event, or null
25
- */
26
- applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
27
- /**
28
- * Applies a radial explosion force
29
- * @param origin the origin of the explosion
30
- * @param radiusOrEventOptions the radius or the options of radial explosion
31
- * @param strength the explosion strength
32
- * @param falloff possible options: Constant & Linear. Defaults to Constant
33
- * @returns A physics radial explosion event, or null
34
- */
35
- applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
36
- /**
37
- * Creates a gravitational field
38
- * @param origin the origin of the explosion
39
- * @param radiusOrEventOptions the radius or the options of radial explosion
40
- * @param strength the explosion strength
41
- * @param falloff possible options: Constant & Linear. Defaults to Constant
42
- * @returns A physics gravitational field event, or null
43
- */
44
- gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
45
- /**
46
- * Creates a physics updraft event
47
- * @param origin the origin of the updraft
48
- * @param radiusOrEventOptions the radius or the options of the updraft
49
- * @param strength the strength of the updraft
50
- * @param height the height of the updraft
51
- * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
52
- * @returns A physics updraft event, or null
53
- */
54
- updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
55
- /**
56
- * Creates a physics vortex event
57
- * @param origin the of the vortex
58
- * @param radiusOrEventOptions the radius or the options of the vortex
59
- * @param strength the strength of the vortex
60
- * @param height the height of the vortex
61
- * @returns a Physics vortex event, or null
62
- * A physics vortex event or null
63
- */
64
- vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
65
- }
66
- /**
67
- * Represents a physics radial explosion event
68
- */
69
- declare class PhysicsRadialExplosionEvent {
70
- private _scene;
71
- private _options;
72
- private _sphere;
73
- private _dataFetched;
74
- /**
75
- * Initializes a radial explosion event
76
- * @param _scene BabylonJS scene
77
- * @param _options The options for the vortex event
78
- */
79
- constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
80
- /**
81
- * Returns the data related to the radial explosion event (sphere).
82
- * @returns The radial explosion event data
83
- */
84
- getData(): PhysicsRadialExplosionEventData;
85
- /**
86
- * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
87
- * @param impostor A physics imposter
88
- * @param origin the origin of the explosion
89
- * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
90
- */
91
- getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
92
- /**
93
- * Triggers affected impostors callbacks
94
- * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
95
- */
96
- triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
97
- /**
98
- * Disposes the sphere.
99
- * @param force Specifies if the sphere should be disposed by force
100
- */
101
- dispose(force?: boolean): void;
102
- /*** Helpers ***/
103
- private _prepareSphere;
104
- private _intersectsWithSphere;
105
- }
106
- /**
107
- * Represents a gravitational field event
108
- */
109
- declare class PhysicsGravitationalFieldEvent {
110
- private _physicsHelper;
111
- private _scene;
112
- private _origin;
113
- private _options;
114
- private _tickCallback;
115
- private _sphere;
116
- private _dataFetched;
117
- /**
118
- * Initializes the physics gravitational field event
119
- * @param _physicsHelper A physics helper
120
- * @param _scene BabylonJS scene
121
- * @param _origin The origin position of the gravitational field event
122
- * @param _options The options for the vortex event
123
- */
124
- constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
125
- /**
126
- * Returns the data related to the gravitational field event (sphere).
127
- * @returns A gravitational field event
128
- */
129
- getData(): PhysicsGravitationalFieldEventData;
130
- /**
131
- * Enables the gravitational field.
132
- */
133
- enable(): void;
134
- /**
135
- * Disables the gravitational field.
136
- */
137
- disable(): void;
138
- /**
139
- * Disposes the sphere.
140
- * @param force The force to dispose from the gravitational field event
141
- */
142
- dispose(force?: boolean): void;
143
- private _tick;
144
- }
145
- /**
146
- * Represents a physics updraft event
147
- */
148
- declare class PhysicsUpdraftEvent {
149
- private _scene;
150
- private _origin;
151
- private _options;
152
- private _physicsEngine;
153
- private _originTop;
154
- private _originDirection;
155
- private _tickCallback;
156
- private _cylinder;
157
- private _cylinderPosition;
158
- private _dataFetched;
159
- /**
160
- * Initializes the physics updraft event
161
- * @param _scene BabylonJS scene
162
- * @param _origin The origin position of the updraft
163
- * @param _options The options for the updraft event
164
- */
165
- constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
166
- /**
167
- * Returns the data related to the updraft event (cylinder).
168
- * @returns A physics updraft event
169
- */
170
- getData(): PhysicsUpdraftEventData;
171
- /**
172
- * Enables the updraft.
173
- */
174
- enable(): void;
175
- /**
176
- * Disables the updraft.
177
- */
178
- disable(): void;
179
- /**
180
- * Disposes the cylinder.
181
- * @param force Specifies if the updraft should be disposed by force
182
- */
183
- dispose(force?: boolean): void;
184
- private _getImpostorHitData;
185
- private _tick;
186
- /*** Helpers ***/
187
- private _prepareCylinder;
188
- private _intersectsWithCylinder;
189
- }
190
- /**
191
- * Represents a physics vortex event
192
- */
193
- declare class PhysicsVortexEvent {
194
- private _scene;
195
- private _origin;
196
- private _options;
197
- private _physicsEngine;
198
- private _originTop;
199
- private _tickCallback;
200
- private _cylinder;
201
- private _cylinderPosition;
202
- private _dataFetched;
203
- /**
204
- * Initializes the physics vortex event
205
- * @param _scene The BabylonJS scene
206
- * @param _origin The origin position of the vortex
207
- * @param _options The options for the vortex event
208
- */
209
- constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
210
- /**
211
- * Returns the data related to the vortex event (cylinder).
212
- * @returns The physics vortex event data
213
- */
214
- getData(): PhysicsVortexEventData;
215
- /**
216
- * Enables the vortex.
217
- */
218
- enable(): void;
219
- /**
220
- * Disables the cortex.
221
- */
222
- disable(): void;
223
- /**
224
- * Disposes the sphere.
225
- * @param force
226
- */
227
- dispose(force?: boolean): void;
228
- private _getImpostorHitData;
229
- private _tick;
230
- /*** Helpers ***/
231
- private _prepareCylinder;
232
- private _intersectsWithCylinder;
233
- }
234
- /**
235
- * Options fot the radial explosion event
236
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
237
- */
238
- export declare class PhysicsRadialExplosionEventOptions {
239
- /**
240
- * The radius of the sphere for the radial explosion.
241
- */
242
- radius: number;
243
- /**
244
- * The strength of the explosion.
245
- */
246
- strength: number;
247
- /**
248
- * The strength of the force in correspondence to the distance of the affected object
249
- */
250
- falloff: PhysicsRadialImpulseFalloff;
251
- /**
252
- * Sphere options for the radial explosion.
253
- */
254
- sphere: {
255
- segments: number;
256
- diameter: number;
257
- };
258
- /**
259
- * Sphere options for the radial explosion.
260
- */
261
- affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
262
- }
263
- /**
264
- * Options fot the updraft event
265
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
266
- */
267
- export declare class PhysicsUpdraftEventOptions {
268
- /**
269
- * The radius of the cylinder for the vortex
270
- */
271
- radius: number;
272
- /**
273
- * The strength of the updraft.
274
- */
275
- strength: number;
276
- /**
277
- * The height of the cylinder for the updraft.
278
- */
279
- height: number;
280
- /**
281
- * The mode for the the updraft.
282
- */
283
- updraftMode: PhysicsUpdraftMode;
284
- }
285
- /**
286
- * Options fot the vortex event
287
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
288
- */
289
- export declare class PhysicsVortexEventOptions {
290
- /**
291
- * The radius of the cylinder for the vortex
292
- */
293
- radius: number;
294
- /**
295
- * The strength of the vortex.
296
- */
297
- strength: number;
298
- /**
299
- * The height of the cylinder for the vortex.
300
- */
301
- height: number;
302
- /**
303
- * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
304
- */
305
- centripetalForceThreshold: number;
306
- /**
307
- * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
308
- */
309
- centripetalForceMultiplier: number;
310
- /**
311
- * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
312
- */
313
- centrifugalForceMultiplier: number;
314
- /**
315
- * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
316
- */
317
- updraftForceMultiplier: number;
318
- }
319
- /**
320
- * The strength of the force in correspondence to the distance of the affected object
321
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
322
- */
323
- export declare enum PhysicsRadialImpulseFalloff {
324
- /** Defines that impulse is constant in strength across it's whole radius */
325
- Constant = 0,
326
- /** Defines that impulse gets weaker if it's further from the origin */
327
- Linear = 1
328
- }
329
- /**
330
- * The strength of the force in correspondence to the distance of the affected object
331
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
332
- */
333
- export declare enum PhysicsUpdraftMode {
334
- /** Defines that the upstream forces will pull towards the top center of the cylinder */
335
- Center = 0,
336
- /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
337
- Perpendicular = 1
338
- }
339
- /**
340
- * Interface for a physics hit data
341
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
342
- */
343
- export interface PhysicsHitData {
344
- /**
345
- * The force applied at the contact point
346
- */
347
- force: Vector3;
348
- /**
349
- * The contact point
350
- */
351
- contactPoint: Vector3;
352
- /**
353
- * The distance from the origin to the contact point
354
- */
355
- distanceFromOrigin: number;
356
- }
357
- /**
358
- * Interface for radial explosion event data
359
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
360
- */
361
- export interface PhysicsRadialExplosionEventData {
362
- /**
363
- * A sphere used for the radial explosion event
364
- */
365
- sphere: Mesh;
366
- }
367
- /**
368
- * Interface for gravitational field event data
369
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
370
- */
371
- export interface PhysicsGravitationalFieldEventData {
372
- /**
373
- * A sphere mesh used for the gravitational field event
374
- */
375
- sphere: Mesh;
376
- }
377
- /**
378
- * Interface for updraft event data
379
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
380
- */
381
- export interface PhysicsUpdraftEventData {
382
- /**
383
- * A cylinder used for the updraft event
384
- */
385
- cylinder: Mesh;
386
- }
387
- /**
388
- * Interface for vortex event data
389
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
390
- */
391
- export interface PhysicsVortexEventData {
392
- /**
393
- * A cylinder used for the vortex event
394
- */
395
- cylinder: Mesh;
396
- }
397
- /**
398
- * Interface for an affected physics impostor
399
- * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine#further-functionality-of-the-impostor-class
400
- */
401
- export interface PhysicsAffectedImpostorWithData {
402
- /**
403
- * The impostor affected by the effect
404
- */
405
- impostor: PhysicsImpostor;
406
- /**
407
- * The data about the hit/force from the explosion
408
- */
409
- hitData: PhysicsHitData;
410
- }
411
- export {};
1
+ export * from "./v1/physicsHelper";