@babylonjs/core 5.52.0 → 5.53.1

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 (168) hide show
  1. package/Animations/animatable.js +1 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/animationGroup.js +8 -1
  4. package/Animations/animationGroup.js.map +1 -1
  5. package/Collisions/pickingInfo.d.ts +2 -1
  6. package/Collisions/pickingInfo.js +4 -3
  7. package/Collisions/pickingInfo.js.map +1 -1
  8. package/DeviceInput/eventFactory.js +4 -0
  9. package/DeviceInput/eventFactory.js.map +1 -1
  10. package/DeviceInput/webDeviceInputSystem.js +17 -9
  11. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  12. package/Engines/Extensions/engine.cubeTexture.js +3 -0
  13. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  14. package/Engines/Extensions/engine.multiRender.js +74 -19
  15. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  16. package/Engines/Extensions/engine.renderTarget.js +2 -5
  17. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  18. package/Engines/WebGL/webGLHardwareTexture.d.ts +3 -1
  19. package/Engines/WebGL/webGLHardwareTexture.js +19 -7
  20. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  21. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +14 -1
  22. package/Engines/WebGL/webGLRenderTargetWrapper.js +76 -6
  23. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  24. package/Engines/WebGPU/Extensions/engine.multiRender.js +20 -0
  25. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  26. package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -1
  27. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  28. package/Engines/WebGPU/webgpuConstants.d.ts +22 -7
  29. package/Engines/WebGPU/webgpuConstants.js +24 -8
  30. package/Engines/WebGPU/webgpuConstants.js.map +1 -1
  31. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +0 -3
  32. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +20 -53
  33. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  34. package/Engines/WebGPU/webgpuTextureHelper.d.ts +3 -2
  35. package/Engines/WebGPU/webgpuTextureHelper.js +33 -14
  36. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  37. package/Engines/WebGPU/webgpuTintWASM.d.ts +3 -2
  38. package/Engines/WebGPU/webgpuTintWASM.js +10 -8
  39. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  40. package/Engines/constants.d.ts +12 -0
  41. package/Engines/constants.js +12 -0
  42. package/Engines/constants.js.map +1 -1
  43. package/Engines/engine.d.ts +130 -72
  44. package/Engines/engine.js +5 -0
  45. package/Engines/engine.js.map +1 -1
  46. package/Engines/nativeEngine.d.ts +1 -0
  47. package/Engines/nativeEngine.js +16 -5
  48. package/Engines/nativeEngine.js.map +1 -1
  49. package/Engines/renderTargetWrapper.d.ts +28 -4
  50. package/Engines/renderTargetWrapper.js +107 -10
  51. package/Engines/renderTargetWrapper.js.map +1 -1
  52. package/Engines/thinEngine.d.ts +6 -6
  53. package/Engines/thinEngine.js +29 -21
  54. package/Engines/thinEngine.js.map +1 -1
  55. package/Engines/webgpuEngine.d.ts +25 -8
  56. package/Engines/webgpuEngine.js +112 -48
  57. package/Engines/webgpuEngine.js.map +1 -1
  58. package/Inputs/scene.inputManager.js +5 -12
  59. package/Inputs/scene.inputManager.js.map +1 -1
  60. package/Materials/PBR/pbrAnisotropicConfiguration.js +0 -1
  61. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  62. package/Materials/PBR/pbrBaseMaterial.js +3 -0
  63. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  64. package/Materials/Textures/Filtering/hdrFiltering.js +4 -0
  65. package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
  66. package/Materials/Textures/internalTexture.d.ts +4 -0
  67. package/Materials/Textures/internalTexture.js.map +1 -1
  68. package/Materials/Textures/multiRenderTarget.d.ts +40 -0
  69. package/Materials/Textures/multiRenderTarget.js +143 -4
  70. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  71. package/Materials/Textures/renderTargetTexture.d.ts +4 -0
  72. package/Materials/Textures/renderTargetTexture.js +10 -2
  73. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  74. package/Materials/Textures/texture.d.ts +4 -2
  75. package/Materials/Textures/texture.js +1 -0
  76. package/Materials/Textures/texture.js.map +1 -1
  77. package/Materials/Textures/textureCreationOptions.d.ts +4 -0
  78. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  79. package/Materials/materialPluginBase.d.ts +3 -2
  80. package/Materials/materialPluginBase.js.map +1 -1
  81. package/Materials/materialPluginManager.js +13 -3
  82. package/Materials/materialPluginManager.js.map +1 -1
  83. package/Materials/uniformBuffer.d.ts +2 -0
  84. package/Materials/uniformBuffer.js +4 -0
  85. package/Materials/uniformBuffer.js.map +1 -1
  86. package/Maths/math.frustum.d.ts +8 -1
  87. package/Maths/math.frustum.js +14 -0
  88. package/Maths/math.frustum.js.map +1 -1
  89. package/Meshes/instancedMesh.d.ts +2 -1
  90. package/Meshes/instancedMesh.js +3 -2
  91. package/Meshes/instancedMesh.js.map +1 -1
  92. package/Meshes/mesh.d.ts +10 -5
  93. package/Meshes/mesh.js +40 -16
  94. package/Meshes/mesh.js.map +1 -1
  95. package/Misc/filesInput.d.ts +5 -2
  96. package/Misc/filesInput.js +39 -20
  97. package/Misc/filesInput.js.map +1 -1
  98. package/Misc/interfaces/screenshotSize.d.ts +17 -3
  99. package/Misc/interfaces/screenshotSize.js.map +1 -1
  100. package/Misc/sceneOptimizer.js +3 -0
  101. package/Misc/sceneOptimizer.js.map +1 -1
  102. package/Misc/screenshotTools.d.ts +2 -2
  103. package/Misc/screenshotTools.js +49 -9
  104. package/Misc/screenshotTools.js.map +1 -1
  105. package/Misc/textureTools.d.ts +1 -1
  106. package/Misc/textureTools.js +4 -2
  107. package/Misc/textureTools.js.map +1 -1
  108. package/Physics/v2/physicsAggregate.js +3 -3
  109. package/Physics/v2/physicsAggregate.js.map +1 -1
  110. package/Physics/v2/physicsBody.d.ts +27 -16
  111. package/Physics/v2/physicsBody.js +31 -16
  112. package/Physics/v2/physicsBody.js.map +1 -1
  113. package/Physics/v2/physicsConstraint.d.ts +6 -6
  114. package/Physics/v2/physicsConstraint.js +6 -6
  115. package/Physics/v2/physicsConstraint.js.map +1 -1
  116. package/Physics/v2/physicsShape.d.ts +7 -7
  117. package/Physics/v2/physicsShape.js +7 -7
  118. package/Physics/v2/physicsShape.js.map +1 -1
  119. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +1 -0
  120. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  121. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.d.ts +5 -0
  122. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.js +7 -0
  123. package/PostProcesses/RenderPipeline/postProcessRenderPipelineManager.js.map +1 -1
  124. package/PostProcesses/depthOfFieldMergePostProcess.d.ts +0 -23
  125. package/PostProcesses/depthOfFieldMergePostProcess.js +0 -5
  126. package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
  127. package/PostProcesses/postProcess.js +1 -0
  128. package/PostProcesses/postProcess.js.map +1 -1
  129. package/Probes/reflectionProbe.js +1 -0
  130. package/Probes/reflectionProbe.js.map +1 -1
  131. package/Rendering/depthPeelingRenderer.js +3 -1
  132. package/Rendering/depthPeelingRenderer.js.map +1 -1
  133. package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
  134. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  135. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +2 -1
  136. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -1
  137. package/Rendering/fluidRenderer/fluidRenderingTextures.js +2 -0
  138. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -1
  139. package/Shaders/default.fragment.js +1 -1
  140. package/Shaders/default.fragment.js.map +1 -1
  141. package/Shaders/depthOfFieldMerge.fragment.js +10 -5
  142. package/Shaders/depthOfFieldMerge.fragment.js.map +1 -1
  143. package/Shaders/fluidRenderingRender.fragment.js +3 -3
  144. package/Shaders/fluidRenderingRender.fragment.js.map +1 -1
  145. package/Shaders/motionBlur.fragment.js +8 -2
  146. package/Shaders/motionBlur.fragment.js.map +1 -1
  147. package/Shaders/screenSpaceReflection2.fragment.js +11 -4
  148. package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
  149. package/Shaders/screenSpaceReflection2Blur.fragment.js +6 -1
  150. package/Shaders/screenSpaceReflection2Blur.fragment.js.map +1 -1
  151. package/Shaders/ssao2.fragment.js +1 -0
  152. package/Shaders/ssao2.fragment.js.map +1 -1
  153. package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js +9 -9
  154. package/ShadersWGSL/ShadersInclude/bakedVertexAnimation.js.map +1 -1
  155. package/ShadersWGSL/ShadersInclude/bonesVertex.js +16 -16
  156. package/ShadersWGSL/ShadersInclude/bonesVertex.js.map +1 -1
  157. package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js +6 -6
  158. package/ShadersWGSL/ShadersInclude/clipPlaneFragment.js.map +1 -1
  159. package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js +6 -6
  160. package/ShadersWGSL/ShadersInclude/clipPlaneVertex.js.map +1 -1
  161. package/ShadersWGSL/ShadersInclude/instancesVertex.js +1 -1
  162. package/ShadersWGSL/ShadersInclude/instancesVertex.js.map +1 -1
  163. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +8 -8
  164. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  165. package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
  166. package/XR/features/WebXRControllerTeleportation.js +28 -4
  167. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  168. package/package.json +1 -1
