@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
@@ -0,0 +1,103 @@
1
+ import type { Nullable } from "../../types";
2
+ import { Vector3 } from "../../Maths/math.vector";
3
+ import type { IPhysicsEngine } from "../IPhysicsEngine";
4
+ import type { IPhysicsEnginePlugin } from "./IPhysicsEnginePlugin";
5
+ import { PhysicsRaycastResult } from "../physicsRaycastResult";
6
+ /**
7
+ * Class used to control physics engine
8
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
9
+ */
10
+ /** @internal */
11
+ export declare class PhysicsEngine implements IPhysicsEngine {
12
+ private _physicsPlugin;
13
+ /** @internal */
14
+ /**
15
+ * Global value used to control the smallest number supported by the simulation
16
+ */
17
+ static Epsilon: number;
18
+ private _subTimeStep;
19
+ /**
20
+ * Gets the gravity vector used by the simulation
21
+ */
22
+ gravity: Vector3;
23
+ getPluginVersion(): number;
24
+ /**
25
+ * Factory used to create the default physics plugin.
26
+ * @returns The default physics plugin
27
+ */
28
+ static DefaultPluginFactory(): IPhysicsEnginePlugin;
29
+ /**
30
+ * Creates a new Physics Engine
31
+ * @param gravity defines the gravity vector used by the simulation
32
+ * @param _physicsPlugin defines the plugin to use (CannonJS by default)
33
+ */
34
+ constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
35
+ /**
36
+ * Sets the gravity vector used by the simulation
37
+ * @param gravity defines the gravity vector to use
38
+ */
39
+ setGravity(gravity: Vector3): void;
40
+ /**
41
+ * Set the time step of the physics engine.
42
+ * Default is 1/60.
43
+ * To slow it down, enter 1/600 for example.
44
+ * To speed it up, 1/30
45
+ * @param newTimeStep defines the new timestep to apply to this world.
46
+ */
47
+ setTimeStep(newTimeStep?: number): void;
48
+ /**
49
+ * Get the time step of the physics engine.
50
+ * @returns the current time step
51
+ */
52
+ getTimeStep(): number;
53
+ /**
54
+ * Set the sub time step of the physics engine.
55
+ * Default is 0 meaning there is no sub steps
56
+ * To increase physics resolution precision, set a small value (like 1 ms)
57
+ * @param subTimeStep defines the new sub timestep used for physics resolution.
58
+ */
59
+ setSubTimeStep(subTimeStep?: number): void;
60
+ /**
61
+ * Get the sub time step of the physics engine.
62
+ * @returns the current sub time step
63
+ */
64
+ getSubTimeStep(): number;
65
+ /**
66
+ * Release all resources
67
+ */
68
+ dispose(): void;
69
+ /**
70
+ * Gets the name of the current physics plugin
71
+ * @returns the name of the plugin
72
+ */
73
+ getPhysicsPluginName(): string;
74
+ /**
75
+ * Adding a new impostor for the impostor tracking.
76
+ * This will be done by the impostor itself.
77
+ * @param impostor the impostor to add
78
+ */
79
+ /**
80
+ * Called by the scene. No need to call it.
81
+ * @param delta defines the timespan between frames
82
+ */
83
+ _step(delta: number): void;
84
+ /**
85
+ * Gets the current plugin used to run the simulation
86
+ * @returns current plugin
87
+ */
88
+ getPhysicsPlugin(): IPhysicsEnginePlugin;
89
+ /**
90
+ * Does a raycast in the physics world
91
+ * @param from when should the ray start?
92
+ * @param to when should the ray end?
93
+ * @param result resulting PhysicsRaycastResult
94
+ */
95
+ raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void;
96
+ /**
97
+ * Does a raycast in the physics world
98
+ * @param from when should the ray start?
99
+ * @param to when should the ray end?
100
+ * @returns PhysicsRaycastResult
101
+ */
102
+ raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
103
+ }
@@ -0,0 +1,146 @@
1
+ import { Vector3 } from "../../Maths/math.vector.js";
2
+ import { PhysicsRaycastResult } from "../physicsRaycastResult.js";
3
+ import { _WarnImport } from "../../Misc/devTools.js";
4
+ /**
5
+ * Class used to control physics engine
6
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
7
+ */
8
+ /** @internal */
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
+ //private _impostors: Array<PhysicsImpostor> = [];
18
+ //private _joints: Array<PhysicsImpostorJoint> = [];
19
+ this._subTimeStep = 0;
20
+ gravity = gravity || new Vector3(0, -9.807, 0);
21
+ this.setGravity(gravity);
22
+ this.setTimeStep();
23
+ }
24
+ getPluginVersion() {
25
+ return this._physicsPlugin.getPluginVersion();
26
+ }
27
+ /**
28
+ * Factory used to create the default physics plugin.
29
+ * @returns The default physics plugin
30
+ */
31
+ static DefaultPluginFactory() {
32
+ throw _WarnImport("");
33
+ }
34
+ /**
35
+ * Sets the gravity vector used by the simulation
36
+ * @param gravity defines the gravity vector to use
37
+ */
38
+ setGravity(gravity) {
39
+ this.gravity = gravity;
40
+ this._physicsPlugin.setGravity(this.gravity);
41
+ }
42
+ /**
43
+ * Set the time step of the physics engine.
44
+ * Default is 1/60.
45
+ * To slow it down, enter 1/600 for example.
46
+ * To speed it up, 1/30
47
+ * @param newTimeStep defines the new timestep to apply to this world.
48
+ */
49
+ setTimeStep(newTimeStep = 1 / 60) {
50
+ this._physicsPlugin.setTimeStep(newTimeStep);
51
+ }
52
+ /**
53
+ * Get the time step of the physics engine.
54
+ * @returns the current time step
55
+ */
56
+ getTimeStep() {
57
+ return this._physicsPlugin.getTimeStep();
58
+ }
59
+ /**
60
+ * Set the sub time step of the physics engine.
61
+ * Default is 0 meaning there is no sub steps
62
+ * To increase physics resolution precision, set a small value (like 1 ms)
63
+ * @param subTimeStep defines the new sub timestep used for physics resolution.
64
+ */
65
+ setSubTimeStep(subTimeStep = 0) {
66
+ this._subTimeStep = subTimeStep;
67
+ }
68
+ /**
69
+ * Get the sub time step of the physics engine.
70
+ * @returns the current sub time step
71
+ */
72
+ getSubTimeStep() {
73
+ return this._subTimeStep;
74
+ }
75
+ /**
76
+ * Release all resources
77
+ */
78
+ dispose() {
79
+ this._physicsPlugin.dispose();
80
+ }
81
+ /**
82
+ * Gets the name of the current physics plugin
83
+ * @returns the name of the plugin
84
+ */
85
+ getPhysicsPluginName() {
86
+ return this._physicsPlugin.name;
87
+ }
88
+ /**
89
+ * Adding a new impostor for the impostor tracking.
90
+ * This will be done by the impostor itself.
91
+ * @param impostor the impostor to add
92
+ */
93
+ /**
94
+ * Called by the scene. No need to call it.
95
+ * @param delta defines the timespan between frames
96
+ */
97
+ _step(delta) {
98
+ //check if any mesh has no body / requires an update
99
+ /*this._impostors.forEach((impostor) => {
100
+ if (impostor.isBodyInitRequired()) {
101
+ this._physicsPlugin.generatePhysicsBody(impostor);
102
+ }
103
+ });
104
+ */
105
+ if (delta > 0.1) {
106
+ delta = 0.1;
107
+ }
108
+ else if (delta <= 0) {
109
+ delta = 1.0 / 60.0;
110
+ }
111
+ this._physicsPlugin.executeStep(delta);
112
+ }
113
+ /**
114
+ * Gets the current plugin used to run the simulation
115
+ * @returns current plugin
116
+ */
117
+ getPhysicsPlugin() {
118
+ return this._physicsPlugin;
119
+ }
120
+ /**
121
+ * Does a raycast in the physics world
122
+ * @param from when should the ray start?
123
+ * @param to when should the ray end?
124
+ * @param result resulting PhysicsRaycastResult
125
+ */
126
+ raycastToRef(from, to, result) {
127
+ this._physicsPlugin.raycast(from, to, result);
128
+ }
129
+ /**
130
+ * Does a raycast in the physics world
131
+ * @param from when should the ray start?
132
+ * @param to when should the ray end?
133
+ * @returns PhysicsRaycastResult
134
+ */
135
+ raycast(from, to) {
136
+ const result = new PhysicsRaycastResult();
137
+ this._physicsPlugin.raycast(from, to, result);
138
+ return result;
139
+ }
140
+ }
141
+ /** @internal */
142
+ /**
143
+ * Global value used to control the smallest number supported by the simulation
144
+ */
145
+ PhysicsEngine.Epsilon = 0.001;
146
+ //# sourceMappingURL=physicsEngine.js.map
@@ -0,0 +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;AAElD;;;GAGG;AACH,gBAAgB;AAChB,MAAM,OAAO,aAAa;IA4BtB;;;;OAIG;IACH,YAAY,OAA0B,EAAU,iBAAuC,aAAa,CAAC,oBAAoB,EAAE;QAA3E,mBAAc,GAAd,cAAc,CAA6D;QA1B3H,kDAAkD;QAClD,oDAAoD;QAC5C,iBAAY,GAAW,CAAC,CAAC;QAyB7B,OAAO,GAAG,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;IApBM,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;IAaD;;;OAGG;IACI,UAAU,CAAC,OAAgB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACI,WAAW,CAAC,cAAsB,CAAC,GAAG,EAAE;QAC3C,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACI,cAAc,CAAC,cAAsB,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,cAAc;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,oBAAoB;QACvB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;;;OAIG;IAEH;;;OAGG;IACI,KAAK,CAAC,KAAa;QACtB,oDAAoD;QACpD;;;;;EAKN;QACM,IAAI,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,CAAC,CAAC;IAC3C,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;;AA1JD,gBAAgB;AAChB;;GAEG;AACW,qBAAO,GAAG,KAAK,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePlugin } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\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 /**\r\n * Global value used to control the smallest number supported by the simulation\r\n */\r\n public static Epsilon = 0.001;\r\n\r\n //private _impostors: Array<PhysicsImpostor> = [];\r\n //private _joints: Array<PhysicsImpostorJoint> = [];\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 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(): IPhysicsEnginePlugin {\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: IPhysicsEnginePlugin = 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 //check if any mesh has no body / requires an update\r\n /*this._impostors.forEach((impostor) => {\r\n if (impostor.isBodyInitRequired()) {\r\n this._physicsPlugin.generatePhysicsBody(impostor);\r\n }\r\n });\r\n*/\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);\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(): IPhysicsEnginePlugin {\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"]}
@@ -0,0 +1,31 @@
1
+ import type { Nullable } from "../../types";
2
+ import type { Observer } from "../../Misc/observable";
3
+ import type { Vector3 } from "../../Maths/math.vector";
4
+ import type { Node } from "../../node";
5
+ import type { PhysicsBody } from "./physicsBody";
6
+ declare module "../../Meshes/abstractMesh" {
7
+ /**
8
+ *
9
+ */
10
+ /** @internal */
11
+ interface AbstractMesh {
12
+ /** @internal */
13
+ _physicsBody: Nullable<PhysicsBody>;
14
+ /**
15
+ * @see
16
+ */
17
+ physicsBody: Nullable<PhysicsBody>;
18
+ /**
19
+ *
20
+ */
21
+ getPhysicsBody(): Nullable<PhysicsBody>;
22
+ /** Apply a physic impulse to the mesh
23
+ * @param force defines the force to apply
24
+ * @param contactPoint defines where to apply the force
25
+ * @returns the current mesh
26
+ */
27
+ applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
28
+ /** @internal */
29
+ _disposePhysicsObserver: Nullable<Observer<Node>>;
30
+ }
31
+ }
@@ -0,0 +1,50 @@
1
+ import { AbstractMesh } from "../../Meshes/abstractMesh.js";
2
+ Object.defineProperty(AbstractMesh.prototype, "physicsBody", {
3
+ get: function () {
4
+ return this._physicsBody;
5
+ },
6
+ set: function (value) {
7
+ if (this._physicsBody === value) {
8
+ return;
9
+ }
10
+ if (this._disposePhysicsObserver) {
11
+ this.onDisposeObservable.remove(this._disposePhysicsObserver);
12
+ }
13
+ this._physicsBody = value;
14
+ if (value) {
15
+ this._disposePhysicsObserver = this.onDisposeObservable.add(() => {
16
+ // Physics
17
+ if (this.physicsBody) {
18
+ this.physicsBody.dispose( /*!doNotRecurse*/);
19
+ this.physicsBody = null;
20
+ }
21
+ });
22
+ }
23
+ },
24
+ enumerable: true,
25
+ configurable: true,
26
+ });
27
+ /**
28
+ * Gets the current physics body
29
+ * @returns a physics body or null
30
+ */
31
+ /** @internal */
32
+ AbstractMesh.prototype.getPhysicsBody = function () {
33
+ return this.physicsBody;
34
+ };
35
+ /**
36
+ * Apply a physic impulse to the mesh
37
+ * @param force defines the force to apply
38
+ * @param contactPoint defines where to apply the force
39
+ * @returns the current mesh
40
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
41
+ */
42
+ /** @internal */
43
+ AbstractMesh.prototype.applyImpulse = function (force, contactPoint) {
44
+ if (!this.physicsBody) {
45
+ throw new Error("No Physics Body for AbstractMesh");
46
+ }
47
+ this.physicsBody.applyImpulse(force, contactPoint);
48
+ return this;
49
+ };
50
+ //# sourceMappingURL=physicsEngineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAmCzD,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,SAAS,EAAE,aAAa,EAAE;IACzD,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,GAAG,EAAE,UAA8B,KAA4B;QAC3D,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC7B,OAAO;SACV;QACD,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAC9B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;SACjE;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBAC7D,UAAU;gBACV,IAAI,IAAI,CAAC,WAAW,EAAE;oBAClB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAC,iBAAiB,CAAC,CAAC;oBAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;iBAC3B;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH;;;GAGG;AACH,gBAAgB;AAChB,YAAY,CAAC,SAAS,CAAC,cAAc,GAAG;IACpC,OAAO,IAAI,CAAC,WAAW,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,gBAAgB;AAChB,YAAY,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAc,EAAE,YAAqB;IACjF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;KACvD;IACD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { Node } from \"../../node\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\ndeclare module \"../../Meshes/abstractMesh\" {\r\n /**\r\n *\r\n */\r\n /** @internal */\r\n export interface AbstractMesh {\r\n /** @internal */\r\n _physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n * @see\r\n */\r\n physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n *\r\n */\r\n getPhysicsBody(): Nullable<PhysicsBody>;\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 */\r\n applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;\r\n\r\n /** @internal */\r\n _disposePhysicsObserver: Nullable<Observer<Node>>;\r\n }\r\n}\r\n\r\nObject.defineProperty(AbstractMesh.prototype, \"physicsBody\", {\r\n get: function (this: AbstractMesh) {\r\n return this._physicsBody;\r\n },\r\n set: function (this: AbstractMesh, value: Nullable<PhysicsBody>) {\r\n if (this._physicsBody === 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._physicsBody = value;\r\n\r\n if (value) {\r\n this._disposePhysicsObserver = this.onDisposeObservable.add(() => {\r\n // Physics\r\n if (this.physicsBody) {\r\n this.physicsBody.dispose(/*!doNotRecurse*/);\r\n this.physicsBody = 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 body\r\n * @returns a physics body or null\r\n */\r\n/** @internal */\r\nAbstractMesh.prototype.getPhysicsBody = function (): Nullable<PhysicsBody> {\r\n return this.physicsBody;\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\n/** @internal */\r\nAbstractMesh.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): AbstractMesh {\r\n if (!this.physicsBody) {\r\n throw new Error(\"No Physics Body for AbstractMesh\");\r\n }\r\n this.physicsBody.applyImpulse(force, contactPoint);\r\n return this;\r\n};\r\n"]}
@@ -0,0 +1,45 @@
1
+ import type { Scene } from "../../scene";
2
+ import type { IPhysicsEnginePlugin } from "./IPhysicsEnginePlugin";
3
+ /**
4
+ *
5
+ */
6
+ /** @internal */
7
+ export declare class PhysicsMaterial {
8
+ /** @internal */
9
+ /**
10
+ *
11
+ */
12
+ _pluginData: any;
13
+ protected _physicsPlugin: IPhysicsEnginePlugin;
14
+ /**
15
+ *
16
+ * @param friction
17
+ * @param restitution
18
+ * @param scene
19
+ */
20
+ constructor(friction: number, restitution: number, scene: Scene);
21
+ /**
22
+ *
23
+ * @param friction
24
+ */
25
+ setFriction(friction: number): void;
26
+ /**
27
+ *
28
+ * @returns
29
+ */
30
+ getFriction(): number;
31
+ /**
32
+ *
33
+ * @param restitution
34
+ */
35
+ setRestitution(restitution: number): void;
36
+ /**
37
+ *
38
+ * @returns
39
+ */
40
+ getRestitution(): number;
41
+ /**
42
+ *
43
+ */
44
+ dispose(): void;
45
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ *
3
+ */
4
+ /** @internal */
5
+ export class PhysicsMaterial {
6
+ /**
7
+ *
8
+ * @param friction
9
+ * @param restitution
10
+ * @param scene
11
+ */
12
+ constructor(friction, restitution, scene) {
13
+ /** @internal */
14
+ /**
15
+ *
16
+ */
17
+ this._pluginData = undefined;
18
+ const physicsEngine = scene.getPhysicsEngine();
19
+ if (!physicsEngine) {
20
+ throw new Error("No Physics Engine available.");
21
+ }
22
+ if (physicsEngine.getPluginVersion() != 2) {
23
+ throw new Error("Plugin version is incorrect. Expected version 2.");
24
+ }
25
+ const physicsPlugin = physicsEngine.getPhysicsPlugin();
26
+ if (!physicsPlugin) {
27
+ throw new Error("No Physics Plugin available.");
28
+ }
29
+ this._physicsPlugin = physicsPlugin;
30
+ this._physicsPlugin.initMaterial(this);
31
+ }
32
+ /**
33
+ *
34
+ * @param friction
35
+ */
36
+ setFriction(friction) {
37
+ this._physicsPlugin.setFriction(this, friction);
38
+ }
39
+ /**
40
+ *
41
+ * @returns
42
+ */
43
+ getFriction() {
44
+ return this._physicsPlugin.getFriction(this);
45
+ }
46
+ /**
47
+ *
48
+ * @param restitution
49
+ */
50
+ setRestitution(restitution) {
51
+ this._physicsPlugin.setRestitution(this, restitution);
52
+ }
53
+ /**
54
+ *
55
+ * @returns
56
+ */
57
+ getRestitution() {
58
+ return this._physicsPlugin.getRestitution(this);
59
+ }
60
+ /**
61
+ *
62
+ */
63
+ dispose() {
64
+ this._physicsPlugin.disposeMaterial(this);
65
+ }
66
+ }
67
+ //# sourceMappingURL=physicsMaterial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physicsMaterial.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsMaterial.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,gBAAgB;AAChB,MAAM,OAAO,eAAe;IASxB;;;;;OAKG;IACH,YAAY,QAAgB,EAAE,WAAmB,EAAE,KAAY;QAd/D,gBAAgB;QAChB;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAWhC,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,aAAqC,CAAC;QAC5D,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IACD;;;OAGG;IACI,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,WAAmB;QACrC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACI,cAAc;QACjB,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IPhysicsEnginePlugin } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n *\r\n */\r\n/** @internal */\r\nexport class PhysicsMaterial {\r\n /** @internal */\r\n /**\r\n *\r\n */\r\n public _pluginData: any = undefined;\r\n\r\n protected _physicsPlugin: IPhysicsEnginePlugin;\r\n\r\n /**\r\n *\r\n * @param friction\r\n * @param restitution\r\n * @param scene\r\n */\r\n constructor(friction: number, restitution: number, scene: Scene) {\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 IPhysicsEnginePlugin;\r\n this._physicsPlugin.initMaterial(this);\r\n }\r\n /**\r\n *\r\n * @param friction\r\n */\r\n public setFriction(friction: number): void {\r\n this._physicsPlugin.setFriction(this, friction);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getFriction(): number {\r\n return this._physicsPlugin.getFriction(this);\r\n }\r\n\r\n /**\r\n *\r\n * @param restitution\r\n */\r\n public setRestitution(restitution: number): void {\r\n this._physicsPlugin.setRestitution(this, restitution);\r\n }\r\n\r\n /**\r\n *\r\n * @returns\r\n */\r\n public getRestitution(): number {\r\n return this._physicsPlugin.getRestitution(this);\r\n }\r\n\r\n /**\r\n *\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeMaterial(this);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,182 @@
1
+ import type { TransformNode } from "../../Meshes/transformNode";
2
+ import type { BoundingBox } from "../../Culling/boundingBox";
3
+ import { ShapeType } from "./IPhysicsEnginePlugin";
4
+ import type { PhysicsShapeParameters } from "./IPhysicsEnginePlugin";
5
+ import type { PhysicsMaterial } from "./physicsMaterial";
6
+ import type { Vector3 } from "../../Maths/math.vector";
7
+ import type { Quaternion } from "../../Maths/math.vector";
8
+ import type { AbstractMesh } from "../../Meshes/abstractMesh";
9
+ import type { Scene } from "../../scene";
10
+ /**
11
+ *
12
+ */
13
+ /** @internal */
14
+ export declare class PhysicsShape {
15
+ /** @internal */
16
+ _pluginData: any;
17
+ private _physicsPlugin;
18
+ private _type;
19
+ /**
20
+ *
21
+ * @param type
22
+ * @param options
23
+ * @param scene
24
+ * @returns
25
+ */
26
+ constructor(type: number, options: PhysicsShapeParameters | undefined, scene: Scene);
27
+ /**
28
+ *
29
+ */
30
+ get type(): ShapeType;
31
+ /**
32
+ *
33
+ * @param layer
34
+ */
35
+ setFilterLayer(layer: number): void;
36
+ /**
37
+ *
38
+ * @returns
39
+ */
40
+ getFilterLayer(): number;
41
+ /**
42
+ *
43
+ * @param materialId
44
+ */
45
+ setMaterial(materialId: PhysicsMaterial): void;
46
+ /**
47
+ *
48
+ * @returns
49
+ */
50
+ getMaterial(): PhysicsMaterial | undefined;
51
+ /**
52
+ *
53
+ * @param density
54
+ */
55
+ setDensity(density: number): void;
56
+ /**
57
+ *
58
+ */
59
+ getDensity(): number;
60
+ /**
61
+ *
62
+ * @param newChild
63
+ * @param childTransform
64
+ */
65
+ addChild(newChild: PhysicsShape, childTransform: TransformNode): void;
66
+ /**
67
+ *
68
+ * @param childIndex
69
+ */
70
+ removeChild(childIndex: number): void;
71
+ /**
72
+ *
73
+ * @returns
74
+ */
75
+ getNumChildren(): number;
76
+ /**
77
+ *
78
+ */
79
+ getBoundingBox(): BoundingBox;
80
+ /**
81
+ *
82
+ */
83
+ dispose(): void;
84
+ }
85
+ /**
86
+ *
87
+ */
88
+ /** @internal */
89
+ export declare class PhysicsShapeSphere extends PhysicsShape {
90
+ /** @internal */
91
+ /**
92
+ *
93
+ * @param center
94
+ * @param radius
95
+ * @param scene
96
+ */
97
+ constructor(center: Vector3, radius: number, scene: Scene);
98
+ }
99
+ /***
100
+ *
101
+ */
102
+ /** @internal */
103
+ export declare class PhysicsShapeCapsule extends PhysicsShape {
104
+ /** @internal */
105
+ /**
106
+ *
107
+ * @param pointA
108
+ * @param pointB
109
+ * @param radius
110
+ * @param scene
111
+ */
112
+ constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene);
113
+ }
114
+ /**
115
+ *
116
+ */
117
+ /** @internal */
118
+ export declare class PhysicsShapeCylinder extends PhysicsShape {
119
+ /** @internal */
120
+ /**
121
+ *
122
+ * @param pointA
123
+ * @param pointB
124
+ * @param radius
125
+ * @param scene
126
+ */
127
+ constructor(pointA: Vector3, pointB: Vector3, radius: number, scene: Scene);
128
+ }
129
+ /**
130
+ *
131
+ */
132
+ /** @internal */
133
+ export declare class PhysicsShapeShapeBox extends PhysicsShape {
134
+ /** @internal */
135
+ /**
136
+ *
137
+ * @param center
138
+ * @param rotation
139
+ * @param extents
140
+ * @param scene
141
+ */
142
+ constructor(center: Vector3, rotation: Quaternion, extents: Vector3, scene: Scene);
143
+ }
144
+ /**
145
+ *
146
+ */
147
+ /** @internal */
148
+ export declare class PhysicsShapeShapeConvexHull extends PhysicsShape {
149
+ /** @internal */
150
+ /**
151
+ *
152
+ * @param mesh
153
+ * @param scene
154
+ */
155
+ constructor(mesh: AbstractMesh, scene: Scene);
156
+ }
157
+ /**
158
+ *
159
+ */
160
+ /** @internal */
161
+ export declare class PhysicsShapeShapeMesh extends PhysicsShape {
162
+ /** @internal */
163
+ /**
164
+ *
165
+ * @param mesh
166
+ * @param scene
167
+ */
168
+ constructor(mesh: AbstractMesh, scene: Scene);
169
+ }
170
+ /**
171
+ *
172
+ */
173
+ /** @internal */
174
+ export declare class PhysicsShapeShapeContainer extends PhysicsShape {
175
+ /** @internal */
176
+ /**
177
+ *
178
+ * @param mesh
179
+ * @param scene
180
+ */
181
+ constructor(mesh: AbstractMesh, scene: Scene);
182
+ }