@babylonjs/core 5.57.0 → 5.57.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.
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +2 -0
- package/Lights/Shadows/shadowGenerator.js +11 -22
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Maths/math.vector.js +4 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +13 -0
- package/Meshes/abstractMesh.js +20 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +4 -1
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +1 -1
- package/Particles/solidParticleSystem.js +1 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Physics/physicsEngineComponent.d.ts +1 -0
- package/Physics/physicsEngineComponent.js +1 -0
- package/Physics/physicsEngineComponent.js.map +1 -1
- package/Physics/physicsHelper.d.ts +12 -5
- package/Physics/physicsHelper.js +160 -90
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/physicsRaycastResult.d.ts +3 -0
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +119 -76
- package/Physics/v2/IPhysicsEnginePlugin.js +119 -48
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +6 -2
- package/Physics/v2/physicsAggregate.js +65 -30
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +48 -62
- package/Physics/v2/physicsBody.js +100 -128
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Physics/v2/physicsConstraint.d.ts +34 -25
- package/Physics/v2/physicsConstraint.js +32 -15
- package/Physics/v2/physicsConstraint.js.map +1 -1
- package/Physics/v2/physicsEngine.d.ts +0 -1
- package/Physics/v2/physicsEngine.js +0 -1
- package/Physics/v2/physicsEngine.js.map +1 -1
- package/Physics/v2/physicsEngineComponent.d.ts +0 -10
- package/Physics/v2/physicsEngineComponent.js +0 -29
- package/Physics/v2/physicsEngineComponent.js.map +1 -1
- package/Physics/v2/physicsShape.d.ts +37 -8
- package/Physics/v2/physicsShape.js +52 -18
- package/Physics/v2/physicsShape.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Scene } from "../../scene";
|
|
2
2
|
import type { Vector3 } from "../../Maths/math.vector";
|
|
3
|
-
import type { IPhysicsEnginePluginV2,
|
|
4
|
-
import {
|
|
3
|
+
import type { IPhysicsEnginePluginV2, PhysicsConstraintAxis, PhysicsConstraintParameters, PhysicsConstraintAxisLimitMode, PhysicsConstraintMotorType } from "./IPhysicsEnginePlugin";
|
|
4
|
+
import { PhysicsConstraintType } from "./IPhysicsEnginePlugin";
|
|
5
5
|
/**
|
|
6
6
|
* This is a holder class for the physics constraint created by the physics plugin
|
|
7
7
|
* It holds a set of functions to control the underlying constraint
|
|
@@ -17,7 +17,7 @@ export declare class PhysicsConstraint {
|
|
|
17
17
|
*/
|
|
18
18
|
protected _physicsPlugin: IPhysicsEnginePluginV2;
|
|
19
19
|
protected _options: PhysicsConstraintParameters;
|
|
20
|
-
protected _type:
|
|
20
|
+
protected _type: PhysicsConstraintType;
|
|
21
21
|
/**
|
|
22
22
|
* Constructs a new constraint for the physics constraint.
|
|
23
23
|
* @param type The type of constraint to create.
|
|
@@ -27,14 +27,14 @@ export declare class PhysicsConstraint {
|
|
|
27
27
|
* 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.
|
|
28
28
|
* If all checks pass, it initializes the constraint with the given type and options.
|
|
29
29
|
*/
|
|
30
|
-
constructor(type:
|
|
30
|
+
constructor(type: PhysicsConstraintType, options: PhysicsConstraintParameters, scene: Scene);
|
|
31
31
|
/**
|
|
32
32
|
* Gets the type of the constraint.
|
|
33
33
|
*
|
|
34
34
|
* @returns The type of the constraint.
|
|
35
35
|
*
|
|
36
36
|
*/
|
|
37
|
-
get type():
|
|
37
|
+
get type(): PhysicsConstraintType;
|
|
38
38
|
/**
|
|
39
39
|
* Retrieves the options of the physics constraint.
|
|
40
40
|
*
|
|
@@ -66,20 +66,35 @@ export declare class PhysicsConstraint {
|
|
|
66
66
|
*
|
|
67
67
|
*/
|
|
68
68
|
get isCollisionsEnabled(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Disposes the constraint from the physics engine.
|
|
71
|
+
*
|
|
72
|
+
* 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.
|
|
73
|
+
*/
|
|
74
|
+
dispose(): void;
|
|
75
|
+
}
|
|
76
|
+
export declare class Physics6DoFLimit {
|
|
77
|
+
axis: PhysicsConstraintAxis;
|
|
78
|
+
minLimit?: number;
|
|
79
|
+
maxLimit?: number;
|
|
80
|
+
}
|
|
81
|
+
export declare class Physics6DoFConstraint extends PhysicsConstraint {
|
|
82
|
+
limits: Physics6DoFLimit[];
|
|
83
|
+
constructor(constraintParams: PhysicsConstraintParameters, limits: Physics6DoFLimit[], scene: Scene);
|
|
69
84
|
/**
|
|
70
85
|
* Sets the friction of the given axis of the physics engine.
|
|
71
86
|
* @param axis - The axis of the physics engine to set the friction for.
|
|
72
87
|
* @param friction - The friction to set for the given axis.
|
|
73
88
|
*
|
|
74
89
|
*/
|
|
75
|
-
setAxisFriction(axis:
|
|
90
|
+
setAxisFriction(axis: PhysicsConstraintAxis, friction: number): void;
|
|
76
91
|
/**
|
|
77
92
|
* Gets the friction of the given axis of the physics engine.
|
|
78
93
|
* @param axis - The axis of the physics engine.
|
|
79
94
|
* @returns The friction of the given axis.
|
|
80
95
|
*
|
|
81
96
|
*/
|
|
82
|
-
getAxisFriction(axis:
|
|
97
|
+
getAxisFriction(axis: PhysicsConstraintAxis): number;
|
|
83
98
|
/**
|
|
84
99
|
* Sets the limit mode for the given axis of the constraint.
|
|
85
100
|
* @param axis The axis to set the limit mode for.
|
|
@@ -90,7 +105,7 @@ export declare class PhysicsConstraint {
|
|
|
90
105
|
* the engine can be configured to either stop the motion of the objects, or to allow them to continue
|
|
91
106
|
* moving beyond the constraint.
|
|
92
107
|
*/
|
|
93
|
-
setAxisMode(axis:
|
|
108
|
+
setAxisMode(axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;
|
|
94
109
|
/**
|
|
95
110
|
* Gets the limit mode of the given axis of the constraint.
|
|
96
111
|
*
|
|
@@ -98,21 +113,21 @@ export declare class PhysicsConstraint {
|
|
|
98
113
|
* @returns The limit mode of the given axis.
|
|
99
114
|
*
|
|
100
115
|
*/
|
|
101
|
-
getAxisMode(axis:
|
|
116
|
+
getAxisMode(axis: PhysicsConstraintAxis): PhysicsConstraintAxisLimitMode;
|
|
102
117
|
/**
|
|
103
118
|
* Sets the minimum limit of a given axis of a constraint.
|
|
104
119
|
* @param axis - The axis of the constraint.
|
|
105
120
|
* @param minLimit - The minimum limit of the axis.
|
|
106
121
|
*
|
|
107
122
|
*/
|
|
108
|
-
setAxisMinLimit(axis:
|
|
123
|
+
setAxisMinLimit(axis: PhysicsConstraintAxis, minLimit: number): void;
|
|
109
124
|
/**
|
|
110
125
|
* Gets the minimum limit of the given axis of the physics engine.
|
|
111
126
|
* @param axis - The axis of the physics engine.
|
|
112
127
|
* @returns The minimum limit of the given axis.
|
|
113
128
|
*
|
|
114
129
|
*/
|
|
115
|
-
getAxisMinLimit(axis:
|
|
130
|
+
getAxisMinLimit(axis: PhysicsConstraintAxis): number;
|
|
116
131
|
/**
|
|
117
132
|
* Sets the maximum limit of the given axis for the physics engine.
|
|
118
133
|
* @param axis - The axis to set the limit for.
|
|
@@ -122,14 +137,14 @@ export declare class PhysicsConstraint {
|
|
|
122
137
|
* which can be used to control the movement of the physics object. This helps to ensure that the
|
|
123
138
|
* physics object does not move beyond the given limit.
|
|
124
139
|
*/
|
|
125
|
-
setAxisMaxLimit(axis:
|
|
140
|
+
setAxisMaxLimit(axis: PhysicsConstraintAxis, limit: number): void;
|
|
126
141
|
/**
|
|
127
142
|
* Gets the maximum limit of the given axis of the physics engine.
|
|
128
143
|
* @param axis - The axis of the physics engine.
|
|
129
144
|
* @returns The maximum limit of the given axis.
|
|
130
145
|
*
|
|
131
146
|
*/
|
|
132
|
-
getAxisMaxLimit(axis:
|
|
147
|
+
getAxisMaxLimit(axis: PhysicsConstraintAxis): number;
|
|
133
148
|
/**
|
|
134
149
|
* Sets the motor type of the given axis of the constraint.
|
|
135
150
|
* @param axis - The axis of the constraint.
|
|
@@ -137,7 +152,7 @@ export declare class PhysicsConstraint {
|
|
|
137
152
|
* @returns void
|
|
138
153
|
*
|
|
139
154
|
*/
|
|
140
|
-
setAxisMotorType(axis:
|
|
155
|
+
setAxisMotorType(axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;
|
|
141
156
|
/**
|
|
142
157
|
* Gets the motor type of the specified axis of the constraint.
|
|
143
158
|
*
|
|
@@ -145,7 +160,7 @@ export declare class PhysicsConstraint {
|
|
|
145
160
|
* @returns The motor type of the specified axis.
|
|
146
161
|
*
|
|
147
162
|
*/
|
|
148
|
-
getAxisMotorType(axis:
|
|
163
|
+
getAxisMotorType(axis: PhysicsConstraintAxis): PhysicsConstraintMotorType;
|
|
149
164
|
/**
|
|
150
165
|
* Sets the target velocity of the motor associated with the given axis of the constraint.
|
|
151
166
|
* @param axis - The axis of the constraint.
|
|
@@ -153,34 +168,28 @@ export declare class PhysicsConstraint {
|
|
|
153
168
|
*
|
|
154
169
|
* This method is useful for setting the target velocity of the motor associated with the given axis of the constraint.
|
|
155
170
|
*/
|
|
156
|
-
setAxisMotorTarget(axis:
|
|
171
|
+
setAxisMotorTarget(axis: PhysicsConstraintAxis, target: number): void;
|
|
157
172
|
/**
|
|
158
173
|
* Gets the target velocity of the motor associated to the given constraint axis.
|
|
159
174
|
* @param axis - The constraint axis associated to the motor.
|
|
160
175
|
* @returns The target velocity of the motor.
|
|
161
176
|
*
|
|
162
177
|
*/
|
|
163
|
-
getAxisMotorTarget(axis:
|
|
178
|
+
getAxisMotorTarget(axis: PhysicsConstraintAxis): number;
|
|
164
179
|
/**
|
|
165
180
|
* Sets the maximum force of the motor of the given axis of the constraint.
|
|
166
181
|
* @param axis - The axis of the constraint.
|
|
167
182
|
* @param maxForce - The maximum force of the motor.
|
|
168
183
|
*
|
|
169
184
|
*/
|
|
170
|
-
setAxisMotorMaxForce(axis:
|
|
185
|
+
setAxisMotorMaxForce(axis: PhysicsConstraintAxis, maxForce: number): void;
|
|
171
186
|
/**
|
|
172
187
|
* Gets the maximum force of the motor of the given axis of the constraint.
|
|
173
188
|
* @param axis - The axis of the constraint.
|
|
174
189
|
* @returns The maximum force of the motor.
|
|
175
190
|
*
|
|
176
191
|
*/
|
|
177
|
-
getAxisMotorMaxForce(axis:
|
|
178
|
-
/**
|
|
179
|
-
* Disposes the constraint from the physics engine.
|
|
180
|
-
*
|
|
181
|
-
* 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.
|
|
182
|
-
*/
|
|
183
|
-
dispose(): void;
|
|
192
|
+
getAxisMotorMaxForce(axis: PhysicsConstraintAxis): number;
|
|
184
193
|
}
|
|
185
194
|
/**
|
|
186
195
|
* Represents a Ball and Socket Constraint, used to simulate a joint
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PhysicsConstraintType } from "./IPhysicsEnginePlugin.js";
|
|
2
2
|
/**
|
|
3
3
|
* This is a holder class for the physics constraint created by the physics plugin
|
|
4
4
|
* It holds a set of functions to control the underlying constraint
|
|
@@ -87,6 +87,31 @@ export class PhysicsConstraint {
|
|
|
87
87
|
get isCollisionsEnabled() {
|
|
88
88
|
return this._physicsPlugin.getCollisionsEnabled(this);
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Disposes the constraint from the physics engine.
|
|
92
|
+
*
|
|
93
|
+
* 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.
|
|
94
|
+
*/
|
|
95
|
+
dispose() {
|
|
96
|
+
this._physicsPlugin.disposeConstraint(this);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/*
|
|
100
|
+
* This describes a single limit used by Physics6DoFConstraint
|
|
101
|
+
*/
|
|
102
|
+
export class Physics6DoFLimit {
|
|
103
|
+
}
|
|
104
|
+
/*
|
|
105
|
+
* A generic constraint, which can be used to build more complex constraints than those specified
|
|
106
|
+
* in PhysicsConstraintType. The axis and pivot options in PhysicsConstraintParameters define the space
|
|
107
|
+
* the constraint operates in. This constraint contains a set of limits, which restrict the
|
|
108
|
+
* relative movement of the bodies in that coordinate system
|
|
109
|
+
*/
|
|
110
|
+
export class Physics6DoFConstraint extends PhysicsConstraint {
|
|
111
|
+
constructor(constraintParams, limits, scene) {
|
|
112
|
+
super(PhysicsConstraintType.SIX_DOF, constraintParams, scene);
|
|
113
|
+
this.limits = limits;
|
|
114
|
+
}
|
|
90
115
|
/**
|
|
91
116
|
* Sets the friction of the given axis of the physics engine.
|
|
92
117
|
* @param axis - The axis of the physics engine to set the friction for.
|
|
@@ -224,14 +249,6 @@ export class PhysicsConstraint {
|
|
|
224
249
|
getAxisMotorMaxForce(axis) {
|
|
225
250
|
return this._physicsPlugin.getAxisMotorMaxForce(this, axis);
|
|
226
251
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Disposes the constraint from the physics engine.
|
|
229
|
-
*
|
|
230
|
-
* This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.
|
|
231
|
-
*/
|
|
232
|
-
dispose() {
|
|
233
|
-
this._physicsPlugin.disposeConstraint(this);
|
|
234
|
-
}
|
|
235
252
|
}
|
|
236
253
|
/**
|
|
237
254
|
* Represents a Ball and Socket Constraint, used to simulate a joint
|
|
@@ -248,7 +265,7 @@ export class PhysicsConstraint {
|
|
|
248
265
|
*/
|
|
249
266
|
export class BallAndSocketConstraint extends PhysicsConstraint {
|
|
250
267
|
constructor(pivotA, pivotB, axisA, axisB, scene) {
|
|
251
|
-
super(
|
|
268
|
+
super(PhysicsConstraintType.BALL_AND_SOCKET, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
|
|
252
269
|
}
|
|
253
270
|
}
|
|
254
271
|
/**
|
|
@@ -263,7 +280,7 @@ export class BallAndSocketConstraint extends PhysicsConstraint {
|
|
|
263
280
|
*/
|
|
264
281
|
export class DistanceConstraint extends PhysicsConstraint {
|
|
265
282
|
constructor(maxDistance, scene) {
|
|
266
|
-
super(
|
|
283
|
+
super(PhysicsConstraintType.DISTANCE, { maxDistance: maxDistance }, scene);
|
|
267
284
|
}
|
|
268
285
|
}
|
|
269
286
|
/**
|
|
@@ -279,7 +296,7 @@ export class DistanceConstraint extends PhysicsConstraint {
|
|
|
279
296
|
*/
|
|
280
297
|
export class HingeConstraint extends PhysicsConstraint {
|
|
281
298
|
constructor(pivotA, pivotB, axisA, axisB, scene) {
|
|
282
|
-
super(
|
|
299
|
+
super(PhysicsConstraintType.HINGE, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
|
|
283
300
|
}
|
|
284
301
|
}
|
|
285
302
|
/**
|
|
@@ -298,7 +315,7 @@ export class HingeConstraint extends PhysicsConstraint {
|
|
|
298
315
|
*/
|
|
299
316
|
export class SliderConstraint extends PhysicsConstraint {
|
|
300
317
|
constructor(pivotA, pivotB, axisA, axisB, scene) {
|
|
301
|
-
super(
|
|
318
|
+
super(PhysicsConstraintType.SLIDER, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
|
|
302
319
|
}
|
|
303
320
|
}
|
|
304
321
|
/**
|
|
@@ -316,7 +333,7 @@ export class SliderConstraint extends PhysicsConstraint {
|
|
|
316
333
|
*/
|
|
317
334
|
export class LockConstraint extends PhysicsConstraint {
|
|
318
335
|
constructor(pivotA, pivotB, axisA, axisB, scene) {
|
|
319
|
-
super(
|
|
336
|
+
super(PhysicsConstraintType.LOCK, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
|
|
320
337
|
}
|
|
321
338
|
}
|
|
322
339
|
/**
|
|
@@ -334,7 +351,7 @@ export class LockConstraint extends PhysicsConstraint {
|
|
|
334
351
|
*/
|
|
335
352
|
export class PrismaticConstraint extends PhysicsConstraint {
|
|
336
353
|
constructor(pivotA, pivotB, axisA, axisB, scene) {
|
|
337
|
-
super(
|
|
354
|
+
super(PhysicsConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);
|
|
338
355
|
}
|
|
339
356
|
}
|
|
340
357
|
//# sourceMappingURL=physicsConstraint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;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;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC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M,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACvG,CAAC;CACJ;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACnD,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACxG,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IACtG,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD,YAAY,MAAe,EAAE,MAAe,EAAE,KAAc,EAAE,KAAc,EAAE,KAAY;QACtF,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAC3G,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEnginePluginV2, ConstraintAxis, PhysicsConstraintParameters, ConstraintAxisLimitMode, ConstraintMotorType } from \"./IPhysicsEnginePlugin\";\r\nimport { ConstraintType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * This is a holder class for the physics constraint created by the physics plugin\r\n * It holds a set of functions to control the underlying constraint\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsConstraint {\r\n /**\r\n * V2 Physics plugin private data for a physics material\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n protected _physicsPlugin: IPhysicsEnginePluginV2;\r\n protected _options: PhysicsConstraintParameters;\r\n protected _type: ConstraintType;\r\n\r\n /**\r\n * Constructs a new constraint for the physics constraint.\r\n * @param type The type of constraint to create.\r\n * @param options The options for the constraint.\r\n * @param scene The scene the constraint belongs to.\r\n *\r\n * This code is useful for creating a new constraint for the physics engine. It checks if the scene has a physics engine, and if the plugin version is correct.\r\n * If all checks pass, it initializes the constraint with the given type and options.\r\n */\r\n constructor(type: ConstraintType, options: PhysicsConstraintParameters, scene: Scene) {\r\n if (!scene) {\r\n 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"]}
|
|
1
|
+
{"version":3,"file":"physicsConstraint.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsConstraint.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAY1B;;;;;;;;OAQG;IACH,YAAY,IAA2B,EAAE,OAAoC,EAAE,KAAY;QApB3F;;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;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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KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;IAClH,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport type {\r\n IPhysicsEnginePluginV2,\r\n PhysicsConstraintAxis,\r\n PhysicsConstraintParameters,\r\n PhysicsConstraintAxisLimitMode,\r\n PhysicsConstraintMotorType,\r\n} from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsConstraintType } 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: PhysicsConstraintType;\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: PhysicsConstraintType, 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(): PhysicsConstraintType {\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 * 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 * This describes a single limit used by Physics6DoFConstraint\r\n */\r\nexport class Physics6DoFLimit {\r\n /*\r\n * The axis ID to limit\r\n */\r\n axis: PhysicsConstraintAxis;\r\n /*\r\n * An optional minimum limit for the axis.\r\n * Corresponds to a distance in meters for linear axes, an angle in radians for angular axes.\r\n */\r\n minLimit?: number;\r\n /*\r\n * An optional maximum limit for the axis.\r\n * Corresponds to a distance in meters for linear axes, an angle in radians for angular axes.\r\n */\r\n maxLimit?: number;\r\n}\r\n\r\n/*\r\n * A generic constraint, which can be used to build more complex constraints than those specified\r\n * in PhysicsConstraintType. The axis and pivot options in PhysicsConstraintParameters define the space\r\n * the constraint operates in. This constraint contains a set of limits, which restrict the\r\n * relative movement of the bodies in that coordinate system\r\n */\r\nexport class Physics6DoFConstraint extends PhysicsConstraint {\r\n /*\r\n * The collection of limits which this constraint will apply\r\n */\r\n public limits: Physics6DoFLimit[];\r\n\r\n constructor(constraintParams: PhysicsConstraintParameters, limits: Physics6DoFLimit[], scene: Scene) {\r\n super(PhysicsConstraintType.SIX_DOF, constraintParams, scene);\r\n this.limits = limits;\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: PhysicsConstraintAxis, 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: PhysicsConstraintAxis): 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: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): 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: PhysicsConstraintAxis): PhysicsConstraintAxisLimitMode {\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: PhysicsConstraintAxis, 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: PhysicsConstraintAxis): 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: PhysicsConstraintAxis, 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: PhysicsConstraintAxis): 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: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): 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: PhysicsConstraintAxis): PhysicsConstraintMotorType {\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: PhysicsConstraintAxis, 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: PhysicsConstraintAxis): 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: PhysicsConstraintAxis, 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: PhysicsConstraintAxis): number {\r\n return this._physicsPlugin.getAxisMotorMaxForce(this, axis);\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(PhysicsConstraintType.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(PhysicsConstraintType.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(PhysicsConstraintType.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(PhysicsConstraintType.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(PhysicsConstraintType.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(PhysicsConstraintType.PRISMATIC, { pivotA: pivotA, pivotB: pivotB, axisA: axisA, axisB: axisB }, scene);\r\n }\r\n}\r\n"]}
|
|
@@ -8,7 +8,6 @@ import type { PhysicsBody } from "./physicsBody";
|
|
|
8
8
|
* Class used to control physics engine
|
|
9
9
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
|
|
10
10
|
*/
|
|
11
|
-
/** @internal */
|
|
12
11
|
export declare class PhysicsEngine implements IPhysicsEngine {
|
|
13
12
|
private _physicsPlugin;
|
|
14
13
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,aAAa;IAUtB;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,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";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(gravity: Nullable<Vector3>, private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n * Add a body as an active component of this engine\r\n * @param body\r\n */\r\n public addBody(physicsBody: PhysicsBody): void {\r\n this._physicsBodies.push(physicsBody);\r\n }\r\n /**\r\n * Removes a particular body from this engine\r\n */\r\n public removeBody(physicsBody: PhysicsBody): void {\r\n const index = this._physicsBodies.indexOf(physicsBody);\r\n if (index > -1) {\r\n /*const removed =*/ this._physicsBodies.splice(index, 1);\r\n }\r\n }\r\n /**\r\n * Returns an array of bodies added to this engine\r\n\r\n */\r\n public getBodies(): Array<PhysicsBody> {\r\n return this._physicsBodies;\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePluginV2 {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult): void {\r\n this._physicsPlugin.raycast(from, to, result);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3): PhysicsRaycastResult {\r\n const result = new PhysicsRaycastResult();\r\n this._physicsPlugin.raycast(from, to, result);\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -3,7 +3,6 @@ import type { Observer } from "../../Misc/observable";
|
|
|
3
3
|
import type { Vector3 } from "../../Maths/math.vector";
|
|
4
4
|
import type { Node } from "../../node";
|
|
5
5
|
import type { PhysicsBody } from "./physicsBody";
|
|
6
|
-
import type { PhysicsShape } from "./physicsShape";
|
|
7
6
|
import "../joinedPhysicsEngineComponent";
|
|
8
7
|
declare module "../../Meshes/transformNode" {
|
|
9
8
|
/**
|
|
@@ -21,15 +20,6 @@ declare module "../../Meshes/transformNode" {
|
|
|
21
20
|
*
|
|
22
21
|
*/
|
|
23
22
|
getPhysicsBody(): Nullable<PhysicsBody>;
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
_physicsShape: Nullable<PhysicsShape>;
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
physicsShape: Nullable<PhysicsShape>;
|
|
32
|
-
getPhysicsShape(): Nullable<PhysicsShape>;
|
|
33
23
|
/** Apply a physic impulse to the mesh
|
|
34
24
|
* @param force defines the force to apply
|
|
35
25
|
* @param contactPoint defines where to apply the force
|
|
@@ -29,37 +29,9 @@ Object.defineProperty(TransformNode.prototype, "physicsBody", {
|
|
|
29
29
|
* Gets the current physics body
|
|
30
30
|
* @returns a physics body or null
|
|
31
31
|
*/
|
|
32
|
-
/** @internal */
|
|
33
32
|
TransformNode.prototype.getPhysicsBody = function () {
|
|
34
33
|
return this.physicsBody;
|
|
35
34
|
};
|
|
36
|
-
Object.defineProperty(TransformNode.prototype, "physicsShape", {
|
|
37
|
-
get: function () {
|
|
38
|
-
return this._physicsShape;
|
|
39
|
-
},
|
|
40
|
-
set: function (value) {
|
|
41
|
-
if (this._physicsShape === value) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (this._physicsShape) {
|
|
45
|
-
//<todo.eoin Remove from body
|
|
46
|
-
}
|
|
47
|
-
this._physicsShape = value;
|
|
48
|
-
if (this._physicsShape) {
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
50
|
-
let cur = this;
|
|
51
|
-
while (cur) {
|
|
52
|
-
if (cur instanceof TransformNode && cur.physicsBody) {
|
|
53
|
-
cur.physicsBody.addNodeShape(this);
|
|
54
|
-
}
|
|
55
|
-
cur = cur.parent;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
TransformNode.prototype.getPhysicsShape = function () {
|
|
61
|
-
return this.physicsShape;
|
|
62
|
-
};
|
|
63
35
|
/**
|
|
64
36
|
* Apply a physic impulse to the mesh
|
|
65
37
|
* @param force defines the force to apply
|
|
@@ -67,7 +39,6 @@ TransformNode.prototype.getPhysicsShape = function () {
|
|
|
67
39
|
* @returns the current mesh
|
|
68
40
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
|
|
69
41
|
*/
|
|
70
|
-
/** @internal */
|
|
71
42
|
TransformNode.prototype.applyImpulse = function (force, contactPoint) {
|
|
72
43
|
if (!this.physicsBody) {
|
|
73
44
|
throw new Error("No Physics Body for TransformNode");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,iCAAiC,CAAC;AAiCzC,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,EAAE;IAC1D,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,GAAG,EAAE,UAA+B,KAA4B;QAC5D,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC7B,OAAO;SACV;QACD,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAC9B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;SACjE;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBAC7D,UAAU;gBACV,IAAI,IAAI,CAAC,WAAW,EAAE;oBAClB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAC,iBAAiB,CAAC,CAAC;oBAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;iBAC3B;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH;;;GAGG;AACH,aAAa,CAAC,SAAS,CAAC,cAAc,GAAG;IACrC,OAAO,IAAI,CAAC,WAAW,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,aAAa,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAc,EAAE,YAAqB;IAClF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACxD;IACD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Node } from \"../../node\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\nimport \"../joinedPhysicsEngineComponent\";\r\n\r\ndeclare module \"../../Meshes/transformNode\" {\r\n /**\r\n *\r\n */\r\n /** @internal */\r\n export interface TransformNode {\r\n /** @internal */\r\n _physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n * @see\r\n */\r\n physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n *\r\n */\r\n getPhysicsBody(): Nullable<PhysicsBody>;\r\n\r\n /** Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n */\r\n applyImpulse(force: Vector3, contactPoint: Vector3): TransformNode;\r\n\r\n /** @internal */\r\n _disposePhysicsObserver: Nullable<Observer<Node>>;\r\n }\r\n}\r\n\r\nObject.defineProperty(TransformNode.prototype, \"physicsBody\", {\r\n get: function (this: TransformNode) {\r\n return this._physicsBody;\r\n },\r\n set: function (this: TransformNode, value: Nullable<PhysicsBody>) {\r\n if (this._physicsBody === value) {\r\n return;\r\n }\r\n if (this._disposePhysicsObserver) {\r\n this.onDisposeObservable.remove(this._disposePhysicsObserver);\r\n }\r\n\r\n this._physicsBody = value;\r\n\r\n if (value) {\r\n this._disposePhysicsObserver = this.onDisposeObservable.add(() => {\r\n // Physics\r\n if (this.physicsBody) {\r\n this.physicsBody.dispose(/*!doNotRecurse*/);\r\n this.physicsBody = null;\r\n }\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Gets the current physics body\r\n * @returns a physics body or null\r\n */\r\nTransformNode.prototype.getPhysicsBody = function (): Nullable<PhysicsBody> {\r\n return this.physicsBody;\r\n};\r\n\r\n/**\r\n * Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nTransformNode.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): TransformNode {\r\n if (!this.physicsBody) {\r\n throw new Error(\"No Physics Body for TransformNode\");\r\n }\r\n this.physicsBody.applyImpulse(force, contactPoint);\r\n return this;\r\n};\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TransformNode } from "../../Meshes/transformNode";
|
|
2
2
|
import type { AbstractMesh } from "../../Meshes/abstractMesh";
|
|
3
3
|
import type { BoundingBox } from "../../Culling/boundingBox";
|
|
4
|
-
import {
|
|
4
|
+
import { PhysicsShapeType } from "./IPhysicsEnginePlugin";
|
|
5
5
|
import type { PhysicsShapeParameters } from "./IPhysicsEnginePlugin";
|
|
6
6
|
import type { PhysicsMaterial } from "./physicsMaterial";
|
|
7
7
|
import { Vector3, Quaternion } from "../../Maths/math.vector";
|
|
@@ -14,7 +14,7 @@ export interface PhysicShapeOptions {
|
|
|
14
14
|
/**
|
|
15
15
|
* The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER
|
|
16
16
|
*/
|
|
17
|
-
type?:
|
|
17
|
+
type?: PhysicsShapeType;
|
|
18
18
|
/**
|
|
19
19
|
* The parameters of the shape. Varies depending of the shape type.
|
|
20
20
|
*/
|
|
@@ -54,20 +54,50 @@ export declare class PhysicsShape {
|
|
|
54
54
|
* If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.
|
|
55
55
|
*/
|
|
56
56
|
constructor(options: PhysicShapeOptions, scene: Scene);
|
|
57
|
+
/**
|
|
58
|
+
* Returns the string "PhysicsShape".
|
|
59
|
+
* @returns "PhysicsShape"
|
|
60
|
+
*/
|
|
61
|
+
getClassName(): string;
|
|
57
62
|
/**
|
|
58
63
|
*
|
|
59
64
|
*/
|
|
60
|
-
get type():
|
|
65
|
+
get type(): PhysicsShapeType;
|
|
61
66
|
/**
|
|
67
|
+
* Set the membership mask of a shape. This is a bitfield of arbitrary
|
|
68
|
+
* "categories" to which the shape is a member. This is used in combination
|
|
69
|
+
* with the collide mask to determine if this shape should collide with
|
|
70
|
+
* another.
|
|
62
71
|
*
|
|
63
|
-
* @param
|
|
72
|
+
* @param membershipMask Bitfield of categories of this shape.
|
|
64
73
|
*/
|
|
65
|
-
set
|
|
74
|
+
set filterMembershipMask(membershipMask: number);
|
|
66
75
|
/**
|
|
76
|
+
* Get the membership mask of a shape.
|
|
77
|
+
* @returns Bitmask of categories which this shape is a member of.
|
|
78
|
+
*/
|
|
79
|
+
get filterMembershipMask(): number;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the collide mask of a shape. This is a bitfield of arbitrary
|
|
82
|
+
* "categories" to which this shape collides with. Given two shapes,
|
|
83
|
+
* the engine will check if the collide mask and membership overlap:
|
|
84
|
+
* shapeA.filterMembershipMask & shapeB.filterCollideMask
|
|
67
85
|
*
|
|
68
|
-
*
|
|
86
|
+
* If this value is zero (i.e. shapeB only collides with categories
|
|
87
|
+
* which shapeA is _not_ a member of) then the shapes will not collide.
|
|
88
|
+
*
|
|
89
|
+
* Note, the engine will also perform the same test with shapeA and
|
|
90
|
+
* shapeB swapped; the shapes will not collide if either shape has
|
|
91
|
+
* a collideMask which prevents collision with the other shape.
|
|
92
|
+
*
|
|
93
|
+
* @param collideMask Bitmask of categories this shape should collide with
|
|
94
|
+
*/
|
|
95
|
+
set filterCollideMask(collideMask: number);
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @returns Bitmask of categories that this shape should collide with
|
|
69
99
|
*/
|
|
70
|
-
get
|
|
100
|
+
get filterCollideMask(): number;
|
|
71
101
|
/**
|
|
72
102
|
*
|
|
73
103
|
* @param material
|
|
@@ -116,7 +146,6 @@ export declare class PhysicsShape {
|
|
|
116
146
|
* Helper object to create a sphere shape
|
|
117
147
|
*/
|
|
118
148
|
export declare class PhysicsShapeSphere extends PhysicsShape {
|
|
119
|
-
/** @internal */
|
|
120
149
|
/**
|
|
121
150
|
* Constructor for the Sphere Shape
|
|
122
151
|
* @param center local center of the sphere
|