@@ -51,6 +51,12 @@ export declare class PhysicsBody {
51
51
  * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.
52
52
  */
53
53
  constructor(transformNode: TransformNode, motionType: PhysicsMotionType, scene: Scene);
54
+ /**
55
+ * Clone the PhysicsBody to a new body and assign it to the transformNode parameter
56
+ * @param transformNode transformNode that will be used for the cloned PhysicsBody
57
+ * @returns the newly cloned PhysicsBody
58
+ */
59
+ clone(transformNode: TransformNode): PhysicsBody;
54
60
  /**
55
61
  * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.
56
62
  */
@@ -67,7 +73,7 @@ export declare class PhysicsBody {
67
73
  * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.
68
74
  * The shape is used to calculate the body's mass, inertia, and other properties.
69
75
  */
70
- setShape(shape: PhysicsShape): void;
76
+ set shape(shape: PhysicsShape);
71
77
  /**
72
78
  * Retrieves the physics shape associated with this object.
73
79
  *
@@ -77,7 +83,7 @@ export declare class PhysicsBody {
77
83
  * This method is useful for retrieving the physics shape associated with this object,
78
84
  * which can be used to apply physical forces to the object or to detect collisions.
79
85
  */
80
- getShape(): PhysicsShape | undefined;
86
+ get shape(): PhysicsShape;
81
87
  /**
82
88
  * Sets the filter group of the physics body.
83
89
  * @param group - The filter group of the physics body.
@@ -86,7 +92,7 @@ export declare class PhysicsBody {
86
92
  * The filter group is used to determine which bodies should collide with each other.
87
93
  * This allows for more control over the physics engine and can be used to create more realistic simulations.
88
94
  */
89
- setFilterGroup(group: number): void;
95
+ set filterGroup(group: number);
90
96
  /**
91
97
  * Gets the filter group of the physics engine.
92
98
  *
@@ -96,7 +102,7 @@ export declare class PhysicsBody {
96
102
  * which is used to determine which objects will interact with each other.
97
103
  * This is important for creating realistic physics simulations.
98
104
  */
99
- getFilterGroup(): number;
105
+ get filterGroup(): number;
100
106
  /**
101
107
  * Sets the event mask for the physics engine.
102
108
  *
@@ -105,7 +111,7 @@ export declare class PhysicsBody {
105
111
  * This method is useful for setting the event mask for the physics engine, which determines which events
106
112
  * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.
107
113
  */
108
- setEventMask(eventMask: number): void;
114
+ set eventMask(eventMask: number);
109
115
  /**
110
116
  * Gets the event mask of the physics engine.
111
117
  *
@@ -116,9 +122,15 @@ export declare class PhysicsBody {
116
122
  * This is important for ensuring that the engine is responding to the correct events and not
117
123
  * wasting resources on unnecessary events.
118
124
  */
119
- getEventMask(): number;
120
- setMotionType(motionType: PhysicsMotionType): void;
121
- getMotionType(): PhysicsMotionType;
125
+ get eventMask(): number;
126
+ /**
127
+ * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.
128
+ */
129
+ set motionType(motionType: PhysicsMotionType);
130
+ /**
131
+ * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.
132
+ */
133
+ get motionType(): PhysicsMotionType;
122
134
  /**
123
135
  * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.
124
136
  * This method is useful for computing the initial mass properties of a physics object, such as its mass,
@@ -135,19 +147,18 @@ export declare class PhysicsBody {
135
147
  * This method is useful for setting the mass properties of a physics object, such as its mass,
136
148
  * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.
137
149
  */
138
- setMassProperties(massProps: MassProperties): void;
150
+ set massProperties(massProps: MassProperties);
139
151
  /**
140
152
  * Retrieves the mass properties of the object.
141
153
  *
142
- * @returns The mass properties of the object, or `undefined` if the physics
143
- * plugin does not support mass properties.
154
+ * @returns The mass properties of the object.
144
155
  *
145
156
  * This method is useful for physics simulations, as it allows the user to
146
157
  * retrieve the mass properties of the object, such as its mass, center of mass,
147
158
  * and moment of inertia. This information is necessary for accurate physics
148
159
  * simulations.
149
160
  */
150
- getMassProperties(): MassProperties | undefined;
161
+ get massProperties(): MassProperties;
151
162
  /**
152
163
  * Sets the linear damping of the physics body.
153
164
  *
@@ -157,7 +168,7 @@ export declare class PhysicsBody {
157
168
  * which is the rate at which the body's velocity decreases over time. This is useful for simulating
158
169
  * the effects of air resistance or other forms of friction.
159
170
  */
160
- setLinearDamping(damping: number): void;
171
+ set linearDamping(damping: number);
161
172
  /**
162
173
  * Gets the linear damping of the physics body.
163
174
  * @returns The linear damping of the physics body.
@@ -166,7 +177,7 @@ export declare class PhysicsBody {
166
177
  * resistance the body has to linear motion. This is useful for simulating realistic physics behavior
167
178
  * in a game.
168
179
  */
169
- getLinearDamping(): number;
180
+ get linearDamping(): number;
170
181
  /**
171
182
  * Sets the angular damping of the physics body.
172
183
  * @param damping The angular damping of the body.
@@ -175,7 +186,7 @@ export declare class PhysicsBody {
175
186
  * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.
176
187
  * This can be used to create realistic physical behavior in a physics engine.
177
188
  */
178
- setAngularDamping(damping: number): void;
189
+ set angularDamping(damping: number);
179
190
  /**
180
191
  * Gets the angular damping of the physics body.
181
192
  *
@@ -185,7 +196,7 @@ export declare class PhysicsBody {
185
196
  * which is the rate of reduction of the angular velocity over time.
186
197
  * This is important for simulating realistic physics behavior in a game.
187
198
  */
188
- getAngularDamping(): number;
199
+ get angularDamping(): number;
189
200
  /**
190
201
  * Sets the linear velocity of the physics object.
191
202
  * @param linVel - The linear velocity to set.
@@ -65,6 +65,16 @@ export class PhysicsBody {
65
65
  this.dispose();
66
66
  });
67
67
  }
68
+ /**
69
+ * Clone the PhysicsBody to a new body and assign it to the transformNode parameter
70
+ * @param transformNode transformNode that will be used for the cloned PhysicsBody
71
+ * @returns the newly cloned PhysicsBody
72
+ */
73
+ clone(transformNode) {
74
+ const clonedBody = new PhysicsBody(transformNode, this.motionType, this.transformNode.getScene());
75
+ clonedBody.shape = this.shape;
76
+ return clonedBody;
77
+ }
68
78
  /**
69
79
  * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.
70
80
  */
@@ -88,7 +98,7 @@ export class PhysicsBody {
88
98
  * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.
89
99
  * The shape is used to calculate the body's mass, inertia, and other properties.
90
100
  */
91
- setShape(shape) {
101
+ set shape(shape) {
92
102
  this._physicsPlugin.setShape(this, shape);
93
103
  }
94
104
  /**
@@ -100,7 +110,7 @@ export class PhysicsBody {
100
110
  * This method is useful for retrieving the physics shape associated with this object,
101
111
  * which can be used to apply physical forces to the object or to detect collisions.
102
112
  */
103
- getShape() {
113
+ get shape() {
104
114
  return this._physicsPlugin.getShape(this);
105
115
  }
106
116
  /**
@@ -111,7 +121,7 @@ export class PhysicsBody {
111
121
  * The filter group is used to determine which bodies should collide with each other.
112
122
  * This allows for more control over the physics engine and can be used to create more realistic simulations.
113
123
  */
114
- setFilterGroup(group) {
124
+ set filterGroup(group) {
115
125
  this._physicsPlugin.setFilterGroup(this, group);
116
126
  }
117
127
  /**
@@ -123,7 +133,7 @@ export class PhysicsBody {
123
133
  * which is used to determine which objects will interact with each other.
124
134
  * This is important for creating realistic physics simulations.
125
135
  */
126
- getFilterGroup() {
136
+ get filterGroup() {
127
137
  return this._physicsPlugin.getFilterGroup(this);
128
138
  }
129
139
  /**
@@ -134,7 +144,7 @@ export class PhysicsBody {
134
144
  * This method is useful for setting the event mask for the physics engine, which determines which events
135
145
  * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.
136
146
  */
137
- setEventMask(eventMask) {
147
+ set eventMask(eventMask) {
138
148
  this._physicsPlugin.setEventMask(this, eventMask);
139
149
  }
140
150
  /**
@@ -147,13 +157,19 @@ export class PhysicsBody {
147
157
  * This is important for ensuring that the engine is responding to the correct events and not
148
158
  * wasting resources on unnecessary events.
149
159
  */
150
- getEventMask() {
160
+ get eventMask() {
151
161
  return this._physicsPlugin.getEventMask(this);
152
162
  }
153
- setMotionType(motionType) {
163
+ /**
164
+ * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.
165
+ */
166
+ set motionType(motionType) {
154
167
  this._physicsPlugin.setMotionType(this, motionType);
155
168
  }
156
- getMotionType() {
169
+ /**
170
+ * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.
171
+ */
172
+ get motionType() {
157
173
  return this._physicsPlugin.getMotionType(this);
158
174
  }
159
175
  /**
@@ -174,21 +190,20 @@ export class PhysicsBody {
174
190
  * This method is useful for setting the mass properties of a physics object, such as its mass,
175
191
  * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.
176
192
  */
177
- setMassProperties(massProps) {
193
+ set massProperties(massProps) {
178
194
  this._physicsPlugin.setMassProperties(this, massProps);
179
195
  }
180
196
  /**
181
197
  * Retrieves the mass properties of the object.
182
198
  *
183
- * @returns The mass properties of the object, or `undefined` if the physics
184
- * plugin does not support mass properties.
199
+ * @returns The mass properties of the object.
185
200
  *
186
201
  * This method is useful for physics simulations, as it allows the user to
187
202
  * retrieve the mass properties of the object, such as its mass, center of mass,
188
203
  * and moment of inertia. This information is necessary for accurate physics
189
204
  * simulations.
190
205
  */
191
- getMassProperties() {
206
+ get massProperties() {
192
207
  return this._physicsPlugin.getMassProperties(this);
193
208
  }
194
209
  /**
@@ -200,7 +215,7 @@ export class PhysicsBody {
200
215
  * which is the rate at which the body's velocity decreases over time. This is useful for simulating
201
216
  * the effects of air resistance or other forms of friction.
202
217
  */
203
- setLinearDamping(damping) {
218
+ set linearDamping(damping) {
204
219
  this._physicsPlugin.setLinearDamping(this, damping);
205
220
  }
206
221
  /**
@@ -211,7 +226,7 @@ export class PhysicsBody {
211
226
  * resistance the body has to linear motion. This is useful for simulating realistic physics behavior
212
227
  * in a game.
213
228
  */
214
- getLinearDamping() {
229
+ get linearDamping() {
215
230
  return this._physicsPlugin.getLinearDamping(this);
216
231
  }
217
232
  /**
@@ -222,7 +237,7 @@ export class PhysicsBody {
222
237
  * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.
223
238
  * This can be used to create realistic physical behavior in a physics engine.
224
239
  */
225
- setAngularDamping(damping) {
240
+ set angularDamping(damping) {
226
241
  this._physicsPlugin.setAngularDamping(this, damping);
227
242
  }
228
243
  /**
@@ -234,7 +249,7 @@ export class PhysicsBody {
234
249
  * which is the rate of reduction of the angular velocity over time.
235
250
  * This is important for simulating realistic physics behavior in a game.
236
251
  */
237
- getAngularDamping() {
252
+ get angularDamping() {
238
253
  return this._physicsPlugin.getAngularDamping(this);
239
254
  }
240
255
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAO1E,OAAO,EAAE,KAAK,EAAE,iCAA6B;AAI7C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA+BpB;;;;;;;;;OASG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,KAAY;QAxCrF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAa7C;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QAiB3B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAC9D,IAAI,CAAC,aA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C,CAAC;IACzC,CAAC;;AAjec,gCAAoB,GAAY,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,gCAAoB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, MassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode, AbstractMesh } from \"../../Meshes\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n private static _DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n private static _IDENTITY_QUATERNION = Quaternion.Identity();\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param motionType - The motion type of the physics body.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, motionType, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * Adds the physics shape associated with the transform node to this body\r\n * @param shapeNode - A node with a physics shape. Should be a child of the body node\r\n */\r\n public addNodeShape(shapeNode: TransformNode) {\r\n this._physicsPlugin.addNodeShape(this, shapeNode);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n public setMotionType(motionType: PhysicsMotionType): void {\r\n this._physicsPlugin.setMotionType(this, motionType);\r\n }\r\n\r\n public getMotionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(): MassProperties {\r\n return this._physicsPlugin.computeMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object, or `undefined` if the physics\r\n * plugin does not support mass properties.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyForce(this, force, location);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n return this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const q = this.transformNode.rotationQuaternion;\r\n const scaling = this.transformNode.scaling.clone();\r\n //reset rotation\r\n this.transformNode.rotationQuaternion = PhysicsBody._IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n tmAbstractMesh.refreshBoundingInfo();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.transformNode.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsBody._DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * returns the delta between the object bounding box center and the mesh origin\r\n * @returns delta between object bounding box center and origin\r\n */\r\n public getObjectCenterDelta(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const delta = new Vector3();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n this.transformNode.computeWorldMatrix(true);\r\n tmAbstractMesh.refreshBoundingInfo();\r\n delta.copyFrom(boundingInfo.boundingBox.centerWorld);\r\n delta.subtractInPlace(tmAbstractMesh.getAbsolutePosition());\r\n delta.x /= tmAbstractMesh.scaling.x;\r\n delta.y /= tmAbstractMesh.scaling.y;\r\n delta.z /= tmAbstractMesh.scaling.z;\r\n return delta;\r\n } else {\r\n return Vector3.Zero();\r\n }\r\n }\r\n\r\n /**\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenter(): Vector3 {\r\n if ((<any>this.transformNode).getBoundingInfo) {\r\n const boundingInfo = (<any>this.transformNode).getBoundingInfo();\r\n return boundingInfo.boundingBox.centerWorld;\r\n } else {\r\n return this.transformNode.position;\r\n }\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAA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,CAAC;;AAjfc,gCAAoB,GAAY,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,gCAAoB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { IPhysicsCollisionEvent, IPhysicsEnginePluginV2, MassProperties, PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode, AbstractMesh } from \"../../Meshes\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n private static _DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n private static _IDENTITY_QUATERNION = Quaternion.Identity();\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for.\r\n * @param motionType - The motion type of the physics body.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, motionType, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.motionType, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * Adds the physics shape associated with the transform node to this body\r\n * @param shapeNode - A node with a physics shape. Should be a child of the body node\r\n */\r\n public addNodeShape(shapeNode: TransformNode) {\r\n this._physicsPlugin.addNodeShape(this, shapeNode);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: PhysicsShape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): PhysicsShape {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public set filterGroup(group: number) {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public get filterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public set eventMask(eventMask: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public get eventMask(): number {\r\n return this._physicsPlugin.getEventMask(this);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public set motionType(motionType: PhysicsMotionType) {\r\n this._physicsPlugin.setMotionType(this, motionType);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * intial values, which you can then customize.\r\n */\r\n public computeMassProperties(): MassProperties {\r\n return this._physicsPlugin.computeMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public set massProperties(massProps: MassProperties) {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public get massProperties(): MassProperties {\r\n return this._physicsPlugin.getMassProperties(this);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public set linearDamping(damping: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public get linearDamping(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public set angularDamping(damping: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public get angularDamping(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.*/\r\n public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3): void {\r\n this._physicsPlugin.applyForce(this, force, location);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for all collisions happening for event-enabled bodies\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n return this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const q = this.transformNode.rotationQuaternion;\r\n const scaling = this.transformNode.scaling.clone();\r\n //reset rotation\r\n this.transformNode.rotationQuaternion = PhysicsBody._IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n tmAbstractMesh.refreshBoundingInfo();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.transformNode.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsBody._DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * returns the delta between the object bounding box center and the mesh origin\r\n * @returns delta between object bounding box center and origin\r\n */\r\n public getObjectCenterDelta(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const delta = new Vector3();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n this.transformNode.computeWorldMatrix(true);\r\n tmAbstractMesh.refreshBoundingInfo();\r\n delta.copyFrom(boundingInfo.boundingBox.centerWorld);\r\n delta.subtractInPlace(tmAbstractMesh.getAbsolutePosition());\r\n delta.x /= tmAbstractMesh.scaling.x;\r\n delta.y /= tmAbstractMesh.scaling.y;\r\n delta.z /= tmAbstractMesh.scaling.z;\r\n return delta;\r\n } else {\r\n return Vector3.Zero();\r\n }\r\n }\r\n\r\n /**\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenter(): Vector3 {\r\n if ((<any>this.transformNode).getBoundingInfo) {\r\n const boundingInfo = (<any>this.transformNode).getBoundingInfo();\r\n return boundingInfo.boundingBox.centerWorld;\r\n } else {\r\n return this.transformNode.position;\r\n }\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
@@ -34,38 +34,38 @@ export declare class PhysicsConstraint {
34
34
  * @returns The type of the constraint.
35
35
  *
36
36
  */
37
- getType(): ConstraintType;
37
+ get type(): ConstraintType;
38
38
  /**
39
39
  * Retrieves the options of the physics constraint.
40
40
  *
41
41
  * @returns The physics constraint parameters.
42
42
  *
43
43
  */
44
- getOptions(): PhysicsConstraintParameters;
44
+ get options(): PhysicsConstraintParameters;
45
45
  /**
46
46
  * Enable/disable the constraint
47
47
  * @param isEnabled value for the constraint
48
48
  */
49
- setEnabled(isEnabled: boolean): void;
49
+ set isEnabled(isEnabled: boolean);
50
50
  /**
51
51
  *
52
52
  * @returns true if constraint is enabled
53
53
  */
54
- getEnabled(): boolean;
54
+ get isEnabled(): boolean;
55
55
  /**
56
56
  * Enables or disables collisions for the physics engine.
57
57
  *
58
58
  * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.
59
59
  *
60
60
  */
61
- setCollisionsEnabled(isEnabled: boolean): void;
61
+ set isCollisionsEnabled(isEnabled: boolean);
62
62
  /**
63
63
  * Gets whether collisions are enabled for this physics object.
64
64
  *
65
65
  * @returns `true` if collisions are enabled, `false` otherwise.
66
66
  *
67
67
  */
68
- getCollisionsEnabled(): boolean;
68
+ get isCollisionsEnabled(): boolean;
69
69
  /**
70
70
  * Sets the friction of the given axis of the physics engine.
71
71
  * @param axis - The axis of the physics engine to set the friction for.
@@ -43,7 +43,7 @@ export class PhysicsConstraint {
43
43
  * @returns The type of the constraint.
44
44
  *
45
45
  */
46
- getType() {
46
+ get type() {
47
47
  return this._type;
48
48
  }
49
49
  /**
@@ -52,21 +52,21 @@ export class PhysicsConstraint {
52
52
  * @returns The physics constraint parameters.
53
53
  *
54
54
  */
55
- getOptions() {
55
+ get options() {
56
56
  return this._options;
57
57
  }
58
58
  /**
59
59
  * Enable/disable the constraint
60
60
  * @param isEnabled value for the constraint
61
61
  */
62
- setEnabled(isEnabled) {
62
+ set isEnabled(isEnabled) {
63
63
  this._physicsPlugin.setEnabled(this, isEnabled);
64
64
  }
65
65
  /**
66
66
  *
67
67
  * @returns true if constraint is enabled
68
68
  */
69
- getEnabled() {
69
+ get isEnabled() {
70
70
  return this._physicsPlugin.getEnabled(this);
71
71
  }
72
72
  /**
@@ -75,7 +75,7 @@ export class PhysicsConstraint {
75
75
  * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.
76
76
  *
77
77
  */
78
- setCollisionsEnabled(isEnabled) {
78
+ set isCollisionsEnabled(isEnabled) {
79
79
  this._physicsPlugin.setCollisionsEnabled(this, isEnabled);
80
80
  }
81
81
  /**
@@ -84,7 +84,7 @@ export class PhysicsConstraint {
84
84
  * @returns `true` if collisions are enabled, `false` otherwise.
85
85
  *
86
86
  */
87
- getCollisionsEnabled() {
87
+ get isCollisionsEnabled() {
88
88
  return this._physicsPlugin.getCollisionsEnabled(this);
89
89
  }
90
90
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAY1B;;;;;;;;OAQG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QApBpF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAkBhC,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SAC1E;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8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G,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: ConstraintType;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n throw new Error(\"Missing scene parameter for constraint constructor.\");\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._options = options;\r\n this._type = type;\r\n }\r\n\r\n /**\r\n * Gets the type of the constraint.\r\n *\r\n * @returns The type of the constraint.\r\n *\r\n */\r\n public getType(): ConstraintType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Retrieves the options of the physics constraint.\r\n *\r\n * @returns The physics constraint parameters.\r\n *\r\n */\r\n public getOptions(): PhysicsConstraintParameters {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Enable/disable the constraint\r\n * @param isEnabled value for the constraint\r\n */\r\n public setEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if constraint is enabled\r\n */\r\n public getEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the physics engine.\r\n *\r\n * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public setCollisionsEnabled(isEnabled: boolean): void {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for this physics object.\r\n *\r\n * @returns `true` if collisions are enabled, `false` otherwise.\r\n *\r\n */\r\n public getCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine to set the friction for.\r\n * @param friction - The friction to set for the given axis.\r\n *\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The friction of the given axis.\r\n *\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the limit mode for the given axis of the constraint.\r\n * @param axis The axis to set the limit mode for.\r\n * @param limitMode The limit mode to set.\r\n *\r\n * This method is useful for setting the limit mode for a given axis of the constraint. This is important for\r\n * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,\r\n * the engine can be configured to either stop the motion of the objects, or to allow them to continue\r\n * moving beyond the constraint.\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n\r\n /**\r\n * Gets the limit mode of the given axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The limit mode of the given axis.\r\n *\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of a given axis of a constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param minLimit - The minimum limit of the axis.\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The minimum limit of the given axis.\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis for the physics engine.\r\n * @param axis - The axis to set the limit for.\r\n * @param limit - The maximum limit of the axis.\r\n *\r\n * This method is useful for setting the maximum limit of the given axis for the physics engine,\r\n * which can be used to control the movement of the physics object. This helps to ensure that the\r\n * physics object does not move beyond the given limit.\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The maximum limit of the given axis.\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param motorType - The type of motor to use.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The motor type of the specified axis.\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the target velocity of the motor associated with the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param target - The target velocity of the motor.\r\n *\r\n * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n * Gets the target velocity of the motor associated to the given constraint axis.\r\n * @param axis - The constraint axis associated to the motor.\r\n * @returns The target velocity of the motor.\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param maxForce - The maximum force of the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @returns The maximum force of the motor.\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n * Disposes the constraint from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Ball and Socket Constraint, used to simulate a joint\r\n *\r\n * @param pivotA - The first pivot, defined locally in the first body frame\r\n * @param pivotB - The second pivot, defined locally in the second body frame\r\n * @param axisA - The axis of the first body\r\n * @param axisB - The axis of the second body\r\n * @param scene - The scene the constraint is applied to\r\n * @returns The Ball and Socket Constraint\r\n *\r\n * This class is useful for simulating a joint between two bodies in a physics engine.\r\n * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.\r\n */\r\nexport class BallAndSocketConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a distance constraint.\r\n * @param maxDistance distance between bodies\r\n * @param scene The scene the constraint belongs to\r\n * @returns DistanceConstraint\r\n *\r\n * This code is useful for creating a distance constraint in a physics engine.\r\n * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.\r\n * The scene is used to add the constraint to the physics engine.\r\n */\r\nexport class DistanceConstraint extends PhysicsConstraint {\r\n constructor(maxDistance: number, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a HingeConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot point, in world space.\r\n * @param pivotB - The second pivot point, in world space.\r\n * @param scene - The scene the constraint is used in.\r\n * @returns The new HingeConstraint.\r\n *\r\n * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.\r\n * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.\r\n */\r\nexport class HingeConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SliderConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint, in world space.\r\n * @param pivotB - The second pivot of the constraint, in world space.\r\n * @param axisA - The first axis of the constraint, in world space.\r\n * @param axisB - The second axis of the constraint, in world space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SliderConstraint.\r\n *\r\n * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.\r\n * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.\r\n * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.\r\n */\r\nexport class SliderConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a LockConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.\r\n */\r\nexport class LockConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.\r\n */\r\nexport class PrismaticConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAY1B;;;;;;;;OAQG;IACH,YAAY,IAAoB,EAAE,OAAoC,EAAE,KAAY;QApBpF;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QAkBhC,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SAC1E;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SAC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EnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: ConstraintType;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n throw new Error(\"Missing scene parameter for constraint constructor.\");\r\n }\r\n const physicsEngine = scene.getPhysicsEngine();\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n this._options = options;\r\n this._type = type;\r\n }\r\n\r\n /**\r\n * Gets the type of the constraint.\r\n *\r\n * @returns The type of the constraint.\r\n *\r\n */\r\n public get type(): ConstraintType {\r\n return this._type;\r\n }\r\n\r\n /**\r\n * Retrieves the options of the physics constraint.\r\n *\r\n * @returns The physics constraint parameters.\r\n *\r\n */\r\n public get options(): PhysicsConstraintParameters {\r\n return this._options;\r\n }\r\n\r\n /**\r\n * Enable/disable the constraint\r\n * @param isEnabled value for the constraint\r\n */\r\n public set isEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n *\r\n * @returns true if constraint is enabled\r\n */\r\n public get isEnabled(): boolean {\r\n return this._physicsPlugin.getEnabled(this);\r\n }\r\n\r\n /**\r\n * Enables or disables collisions for the physics engine.\r\n *\r\n * @param isEnabled - A boolean value indicating whether collisions should be enabled or disabled.\r\n *\r\n */\r\n public set isCollisionsEnabled(isEnabled: boolean) {\r\n this._physicsPlugin.setCollisionsEnabled(this, isEnabled);\r\n }\r\n\r\n /**\r\n * Gets whether collisions are enabled for this physics object.\r\n *\r\n * @returns `true` if collisions are enabled, `false` otherwise.\r\n *\r\n */\r\n public get isCollisionsEnabled(): boolean {\r\n return this._physicsPlugin.getCollisionsEnabled(this);\r\n }\r\n\r\n /**\r\n * Sets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine to set the friction for.\r\n * @param friction - The friction to set for the given axis.\r\n *\r\n */\r\n public setAxisFriction(axis: ConstraintAxis, friction: number): void {\r\n this._physicsPlugin.setAxisFriction(this, axis, friction);\r\n }\r\n\r\n /**\r\n * Gets the friction of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The friction of the given axis.\r\n *\r\n */\r\n public getAxisFriction(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisFriction(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the limit mode for the given axis of the constraint.\r\n * @param axis The axis to set the limit mode for.\r\n * @param limitMode The limit mode to set.\r\n *\r\n * This method is useful for setting the limit mode for a given axis of the constraint. This is important for\r\n * controlling the behavior of the physics engine when the constraint is reached. By setting the limit mode,\r\n * the engine can be configured to either stop the motion of the objects, or to allow them to continue\r\n * moving beyond the constraint.\r\n */\r\n public setAxisMode(axis: ConstraintAxis, limitMode: ConstraintAxisLimitMode): void {\r\n this._physicsPlugin.setAxisMode(this, axis, limitMode);\r\n }\r\n\r\n /**\r\n * Gets the limit mode of the given axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The limit mode of the given axis.\r\n *\r\n */\r\n public getAxisMode(axis: ConstraintAxis): ConstraintAxisLimitMode {\r\n return this._physicsPlugin.getAxisMode(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the minimum limit of a given axis of a constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param minLimit - The minimum limit of the axis.\r\n *\r\n */\r\n public setAxisMinLimit(axis: ConstraintAxis, minLimit: number): void {\r\n this._physicsPlugin.setAxisMinLimit(this, axis, minLimit);\r\n }\r\n\r\n /**\r\n * Gets the minimum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The minimum limit of the given axis.\r\n *\r\n */\r\n public getAxisMinLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMinLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum limit of the given axis for the physics engine.\r\n * @param axis - The axis to set the limit for.\r\n * @param limit - The maximum limit of the axis.\r\n *\r\n * This method is useful for setting the maximum limit of the given axis for the physics engine,\r\n * which can be used to control the movement of the physics object. This helps to ensure that the\r\n * physics object does not move beyond the given limit.\r\n */\r\n public setAxisMaxLimit(axis: ConstraintAxis, limit: number): void {\r\n this._physicsPlugin.setAxisMaxLimit(this, axis, limit);\r\n }\r\n\r\n /**\r\n * Gets the maximum limit of the given axis of the physics engine.\r\n * @param axis - The axis of the physics engine.\r\n * @returns The maximum limit of the given axis.\r\n *\r\n */\r\n public getAxisMaxLimit(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMaxLimit(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the motor type of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param motorType - The type of motor to use.\r\n * @returns void\r\n *\r\n */\r\n public setAxisMotorType(axis: ConstraintAxis, motorType: ConstraintMotorType): void {\r\n this._physicsPlugin.setAxisMotorType(this, axis, motorType);\r\n }\r\n\r\n /**\r\n * Gets the motor type of the specified axis of the constraint.\r\n *\r\n * @param axis - The axis of the constraint.\r\n * @returns The motor type of the specified axis.\r\n *\r\n */\r\n public getAxisMotorType(axis: ConstraintAxis): ConstraintMotorType {\r\n return this._physicsPlugin.getAxisMotorType(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the target velocity of the motor associated with the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param target - The target velocity of the motor.\r\n *\r\n * This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.\r\n */\r\n public setAxisMotorTarget(axis: ConstraintAxis, target: number): void {\r\n this._physicsPlugin.setAxisMotorTarget(this, axis, target);\r\n }\r\n\r\n /**\r\n * Gets the target velocity of the motor associated to the given constraint axis.\r\n * @param axis - The constraint axis associated to the motor.\r\n * @returns The target velocity of the motor.\r\n *\r\n */\r\n public getAxisMotorTarget(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorTarget(this, axis);\r\n }\r\n\r\n /**\r\n * Sets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @param maxForce - The maximum force of the motor.\r\n *\r\n */\r\n public setAxisMotorMaxForce(axis: ConstraintAxis, maxForce: number): void {\r\n this._physicsPlugin.setAxisMotorMaxForce(this, axis, maxForce);\r\n }\r\n\r\n /**\r\n * Gets the maximum force of the motor of the given axis of the constraint.\r\n * @param axis - The axis of the constraint.\r\n * @returns The maximum force of the motor.\r\n *\r\n */\r\n public getAxisMotorMaxForce(axis: ConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\r\n }\r\n\r\n /**\r\n * Disposes the constraint from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.disposeConstraint(this);\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Ball and Socket Constraint, used to simulate a joint\r\n *\r\n * @param pivotA - The first pivot, defined locally in the first body frame\r\n * @param pivotB - The second pivot, defined locally in the second body frame\r\n * @param axisA - The axis of the first body\r\n * @param axisB - The axis of the second body\r\n * @param scene - The scene the constraint is applied to\r\n * @returns The Ball and Socket Constraint\r\n *\r\n * This class is useful for simulating a joint between two bodies in a physics engine.\r\n * It allows for the two bodies to move relative to each other in a way that mimics a ball and socket joint, such as a shoulder or hip joint.\r\n */\r\nexport class BallAndSocketConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a distance constraint.\r\n * @param maxDistance distance between bodies\r\n * @param scene The scene the constraint belongs to\r\n * @returns DistanceConstraint\r\n *\r\n * This code is useful for creating a distance constraint in a physics engine.\r\n * A distance constraint is a type of constraint that keeps two objects at a certain distance from each other.\r\n * The scene is used to add the constraint to the physics engine.\r\n */\r\nexport class DistanceConstraint extends PhysicsConstraint {\r\n constructor(maxDistance: number, scene: Scene) {\r\n super(ConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a HingeConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot point, in world space.\r\n * @param pivotB - The second pivot point, in world space.\r\n * @param scene - The scene the constraint is used in.\r\n * @returns The new HingeConstraint.\r\n *\r\n * This code is useful for creating a HingeConstraint, which is a type of PhysicsConstraint.\r\n * This constraint is used to simulate a hinge joint between two rigid bodies, allowing them to rotate around a single axis.\r\n */\r\nexport class HingeConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a SliderConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint, in world space.\r\n * @param pivotB - The second pivot of the constraint, in world space.\r\n * @param axisA - The first axis of the constraint, in world space.\r\n * @param axisB - The second axis of the constraint, in world space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created SliderConstraint.\r\n *\r\n * This code is useful for creating a SliderConstraint, which is a type of PhysicsConstraint.\r\n * It allows the user to specify the two pivots and two axes of the constraint in world space, as well as the scene the constraint belongs to.\r\n * This is useful for creating a constraint between two rigid bodies that allows them to move along a certain axis.\r\n */\r\nexport class SliderConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a LockConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a LockConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a LockConstraint.\r\n */\r\nexport class LockConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n\r\n/**\r\n * Creates a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n *\r\n * @param pivotA - The first pivot of the constraint in local space.\r\n * @param pivotB - The second pivot of the constraint in local space.\r\n * @param axisA - The first axis of the constraint in local space.\r\n * @param axisB - The second axis of the constraint in local space.\r\n * @param scene - The scene the constraint belongs to.\r\n * @returns The created LockConstraint.\r\n *\r\n * This code is useful for creating a PrismaticConstraint, which is a type of PhysicsConstraint.\r\n * It takes in two pivots and two axes in local space, as well as the scene the constraint belongs to, and creates a PrismaticConstraint.\r\n */\r\nexport class PrismaticConstraint extends PhysicsConstraint {\r\n constructor(pivotA: Vector3, pivotB: Vector3, axisA: Vector3, axisB: Vector3, scene: Scene) {\r\n super(ConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}